Asset Containers - parent nodes

I have a scene where I have separated my meshes into asset containers. I updated my version of babylonjs and now I am getting errors saying that the parent of my meshes are also not in the asset container. My issue is that the parent is the root mesh, and from my understanding we cannot add a mesh into more than one asset container. What do I do in this situation? I tested out adding in the root mesh to the containers but my model was no longer visible.

Hey! can you repro in the PG?

Hi, apologies for the delayed reply it took me a while to build in the playground.

I have loaded in the model that we are experiencing the issue with, and have created 2 viewports with 2 separate cameras. The file loaded in has 2 models and I have put model1 in the top window and model2 in the bottom window (using layer masks). I have created 2 asset containers:
- Container1 containers one part/mesh from each model (one mesh from both windows)
- Container2 contains all the other model parts

The issue arises when we start to add and remove the containers from the scene, which is where we get warnings that the hierarchy isn’t valid. If you uncomment line 88, 89 and 91 you will see these warnings in the console log.

To try fix these warnings, I created code which adds the parents of the meshes into the containers as well - this function recurses on the mesh up the tree structure. This adds in the model nodes and the root node too. If you uncomment lines 79 and 83, you can see this fix in play.

Despite adding a fix to these warnings, you can see that no models are displayed, I think this has something to do with the root node perhaps being in both containers, however I am unsure where to go from here. Any thoughts?

Thank you!

It is actually working :wink:
But because how the camera is angled you do not see them :smiley:

Just rotate a bit and you will see it

Same if I attach to camera2 and I rotate a bit:

Ah okay thank you. I am still seeing the same issue in my program however. What is the situation with adding the root node into asset containers - should this be done? If you have multiple asset containers, should it be added to all containers? And if it shouldn’t be added, how do I get round the error that the parent node (i.e the root node) doesn’t exist in the container?

the rule is that all node hierarchy has to be in the container so if you add a node you have to add all its hiearchy up to the top

So does this mean the root node should be in every container?

Yes or you can also unparent items before adding them and setting them free :smiley: (with node.setParent(null))