I've encountered an issue in my code where I'm unable to locate the mistake(s)... The problem lies within a loop that loads multiple objects and assigns them names, but the "objects" array remains empty as a result. My goal is to give each object a unique name for intersection detection purposes (which works fine in the code). However, when interacting with different parts of a loaded object (a cathedral), the database is being contacted even though all objects have the same name. Can anyone shed light on why this might be happening? Here is the code snippet: The 'objects' array stores all geometries, and 'object' is the argument of the function. 'load_obj' is defined by a loop using the values stored in another array named OBJETS containing the names of different parts of the cathedral.
for (var i in OBJETS){
load_obj = OBJETS[i];
loader.load('./Donnees/OBJ/'+load_obj+'.obj', './Donnees/OBJ/'+load_obj+'.mtl', function ( object ) {
object.name = load_obj;
scene.add(object);
objects.push(object);
}, onProgress, onError );
}
Appreciate any assistance provided!