Hey everyone I have to access a box dimension property (width, height, depth) even when rotated, any ideas how to achieve that?
I am totally unsure what you are trying to access ?
If local scale, you can through mesh.scaling.x/y/z
If world bounding info you can with getBoundingInfo and such.
I want the box informations (width, depth and height) locally even if the box is tilted or rotated.
I pass this information when I create, how can I retrieve it after a scaling, for example?
When you know the width, depth and height before creating the box then the only transformation that changes these dimensions is scaling. Knowing the scaling values you can calculate the new width, depth and height.
The mesh’s bounding info is updated after its world matrix is computed, so we can get a box mesh’s rotated/scaled width, height, and depth straight from the computed bounding box like this:
box.computeWorldMatrix(true); const boundingBox = box.getBoundingInfo().boundingBox; const transformedSize = boundingBox.extendSizeWorld.scale(2);
Note: the size is scaled by 2 because Babylon scales it by 0.5, so we’re just reverting it to the full size. Here’s a little playground showing this in action:
Actually, this doesn’t work in my case, if I rotate around some axis the bounding box gets the full dimension and doesn’t show the scaled dimensions.