If I call this function in Javascript, it works, and it 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 replace:
scene.add(object);
with:
return object;
It seems to return undefined.
I tried using Promises, as well as the Loading Manager, but both only seem to be able to add the object to the scene, and not return an object.
I think this is because there are two nested functions within each other, as well as the loading being asynchronous. But I'm not sure how to fix this, as this is a standard way to load objects.