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 uploadUrl String
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.createInstanceMaterial = function(
|
GameLib.D3.Material.CreateInstanceMaterial = function(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
graphics,
|
graphics,
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
|
@ -1571,10 +1571,13 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("material type is not implemented yet: " + gameLibMaterial.materialType + " - material indexes could be screwed up");
|
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) {
|
if (blenderMaps.length > 0) {
|
||||||
var textureMaps = GameLib.D3.Texture.loadMaps(
|
|
||||||
|
var textureMaps = GameLib.D3.Texture.LoadMaps(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
blenderMaps,
|
blenderMaps,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
|
@ -1582,16 +1585,22 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
progressCallback
|
progressCallback
|
||||||
);
|
);
|
||||||
Q.all(textureMaps).then(
|
|
||||||
function(){
|
if (textureMaps.length > 0) {
|
||||||
defer.resolve(instanceMaterial);
|
Q.all(textureMaps).then(
|
||||||
}
|
function onFulfilled(map){
|
||||||
).catch(
|
defer.resolve(instanceMaterial);
|
||||||
function(error){
|
},
|
||||||
console.log(error);
|
function onRejected(message) {
|
||||||
defer.reject(error);
|
console.log(message);
|
||||||
}
|
defer.reject(message);
|
||||||
)
|
},
|
||||||
|
function onProgress(progress) {
|
||||||
|
console.log('progress');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
defer.resolve(instanceMaterial);
|
defer.resolve(instanceMaterial);
|
||||||
}
|
}
|
||||||
|
@ -1935,7 +1944,7 @@ GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.createInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
GameLib.D3.Mesh.CreateInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||||
|
|
||||||
var threeMesh = null;
|
var threeMesh = null;
|
||||||
|
|
||||||
|
@ -3390,24 +3399,16 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
geometry.computeVertexNormals();
|
geometry.computeVertexNormals();
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceMaterialLoaders = [];
|
var instanceMaterial = GameLib.D3.Material.CreateInstanceMaterial(
|
||||||
|
materials[0],
|
||||||
|
graphics,
|
||||||
|
uploadUrl,
|
||||||
|
progressCallback
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
var result = instanceMaterial.then(
|
||||||
* Setup materials
|
|
||||||
*/
|
|
||||||
for (var mi = 0; mi < materials.length; mi++) {
|
|
||||||
instanceMaterialLoaders.push(
|
|
||||||
GameLib.D3.Material.createInstanceMaterial(
|
|
||||||
materials[mi],
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Q.all(instanceMaterialLoaders).then(
|
(function(__mesh, __geometry) {
|
||||||
function(mesh, geometry) {
|
|
||||||
return function(materials) {
|
return function(materials) {
|
||||||
|
|
||||||
console.log("loaded material : " + materials[0].name);
|
console.log("loaded material : " + materials[0].name);
|
||||||
|
@ -3417,41 +3418,49 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
*/
|
*/
|
||||||
var material = materials[0];
|
var material = materials[0];
|
||||||
|
|
||||||
var threeMesh = GameLib.D3.Mesh.createInstanceMesh(
|
var instanceMesh = GameLib.D3.Mesh.CreateInstanceMesh(
|
||||||
mesh,
|
__mesh,
|
||||||
geometry,
|
__geometry,
|
||||||
material,
|
material,
|
||||||
graphics
|
graphics
|
||||||
);
|
);
|
||||||
threeMesh.name = mesh.name;
|
instanceMesh.name = __mesh.name;
|
||||||
|
|
||||||
threeMesh.position.x = mesh.position.x;
|
instanceMesh.position.x = __mesh.position.x;
|
||||||
threeMesh.position.y = mesh.position.y;
|
instanceMesh.position.y = __mesh.position.y;
|
||||||
threeMesh.position.z = mesh.position.z;
|
instanceMesh.position.z = __mesh.position.z;
|
||||||
|
|
||||||
threeMesh.rotation.x = mesh.rotation.x;
|
instanceMesh.rotation.x = __mesh.rotation.x;
|
||||||
threeMesh.rotation.y = mesh.rotation.y;
|
instanceMesh.rotation.y = __mesh.rotation.y;
|
||||||
threeMesh.rotation.z = mesh.rotation.z;
|
instanceMesh.rotation.z = __mesh.rotation.z;
|
||||||
|
|
||||||
threeMesh.scale.x = mesh.scale.x;
|
instanceMesh.scale.x = __mesh.scale.x;
|
||||||
threeMesh.scale.y = mesh.scale.y;
|
instanceMesh.scale.y = __mesh.scale.y;
|
||||||
threeMesh.scale.z = mesh.scale.z;
|
instanceMesh.scale.z = __mesh.scale.z;
|
||||||
|
|
||||||
threeMesh.quaternion.x = mesh.quaternion.x;
|
instanceMesh.quaternion.x = __mesh.quaternion.x;
|
||||||
threeMesh.quaternion.y = mesh.quaternion.y;
|
instanceMesh.quaternion.y = __mesh.quaternion.y;
|
||||||
threeMesh.quaternion.z = mesh.quaternion.z;
|
instanceMesh.quaternion.z = __mesh.quaternion.z;
|
||||||
threeMesh.quaternion.w = mesh.quaternion.w;
|
instanceMesh.quaternion.w = __mesh.quaternion.w;
|
||||||
|
|
||||||
return threeMesh;
|
return instanceMesh;
|
||||||
};
|
};
|
||||||
}(mesh, geometry)
|
})(mesh, geometry),
|
||||||
).catch(function(error){
|
function onRejected(message) {
|
||||||
console.log(error);
|
console.log(message);
|
||||||
});
|
return null;
|
||||||
|
},
|
||||||
|
function onProgress(progress) {
|
||||||
|
console.log('material progress');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
meshQ.push(result);
|
meshQ.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugger;
|
||||||
|
console.log('hi');
|
||||||
|
|
||||||
Q.all(meshQ).then(
|
Q.all(meshQ).then(
|
||||||
function(instanceMeshes){
|
function(instanceMeshes){
|
||||||
console.log("all meshes have loaded");
|
console.log("all meshes have loaded");
|
||||||
|
@ -3541,7 +3550,11 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}).catch(
|
},
|
||||||
|
function(error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
).catch(
|
||||||
function(error){
|
function(error){
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
@ -4162,7 +4175,7 @@ GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.loadMap = function(
|
GameLib.D3.Texture.LoadMap = function(
|
||||||
gameLibTexture,
|
gameLibTexture,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
instanceMaterialMapType,
|
instanceMaterialMapType,
|
||||||
|
@ -4184,62 +4197,61 @@ GameLib.D3.Texture.loadMap = function(
|
||||||
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imagePath) {
|
if (!imagePath) {
|
||||||
|
defer.reject("No image path");
|
||||||
textureLoader.crossOrigin = '';
|
return defer.promise;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return defer.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4254,7 +4266,7 @@ GameLib.D3.Texture.loadMap = function(
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @returns Q[]
|
* @returns Q[]
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.loadMaps = function(
|
GameLib.D3.Texture.LoadMaps = function(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
blenderMaps,
|
blenderMaps,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
|
@ -4262,7 +4274,6 @@ GameLib.D3.Texture.loadMaps = function(
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
progressCallback
|
progressCallback
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var textureMaps = [];
|
var textureMaps = [];
|
||||||
|
|
||||||
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
||||||
|
@ -4330,7 +4341,7 @@ GameLib.D3.Texture.loadMaps = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
textureMaps.push(
|
textureMaps.push(
|
||||||
GameLib.D3.Texture.loadMap(
|
GameLib.D3.Texture.LoadMap(
|
||||||
gameLibMaterial.maps[map],
|
gameLibMaterial.maps[map],
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
instanceMap,
|
instanceMap,
|
||||||
|
|
|
@ -513,7 +513,7 @@ GameLib.D3.Material.TYPE_MULTI_MATERIAL= "MultiMaterial";
|
||||||
* @param uploadUrl String
|
* @param uploadUrl String
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Material.createInstanceMaterial = function(
|
GameLib.D3.Material.CreateInstanceMaterial = function(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
graphics,
|
graphics,
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
|
@ -665,10 +665,13 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("material type is not implemented yet: " + gameLibMaterial.materialType + " - material indexes could be screwed up");
|
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) {
|
if (blenderMaps.length > 0) {
|
||||||
var textureMaps = GameLib.D3.Texture.loadMaps(
|
|
||||||
|
var textureMaps = GameLib.D3.Texture.LoadMaps(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
blenderMaps,
|
blenderMaps,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
|
@ -676,16 +679,22 @@ GameLib.D3.Material.createInstanceMaterial = function(
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
progressCallback
|
progressCallback
|
||||||
);
|
);
|
||||||
Q.all(textureMaps).then(
|
|
||||||
function(){
|
if (textureMaps.length > 0) {
|
||||||
defer.resolve(instanceMaterial);
|
Q.all(textureMaps).then(
|
||||||
}
|
function onFulfilled(map){
|
||||||
).catch(
|
defer.resolve(instanceMaterial);
|
||||||
function(error){
|
},
|
||||||
console.log(error);
|
function onRejected(message) {
|
||||||
defer.reject(error);
|
console.log(message);
|
||||||
}
|
defer.reject(message);
|
||||||
)
|
},
|
||||||
|
function onProgress(progress) {
|
||||||
|
console.log('progress');
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
defer.resolve(instanceMaterial);
|
defer.resolve(instanceMaterial);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ GameLib.D3.Mesh.TYPE_SKINNED = 1;
|
||||||
* @param graphics
|
* @param graphics
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Mesh.createInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
GameLib.D3.Mesh.CreateInstanceMesh = function(gameLibMesh, instanceGeometry, instanceMaterial, graphics) {
|
||||||
|
|
||||||
var threeMesh = null;
|
var threeMesh = null;
|
||||||
|
|
||||||
|
|
|
@ -470,24 +470,16 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
geometry.computeVertexNormals();
|
geometry.computeVertexNormals();
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceMaterialLoaders = [];
|
var instanceMaterial = GameLib.D3.Material.CreateInstanceMaterial(
|
||||||
|
materials[0],
|
||||||
|
graphics,
|
||||||
|
uploadUrl,
|
||||||
|
progressCallback
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
var result = instanceMaterial.then(
|
||||||
* Setup materials
|
|
||||||
*/
|
|
||||||
for (var mi = 0; mi < materials.length; mi++) {
|
|
||||||
instanceMaterialLoaders.push(
|
|
||||||
GameLib.D3.Material.createInstanceMaterial(
|
|
||||||
materials[mi],
|
|
||||||
graphics,
|
|
||||||
uploadUrl,
|
|
||||||
progressCallback
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
var result = Q.all(instanceMaterialLoaders).then(
|
(function(__mesh, __geometry) {
|
||||||
function(mesh, geometry) {
|
|
||||||
return function(materials) {
|
return function(materials) {
|
||||||
|
|
||||||
console.log("loaded material : " + materials[0].name);
|
console.log("loaded material : " + materials[0].name);
|
||||||
|
@ -497,41 +489,49 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
*/
|
*/
|
||||||
var material = materials[0];
|
var material = materials[0];
|
||||||
|
|
||||||
var threeMesh = GameLib.D3.Mesh.createInstanceMesh(
|
var instanceMesh = GameLib.D3.Mesh.CreateInstanceMesh(
|
||||||
mesh,
|
__mesh,
|
||||||
geometry,
|
__geometry,
|
||||||
material,
|
material,
|
||||||
graphics
|
graphics
|
||||||
);
|
);
|
||||||
threeMesh.name = mesh.name;
|
instanceMesh.name = __mesh.name;
|
||||||
|
|
||||||
threeMesh.position.x = mesh.position.x;
|
instanceMesh.position.x = __mesh.position.x;
|
||||||
threeMesh.position.y = mesh.position.y;
|
instanceMesh.position.y = __mesh.position.y;
|
||||||
threeMesh.position.z = mesh.position.z;
|
instanceMesh.position.z = __mesh.position.z;
|
||||||
|
|
||||||
threeMesh.rotation.x = mesh.rotation.x;
|
instanceMesh.rotation.x = __mesh.rotation.x;
|
||||||
threeMesh.rotation.y = mesh.rotation.y;
|
instanceMesh.rotation.y = __mesh.rotation.y;
|
||||||
threeMesh.rotation.z = mesh.rotation.z;
|
instanceMesh.rotation.z = __mesh.rotation.z;
|
||||||
|
|
||||||
threeMesh.scale.x = mesh.scale.x;
|
instanceMesh.scale.x = __mesh.scale.x;
|
||||||
threeMesh.scale.y = mesh.scale.y;
|
instanceMesh.scale.y = __mesh.scale.y;
|
||||||
threeMesh.scale.z = mesh.scale.z;
|
instanceMesh.scale.z = __mesh.scale.z;
|
||||||
|
|
||||||
threeMesh.quaternion.x = mesh.quaternion.x;
|
instanceMesh.quaternion.x = __mesh.quaternion.x;
|
||||||
threeMesh.quaternion.y = mesh.quaternion.y;
|
instanceMesh.quaternion.y = __mesh.quaternion.y;
|
||||||
threeMesh.quaternion.z = mesh.quaternion.z;
|
instanceMesh.quaternion.z = __mesh.quaternion.z;
|
||||||
threeMesh.quaternion.w = mesh.quaternion.w;
|
instanceMesh.quaternion.w = __mesh.quaternion.w;
|
||||||
|
|
||||||
return threeMesh;
|
return instanceMesh;
|
||||||
};
|
};
|
||||||
}(mesh, geometry)
|
})(mesh, geometry),
|
||||||
).catch(function(error){
|
function onRejected(message) {
|
||||||
console.log(error);
|
console.log(message);
|
||||||
});
|
return null;
|
||||||
|
},
|
||||||
|
function onProgress(progress) {
|
||||||
|
console.log('material progress');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
meshQ.push(result);
|
meshQ.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugger;
|
||||||
|
console.log('hi');
|
||||||
|
|
||||||
Q.all(meshQ).then(
|
Q.all(meshQ).then(
|
||||||
function(instanceMeshes){
|
function(instanceMeshes){
|
||||||
console.log("all meshes have loaded");
|
console.log("all meshes have loaded");
|
||||||
|
@ -621,7 +621,11 @@ GameLib.D3.Scene.loadScene = function(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}).catch(
|
},
|
||||||
|
function(error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
).catch(
|
||||||
function(error){
|
function(error){
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ GameLib.D3.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.loadMap = function(
|
GameLib.D3.Texture.LoadMap = function(
|
||||||
gameLibTexture,
|
gameLibTexture,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
instanceMaterialMapType,
|
instanceMaterialMapType,
|
||||||
|
@ -235,62 +235,61 @@ GameLib.D3.Texture.loadMap = function(
|
||||||
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
imagePath = uploadUrl + '/' + gameLibTexture.image.filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imagePath) {
|
if (!imagePath) {
|
||||||
|
defer.reject("No image path");
|
||||||
textureLoader.crossOrigin = '';
|
return defer.promise;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return defer.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -305,7 +304,7 @@ GameLib.D3.Texture.loadMap = function(
|
||||||
* @param progressCallback
|
* @param progressCallback
|
||||||
* @returns Q[]
|
* @returns Q[]
|
||||||
*/
|
*/
|
||||||
GameLib.D3.Texture.loadMaps = function(
|
GameLib.D3.Texture.LoadMaps = function(
|
||||||
gameLibMaterial,
|
gameLibMaterial,
|
||||||
blenderMaps,
|
blenderMaps,
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
|
@ -313,7 +312,6 @@ GameLib.D3.Texture.loadMaps = function(
|
||||||
uploadUrl,
|
uploadUrl,
|
||||||
progressCallback
|
progressCallback
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var textureMaps = [];
|
var textureMaps = [];
|
||||||
|
|
||||||
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
for (var ti = 0; ti < blenderMaps.length; ti++) {
|
||||||
|
@ -381,7 +379,7 @@ GameLib.D3.Texture.loadMaps = function(
|
||||||
}
|
}
|
||||||
|
|
||||||
textureMaps.push(
|
textureMaps.push(
|
||||||
GameLib.D3.Texture.loadMap(
|
GameLib.D3.Texture.LoadMap(
|
||||||
gameLibMaterial.maps[map],
|
gameLibMaterial.maps[map],
|
||||||
instanceMaterial,
|
instanceMaterial,
|
||||||
instanceMap,
|
instanceMap,
|
||||||
|
|
Loading…
Reference in New Issue