Part of the 3D entity created through assetcontainer. Instantiatemodelstoscene() is not visible

The 3D object created by assetcontainer. Addalltoscene() can be displayed completely, while the 3D object created by assetcontainer. Instantiatemodelstoscene() cannot be displayed if the angle is not right. I compared the difference between the two and found some rules,this is a 3D object created by addalltoscene(). Its area is like this:

,However, for the 3D object created by instantiatemodelstoscene(), its area is like this: ,I use my own debugging tools, using this:3 [enable/disable bounding box mode],By the way, what does the 3d blue box in this debugging tool represent?This is the project file:demo.zip (3.0 MB) ,Looking forward to your answer!

Unfortunately I can only answer part of your question

This is a bounding box gizmo used to rotate or scale the selected model.

In your first image you have selected the _root_ node for the imported model, whereas in the second you have selected the bot_root_0 node, hence the gizmo is in different positions. Both of these are parents to further nodes which you can view and select using the + next to them.

For the main part of your question, it would be easier to answer if you repro in a playground either using an available model Available Meshes to Import - Babylon.js Documentation or your own Using External Assets - Babylon.js Documentation

1 Like

Thank you for your reply, the playground is here : https://www.babylonjs-playground.com/#4JTV9Z,Comparing two gizmo, this picture shows the gizmo of the non-clone entity:


This picture shows the cloned entity:

Using the Inspector you can clearly find the difference between the two. My problem now is that I do n’t know why the two are different. This may cause the model I copied can only see a part of it at a certain angle. Thank you for replying and looking forward to your answer. .

pinging @Cedric to see if he can help

I’m taking a look!

It looks like the BBox is not properly updated when cloning meshes.

Thank you for your help, so what should I do?

I’m doing more investigation. I think it’s a bug in the cloning code. I’ll keep you posted :slight_smile:

thank you for your help!

@Deltakosh to me it looks like a rotation is not applied (or applied 2 times) when instantiateModelsToScene is called. Can you please point me where the transform datas are copied?

the rotation is supposed to be cloned here: Babylon.js/mesh.ts at master · BabylonJS/Babylon.js · GitHub

It looks like if the first node to clone and instanciate is not a mesh, the bounding box is not computed correctly. It’s skipped and BVH is not correct. Still investigating…

4 Likes

Excuse me, when will this be resolved?

As soon as I find something :slight_smile:

2 Likes

Hey @Deltakosh, here is a PG that highlights the bbox issue.
https://www.babylonjs-playground.com/#2FHNQM
I tried to dump and analyse the compute bbox but didn’t find anything relevant. Any idea?

It seems you need to refresh the bounding box computation by passing true to the function (==“applySkeleton”):

https://playground.babylonjs.com/#3H43QR

Maybe it should be done by instantiateModelsToScene?

Note the PG freezes when re-starting it, it’s fixed by:

3 Likes

I tried the following methods to solve my problem
NJJ48LBG`9HAT8R7_~KF The refreshBoundingInfo method you provided solved my problem perfectly, thank you for your help!

Thank you also for helping me.