/rotation_fix.js Secret
Created
October 26, 2024 01:19
BFCM Globe 2023: Camera Rotation Fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First rotate along Y axis, then rotate along X axis | |
const rotationOrder = "YXZ"; | |
// Offset phi by Math.PI * 0.5 (90 degrees) since phi is '0' along the Y axis, but we want '0' to be along the X axis to align with Three.js' coordinates | |
const rotation = new THREE.Euler( | |
cameraSettings.phi - Math.PI * 0.5, | |
cameraSettings.theta, | |
0, | |
rotationOrder | |
); | |
// Rotate the default up vector (0, 1, 0) by our rotation | |
const upVector = new THREE.Vector3(0, 1, 0).applyEuler(rotation); | |
camera.up.copy(upVector); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment