Bounding box bug?

Hi,

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

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

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

box.computeWorldMatrix(true)

Before you get your line positions.

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

Hi @SvenFrankson,

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

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

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.

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

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

2 Likes