Reputation: 321
Loading a single texture with a callback is easy, eg:
var loader = new THREE.TextureLoader();
var texture1 = loader.load("https://i.imgur.com/UiTMJzv.png", process);
//called only after texture1 is loaded
function process(){
}
The question is how can I load multiple textures asynchronously (and not sequentially) and only call a processing function when all have been loaded?
Upvotes: 0
Views: 609
Reputation: 31026
You can use THREE.LoadingManager for this:
var manager = new THREE.LoadingManager( function() {
// this onLoad callback is executed when both textures are loaded
} );
var loader = new THREE.TextureLoader( manager );
var texture1 = loader.load( 'texture1.png' );
var texture2 = loader.load( 'texture2.png' );
Upvotes: 3