Check out my snippet below for loading a .fbx object. It defaults to loading an object as BufferGeometry
:
const loader = new THREE.FBXLoader();
async function loadFiles(scene, props) {
const { files, path, childName, fn } = props;
if (index > files.length - 1) return;
loader.load(path + files[index], object => {
// apply functions / transformations to obj
let sceneObj = fn.call(null, object, props);
if (sceneObj) { scene.add(sceneObj) }
// add obj to scene and push to array
scene.add(object);
objects.push(object);
// if there is another object to load, load it
index++;
loadFiles(scene, props);
});
}
I encountered a challenge when attempting to use
var geometry = new THREE.Geometry().fromBufferGeometry(bufferGeometry);
to resolve the issue. The problem lies in not creating a mesh
in my loading function, making it difficult to implement this code.
My goal is to have a more user-friendly way of accessing the vertices of the object, hence why I prefer not to load it as BufferGeometry
.