Add behavior to a .glb file which contains multiple meshes

What would be the proper way to add behavior to a imported .glb file when it contains multiple meshes.
i mean, i want the imported file act as a whole even if it contains many meshes. Should i add behavior to the root node which is the first of the meshes array, or should i set all the meshes a parent transformNode? i made a playground here: https://playground.babylonjs.com/#JHRF6T#77

Hi! You can use MakeNotPickableAndWrapInBoundingBox to wrap the mesh in a bounding box which will be used to attach behavior/picking. This has the added benefit of making the picking much faster since the bounding box is a simpler geometry :slight_smile:

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

1 Like

Thank you for your help! I have tried that way before, however, i was not able to add showBoundingBox property to the MakeNotPickableAndWrapInBoundingBox. And the BoundingBoxGizmo does not conform to my needs. I just want this effect when the mesh chosen:


Can i achieve this with MakeNotPickableAndWrapInBoundingBox?

Hmm, I think showBoundingBox needs a mesh with vertex information to be shown, so you could get the bounding box hierarchy information and manually construct a box mesh, like this: Available Mesh Emoji Heart | Babylon.js Playground (babylonjs.com)

1 Like

thanks so much for the help! that works for me.