I am trying to add some child meshes to the scene, but the setParent
function does not seem to work as expected. Here is what my code looks like:
await BABYLON.SceneLoader.AppendAsync("/", "parent.glb", scene);
const rootMesh = scene.meshes[0];
importChild(scene, rootMesh)
importChild function:
const { meshes } = await BABYLON.SceneLoader.ImportChildAsync(
null,
"/",
"child.glb",
scene
);
const rootMesh = meshes[0];
for (let i=1; i < meshes.length; i++) { // This code breaks something, but there are no console errors, because if I comment this out, the child gets imported but is not attached to the parent
meshes[i].setParent(parent);
}
How should I fix this issue?