Hello,
I try to display the bounding box of a complex mesh when i click on it, but the bounding box is displayed centered on {0,0,0}. How to set it around the mesh ?
function showBoundingBox(obj) {
let { min, max } = obj.getHierarchyBoundingVectors()
let bi = new BABYLON.BoundingInfo(min, max)
obj.setBoundingInfo(bi)
obj.showBoundingBox = ! obj.showBoundingBox
}
Thanks,
But the problem is the same with unique object.
Object is first created in origin (x:0, y:0, z:0) of the world. And then move to a place.
But the bounding info seems to be always in origin.
How to update them ?
Best regards.
center, minimum and maximum are in local coordinate space. You should use centerWorld, minimumWorld and maximumWorld instead. Also, you should recompute the world matrix after you update the position, because the world matrix is recomputed automatically only when you are in the render loop: