# Axis Aligned Bounding Box

**URL:** <https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394>\
**Category:** Questions\
**Tags:** gui\
**Created:** [March 23, 2020, 9:17am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394 "2020-03-23T09:17:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 23, 2020, 9:17am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/1 "2020-03-23T09:17:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 23, 2020, 11:35am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/2 "2020-03-23T11:35:50Z")

</div>

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

[https://doc.babylonjs.com/how\_to/how\_to\_display\_bounding\_boxes](https://doc.babylonjs.com/how_to/how_to_display_bounding_boxes)

---

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 24, 2020, 8:40am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/3 "2020-03-24T08:40:42Z")

</div>

Thank you for reply, very important article.  
But i have situation when axis aligned bounding box is not optimal: [Babylon.js Playground](https://playground.babylonjs.com/#WAMB8F)  
In this case i want to get AABB, which is red rectangle on the screenshot.

 ![AABB](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/1/14be15b08f5b151e1d6002ff33059410034fdd15.png)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 24, 2020, 11:10am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/4 "2020-03-24T11:10:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 24, 2020, 12:42pm UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/5 "2020-03-24T12:42:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 24, 2020, 1:18pm UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/6 "2020-03-24T13:18:38Z")

</div>

`mesh.showBoundingBox = true` should work.

---

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 24, 2020, 1:20pm UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/7 "2020-03-24T13:20:27Z")

</div>

In this case we get OBB (oriented bounding box, but not AABB)  
Please see this example [Babylon.js Playground](https://playground.babylonjs.com/#WAMB8F)  
After mesh rotation, bounding box is also rotated automatically, but i don’t want this behaviour.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 24, 2020, 2:49pm UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/8 "2020-03-24T14:49:29Z")

</div>

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](https://playground.babylonjs.com/#WAMB8F#1)

---

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 25, 2020, 9:37am UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/9 "2020-03-25T09:37:43Z")

</div>

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](https://playground.babylonjs.com/#WAMB8F#3)

---

<div class="post-metadata">

**Author:** ![vistratov](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@vistratov](https://forum.babylonjs.com/u/vistratov)\
**Post date:** [March 25, 2020, 1:13pm UTC](https://forum.babylonjs.com/t/axis-aligned-bounding-box/9394/10 "2020-03-25T13:13:20Z")

</div>

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