The metadata of the mesh cloned by the instantiateModelsToScene method is a shallow copy

It should be a deep copy, not a shallow copy.Otherwise, when you change the value of a metadata attribute, all metadata is the same.
https://playground.babylonjs.com/#96I5S8

The problem is that the shallow copy can take ages depending on what you have in your metadata. This is why we opted for a simple copy

  1. The mesh.clone method is a deep copy, and this inconsistent behavior is very confusing.It took me most of the day to find out the problem.I always suspected that there was a logic problem with my own code, never a problem with the Babylon engine.

  2. Shallow copies may have a potential memory leak.When a mesh is freed, it cannot be freed because it holds shared metadata objects internally.I checked the source code and there is really no way to release metadata in the dispose method.One memory leak is nothing to worry about, but after hundreds or thousands of leaks, it can seriously cripple your program.

what we can do for 2 is to add metadata = null in dispose code

for 1 if you want to add the option, no problem :slight_smile: I will gladly review the PR (by the way clone and instantiate are not the same. Instantiate is all about sharing everything but materials)

  1. will be fixed with next nightly