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.
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.
One way of doing that would be this - Bounding Box Fun | Babylon.js Playground (babylonjs.com)
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)
You can also go through vectors (points), which basically represents corners that you are looking for.
My bad here, if you remove computeWorldMatrix from the code, you will get proper dimensions of the box.
https://playground.babylonjs.com/#4F33I3#208
here is modified playground if needed (combined with the RaananW answer above)
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.
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)
})
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)