Add "cloneModelsToScene" Method to AssetContainer Class

I was wondering if it would be possible to add a new method to the AssetContainer class in Babylon.js that allows models to be cloned to another scene. Currently, we can clone individual meshes using the instantiateModelsToScene method, but there is no built-in way to clone all of the models in an AssetContainer to another scene.

If it is possible, I would like to propose adding a cloneModelsToScene method to the AssetContainer class in Babylon.js. This would allow for more efficient use of resources and faster scene loading times when using multiple scenes with similar models.

Before proposing this feature, I wanted to ask if there are any plans to add it to a future release. If not, I would be happy to submit a feature request and provide any additional information or code examples if needed.

Thank you for your consideration, and I look forward to hearing your thoughts on this proposal.

@MILIFIRE I love the overall idea but it is a rather really complex feature :frowning:

To summarize, so far today every single element that is created belongs to a scene. (mesh, materials, lights,…) and their clone/instantiate functions can only do it within their current scene as some parts are still used through references.

What we would nee:

  1. Every “elements” at play should be able to be cloned in a separate scene
  2. Tree cloning are available in a separate scene
  3. Asset container clone (no remove/add and such) can work across scene

Despite being interested it is probably not a small endeavor to ensure we are not leaking or keeping cross scene references.

Let s see how much traction this gets to consider it for 7.0 ?

Hey guys, I wanted to create similar question and found this topic.

My game have multiple scenes and i wanted to create some factory class which will have map of all assetContainers with meshes, so I will be able to create new scenes from them(those assetContainers) when new scene must be created, but according to @sebavan answer it’s not possible and I my scenes will load already loaded meshes by different scene :frowning:

I tried to reassign assetContainer scene and then instantiate but it looks like it’s not working
assetContainer.scene = scene;

Additional request from me is:
assetContainer is not linked with any scene. So game can prepare asset containers before actual loading of scene. (I want to prepare assetContainer with meshes when no canvas or engine or scene are exist for example in menu)