# Bounding box bug?

**URL:** <https://forum.babylonjs.com/t/bounding-box-bug/36999>\
**Category:** Questions\
**Created:** [December 30, 2022, 12:25pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999 "2022-12-30T12:25:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [December 30, 2022, 12:25pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999/1 "2022-12-30T12:25:05Z")

</div>

Hi,

I want to calculate the bounding box in this simple example:

> **[Babylon.js Playground](https://playground.babylonjs.com/#RA67AR%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

As you can see, the bounding box is well designed but its min and max world coordinates do not fit the drawing and i don’t know why.

I’ve draw a line between the min and max coordinates to show you what happens.

Is this a bug or a mistake i’ve done ?

Thanks for your help,

Boris

---

<div class="post-metadata">

**Author:** ![SvenFrankson](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/svenfrankson/32/29446_2.png) [@SvenFrankson](https://forum.babylonjs.com/u/SvenFrankson)\
**Post date:** [December 30, 2022, 12:52pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999/2 "2022-12-30T12:52:40Z")

</div>

Hi,

It’s because box worldMatrix has not been updated when you draw the line.

You may either draw the line next frame, or call

```auto
box.computeWorldMatrix(true)

```

Before you get your line positions.

---

<div class="post-metadata">

**Author:** ![Boz](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/boz/32/4294_2.png) [@Boz](https://forum.babylonjs.com/u/Boz)\
**Post date:** [December 30, 2022, 1:04pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999/3 "2022-12-30T13:04:22Z")

</div>

I am facing the same problem but the computation of WorldMatrix does not solves my problem : [https://playground.babylonjs.com/#ZIUHK6#10](https://playground.babylonjs.com/#ZIUHK6#10)

---

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [December 30, 2022, 1:59pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999/4 "2022-12-30T13:59:34Z")

</div>

Hi @SvenFrankson,

I’ve done what you told me but it’s not well either.

> **[Babylon.js Playground](https://playground.babylonjs.com/#RA67AR%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Now my minimumWorld is [0,0,0] and my MaximumWorld is [10,15,5]. It would be correct if my box was not rotated and translated.

if I call box.computeWorldMatrix(true) after the displacement and rotation of my box, my minimumWorld is [X: 1.0000000894069672 Y: 0 Z: -7.071067720651627] and my maximumWorld is [X: 11.606601625680923 Y: 15 Z: 3.5355338156223297] which fits to the red cube in my PG but which is not correct.

Here’s the PG :[https://playground.babylonjs.com/#RA67AR#5](https://playground.babylonjs.com/#RA67AR#5)

I mean that the boundingbox min and max world values should fit to the real bounding box.

I’m sure i’ve done an error but i’m a little bit lost.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 27, 2023, 4:34pm UTC](https://forum.babylonjs.com/t/bounding-box-bug/36999/5 "2023-01-27T16:34:37Z")

</div>

The boundingBox property is a axis-aligned bounding box, not an object aligned one, so it will only fit perfectly if the rotations are multiples of 90 degrees:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/6/467f07662ebf46f77ea3f09ee48185e0e6247889.png)

If you need to compute the object aligned box I’d bake the transform in the object and compute the BB again
