1. A concise explanation of the problem you’re experiencing.
I have quaternion an want to apply it to camera orientation. To set camera orientation I can use heading, pitch, roll or direction vectors. Heading, pitch, roll doesn’t work for me since gimbal lock preventing from changing heading too much. With vectors problem is that their value changing depending on location and i can’t just apply vectors from rotation matrix that I get from my quanterion, not messing up starting camera orientation. So, my question is, how to apply quanterion rotation to camera direction vectors. This sounds like something simple. but I couldn’t find the answer.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
Right now my working code looks like this:
let dirForward = new Cesium.Cartesian3(); dirForward.x = 2 * (quat.x * quat.z + quat.w * quat.y);
dirForward.y = 2 * (quat.y * quat.z - quat.w * quat.x);
dirForward.z = 1 - 2 * (quat.x * quat.x + quat.y * quat.y); let dirUp = new Cesium.Cartesian3();
dirUp.x = 2 * (quat.x * quat.y - quat.w * quat.z);
dirUp.y = 1 - 2 * (quat.x * quat.x + quat.z * quat.z);
dirUp.z = 2 * (quat.y * quat.z + quat.w * quat.x);
But when stepping into it, camera goes somewhere, where it is not supposed to be, I want camera to stay stil, when quanterion is 0,0,0,1.
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I’m building for VR and I’m only able to get quaternion as headset orientation, but not able to directly apply is to camera.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.59, Windows 10, Chrome 76
P.S. What’s up with tags? I couldn’t add any.