Best Way to get the True Extends of a Mesh?

Ive noticed that if I try to get the extends of a mesh sometimes it comes back incorrect. Like for example if the parent mesh is empty and has children that have some weird scaling applied even when iterating through the childMeshes and grabbing the max values for extends it will we way off from what I am visually seeing. Im assuming there is a need to decompose the global Matrix and apply the scaling factor to the local extends to get the true size?

What would be the best way to take any mesh and just get its correct bounding box size that includes children?

This sounds related to a question I had in this thread. TLDR getHierarchyBoundingVectors will return the bounding vectors of a mesh and all its children in world space which you can covert back to local space as needed. In my experience calling computeWorldMatrix(true) before calculating the bounding vector ensures I get the correct values, getHierarchyBoundingVectors() already does this when its called.

If you are finding different behavior maybe you could try to reproduce it in this playground: https://playground.babylonjs.com/#4F33I3#793

Here is an example of where its going wrong. Iā€™m trying to naturalize the size of the model to approx one unit.

Ill take a look at what you just posted!

@dsaffo perfect thank you!

1 Like