Skip to content Skip to sidebar Skip to footer

Three.js Loading Order

I have a problem with my Three.js Json-Loader. I have some object their path is saved in an array. Now I want to load them and sort them in a List so that I can select them. But th

Solution 1:

You are being bitten by a rather common mistake involving JavaScript closure rules, see this link. In short, to get the correct path passed to the save function, you need to wrap it into a helper function factory, like this: (or as shown in the above link)

function saveHelper(path) {
    return function(geometry) {
        save(geometry, path);
    }
}

for(var j=0;j<21;j++){
    var path = objPath[j];
    loader.load( path, saveHelper(path) );
}

Post a Comment for "Three.js Loading Order"