From d0e01b03b21414d66242725d8f61b0f320bc18c4 Mon Sep 17 00:00:00 2001 From: Kevin Nadro Date: Mon, 25 Nov 2024 14:05:10 -0600 Subject: [PATCH 1/2] fix: upon entering sketch mode, axis do not rotate. --- src/clientSideScene/CameraControls.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index fdc83ab70e..e49a616918 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -273,14 +273,19 @@ export class CameraControls { camSettings.center.y, camSettings.center.z ) - const quat = new Quaternion( + const orientation = new Quaternion( camSettings.orientation.x, camSettings.orientation.y, camSettings.orientation.z, camSettings.orientation.w ).invert() - this.camera.up.copy(new Vector3(0, 1, 0).applyQuaternion(quat)) + this.camera.quaternion.set( + orientation.x, + orientation.y, + orientation.z, + orientation.w + ) if (this.camera instanceof PerspectiveCamera && camSettings.ortho) { this.useOrthographicCamera() } @@ -1164,7 +1169,7 @@ export class CameraControls { this.camera.updateProjectionMatrix() } - if (this.syncDirection === 'clientToEngine' || forceUpdate) + if (this.syncDirection === 'clientToEngine' || forceUpdate) { this.throttledUpdateEngineCamera({ quaternion: this.camera.quaternion, position: this.camera.position, @@ -1172,6 +1177,7 @@ export class CameraControls { isPerspective: this.isPerspective, target: this.target, }) + } this.deferReactUpdate(this.reactCameraProperties) Object.values(this._camChangeCallbacks).forEach((cb) => cb()) } From dfb5b48fb765e3b046473ba1d3f56685c157c4c5 Mon Sep 17 00:00:00 2001 From: Kevin Nadro Date: Tue, 26 Nov 2024 12:55:35 -0600 Subject: [PATCH 2/2] fix: camera settings has the up vector to set, this should now work --- src/clientSideScene/CameraControls.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index e49a616918..a0d9553d2a 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -280,12 +280,19 @@ export class CameraControls { camSettings.orientation.w ).invert() + const newUp = new Vector3( + camSettings.up.x, + camSettings.up.y, + camSettings.up.z + ) this.camera.quaternion.set( orientation.x, orientation.y, orientation.z, orientation.w ) + this.camera.up.copy(newUp) + this.camera.updateProjectionMatrix() if (this.camera instanceof PerspectiveCamera && camSettings.ortho) { this.useOrthographicCamera() }