So, this is my GLTF model in Blender:
This code…
new GLTFLoader(manager).load('./model.glb', (gltf) => {
console.log("scene.children : ", gltf.scene.children);
gltf.scene.children.forEach((mesh) => {
console.log("Iterating scene.children : ", mesh);
scene.add(mesh);
});
});
…prints out this: (notice how the names don’t match!)
While the same code without the “add” function call…
new GLTFLoader(manager).load('./model.glb', (gltf) => {
console.log("scene.children : ", gltf.scene.children);
gltf.scene.children.forEach((mesh) => {
console.log("Iterating scene.children : ", mesh);
// scene.add(mesh);
});
});
…correctly prints out this:
While trying for hours, I just assumed this is probably some deep multithreading problem. I tried adding more loops because why not:
new GLTFLoader(manager).load('./model.glb', (gltf) => {
console.log("scene.children : ", gltf.scene.children);
gltf.scene.children.forEach((mesh) => {
console.log("Iterating scene.children : ", mesh);
scene.add(mesh);
});
gltf.scene.children.forEach((mesh) => {
console.log("Iterating scene.children : ", mesh);
scene.add(mesh);
});
gltf.scene.children.forEach((mesh) => {
console.log("Iterating scene.children : ", mesh);
scene.add(mesh);
});
});
And it actually worked! What! But scene.children is empty.
Please tell me I’m missing something super basic… This is driving me insane