Currently, I am working on release R73 and my task involves populating an array with materials for later use. The successful loading of all materials in this array is crucial for their intended usage.
At the moment, I am iterating through a JSON information array and executing the following code for each element:
TLoader.load(
BASE_ODB_URL + jsonMat.pic,
function (texture) {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(jsonMat.scaleu, jsonMat.scalev);
Mat = new THREE.MeshLambertMaterial({
map : texture,
side : THREE.DoubleSide,
name : jsonMat.mname
});
THREEMatList.push(Mat);
},
function (xhr) {
}, //onProgress
function (xhr) {
Mat = new THREE.MeshLambertMaterial({
color : 0xff0000,
side : THREE.DoubleSide,
name : jsonMat.mname
});
THREEMatList.push(Mat);
}
)
The TLoader is instantiated at the beginning: variable TLoader = new THREE.TextureLoader();
If a material is not available when required, a fallback material is used as an error handling mechanism. Is there a method to ensure that .load() completes before proceeding?