I want to load a model from glTF, combine all the meshes it contains into one, and add it to the scene.
So I tried the following code.
const gltf = await loader.loadAsync(modelFilePaths[i]);
const geometries = [];
gltf.scene.traverse(function(obj) {
if (obj instanceof THREE.Mesh === true) {
var mesh = obj;
geometries.push(mesh.geometry);
}
});
const geometry = THREE.BufferGeometryUtils.mergeBufferGeometries(geometries);
const material = new THREE.MeshNormalMaterial();
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
When executed, the following runtime error occurs Is there something wrong with the usage?