start messing around with texture loading
parent
0ff071bb6b
commit
eb38cbe27c
File diff suppressed because one or more lines are too long
|
@ -1419,7 +1419,7 @@ GameLib.D3.Material.TYPE_MULTI_MATERIAL= "MultiMaterial";
|
|||
* @param uploadUrl String
|
||||
* @param progressCallback
|
||||
*/
|
||||
GameLib.D3.Material.createInstanceMaterial = function(
|
||||
GameLib.D3.Material.CreateInstanceMaterial = function(
|
||||
gameLibMaterial,
|
||||
graphics,
|
||||
uploadUrl,
|
||||
|
@ -1571,10 +1571,13 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
|||
|
||||
} else {
|
||||
console.log("material type is not implemented yet: " + gameLibMaterial.materialType + " - material indexes could be screwed up");
|
||||
defer.reject(null);
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
if (blenderMaps.length > 0) {
|
||||
var textureMaps = GameLib.D3.Texture.loadMaps(
|
||||
|
||||
var textureMaps = GameLib.D3.Texture.LoadMaps(
|
||||
gameLibMaterial,
|
||||
blenderMaps,
|
||||
instanceMaterial,
|
||||
|
@ -1582,16 +1585,22 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
|||
uploadUrl,
|
||||
progressCallback
|
||||
);
|
||||
Q.all(textureMaps).then(
|
||||
function(){
|
||||
defer.resolve(instanceMaterial);
|
||||
}
|
||||
).catch(
|
||||
function(error){
|
||||
console.log(error);
|
||||
defer.reject(error);
|
||||
}
|
||||
)
|
||||
|
||||
if (textureMaps.length > 0) {
|
||||
Q.all(textureMaps).then(
|
||||
function onFulfilled(map){
|
||||
defer.resolve(instanceMaterial);
|
||||
},
|
||||
function onRejected(message) {
|
||||
console.log(message);
|
||||
defer.reject(message);
|
||||
},
|
||||
function onProgress(progress) {
|
||||
console.log('progress');
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
defer.resolve(instanceMaterial);
|
||||
}
|
||||
|
@ -1935,7 +1944,7 @@ GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
|||
* @param graphics
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.D3.Mesh.createInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||
GameLib.D3.Mesh.CreateInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||
|
||||
var threeMesh = null;
|
||||
|
||||
|
@ -3390,24 +3399,16 @@ GameLib.D3.Scene.loadScene = function(
|
|||
geometry.computeVertexNormals();
|
||||
}
|
||||
|
||||
var instanceMaterialLoaders = [];
|
||||
var instanceMaterial = GameLib.D3.Material.CreateInstanceMaterial(
|
||||
materials[0],
|
||||
graphics,
|
||||
uploadUrl,
|
||||
progressCallback
|
||||
);
|
||||
|
||||
/**
|
||||
* Setup materials
|
||||
*/
|
||||
for (var mi = 0; mi < materials.length; mi++) {
|
||||
instanceMaterialLoaders.push(
|
||||
GameLib.D3.Material.createInstanceMaterial(
|
||||
materials[mi],
|
||||
graphics,
|
||||
uploadUrl,
|
||||
progressCallback
|
||||
)
|
||||
);
|
||||
}
|
||||
var result = instanceMaterial.then(
|
||||
|
||||
var result = Q.all(instanceMaterialLoaders).then(
|
||||
function(mesh, geometry) {
|
||||
(function(__mesh, __geometry) {
|
||||
return function(materials) {
|
||||
|
||||
console.log("loaded material : " + materials[0].name);
|
||||
|
@ -3417,41 +3418,49 @@ GameLib.D3.Scene.loadScene = function(
|
|||
*/
|
||||
var material = materials[0];
|
||||
|
||||
var threeMesh = GameLib.D3.Mesh.createInstanceMesh(
|
||||
mesh,
|
||||
geometry,
|
||||
var instanceMesh = GameLib.D3.Mesh.CreateInstanceMesh(
|
||||
__mesh,
|
||||
__geometry,
|
||||
material,
|
||||
graphics
|
||||
);
|
||||
threeMesh.name = mesh.name;
|
||||
instanceMesh.name = __mesh.name;
|
||||
|
||||
threeMesh.position.x = mesh.position.x;
|
||||
threeMesh.position.y = mesh.position.y;
|
||||
threeMesh.position.z = mesh.position.z;
|
||||
instanceMesh.position.x = __mesh.position.x;
|
||||
instanceMesh.position.y = __mesh.position.y;
|
||||
instanceMesh.position.z = __mesh.position.z;
|
||||
|
||||
threeMesh.rotation.x = mesh.rotation.x;
|
||||
threeMesh.rotation.y = mesh.rotation.y;
|
||||
threeMesh.rotation.z = mesh.rotation.z;
|
||||
instanceMesh.rotation.x = __mesh.rotation.x;
|
||||
instanceMesh.rotation.y = __mesh.rotation.y;
|
||||
instanceMesh.rotation.z = __mesh.rotation.z;
|
||||
|
||||
threeMesh.scale.x = mesh.scale.x;
|
||||
threeMesh.scale.y = mesh.scale.y;
|
||||
threeMesh.scale.z = mesh.scale.z;
|
||||
instanceMesh.scale.x = __mesh.scale.x;
|
||||
instanceMesh.scale.y = __mesh.scale.y;
|
||||
instanceMesh.scale.z = __mesh.scale.z;
|
||||
|
||||
threeMesh.quaternion.x = mesh.quaternion.x;
|
||||
threeMesh.quaternion.y = mesh.quaternion.y;
|
||||
threeMesh.quaternion.z = mesh.quaternion.z;
|
||||
threeMesh.quaternion.w = mesh.quaternion.w;
|
||||
instanceMesh.quaternion.x = __mesh.quaternion.x;
|
||||
instanceMesh.quaternion.y = __mesh.quaternion.y;
|
||||
instanceMesh.quaternion.z = __mesh.quaternion.z;
|
||||
instanceMesh.quaternion.w = __mesh.quaternion.w;
|
||||
|
||||
return threeMesh;
|
||||
return instanceMesh;
|
||||
};
|
||||
}(mesh, geometry)
|
||||
).catch(function(error){
|
||||
console.log(error);
|
||||
});
|
||||
})(mesh, geometry),
|
||||
function onRejected(message) {
|
||||
console.log(message);
|
||||
return null;
|
||||
},
|
||||
function onProgress(progress) {
|
||||
console.log('material progress');
|
||||
}
|
||||
);
|
||||
|
||||
meshQ.push(result);
|
||||
}
|
||||
|
||||
debugger;
|
||||
console.log('hi');
|
||||
|
||||
Q.all(meshQ).then(
|
||||
function(instanceMeshes){
|
||||
console.log("all meshes have loaded");
|
||||
|
@ -3541,7 +3550,11 @@ GameLib.D3.Scene.loadScene = function(
|
|||
}
|
||||
);
|
||||
}
|
||||
}).catch(
|
||||
},
|
||||
function(error) {
|
||||
console.log(error);
|
||||
}
|
||||
).catch(
|
||||
function(error){
|
||||
console.log(error);
|
||||
}
|
||||
|
@ -4162,7 +4175,7 @@ GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
|||
* @param progressCallback
|
||||
* @returns {Promise}
|
||||
*/
|
||||
GameLib.D3.Texture.loadMap = function(
|
||||
GameLib.D3.Texture.LoadMap = function(
|
||||
gameLibTexture,
|
||||
instanceMaterial,
|
||||
instanceMaterialMapType,
|
||||
|
@ -4184,62 +4197,61 @@ GameLib.D3.Texture.loadMap = function(
|
|||
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
||||
}
|
||||
|
||||
if (imagePath) {
|
||||
|
||||
textureLoader.crossOrigin = '';
|
||||
|
||||
textureLoader.load(
|
||||
imagePath,
|
||||
function(texture) {
|
||||
/**
|
||||
* onLoad
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType] = texture;
|
||||
instanceMaterial[instanceMaterialMapType].name = gameLibTexture.name;
|
||||
instanceMaterial[instanceMaterialMapType].anisotropy = gameLibTexture.anisotropy;
|
||||
instanceMaterial[instanceMaterialMapType].encoding = gameLibTexture.encoding;
|
||||
instanceMaterial[instanceMaterialMapType].flipY = gameLibTexture.flipY;
|
||||
/**
|
||||
* We don't restore the format since this changing from OS to OS and breaks the implementation sometimes
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType].generateMipmaps = gameLibTexture.generateMipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].magFilter = gameLibTexture.magFilter;
|
||||
instanceMaterial[instanceMaterialMapType].minFilter = gameLibTexture.minFilter;
|
||||
instanceMaterial[instanceMaterialMapType].mapping = gameLibTexture.mapping;
|
||||
instanceMaterial[instanceMaterialMapType].mipmaps = gameLibTexture.mipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].offset = new graphics.instance.Vector2(
|
||||
gameLibTexture.offset.x,
|
||||
gameLibTexture.offset.y
|
||||
);
|
||||
instanceMaterial[instanceMaterialMapType].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
||||
instanceMaterial[instanceMaterialMapType].textureType = gameLibTexture.textureType;
|
||||
instanceMaterial[instanceMaterialMapType].wrapS = gameLibTexture.wrapS;
|
||||
instanceMaterial[instanceMaterialMapType].wrapT = gameLibTexture.wrapT;
|
||||
instanceMaterial[instanceMaterialMapType].unpackAlignment = gameLibTexture.unpackAlignment;
|
||||
instanceMaterial.needsUpdate = true;
|
||||
defer.resolve(true);
|
||||
},
|
||||
function(xhr) {
|
||||
/**
|
||||
* onProgress
|
||||
*/
|
||||
if (progressCallback) {
|
||||
progressCallback(Math.round(xhr.loaded / xhr.total * 100));
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
/**
|
||||
* onError
|
||||
*/
|
||||
console.log("an error occurred while trying to load the image : " + imagePath);
|
||||
defer.resolve(null);
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
defer.resolve(null);
|
||||
if (!imagePath) {
|
||||
defer.reject("No image path");
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
textureLoader.crossOrigin = '';
|
||||
|
||||
textureLoader.load(
|
||||
imagePath,
|
||||
function(texture) {
|
||||
/**
|
||||
* onLoad
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType] = texture;
|
||||
instanceMaterial[instanceMaterialMapType].name = gameLibTexture.name;
|
||||
instanceMaterial[instanceMaterialMapType].anisotropy = gameLibTexture.anisotropy;
|
||||
instanceMaterial[instanceMaterialMapType].encoding = gameLibTexture.encoding;
|
||||
instanceMaterial[instanceMaterialMapType].flipY = gameLibTexture.flipY;
|
||||
/**
|
||||
* We don't restore the format since this changing from OS to OS and breaks the implementation sometimes
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType].generateMipmaps = gameLibTexture.generateMipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].magFilter = gameLibTexture.magFilter;
|
||||
instanceMaterial[instanceMaterialMapType].minFilter = gameLibTexture.minFilter;
|
||||
instanceMaterial[instanceMaterialMapType].mapping = gameLibTexture.mapping;
|
||||
instanceMaterial[instanceMaterialMapType].mipmaps = gameLibTexture.mipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].offset = new graphics.instance.Vector2(
|
||||
gameLibTexture.offset.x,
|
||||
gameLibTexture.offset.y
|
||||
);
|
||||
instanceMaterial[instanceMaterialMapType].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
||||
instanceMaterial[instanceMaterialMapType].textureType = gameLibTexture.textureType;
|
||||
instanceMaterial[instanceMaterialMapType].wrapS = gameLibTexture.wrapS;
|
||||
instanceMaterial[instanceMaterialMapType].wrapT = gameLibTexture.wrapT;
|
||||
instanceMaterial[instanceMaterialMapType].unpackAlignment = gameLibTexture.unpackAlignment;
|
||||
instanceMaterial.needsUpdate = true;
|
||||
defer.resolve(true);
|
||||
},
|
||||
function(xhr) {
|
||||
/**
|
||||
* onProgress
|
||||
*/
|
||||
if (progressCallback) {
|
||||
progressCallback(Math.round(xhr.loaded / xhr.total * 100));
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
/**
|
||||
* onError
|
||||
*/
|
||||
console.log('Image could not be loaded: ' + imagePath, error);
|
||||
defer.reject('Image could not be loaded: ' + imagePath);
|
||||
}
|
||||
);
|
||||
|
||||
return defer.promise;
|
||||
};
|
||||
|
||||
|
@ -4254,7 +4266,7 @@ GameLib.D3.Texture.loadMap = function(
|
|||
* @param progressCallback
|
||||
* @returns Q[]
|
||||
*/
|
||||
GameLib.D3.Texture.loadMaps = function(
|
||||
GameLib.D3.Texture.LoadMaps = function(
|
||||
gameLibMaterial,
|
||||
blenderMaps,
|
||||
instanceMaterial,
|
||||
|
@ -4262,7 +4274,6 @@ GameLib.D3.Texture.loadMaps = function(
|
|||
uploadUrl,
|
||||
progressCallback
|
||||
) {
|
||||
|
||||
var textureMaps = [];
|
||||
|
||||
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
||||
|
@ -4330,7 +4341,7 @@ GameLib.D3.Texture.loadMaps = function(
|
|||
}
|
||||
|
||||
textureMaps.push(
|
||||
GameLib.D3.Texture.loadMap(
|
||||
GameLib.D3.Texture.LoadMap(
|
||||
gameLibMaterial.maps[map],
|
||||
instanceMaterial,
|
||||
instanceMap,
|
||||
|
|
|
@ -513,7 +513,7 @@ GameLib.D3.Material.TYPE_MULTI_MATERIAL= "MultiMaterial";
|
|||
* @param uploadUrl String
|
||||
* @param progressCallback
|
||||
*/
|
||||
GameLib.D3.Material.createInstanceMaterial = function(
|
||||
GameLib.D3.Material.CreateInstanceMaterial = function(
|
||||
gameLibMaterial,
|
||||
graphics,
|
||||
uploadUrl,
|
||||
|
@ -665,10 +665,13 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
|||
|
||||
} else {
|
||||
console.log("material type is not implemented yet: " + gameLibMaterial.materialType + " - material indexes could be screwed up");
|
||||
defer.reject(null);
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
if (blenderMaps.length > 0) {
|
||||
var textureMaps = GameLib.D3.Texture.loadMaps(
|
||||
|
||||
var textureMaps = GameLib.D3.Texture.LoadMaps(
|
||||
gameLibMaterial,
|
||||
blenderMaps,
|
||||
instanceMaterial,
|
||||
|
@ -676,16 +679,22 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
|||
uploadUrl,
|
||||
progressCallback
|
||||
);
|
||||
Q.all(textureMaps).then(
|
||||
function(){
|
||||
defer.resolve(instanceMaterial);
|
||||
}
|
||||
).catch(
|
||||
function(error){
|
||||
console.log(error);
|
||||
defer.reject(error);
|
||||
}
|
||||
)
|
||||
|
||||
if (textureMaps.length > 0) {
|
||||
Q.all(textureMaps).then(
|
||||
function onFulfilled(map){
|
||||
defer.resolve(instanceMaterial);
|
||||
},
|
||||
function onRejected(message) {
|
||||
console.log(message);
|
||||
defer.reject(message);
|
||||
},
|
||||
function onProgress(progress) {
|
||||
console.log('progress');
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
defer.resolve(instanceMaterial);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
|||
* @param graphics
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.D3.Mesh.createInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||
GameLib.D3.Mesh.CreateInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||
|
||||
var threeMesh = null;
|
||||
|
||||
|
|
|
@ -470,24 +470,16 @@ GameLib.D3.Scene.loadScene = function(
|
|||
geometry.computeVertexNormals();
|
||||
}
|
||||
|
||||
var instanceMaterialLoaders = [];
|
||||
var instanceMaterial = GameLib.D3.Material.CreateInstanceMaterial(
|
||||
materials[0],
|
||||
graphics,
|
||||
uploadUrl,
|
||||
progressCallback
|
||||
);
|
||||
|
||||
/**
|
||||
* Setup materials
|
||||
*/
|
||||
for (var mi = 0; mi < materials.length; mi++) {
|
||||
instanceMaterialLoaders.push(
|
||||
GameLib.D3.Material.createInstanceMaterial(
|
||||
materials[mi],
|
||||
graphics,
|
||||
uploadUrl,
|
||||
progressCallback
|
||||
)
|
||||
);
|
||||
}
|
||||
var result = instanceMaterial.then(
|
||||
|
||||
var result = Q.all(instanceMaterialLoaders).then(
|
||||
function(mesh, geometry) {
|
||||
(function(__mesh, __geometry) {
|
||||
return function(materials) {
|
||||
|
||||
console.log("loaded material : " + materials[0].name);
|
||||
|
@ -497,41 +489,49 @@ GameLib.D3.Scene.loadScene = function(
|
|||
*/
|
||||
var material = materials[0];
|
||||
|
||||
var threeMesh = GameLib.D3.Mesh.createInstanceMesh(
|
||||
mesh,
|
||||
geometry,
|
||||
var instanceMesh = GameLib.D3.Mesh.CreateInstanceMesh(
|
||||
__mesh,
|
||||
__geometry,
|
||||
material,
|
||||
graphics
|
||||
);
|
||||
threeMesh.name = mesh.name;
|
||||
instanceMesh.name = __mesh.name;
|
||||
|
||||
threeMesh.position.x = mesh.position.x;
|
||||
threeMesh.position.y = mesh.position.y;
|
||||
threeMesh.position.z = mesh.position.z;
|
||||
instanceMesh.position.x = __mesh.position.x;
|
||||
instanceMesh.position.y = __mesh.position.y;
|
||||
instanceMesh.position.z = __mesh.position.z;
|
||||
|
||||
threeMesh.rotation.x = mesh.rotation.x;
|
||||
threeMesh.rotation.y = mesh.rotation.y;
|
||||
threeMesh.rotation.z = mesh.rotation.z;
|
||||
instanceMesh.rotation.x = __mesh.rotation.x;
|
||||
instanceMesh.rotation.y = __mesh.rotation.y;
|
||||
instanceMesh.rotation.z = __mesh.rotation.z;
|
||||
|
||||
threeMesh.scale.x = mesh.scale.x;
|
||||
threeMesh.scale.y = mesh.scale.y;
|
||||
threeMesh.scale.z = mesh.scale.z;
|
||||
instanceMesh.scale.x = __mesh.scale.x;
|
||||
instanceMesh.scale.y = __mesh.scale.y;
|
||||
instanceMesh.scale.z = __mesh.scale.z;
|
||||
|
||||
threeMesh.quaternion.x = mesh.quaternion.x;
|
||||
threeMesh.quaternion.y = mesh.quaternion.y;
|
||||
threeMesh.quaternion.z = mesh.quaternion.z;
|
||||
threeMesh.quaternion.w = mesh.quaternion.w;
|
||||
instanceMesh.quaternion.x = __mesh.quaternion.x;
|
||||
instanceMesh.quaternion.y = __mesh.quaternion.y;
|
||||
instanceMesh.quaternion.z = __mesh.quaternion.z;
|
||||
instanceMesh.quaternion.w = __mesh.quaternion.w;
|
||||
|
||||
return threeMesh;
|
||||
return instanceMesh;
|
||||
};
|
||||
}(mesh, geometry)
|
||||
).catch(function(error){
|
||||
console.log(error);
|
||||
});
|
||||
})(mesh, geometry),
|
||||
function onRejected(message) {
|
||||
console.log(message);
|
||||
return null;
|
||||
},
|
||||
function onProgress(progress) {
|
||||
console.log('material progress');
|
||||
}
|
||||
);
|
||||
|
||||
meshQ.push(result);
|
||||
}
|
||||
|
||||
debugger;
|
||||
console.log('hi');
|
||||
|
||||
Q.all(meshQ).then(
|
||||
function(instanceMeshes){
|
||||
console.log("all meshes have loaded");
|
||||
|
@ -621,7 +621,11 @@ GameLib.D3.Scene.loadScene = function(
|
|||
}
|
||||
);
|
||||
}
|
||||
}).catch(
|
||||
},
|
||||
function(error) {
|
||||
console.log(error);
|
||||
}
|
||||
).catch(
|
||||
function(error){
|
||||
console.log(error);
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
|||
* @param progressCallback
|
||||
* @returns {Promise}
|
||||
*/
|
||||
GameLib.D3.Texture.loadMap = function(
|
||||
GameLib.D3.Texture.LoadMap = function(
|
||||
gameLibTexture,
|
||||
instanceMaterial,
|
||||
instanceMaterialMapType,
|
||||
|
@ -235,62 +235,61 @@ GameLib.D3.Texture.loadMap = function(
|
|||
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
||||
}
|
||||
|
||||
if (imagePath) {
|
||||
|
||||
textureLoader.crossOrigin = '';
|
||||
|
||||
textureLoader.load(
|
||||
imagePath,
|
||||
function(texture) {
|
||||
/**
|
||||
* onLoad
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType] = texture;
|
||||
instanceMaterial[instanceMaterialMapType].name = gameLibTexture.name;
|
||||
instanceMaterial[instanceMaterialMapType].anisotropy = gameLibTexture.anisotropy;
|
||||
instanceMaterial[instanceMaterialMapType].encoding = gameLibTexture.encoding;
|
||||
instanceMaterial[instanceMaterialMapType].flipY = gameLibTexture.flipY;
|
||||
/**
|
||||
* We don't restore the format since this changing from OS to OS and breaks the implementation sometimes
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType].generateMipmaps = gameLibTexture.generateMipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].magFilter = gameLibTexture.magFilter;
|
||||
instanceMaterial[instanceMaterialMapType].minFilter = gameLibTexture.minFilter;
|
||||
instanceMaterial[instanceMaterialMapType].mapping = gameLibTexture.mapping;
|
||||
instanceMaterial[instanceMaterialMapType].mipmaps = gameLibTexture.mipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].offset = new graphics.instance.Vector2(
|
||||
gameLibTexture.offset.x,
|
||||
gameLibTexture.offset.y
|
||||
);
|
||||
instanceMaterial[instanceMaterialMapType].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
||||
instanceMaterial[instanceMaterialMapType].textureType = gameLibTexture.textureType;
|
||||
instanceMaterial[instanceMaterialMapType].wrapS = gameLibTexture.wrapS;
|
||||
instanceMaterial[instanceMaterialMapType].wrapT = gameLibTexture.wrapT;
|
||||
instanceMaterial[instanceMaterialMapType].unpackAlignment = gameLibTexture.unpackAlignment;
|
||||
instanceMaterial.needsUpdate = true;
|
||||
defer.resolve(true);
|
||||
},
|
||||
function(xhr) {
|
||||
/**
|
||||
* onProgress
|
||||
*/
|
||||
if (progressCallback) {
|
||||
progressCallback(Math.round(xhr.loaded / xhr.total * 100));
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
/**
|
||||
* onError
|
||||
*/
|
||||
console.log("an error occurred while trying to load the image : " + imagePath);
|
||||
defer.resolve(null);
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
defer.resolve(null);
|
||||
if (!imagePath) {
|
||||
defer.reject("No image path");
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
textureLoader.crossOrigin = '';
|
||||
|
||||
textureLoader.load(
|
||||
imagePath,
|
||||
function(texture) {
|
||||
/**
|
||||
* onLoad
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType] = texture;
|
||||
instanceMaterial[instanceMaterialMapType].name = gameLibTexture.name;
|
||||
instanceMaterial[instanceMaterialMapType].anisotropy = gameLibTexture.anisotropy;
|
||||
instanceMaterial[instanceMaterialMapType].encoding = gameLibTexture.encoding;
|
||||
instanceMaterial[instanceMaterialMapType].flipY = gameLibTexture.flipY;
|
||||
/**
|
||||
* We don't restore the format since this changing from OS to OS and breaks the implementation sometimes
|
||||
*/
|
||||
instanceMaterial[instanceMaterialMapType].generateMipmaps = gameLibTexture.generateMipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].magFilter = gameLibTexture.magFilter;
|
||||
instanceMaterial[instanceMaterialMapType].minFilter = gameLibTexture.minFilter;
|
||||
instanceMaterial[instanceMaterialMapType].mapping = gameLibTexture.mapping;
|
||||
instanceMaterial[instanceMaterialMapType].mipmaps = gameLibTexture.mipmaps;
|
||||
instanceMaterial[instanceMaterialMapType].offset = new graphics.instance.Vector2(
|
||||
gameLibTexture.offset.x,
|
||||
gameLibTexture.offset.y
|
||||
);
|
||||
instanceMaterial[instanceMaterialMapType].premultiplyAlpha = gameLibTexture.premultiplyAlpha;
|
||||
instanceMaterial[instanceMaterialMapType].textureType = gameLibTexture.textureType;
|
||||
instanceMaterial[instanceMaterialMapType].wrapS = gameLibTexture.wrapS;
|
||||
instanceMaterial[instanceMaterialMapType].wrapT = gameLibTexture.wrapT;
|
||||
instanceMaterial[instanceMaterialMapType].unpackAlignment = gameLibTexture.unpackAlignment;
|
||||
instanceMaterial.needsUpdate = true;
|
||||
defer.resolve(true);
|
||||
},
|
||||
function(xhr) {
|
||||
/**
|
||||
* onProgress
|
||||
*/
|
||||
if (progressCallback) {
|
||||
progressCallback(Math.round(xhr.loaded / xhr.total * 100));
|
||||
}
|
||||
},
|
||||
function(error) {
|
||||
/**
|
||||
* onError
|
||||
*/
|
||||
console.log('Image could not be loaded: ' + imagePath, error);
|
||||
defer.reject('Image could not be loaded: ' + imagePath);
|
||||
}
|
||||
);
|
||||
|
||||
return defer.promise;
|
||||
};
|
||||
|
||||
|
@ -305,7 +304,7 @@ GameLib.D3.Texture.loadMap = function(
|
|||
* @param progressCallback
|
||||
* @returns Q[]
|
||||
*/
|
||||
GameLib.D3.Texture.loadMaps = function(
|
||||
GameLib.D3.Texture.LoadMaps = function(
|
||||
gameLibMaterial,
|
||||
blenderMaps,
|
||||
instanceMaterial,
|
||||
|
@ -313,7 +312,6 @@ GameLib.D3.Texture.loadMaps = function(
|
|||
uploadUrl,
|
||||
progressCallback
|
||||
) {
|
||||
|
||||
var textureMaps = [];
|
||||
|
||||
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
||||
|
@ -381,7 +379,7 @@ GameLib.D3.Texture.loadMaps = function(
|
|||
}
|
||||
|
||||
textureMaps.push(
|
||||
GameLib.D3.Texture.loadMap(
|
||||
GameLib.D3.Texture.LoadMap(
|
||||
gameLibMaterial.maps[map],
|
||||
instanceMaterial,
|
||||
instanceMap,
|
||||
|
|
Loading…
Reference in New Issue