BoundingBoxGizmo attachedMesh resize issue

Every time a child mesh is attached to a BoundingBoxGizmo, it automatically resizes. This only happens if the parents are scaled. If parent scaling is set to 1,1,1, then it’s working as expected.

Please have a look at a demo, when only selecting a mesh, it auto resizes.

adding @Cedric

Thank you for the repro. It looks like a bug. I’m taking a look…

After tests and debugging, this issue has deep implication in the gizmo and the scene graph.
The root is meshes transforms are represented as translate/scale/orientation. This always results in an orthogonal matrix.
But when mixing parenting and scales, and doing the computation on matrix, you end up with non orthogonal matrix and invalid resulting translation/rotation/scale.
See this example:

Black square on the left is parent of the right one.
When scaling the parent, the child is also scaled but not on axis. The mesh is squizzed and the transform values can’t be computed. Hence your issue.
This doesn’t happen when having no parenting or no scales.
There is nothing I can do for now. Maybe I can try to find a work around. What do you want to achieve?

Hi, thank you for looking into this, I really appreciate it.
I would like to achieve 2 things, one is having an option to transform child meshes and one is having a box around the mesh that is being transformed, as a visual aid.

I have tried bounding box to solve the selected problem. But the issue with it is reverse. While for the lowest child there is no children bounds calculation, once you move up the tree, you need to calculate new bounds for the box.

The issue is that the meshes are constantly changing as they are receiving messages for position and rotation updates, so the bounding box needs to move with the mesh, with children.

To display a bounding box for selected mesh, you can query the boundingInfo of the mesh and its child, then create a box with a wire material, set the position to the center and scale is as the half of the extend.
But, the issue will remain. If you mix hierarchy/parenting and scales, you will get the same issue with squizzed mesh.
Do you need to change the scale of the meshes?

sorry for a late reply.
I don’t need to change the scale, it’s in the UI and maybe we should remove it.

I did use the bounding box info and absolute positions before to show a bounding box around the element. But the box was lagging behind when objects were animating.

Any ways, will try to do what you suggested. A solution with a custom box on on the selected element and add it as a child, so it moves with the parent automatically.

Are the meshes reshaping cause every time you put a BoundingBoxGizmo around them, their position gets recalculated?

I don’t have all the code in mind but yes, it’s possible mesh position is slightly different when attached to a gizmo. A transient hierarchy is built and used by the gizmo so position/scale/rotation are cascaded between parent and children. The difference is not noticeable until you display the value in the console and is mostly due to floating number precision.