From 77293952c04ea33e6697795f18a05b9a22756503 Mon Sep 17 00:00:00 2001 From: Kevin Nadro Date: Wed, 4 Dec 2024 16:57:17 -0500 Subject: [PATCH] fix: upon entering sketch mode, axis do not rotate. (#4572) * fix: upon entering sketch mode, axis do not rotate. * fix: camera settings has the up vector to set, this should now work --- src/clientSideScene/CameraControls.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/clientSideScene/CameraControls.ts b/src/clientSideScene/CameraControls.ts index fdc83ab70e..a0d9553d2a 100644 --- a/src/clientSideScene/CameraControls.ts +++ b/src/clientSideScene/CameraControls.ts @@ -273,14 +273,26 @@ 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)) + 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() } @@ -1164,7 +1176,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 +1184,7 @@ export class CameraControls { isPerspective: this.isPerspective, target: this.target, }) + } this.deferReactUpdate(this.reactCameraProperties) Object.values(this._camChangeCallbacks).forEach((cb) => cb()) }