When I invoke this JavaScript function, it successfully adds the object to the scene:
var loader = new THREE.FBXLoader();
function returnFBX(PATH, scene) {
loader.load('obj/' + PATH + '.fbx', function (object) {
scene.add(object);
});
}
However, if I change:
scene.add(object);
to:
return object;
It appears to return undefined.
I attempted using Promises and the Loading Manager, but both only managed to add the object to the scene rather than returning it as expected.
The issue may stem from having two nested functions and the asynchronous nature of loading. Yet, I am unsure how to resolve this given that this is a common method for loading objects.