I'm facing an issue with my Three.js Json-Loader. I have a set of objects whose paths are stored in an array. My goal is to load them and organize them into a list for easy selection. However, the order in which they load differs from their arrangement in the array because of varying sizes – smaller objects are loaded first and larger ones last. As a result, after loading them, I am unable to determine the name of the object (which is represented by its path).
Here's my current code:
for(var j=0;j<21;j++){
var path = objPath[j];
loader.load( path, function( geometry ) { save(geometry, path); } );
}
As per this code snippet, the path passed to the save method always corresponds to the last path in the array (objPath[20]) due to the for-loop executing faster than the loading method itself. How can I ensure that the correct path is retained?