From e894149650fd305346fc75f60dd73591b187798e Mon Sep 17 00:00:00 2001 From: Quicksticks-oss Date: Wed, 17 Apr 2024 17:10:47 -0400 Subject: [PATCH 1/2] Fixed camera object rotation glitch by converting degrees to rads. --- app/pages/PageEnigma/datastructures/clips/transform_clip.ts | 5 +++-- app/pages/PageEnigma/js/editor.ts | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/pages/PageEnigma/datastructures/clips/transform_clip.ts b/app/pages/PageEnigma/datastructures/clips/transform_clip.ts index 7ec3b2908e..8aa096d43a 100644 --- a/app/pages/PageEnigma/datastructures/clips/transform_clip.ts +++ b/app/pages/PageEnigma/datastructures/clips/transform_clip.ts @@ -86,7 +86,7 @@ export class TransformClip { //if (this.step_frame < 0) { this.step_frame = 0; } //if (this.step_frame >= this.length) { return; } // Reached max frames. if (this.keyframes.length < 1) { return; } // If there are enough points in the scene. - + // Find the current and next keyframes based on time_frame let { currentKeyframe, nextKeyframe } = this.findNextNumber(this.step_frame); if (nextKeyframe != undefined && currentKeyframe != undefined) { @@ -123,9 +123,10 @@ export class TransformClip { if (this.keyframes.length > 0) { let first_pos = this.keyframes[0].position; let first_rot = this.keyframes[0].rotation; + let first_quat = new THREE.Quaternion().setFromEuler(new THREE.Euler(THREE.MathUtils.degToRad(first_rot.x), THREE.MathUtils.degToRad(first_rot.y), THREE.MathUtils.degToRad(first_rot.z))); let first_scl = this.keyframes[0].scale; object.position.copy(first_pos); - object.rotation.set(first_rot.x, first_rot.y, first_rot.z); + object.rotation.set(first_quat.x, first_quat.y, first_quat.z); object.scale.copy(first_scl); this.step_frame = 0; } diff --git a/app/pages/PageEnigma/js/editor.ts b/app/pages/PageEnigma/js/editor.ts index 8bbd9e8968..1f56d11c63 100644 --- a/app/pages/PageEnigma/js/editor.ts +++ b/app/pages/PageEnigma/js/editor.ts @@ -520,7 +520,6 @@ class Editor { switchCameraView() { this.camera_person_mode = !this.camera_person_mode; - console.log(this.camera_person_mode); if (this.cam_obj) { if (this.camera_person_mode) { this.last_cam_pos.copy(this.camera.position); From b28e87bfd5255edf99c71e7e31477d1bd848cca1 Mon Sep 17 00:00:00 2001 From: Quicksticks-oss Date: Wed, 17 Apr 2024 17:22:25 -0400 Subject: [PATCH 2/2] Fixed keypress when going out of view. --- app/pages/PageEnigma/js/editor.ts | 2 ++ app/pages/PageEnigma/js/free_cam.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/pages/PageEnigma/js/editor.ts b/app/pages/PageEnigma/js/editor.ts index 1f56d11c63..28ff42c3c7 100644 --- a/app/pages/PageEnigma/js/editor.ts +++ b/app/pages/PageEnigma/js/editor.ts @@ -380,6 +380,7 @@ class Editor { this.orbitControls.enabled = false; this.cameraViewControls.enabled = false; } + this.cameraViewControls?.reset(); } }); @@ -520,6 +521,7 @@ class Editor { switchCameraView() { this.camera_person_mode = !this.camera_person_mode; + this.cameraViewControls?.reset(); if (this.cam_obj) { if (this.camera_person_mode) { this.last_cam_pos.copy(this.camera.position); diff --git a/app/pages/PageEnigma/js/free_cam.js b/app/pages/PageEnigma/js/free_cam.js index 6fd1e8007c..bb916b24ac 100644 --- a/app/pages/PageEnigma/js/free_cam.js +++ b/app/pages/PageEnigma/js/free_cam.js @@ -112,11 +112,24 @@ class FreeCam extends EventDispatcher { }; + this.reset = function() { + this.moveState.forward = 0; + this.moveState.back = 0; + this.moveState.left = 0; + this.moveState.right = 0; + this.moveState.pitchUp = 0; + this.moveState.pitchDown = 0; + this.moveState.yawLeft = 0; + this.moveState.yawRight = 0; + this.moveState.down = 0; + this.moveState.up = 0; + this.updateMovementVector(); + } + this.update = function ( delta ) { if ( this.enabled === false ) return; - const moveMult = delta * scope.movementSpeed; scope.object.translateX( scope.moveVector.x * moveMult );