Instances on imported mesh

Hello,
I’m trying to create instances of a imported mesh in gltf format.
But before, here the result without making instances : Capture — ImgBB

for (let i = 0; i < 5000 / 300; i++) {
            loader = BABYLON.SceneLoader.ImportMesh("", 'assets/model/', 'scene1bin.glb', scene, function (mesh) {
                mesh = mesh[0];
                mesh.position = new BABYLON.Vector3(i * 300, -105, 55)
                mesh.scaling = new BABYLON.Vector3(4, 4, 5)

        })

So now, I use as a model the code available in the doc: “how_to_use_instances”

 loader = BABYLON.SceneLoader.ImportMesh("", 'assets/model/', 'scene1bin.glb', scene, function (mesh) {
        mesh = mesh[0];
        // position changed in order to see it
        mesh.position = new BABYLON.Vector3(300, 0, 0)
        mesh.scaling = new BABYLON.Vector3(4, 4, 5)
        for (let i = 1; i < 5000 / 300; i++) {
            var meshInst = mesh.createInstances("i"+i)
            mesh.position = new BABYLON.Vector3(i * 300, -105, 55)
            mesh.scaling = new BABYLON.Vector3(4, 4, 5)
        }
    })

Here the result: Capture2-PNG — ImgBB

As you see, my instances are not visible and I don’t understand why.

Thank you for you help :slight_smile:

Welcome to the forums @darkloner99!

mesh[0] is a root node that does have any mesh attached. What you probably want is to call instantiateHierarchy or use SceneLoader.LoadAssetContainer and call instantiateModelsToScene.

2 Likes