diff --git a/src/components/pitch-yaw-rotator.js b/src/components/pitch-yaw-rotator.js index 7af5799e72077977f81abd5ddff3a4686c46fe1f..bc1bd4f7876789f87eaa6d5e638d3efa3b3e0af4 100644 --- a/src/components/pitch-yaw-rotator.js +++ b/src/components/pitch-yaw-rotator.js @@ -1,4 +1,6 @@ const degToRad = THREE.Math.degToRad; +const radToDeg = THREE.Math.radToDeg; + AFRAME.registerComponent("pitch-yaw-rotator", { schema: { minPitch: { default: -50 }, @@ -17,6 +19,11 @@ AFRAME.registerComponent("pitch-yaw-rotator", { this.yaw += deltaYaw; }, + set(pitch, yaw) { + this.pitch = radToDeg(pitch); + this.yaw = radToDeg(yaw); + }, + tick() { this.el.object3D.rotation.set(degToRad(this.pitch), degToRad(this.yaw), 0); this.el.object3D.rotation.order = "YXZ"; diff --git a/src/hub.js b/src/hub.js index 692213b2575560e520e3a42c1974fdb9a9da6764..b694d396c36f4e8f202c90fbcbfa429c13c22d76 100644 --- a/src/hub.js +++ b/src/hub.js @@ -188,6 +188,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); } let uiProps = {};