RotationGizmo: Can I get precise rotation value instead of Quaternion?


My scene uses a gizmo with 3 position gizmo and a rotation-y gizmo, the configure is like below:

    const gizmoMgr = new GizmoManager(scene);
    gizmoMgr.scaleGizmoEnabled = false;
    gizmoMgr.positionGizmoEnabled = true;
    gizmoMgr.rotationGizmoEnabled = true;
    gizmoMgr.usePointerToAttachGizmos = false;
    gizmoMgr.gizmos.rotationGizmo!.xGizmo.isEnabled = false;
    gizmoMgr.gizmos.rotationGizmo!.zGizmo.isEnabled = false;

When I use the rotation-y gizmo, the mesh in the scene works well, but the rotationQuaternion.toEulerAngles() always return a rotation-z(negative PI) and a rotation-y.

I know it is about the rotation order, but can I recaculate it as rotation-Y only? my database uses only rotation Y.

my code is like this:

        // the Load-and-Show phase
        // worldInfo is from db, the rotation contains string "0" as rotation.x and rotation.y
        const { position, rotation, scaling } = nodeInfo.worldInfo;
        const rotationArray = [rotation.x, rotation.y, rotation.z].map((v) => toRad(Number(v))) as [
        // and this is where the gizmo attached
        this.rootNode.rotationQuaternion = Quaternion.RotationAxis(Axis.Y, rotationArray[1]);
        // the Export phase
        const { position } = this.rootNode;
        const quaternion = this.rootNode.rotationQuaternion!;
        const quaternionRotation = quaternion.toEulerAngles();

        return {
            soulCode: this.nodeInfo.soulCode,
            worldInfo: {
                position: getStringCoord(position),
                rotation: getStringCoord(quaternionRotation, true), // parse an x,y,z like object to string and turn it into degree (the 2nd arg)

                scaling: getStringCoord(scaling),

I believe you can’t. You have to null the quartenion or set a new (Vector3 rotate), as per


Is the object you’re trying to rotate a GLB mesh? The z rotation might be related to the transformations to convert handedness. If so, you can use scene.useRightHandedSystem = true so the root node doesn’t have rotations anymore.


Thank you, It is a glb mesh root. I later use AssetContainer.createRootMesh() to create a parent and attached the gizmo to parent, it works fine :slight_smile:

1 Like