How to use the euler angles with rotations in "YXZ" ranging from -180 to 180 in a non three.js system into a three.js system

535 Views Asked by At

I have a 360 image (non three.js) system that outputs my Euler angles ( pitch (x), yaw (y) and roll (z) ) on rotation as "YXZ" order. The bounds of for example yaw are from [-180 to 180] (a net total of 360).

I want to use these angles to rotate a 3d object in another system which is built on three.js. On change of values in my system 1, I set my Euler angles to the target vector of the camera object in the second system, It rotates to an extent, but I feel i'm doing something wrong in terms of bounds or may be some other issue due to my very limited knowledge of three.js

Any help would enhance my knowledge

1

There are 1 best solutions below

0
M - On

Three.js rotations are in radians, and it looks like the [-180, 180] range is in degrees. So you're going to have to convert the rotation values from degrees to radians. You could simply use MathUtils.degToRad() to do the conversion for you:

var pitch = xxx; // Get pitch from your other system somehow
object.rotation.x = THREE.MathUtils.degToRad(pitch);