stalgiag / p5.xr

a library that helps turn p5.js sketches into immersive experiences using WebXR
GNU Lesser General Public License v2.1
117 stars 25 forks source link

Controller Input Rotation Data #158

Closed atkin498 closed 2 years ago

atkin498 commented 2 years ago

Nature of issue?

Which area does this problem relate to?

Feature enhancement details:

When getting input from my VR controllers, I can use the following code to draw a box at the left controllers position:

let left = getXRInput(LEFT); push(); translate(left.position.x, left.position.y, left.position.z); box(0.05); pop();

I would also like to get the rotation angles around the global x, y, and z-axis. Unfortunately, due to things I need to do beyond drawing something with the controller's orientation and position, I cannot use the applyMatrix function. I have tried using the upper left 3x3 elements of the left.pose matrix (which I understand to be the rotation matrix) by converting this to euler angles. I have not been able to get the correct data by doing this though. Is there something I could call like left.rotation.x or some manipulation I could do to the matrix data to get these values?

stalgiag commented 2 years ago

resolved by #181