# How to create box mesh base on bounding box

**URL:** <https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999>\
**Category:** Questions\
**Tags:** documentation\
**Created:** [November 4, 2021, 9:21am UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999 "2021-11-04T09:21:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![11123](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/11123/32/10880_2.png) [@11123](https://forum.babylonjs.com/u/11123)\
**Post date:** [November 4, 2021, 9:21am UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/1 "2021-11-04T09:21:26Z")

</div>

[https://playground.babylonjs.com/#4F33I3#205](https://playground.babylonjs.com/#4F33I3#205)

I want to create a box base on bounding box, but I do not know how to find bouding box corner position.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 4, 2021, 2:03pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/2 "2021-11-04T14:03:00Z")

</div>

One way of doing that would be this - [Bounding Box Fun | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#4F33I3#207)

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [November 4, 2021, 2:03pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/3 "2021-11-04T14:03:24Z")

</div>

[https://playground.babylonjs.com/#4F33I3#206](https://playground.babylonjs.com/#4F33I3#206)

Hi. Not sure what exactly you want to achieve, but this might help you. Basically I’ve created a box based on bounding box, but note here that because the parent bounding box is slightly tilted the info you get from extendSize is from the most top right left bottom points of that bounding box (check image)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/6/e6f6b22b722985c80afd0ae4a495294cc6d2918f.png)

You can also go through vectors (points), which basically represents corners that you are looking for.

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [November 4, 2021, 2:19pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/4 "2021-11-04T14:19:33Z")

</div>

My bad here, if you remove computeWorldMatrix from the code, you will get proper dimensions of the box.

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [November 4, 2021, 2:29pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/5 "2021-11-04T14:29:18Z")

</div>

[https://playground.babylonjs.com/#4F33I3#208](https://playground.babylonjs.com/#4F33I3#208)

here is modified playground if needed (combined with the RaananW answer above)

---

<div class="post-metadata">

**Author:** ![11123](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/11123/32/10880_2.png) [@11123](https://forum.babylonjs.com/u/11123)\
**Post date:** [November 4, 2021, 2:58pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/6 "2021-11-04T14:58:14Z")

</div>

Thank you so much, I did not notice that there is a vectorsWorld attribute. and the idea of using the dimensions of boundingbox to construct a box mesh also help a lot.

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [November 4, 2021, 3:00pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/7 "2021-11-04T15:00:04Z")

</div>

Hi. I am a bit confused on why we have to use onAfterRenderObservable here to set the position to the center of the boundingBox, while without it it will not be properly positioned?

scene.onAfterRenderObservable.addOnce(() =\> {  
b.position.copyFrom(bi.boundingBox.centerWorld)  
})

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [November 4, 2021, 4:55pm UTC](https://forum.babylonjs.com/t/how-to-create-box-mesh-base-on-bounding-box/24999/8 "2021-11-04T16:55:10Z")

</div>

that’s because of the not-updated world matrix of the rotated element. On after render, the bounding information is being updated with the right center.  
You can force-update the world matrix:  
[Bounding Box Fun | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#4F33I3#210)
