Bbox Gizmo attach causes scaling/pos inaccuracy

Attaching the bounding box gizmo to a rotated mesh causes the scaling and/or the position of the mesh to have a lot of decimals.
eg. mesh scaling x 2 becomes 2.00000325… after attaching the bbox gizmo.

PG: https://playground.babylonjs.com/#851PUZ#26
Attach the bbox gizmo to the mesh and press “1” to log position and scaling values.

Tagging @Cedric

Please be patient, as @Cedric is on vacation this week.

However, I think it’s because there are some recalculations that are performed when you attach a gizmo to an object, and it may not exactly yield the same result than the original data, even if the transformation is the identity transformation. You can round / truncate the results, if you don’t want so many decimals.

2 Likes

I semi-fixed this by storing the mesh transformations before attaching, and them re-applying them after attaching the gizmo :+1:

Yes, as said by @Evgeni_Popov , there are matrix and component decomposition/recomposition. Even with double precision float, it’s not enough and there is this epsilon.
In practice, this epsilon is really small and doesn’t lead to visible glitches.
It depends what you want to do with the result. If you need to do threshold checks, you’ll need an epsilon to compare the value with, anyways.

1 Like