Promise, , , TextureLoader doesn 't a Promise ( ). , IE11 polyfill, promises.
- , textureArray JSON Array:
var allPromises = [];
textureArray.forEach( function( jsonMat ) {
allPromises.push( new Promise( function( resolve, reject ) {
TLoader.load(
BASE_ODB_URL + jsonMat.pic,
function( texture ) {
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( jsonMat.scaleu, jsonMat.scalev );
var material = new THREE.MeshLambertMaterial({
map: texture,
side: THREE.DoubleSide,
name: jsonMat.mname
});
THREEMatList.push( material );
resolve( material );
},
function( xhr ) {
},
function( xhr ) {
reject( new Error( 'Could not load ' + jsonMat.pic ) );
}
);
}));
});
Promise.all( allPromises )
.then( function( arrayOfMaterials ) {
}, function( error ) {
console.error( "Could not load all textures:", error );
});
, , , Promise Promise s. Promise, allPromises. , promises , .
, Promise.all , , , - . , Promise polyfill , Promise/A +, RSVP.js. reject() resolve() .