Gizmo does't fit the .glb mesh position

I got this quesition recently: when i set the root mesh a parent, and then make the parent showing boundingbox, and attach a gizmo to the parent. the gizmo always show in the zero point.
I just want to achieve these following things:

  1. when i point down the legs or the arms of the girl, i want the whole body showbounding box to indicate that this girl was chosen. I do not want the arms or the legs show boundingbox themselves, i just want them act in a whole.
  2. I also want to show the gizmo attached to the girl and i want the gizmo sits in the girl’ position.
    Based on that requirements, i tried like this way:

When point down triggers, i will find the root of the pointed mesh, and then create a parent mesh to be the parent of the root mesh, and i will calculate the boundingbox and add bounding box to the parent mesh. It seems that it works, but the gizmo was not in the expected position, and it always locate in the zero vector. I have no idea about that.

Can anyone have a better idea to achieve the needs? By the way, i tried MakeNotPickableAndWrapInBoundingBox and it cannot meet my requirements. Because when you mouse down a place near by the body which includes in the MakeNotPickableAndWrapInBoundingBox area, the boundingbox would show. I just want to make sure that any part of the body got clicked and then the boundingbox show.
I really need help on that, i appreciate if anyone can help me.
I created the simple playground here:

cc @Cedric

I’m not sure to follow, let me try to summarize:

  • you want to build a bounding box around the mesh you clikc-select
  • you want to gizmo at the bounding box root

So, if I understand correctly, you almost did it: get back to ancestor then add a transient parent that will hold the gizmo.

I did a few changes in your PG to get the gizmo centered on the bbox:

Available Mesh Emoji Heart | Babylon.js Playground (babylonjs.com)

Thanks for the help, that is what i want. And i am still wondering why the bounding box does not wrap the mesh in this new playground?

This happens because getHierarchyBoundingVectors returns bounding min and max in world coordinates.
Whereas BoundingInfo takes local coordinates. Transform size min and max in local coordinates (subtract mesh position) and it should work.

I appreciate your help! Actually i am newbie to the 3D stuff and i still could not make it right after trying.
Would you plesase show me in the playground? I think i really have a long way to go to be familar with the 3D stuff.

Here you go

1 Like

I really appreciate your help, i read your response and your playground over and over again and finally i understand all of them. Now i solved all the relative bounding box position and gizmo position issue in my project. Thank you so much for your help!

2 Likes