diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index 44be60d048..2edd2f2022 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2450,12 +2450,16 @@ p5.Camera = class Camera { rotatedCenter[2] += this.eyeZ; // Rotate the up vector to keep the correct camera orientation + /* eslint-disable max-len */ - const upX = this.upX * rotation.mat4[0] + this.upY * rotation.mat4[4] + this.upZ * rotation.mat4[8]; - const upY = this.upX * rotation.mat4[1] + this.upY * rotation.mat4[5] + this.upZ * rotation.mat4[9]; - const upZ = this.upX * rotation.mat4[2] + this.upY * rotation.mat4[6] + this.upZ * rotation.mat4[10]; + let up = new p5.Vector( + this.upX * rotation.mat4[0] + this.upY * rotation.mat4[4] + this.upZ * rotation.mat4[8], + this.upX * rotation.mat4[1] + this.upY * rotation.mat4[5] + this.upZ * rotation.mat4[9], + this.upX * rotation.mat4[2] + this.upY * rotation.mat4[6] + this.upZ * rotation.mat4[10] + ); /* eslint-enable max-len */ + up.normalize(); this.camera( this.eyeX, this.eyeY, @@ -2463,9 +2467,9 @@ p5.Camera = class Camera { rotatedCenter[0], rotatedCenter[1], rotatedCenter[2], - upX, - upY, - upZ + up.x, + up.y, + up.z ); }