Skip to content

Commit

Permalink
Gizmo rotation fix for orthographic (playcanvas#7072)
Browse files Browse the repository at this point in the history
* Rotation fix for orthographic

* Removed trailing space
  • Loading branch information
kpal81xd committed Oct 28, 2024
1 parent d27e50f commit 72f5afd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/extras/gizmo/rotate-gizmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class RotateGizmo extends TransformGizmo {
// calculate angle
const facingDir = tmpV2.copy(this.facing);
const facingDot = plane.normal.dot(facingDir);
if (axis === GIZMOAXIS_FACE || Math.abs(facingDot) > FACING_THRESHOLD) {
if (Math.abs(facingDot) > FACING_THRESHOLD) {
// plane facing camera so based on mouse position around gizmo
tmpV1.sub2(point, gizmoPos);

Expand Down
16 changes: 4 additions & 12 deletions src/extras/gizmo/transform-gizmo.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,20 +539,12 @@ class TransformGizmo extends Gizmo {
* @protected
*/
_createRay(mouseWPos) {
const cameraPos = this._camera.entity.getPosition();
const cameraTransform = this._camera.entity.getWorldTransform();

const ray = tmpR1.set(cameraPos, Vec3.ZERO);

// calculate ray direction from mouse position
if (this._camera.projection === PROJECTION_PERSPECTIVE) {
ray.direction.sub2(mouseWPos, ray.origin).normalize();
} else {
ray.origin.add(mouseWPos);
cameraTransform.transformVector(tmpV1.set(0, 0, -1), ray.direction);
tmpR1.origin.copy(this._camera.entity.getPosition());
tmpR1.direction.sub2(mouseWPos, tmpR1.origin).normalize();
return tmpR1;
}

return ray;
return tmpR1.set(mouseWPos, this._camera.entity.forward);
}

/**
Expand Down

0 comments on commit 72f5afd

Please sign in to comment.