# Cloning an InstancedMesh changes its isEnabled state

**URL:** <https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777>\
**Category:** Bugs\
**Tags:** mesh\
**Created:** [September 8, 2022, 8:35am UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777 "2022-09-08T08:35:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hschmiedhofer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hschmiedhofer/32/19691_2.png) [@hschmiedhofer](https://forum.babylonjs.com/u/hschmiedhofer)\
**Post date:** [September 8, 2022, 8:35am UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777/1 "2022-09-08T08:35:48Z")

</div>

When cloning a **disabled** InstancedMesh, I noticed that the clone will be **enabled**. Please see my [playground](https://playground.babylonjs.com/#Y15S3C).

Is this by design?

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [September 8, 2022, 9:32am UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777/2 "2022-09-08T09:32:11Z")

</div>

I believe there’s a PR (not sure if it has gone through) making the clone a new source.  
May be this is related and then may be not.

> [@InstancedMeshes cloned from AssetContainer - set new source?](https://forum.babylonjs.com/t/instancedmeshes-cloned-from-assetcontainer-set-new-source/33301/2):
>
> Thats an interesting philosophical question slight_smile Is the cloned instancedmesh sourced from the clone, or the original mesh it was instanced from? At the moment it is option B, but i assume it would make sense, in that case, to allow changing the source mesh. The clone function of instancedmesh generate a new instance from the current source mesh, which is the base of this issue. We could add a way to override the sourceMesh and define a new one when cloning. @Deltakosh , wondering wha…

@RaananW I guess you can answer this one, yes? Thx,

---

<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:** [September 8, 2022, 9:44am UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777/3 "2022-09-08T09:44:54Z")

</div>

Well! Another philosophical question! 😉

Actually, in this case it is very technicaly. disabled/enabled is not copied when cloning a mesh, since disabled is a private property and not considered a part of the state that will be copied. Enabled is true per default, and this is what you are seeing. We can discuss here what makes more sense - should disabled be copied or not? Will be happy to hear opinions both ways 😉

Personally, I usually clone disabled nodes and expect them to be disabled. However, when serializing an object, we do store the enabled state. Adding the enabled state to cloning will break back-compat, so I am not sure we can change it, unless we consider it a bug

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [September 8, 2022, 10:04am UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777/4 "2022-09-08T10:04:30Z")

</div>

> [@RaananW](#):
>
> We can discuss here what makes more sense - should disabled be copied or not?

I’d say, assuming we will eventually later consider the clone a new source, it would make sense that it also comes with its own defaults (and private property settings). My opinion only.

> [@RaananW](#):
>
> Adding the enabled state to cloning will break back-compat

Since this is a matter of philosophy, and now knowing a little about BJS philosophy, I’d say let’s not make a breaking change for that. EZ for me to say that since I don’t really use clones from instances, rather the other way round 😉 And then again, my opinion only.

---

<div class="post-metadata">

**Author:** ![hschmiedhofer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/hschmiedhofer/32/19691_2.png) [@hschmiedhofer](https://forum.babylonjs.com/u/hschmiedhofer)\
**Post date:** [September 12, 2022, 12:21pm UTC](https://forum.babylonjs.com/t/cloning-an-instancedmesh-changes-its-isenabled-state/33777/5 "2022-09-12T12:21:24Z")

</div>

Thanks for clearing that up, @RaananW ! Just wanted to make sure we’re not dealing with a bug here. Basically we’re fine with the current behaviour.
