From 4258abff8a6e1539fc8ea7d8b397d03e6cc1727c Mon Sep 17 00:00:00 2001 From: FORCHA PEARL Date: Sat, 29 Mar 2025 08:34:38 +0100 Subject: [PATCH 1/5] Normalized up vector of P5Camera tilt --- src/webgl/p5.Camera.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index 44be60d048..26cb191603 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2456,6 +2456,7 @@ p5.Camera = class Camera { const upZ = 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, From 1a262ee1246d5fcebab5b773b830cb1e76f3de5b Mon Sep 17 00:00:00 2001 From: FORCHA PEARL Date: Sat, 29 Mar 2025 08:44:36 +0100 Subject: [PATCH 2/5] Fixed test failures --- src/webgl/p5.Camera.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index 26cb191603..f8cd86a0b3 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2451,12 +2451,15 @@ p5.Camera = class Camera { // 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 upX = this.upX * rotation.mat4[0] + this.upY * rotation.mat4[4] + this.upZ * rotation.mat4[8]; + let upY = this.upX * rotation.mat4[1] + this.upY * rotation.mat4[5] + this.upZ * rotation.mat4[9]; + let upZ = this.upX * rotation.mat4[2] + this.upY * rotation.mat4[6] + this.upZ * rotation.mat4[10]; /* eslint-enable max-len */ - up.normalize(); + upX.normalize(); + upY.normalize(); + upZ.normalize(); + this.camera( this.eyeX, this.eyeY, From adfe00fc959eef1e1330173fba4f0a8072cc3b0e Mon Sep 17 00:00:00 2001 From: FORCHA PEARL Date: Sat, 29 Mar 2025 09:00:46 +0100 Subject: [PATCH 3/5] Update p5.Camera.js --- src/webgl/p5.Camera.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index f8cd86a0b3..d3e3957998 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2450,16 +2450,16 @@ p5.Camera = class Camera { rotatedCenter[2] += this.eyeZ; // Rotate the up vector to keep the correct camera orientation + /* eslint-disable max-len */ - let upX = this.upX * rotation.mat4[0] + this.upY * rotation.mat4[4] + this.upZ * rotation.mat4[8]; - let upY = this.upX * rotation.mat4[1] + this.upY * rotation.mat4[5] + this.upZ * rotation.mat4[9]; - let 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 */ - upX.normalize(); - upY.normalize(); - upZ.normalize(); - + up.normalize() this.camera( this.eyeX, this.eyeY, From 87975591278ada6eb3e740b776611a9ab01a768f Mon Sep 17 00:00:00 2001 From: FORCHA PEARL Date: Sat, 29 Mar 2025 09:06:13 +0100 Subject: [PATCH 4/5] Fixed Lint Error --- src/webgl/p5.Camera.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index d3e3957998..58266ab77c 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2459,7 +2459,7 @@ p5.Camera = class Camera { ); /* eslint-enable max-len */ - up.normalize() + up.normalize(); this.camera( this.eyeX, this.eyeY, From 55de54749878045ec6cd79bd8cd4a7cd8bcebddf Mon Sep 17 00:00:00 2001 From: FORCHA PEARL Date: Sat, 29 Mar 2025 09:17:53 +0100 Subject: [PATCH 5/5] Fixed Logic errors --- src/webgl/p5.Camera.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/webgl/p5.Camera.js b/src/webgl/p5.Camera.js index 58266ab77c..2edd2f2022 100644 --- a/src/webgl/p5.Camera.js +++ b/src/webgl/p5.Camera.js @@ -2467,9 +2467,9 @@ p5.Camera = class Camera { rotatedCenter[0], rotatedCenter[1], rotatedCenter[2], - upX, - upY, - upZ + up.x, + up.y, + up.z ); }