Rotate gizmo not working with non uniform mesh scaling

Hi all.

The gizmo rotation is not working when the mesh has non-uniform scaling
Check this pg: https://playground.babylonjs.com/#31M2AP#358

Yes, it is a known limitation of the gizmo rotation.

See for eg:

There are a number of other posts in this forum on this topic.

It was working with the early versions of babylon js. I noticed this problem after a couple of months. The position gizmo works well

cc @Cedric.

Maybe it was working in some cases and not in others, that’s why we now issue a warning when trying to use the rotation gizmo with non uniform scaling.

Since bjs 3 or 4, rotation with non uniform scaling makes the mesh to explode because inconsistency between the world matrix and orientation quaternion.
I’ve changed that recently to display a message instead of watching NaN vertices everywhere.
It’s possible to have non uniform scaling and rotation but you have to set updateGizmoRotationToMatchAttachedMesh to false.
Another solution is to use the gizmo with a proxy transform and apply rotation to the mesh when dragging gizmo.
I’ll find time to improve this after 6.0 release.

3 Likes

I tried to set this updateGizmoRotationToMatchAttachedMesh to false, but the mesh expands while rotating. Anyway, I will be waiting for the 6.0 release. Thank you!

1 Like

when will v6.0 version come XD?
really need this improvement. tks.

I meet the same problem,waiting for solution in the 6.0 :flushed:

cc @Cedric

unfortunately I cannot wait until fix - I have a tight deadline in my project :stuck_out_tongue_winking_eye:
I made an proxy object not connected to the mesh/skeleton. setting position is easy.
setting initial rotation is also easy:

let worldMatrix = pickedTransformNode.getWorldMatrix();
let quatRotation =  new BABYLON.Quaternion();
let position = new BABYLON.Vector3();
let scale = new BABYLON.Vector3();
worldMatrix.decompose(scale, quatRotation, position);                        
let euler=quatRotation.toEulerAngles()
proxySphere.rotation=euler

and set gizmo to proxySphere.
but now after some rotation by gizmo how to re-calculate own absolute rotation of that proxy back to the rotation of that one joint of skeleton with local rotation?
thank you!

Can you please rephrase it? I don’t understand.

I cannot attach proxy to the mesh because it deactivates rotation after scaling so I put it outside of it.
position and initial rotation works.
the white sphere is my proxy and initial setup is good now:

but now I want to rotate it and local rotation should be transferred from global one.

To transform a world coordinate to a local, multiply by inverse of parent world.
To transform from a local coordinate to a world, multiply by parent world.

ok I made this one now:

let worldRotationQuat = BABYLON.Quaternion.FromEulerVector(proxySphere.rotation);
 var worldMatrix = pickedTransformNode.parent.getWorldMatrix();                       
var quatRotation =  new BABYLON.Quaternion();
var position = new BABYLON.Vector3();
var scale = new BABYLON.Vector3();
worldMatrix.decompose(scale, quatRotation, position);             
let rotationQuaternion = worldRotationQuat.multiply(BABYLON.Quaternion.Inverse(quatRotation))                        pickedTransformNode.rotation=rotationQuaternion.toEulerAngles()

but it is using the wrong axis here now.
I also tried using delta on axis from gizmo rotation and pickedTransformNode.rotate(getRotationAxis(currentAxis), dt, BABYLON.Space.LOCAL)
but one axis (x) refused to work correctly using delta.

So in case that my information is not helpful I could try to make a playground. This would be a lot of work (several hours) to make an example from my project code.

Thank you!

Will this logic be improved anytime soon? I really want the rotation of the gizmo to precisely align with the rotation of the mesh.

Yes, it’s still on my todo list. No ETA yet.

just made a playground example of proxy - some idea how to solve? thank you!

sorry the playground link was missing: https://playground.babylonjs.com//#CN4KJL#129
code can be found around line 63

sorry for the delay. I’ll work on this issue next week.

2 Likes