BABYLON.SceneLoader.ImportMesh('', '/api/tunnel/', 'camera-min.glb', scene, (meshes, particleSystems, skeletons )=>{
for (let i = 0; i < 10; i++) {
let mesh = meshes[0];
mesh.position.set(20*i, 0, 0);
mesh.scaling.set(100,100,100);
scene.addMesh(mesh);
}
});
Welcome aboard!
Trying to guess your problem…
First you don’t need to call addMesh
as ImportMesh
will do it itself.
If you want 10 instances of your mesh you should either clone it or instance it by using either meshes[0].clone("name")
or meshes[0].createInstance("name")
:
And if you want them all separate you could also rely on the AssetContainer feature: Asset Containers | Babylon.js Documentation
Using asset containers, you can duplicate them using the instantiateModelsToScene
function as it says in the doc link.
Thank you very much!