Instances with animation

I tried to import a mesh with animations and created instance for it using below reference. But, the main mesh only animating, the instance mesh is not animating. How to solve this?

In Chrome I see both models animated -


Thanks For your reply @labris . I couldn’t see this models in my browser(Chrome). In my browser ,there is the plane only.
Any other references for import meshes and instancing that with animations.

It’s working on my mobile phone as well. Chrome.

1 Like

yes, In mobile, it is working fine. But why not on desktop.

Oh. It is just because of the firewall settings. Now only I am seeing the error in my console.
And I am using this same script in my project as well, I am sharing script below. In that, the model is loaded. the instances also created . But the animation happens only on the actual mesh. not on instances.

    'Hotspot Light.glb',
    function (meshes, particleSystems, skeletons, animationGroups) {
      let inst = createInst(meshes[0],1,0.05, -1,animationGroups);
      let inst2 = createInst(meshes[0],1,0.05, -1.4,animationGroups);
      let inst3 = createInst(meshes[0],0.5,0.05, -1.45,animationGroups);
      let inst4 = createInst(meshes[0],0.85,0.05, -1.8,animationGroups);
      let inst5 = createInst(meshes[0],-0.22,0.3, -0.5,animationGroups);
      meshes.forEach((mesh) => {
        if (mesh.material) {
          mesh.actionManager = action_manager_mesh;    

  function createInst(mesh:any, x:any, y:any,z:any,animations:any){
    let instRoot = new BABYLON.TransformNode("instRoot", scene2);
    for (let i = 0; i < mesh.getChildren().length; i++) {
        let bodyPart = new BABYLON.TransformNode("bodyPart", scene2);
        bodyPart.parent = instRoot;
        bodyPart.position = mesh.getChildren()[i].position;

        for (let j = 0; j < mesh.getChildren()[i].getChildren().length; j++) {

            let bodyPartInst = mesh.getChildren()[i].getChildren()[j].createInstance("bodyPartInst");
            bodyPartInst.actionManager = action_manager_mesh;
            if(i>0) bodyPart.animations.push(mesh.getChildren()[i].animations[j]);
            bodyPartInst.parent = bodyPart;
          scene2.beginAnimation(bodyPart, 0, 100, true);            
    instRoot.scaling = new BABYLON.Vector3(0.01,0.01,0.01);
    instRoot.position.x += x;
    instRoot.position.z += z;
    return instRoot;

Try to search for ‘instances animation’ on the forum. It yields in 50+ results. I bet you will find a solution. If not, come back. :sunglasses:


Do you see animations in these examples - and ?

1 Like

Thanks for your references @labris . I tried with the second one .

But it throws an error while calling createInstance() . I have given below the error message.

Property ‘createInstance’ does not exist on type ‘AbstractMesh’.

Which browser do you use? Also, make sure that PG is latest version.
I have no problems with this PG - - in Chrome latest.
They all are running :slight_smile:

Oh. Sorry @labris . I didn’t mean the issue is in playground, I am facing the issue while using this code in my project. That is actually an angular project. So I am writing this within the .ts

And this is completely true, there is no such property - AbstractMesh | Babylon.js Documentation
So it seems you need to import { Mesh } which has such property - Mesh | Babylon.js Documentation

1 Like

Hi @jayakannan just checkin in, do you have any more questions? :slightly_smiling_face:

1 Like

No @carolhmj . I am not having related to this now.

1 Like