# Instance mesh source change

**URL:** <https://forum.babylonjs.com/t/instance-mesh-source-change/18665>\
**Category:** Questions\
**Created:** [February 25, 2021, 2:28am UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665 "2021-02-25T02:28:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mostafa\_Salloum](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mostafa_salloum/32/13074_2.png) [@Mostafa\_Salloum](https://forum.babylonjs.com/u/Mostafa_Salloum)\
**Post date:** [February 25, 2021, 2:28am UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/1 "2021-02-25T02:28:50Z")

</div>

Hello, I am trying to change the source of the instanced mesh I did this playground [https://playground.babylonjs.com/#0R1EDI#11](https://playground.babylonjs.com/#0R1EDI#11)  
when you press on the middle sphere of the second clone it will change the material but the instanced mesh won’t change because its source isn’t the clone its the original model,  
so is there are a way different then this way that I did in the second playground to change the source of instance  
[https://playground.babylonjs.com/#0R1EDI#14](https://playground.babylonjs.com/#0R1EDI#14)

or is there are an option while I clone the model the source of instance in the cloned model will follow the meshes in the clone.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 25, 2021, 10:50am UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/2 "2021-02-25T10:50:20Z")

</div>

You can’t change the `source` of an instanced mesh, it’s a readonly property.

Why would you want to change the source in the first place? Instead, you should make an instance from the mesh you want to set as source of the existing instance.

---

<div class="post-metadata">

**Author:** ![Mostafa\_Salloum](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mostafa_salloum/32/13074_2.png) [@Mostafa\_Salloum](https://forum.babylonjs.com/u/Mostafa_Salloum)\
**Post date:** [February 25, 2021, 1:35pm UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/3 "2021-02-25T13:35:10Z")

</div>

the instances are already set from the model so I am not creating the instance in the code

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 25, 2021, 3:13pm UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/4 "2021-02-25T15:13:54Z")

</div>

Ok but why do you want to change their source parameter? If you need to do that, it means you don’t need those instances but you need other ones. So just delete these instances and create new ones from the right master mesh. Changing the `_source` property won’t work.

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [February 25, 2021, 7:35pm UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/5 "2021-02-25T19:35:28Z")

</div>

Having hard time understanding the issue…

So you have instances created in 3D software and loaded into a scene. You are cloning these instances inside the code. And when you change the material of the clone, the mesh from which you cloned (slash instance created in 3D software) will not change the material?

If above is correct, that’s expected behavior, as **mesh.clone** will not create an instance of the mesh (which will share properties with original mesh), it will just create a copy of that object with it’s own set of properties… Instead you could try using createInstance().

> **[Clones | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/copies/clones)**
>
> Learn clones and cloning in Babylon.js.

> **[Instances | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/mesh/copies/instances)**
>
> Learn all about the instancing system in Babylon.js.

---

<div class="post-metadata">

**Author:** ![Mostafa\_Salloum](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mostafa_salloum/32/13074_2.png) [@Mostafa\_Salloum](https://forum.babylonjs.com/u/Mostafa_Salloum)\
**Post date:** [February 25, 2021, 9:03pm UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/6 "2021-02-25T21:03:24Z")

</div>

okay so in the above playground is a simple example of what I am doing in the local project

I have a model created in 3D software and that model has multiple meshes and the instance’s of them  
I am cloning the model into 3 clones but the instance meshes of the clone are following the source of the original model, so when I change the material of mesh of 1 clone the instance in the clone won’t change material because the source not changing material,  
I did try to change \_sourceMesh it worked in the playground but in local the meshes of the original model is disappearing but everything in the inspector look fine like the meshes are enabled and the material is enabled  
so i am asking if there are a way to change the source other then that way or a way to set material for the instance because there are not.  
thank you anw

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 26, 2021, 1:37am UTC](https://forum.babylonjs.com/t/instance-mesh-source-change/18665/7 "2021-02-26T01:37:03Z")

</div>

You can’t update `mesh._sourceMesh`, it’s a private property and even if it works in some cases it is not supported and will likely fail at some point: meshes you create by calling `masterMesh.createInstance(...)` on a master mesh can’t have a material different from `masterMesh`, it’s by design and a limit of the instancing feature.

If you want to copy some meshes and be able to use a different material for each copy, use `masterMesh.clone(...)` instead.
