Converting the viewer rotation coordinates to three.js camera vectors
fareed945 opened this issue · comments
Hey, thanks a ton for this amazing light weight library !!
I'm kind of confused as to how to convert these pitch, yaw to the three.js camera target vectors .
Anyone can help on this ?
Basically, i'm synchronizing pannellum with another third party 3d rendering library, that uses three.js
The pitch and yaw are Euler angles, with a YXZ
order. Pitch is X
, yaw is Y
, and roll is Z
. You might need to add in a minus sign or two or add or subtract pi to get things to match up with three.js.
Thanks, i'll try this out and confirm
hey @mpetroff i'm struggling to get them in-line, few clarifications
- The order of rotation is YXZ where-in
y is yaw
,x is pitch
andZ is roll
. Correct ? - Should roll be set to Zero?
- That's correct.
- The roll is normally zero, but it's non-zero when device orientation mode is in use.
In case it's helpful, here's a snippet showing how to go the opposite direction, to synchronize Pannellum to a three.js camera:
var quat = new THREE.Quaternion();
var euler = new THREE.Euler(0, 0, 0, 'YXZ');
camera.getWorldQuaternion(quat); // THREE.PerspectiveCamera
euler.setFromQuaternion(quat, 'YXZ');
var pitch = -euler.x;
var yaw = Math.PI + euler.y;
var roll = euler.z - Math.PI;