Skip to content

Commit

Permalink
fix(CameraUtils): fix rotation animation when start heading is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mgermerie authored and gchoqueux committed May 17, 2021
1 parent ae194d3 commit 1ca0c17
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utils/CameraUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class CameraRig extends THREE.Object3D {
const range = this.camera.position.length();
this.target.rotation.x = Math.asin(this.camera.position.z / range);
const cosPlanXY = THREE.MathUtils.clamp(this.camera.position.y / (Math.cos(this.target.rotation.x) * range), -1, 1);
this.target.rotation.z = Math.sign(-this.camera.position.x) * Math.acos(cosPlanXY);
this.target.rotation.z = Math.sign(-this.camera.position.x || 1) * Math.acos(cosPlanXY);
this.camera.position.set(0, range, 0);
}

Expand Down

0 comments on commit 1ca0c17

Please sign in to comment.