Skip to content

Commit

Permalink
Merge pull request #6154 from inaridarkfox4231/orbitControl_angleBetw…
Browse files Browse the repository at this point in the history
…een_BUG

Do not use angleBetween() for angle calculation in _orbit() inside orbtiControl().
  • Loading branch information
davepagurek committed May 23, 2023
2 parents ab18566 + 7e66e4a commit 914d637
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/webgl/p5.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,11 @@ p5.Camera.prototype._orbit = function(dTheta, dPhi, dRadius) {

// calculate updated camera angle
// Find the angle between the "up" and the "front", add dPhi to that.
const camPhi = front.angleBetween(up) + dPhi;
// angleBetween() may return negative value. Since this specification is subject to change
// due to version updates, it cannot be adopted, so here we calculate using a method
// that directly obtains the absolute value.
const camPhi =
Math.acos(Math.max(-1, Math.min(1, p5.Vector.dot(front, up)))) + dPhi;
// Rotate by dTheta in the shortest direction from "vertical" to "side"
const camTheta = dTheta;

Expand Down

0 comments on commit 914d637

Please sign in to comment.