From 337fc967df249b42ae76663c7a6a08577fe9a34d Mon Sep 17 00:00:00 2001 From: Brian Peiris <brianpeiris@gmail.com> Date: Tue, 2 Oct 2018 16:38:58 -0700 Subject: [PATCH] Fix rotation order discrepancy --- src/components/pitch-yaw-rotator.js | 5 +++-- src/hub.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/pitch-yaw-rotator.js b/src/components/pitch-yaw-rotator.js index bc1bd4f78..bb7eb4c56 100644 --- a/src/components/pitch-yaw-rotator.js +++ b/src/components/pitch-yaw-rotator.js @@ -15,12 +15,13 @@ AFRAME.registerComponent("pitch-yaw-rotator", { look(deltaPitch, deltaYaw) { const { minPitch, maxPitch } = this.data; this.pitch += deltaPitch; - this.pitch = Math.max(minPitch, Math.min(maxPitch, this.pitch)); + this.pitch = THREE.Math.clamp(this.pitch, minPitch, maxPitch); this.yaw += deltaYaw; }, set(pitch, yaw) { - this.pitch = radToDeg(pitch); + const { minPitch, maxPitch } = this.data; + this.pitch = THREE.Math.clamp(radToDeg(pitch), minPitch, maxPitch); this.yaw = radToDeg(yaw); }, diff --git a/src/hub.js b/src/hub.js index b694d396c..4110680e4 100644 --- a/src/hub.js +++ b/src/hub.js @@ -181,6 +181,7 @@ function setupLobbyCamera() { if (previewCamera) { camera.object3D.position.copy(previewCamera.position); camera.object3D.rotation.copy(previewCamera.rotation); + camera.object3D.rotation.reorder("YXZ"); camera.object3D.updateMatrix(); } else { const cameraPos = camera.object3D.position; @@ -188,7 +189,7 @@ function setupLobbyCamera() { } camera.setAttribute("scene-preview-camera", "positionOnly: true; duration: 60"); - camera.components["pitch-yaw-rotator"].set(camera.object3D.rotation.x / 2, camera.object3D.rotation.y); + camera.components["pitch-yaw-rotator"].set(camera.object3D.rotation.x, camera.object3D.rotation.y); } let uiProps = {}; -- GitLab