In THREE.js, if I have multiple JSONLoader calls to load multiple objects like this (simplified example):
function init() {
var loader = new THREE.JSONLoader();
loader.load("mesh1.js", createScene);
loader.load("mesh2.js", createScene);
}
function createScene( geometry ) {
if (geometry.filename == "mesh1.js") {
mesh1 = new THREE.Mesh( geometry, material );
scene.add( mesh1 );
} else if (geometry.filename == "mesh2.js") {
mesh2 = new THREE.Mesh( geometry, material );
scene.add( mesh2 );
}
}
How to determine which grid was returned in the callback, especially when they often fail?
I am trying to handle multiple returned grids with one common callback function. Is there any property in the returned geometry that indicates the original file name that I can verify?
Or maybe there is a more elegant way? Perhaps creating a new THREE.JSONLoader object for each call will help the callback function determine which grid arrived?
I appreciate any help / ideas! Thank!
source
share