Axis Aligned Bounding Box

How to get the mesh AABB (minimum and maximum or BoundingInfo object) including entire hierarchy under current node, like Mesh.getHierarchyBoundingVectors() ?

You are lucky, @PirateJC wrote a doc about this a few days ago:

https://doc.babylonjs.com/how_to/how_to_display_bounding_boxes

3 Likes

Thank you for reply, very important article.
But i have situation when axis aligned bounding box is not optimal: Babylon.js Playground
In this case i want to get AABB, which is red rectangle on the screenshot.

I don’t really understand, the AABB is the red rectangle.

If you want to calculate the rotated bounding box instead then I don’t really know, a more complicated must be used.

Yes, AABB is the red rectangle, but i painted it on screenshot.
How can i draw it using babylon?

mesh.showBoundingBox = true should work.

In this case we get OBB (oriented bounding box, but not AABB)
Please see this example Babylon.js Playground
After mesh rotation, bounding box is also rotated automatically, but i don’t want this behaviour.

The bounding box is AABB in the local space of the mesh…

If you apply a transformation to the mesh and still want an AABB, I think the only solution is to regenerate the AABB by computing the transformed vertices and finding the min/max:

https://playground.babylonjs.com/#WAMB8F#1

2 Likes

Thank you very much for your help, sorry for so many questions.
I added gizmos and want to recalculate AABB in world space, but it works incorrect.
https://playground.babylonjs.com/#WAMB8F#3

I realized what the problem is.
I need to force compute world matrix by calling mesh.computeWorldMatrix(true)

3 Likes