# How to clone a .glb model and play seperate animation on each clone?

**URL:** <https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183>\
**Category:** Questions\
**Tags:** material, mesh, meshes\
**Created:** [January 28, 2022, 10:04am UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183 "2022-01-28T10:04:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [January 28, 2022, 10:04am UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/1 "2022-01-28T10:04:42Z")

</div>

I’m importing the .glb file to babylonjs. Then I clone. The cloning is successful. Animation can be managed in the mesh I imported, but there is no animation in the meshes I cloned. What could be the reason? Can you help me?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [January 28, 2022, 11:31am UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/2 "2022-01-28T11:31:25Z")

</div>

The cloned mesh requires the skeleton and the animation groups added to it, otherwise you won’t be able to animate it.

Can I recommend using the Asset Container to load the model? This way you can duplicate the model as many times as you wish (of course - with performance in mind):

> **[Asset Containers | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/importers/assetContainers#duplicating-the-models)**
>
> Learn all about using asset containers in Babylon.js.

If you require further help, a playground will be awesome.

---

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [January 28, 2022, 12:13pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/3 "2022-01-28T12:13:46Z")

</div>

[Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#S7E00P#189)

Thanks for your answer. Unfortunately, I want to do this with clone instead of instance. As you can see in the example, I cannot change the material of the mesh when I import it as an instance.

I am implementing the skeleton and animation grub for the clone. I can clone all your requirements. I am preparing a playground for you.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [January 28, 2022, 12:16pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/4 "2022-01-28T12:16:33Z")

</div>

You don’t have to create an instance, you can clone. it is configurable in the options:

> **[AssetContainer | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/babylon.assetcontainer#instantiatemodelstoscene)**
>
> Container with a set of assets that can be added or removed from a scene. \[API\]

---

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [January 28, 2022, 12:18pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/5 "2022-01-28T12:18:18Z")

</div>

I try now, thank you.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 28, 2022, 12:50pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/6 "2022-01-28T12:50:00Z")

</div>

Here is the example - [https://playground.babylonjs.com/#AJA5J6#139](https://playground.babylonjs.com/#AJA5J6#139)

---

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [January 28, 2022, 12:58pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/7 "2022-01-28T12:58:57Z")

</div>

[animating-clones-from-glb | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#AJA5J6#145)

Thanks for your answer. However, I wanted to use the clone() function because I could not meet some requirements with this method. As in the example, the material does not change with this method.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 28, 2022, 2:15pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/8 "2022-01-28T14:15:50Z")

</div>

Here is the example with changed material - [https://playground.babylonjs.com/#AJA5J6#146](https://playground.babylonjs.com/#AJA5J6#146)  
This line is defines whether it will be clone or instance:

```auto
let entries = container.instantiateModelsToScene(undefined, false, { doNotInstantiate: true });

```

For cloning use

```auto
{ doNotInstantiate: true }

```

For instancing use

```auto
{ doNotInstantiate: false}

```

---

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [January 28, 2022, 2:20pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/9 "2022-01-28T14:20:57Z")

</div>

You are very good. I will see if I can integrate this method without clone at the first opportunity. Thanks.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [January 28, 2022, 2:25pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/10 "2022-01-28T14:25:34Z")

</div>

Without cloning (with instancing) you will not be able to use neither different materials nor animations.

---

<div class="post-metadata">

**Author:** ![farukcelim](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/farukcelim/32/27134_2.png) [@farukcelim](https://forum.babylonjs.com/u/farukcelim)\
**Post date:** [February 7, 2022, 2:23pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/11 "2022-02-07T14:23:15Z")

</div>

[animating-clones-from-glb | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#AJA5J6#146) use material but not clone.

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [February 8, 2022, 1:28pm UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/12 "2022-02-08T13:28:46Z")

</div>

The line 11 at your example [https://playground.babylonjs.com/#AJA5J6#146](https://playground.babylonjs.com/#AJA5J6#146)

```auto
        let entries = container.instantiateModelsToScene(undefined, false, { doNotInstantiate: true });

```

has the option

```auto
{ doNotInstantiate: true }

```

When it is `true` it makes a **clone** of the GLB model and you can change material, animations etc.  
When it is `false` it makes an **instance** of the GLB model.

---

<div class="post-metadata">

**Author:** ![samevision](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@samevision](https://forum.babylonjs.com/u/samevision)\
**Post date:** [March 3, 2022, 12:13am UTC](https://forum.babylonjs.com/t/how-to-clone-a-glb-model-and-play-seperate-animation-on-each-clone/27183/13 "2022-03-03T00:13:19Z")

</div>

Hello guys,

unfortunately a have a problem with cloning the animation groups. I can’t reproduce the problem in pg, even though I use exactly the same code locally: [Babylon.js Playground](https://playground.babylonjs.com/#8RJEY8)

Meshes and skeletons get cloned correctly but the animation group seems to ne the same one. The name of the cloned animation group equals the original one (but it should be “Clone of …”). And I can’t play the animation of the cloned mesh.

Any idea what the problem could be?

EDIT:

It is working on beta-11. I was on beta-7 before.
