diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index 4d55e0319e..bc3be9ae72 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -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;