Skip to content

Commit

Permalink
Gizmo rotation direction fix (#7076)
Browse files Browse the repository at this point in the history
* Fixed gizmo rotation issue at large distances

* Removed line draw
  • Loading branch information
kpal81xd committed Oct 30, 2024
1 parent f210d14 commit 3fbfb01
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/extras/gizmo/rotate-gizmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { TransformGizmo } from './transform-gizmo.js';
// temporary variables
const tmpV1 = new Vec3();
const tmpV2 = new Vec3();
const tmpV3 = new Vec3();
const tmpV4 = new Vec3();
const tmpM1 = new Mat4();
const tmpQ1 = new Quat();
const tmpQ2 = new Quat();
Expand Down Expand Up @@ -477,10 +479,11 @@ class RotateGizmo extends TransformGizmo {
angle = Math.sign(facingDot) * Math.atan2(tmpV1.y, tmpV1.x) * math.RAD_TO_DEG;
} else {
// convert rotation axis to screen space
tmpV2.cross(plane.normal, facingDir).normalize();
this._camera.worldToScreen(tmpV1.copy(gizmoPos), tmpV1);
this._camera.worldToScreen(tmpV2.add(gizmoPos), tmpV2);
tmpV1.sub2(tmpV2, tmpV1).normalize();
tmpV1.copy(gizmoPos);
tmpV2.cross(plane.normal, facingDir).normalize().add(gizmoPos);
this._camera.worldToScreen(tmpV1, tmpV3);
this._camera.worldToScreen(tmpV2, tmpV4);
tmpV1.sub2(tmpV4, tmpV3).normalize();
tmpV2.set(x, y, 0);
angle = tmpV1.dot(tmpV2);
}
Expand Down

0 comments on commit 3fbfb01

Please sign in to comment.