Find viewing angle from DeviceOrientationControls in threejs

115 Views Asked by At

I'm making a WebVR environment. I've added controls so you can navigate in the scene and added DeviceOrientationControls so I can use the scene in my cardboard.

However, the controls I'm using now are influencing the camera and when I'm looking around (by tilting my phone around) the controls don't get translated to where I'm looking.

For example, I'm in my scene and I'm looking backwards (so I turned my head 180°), if I now go forwards with my controls, I will visually be going backwards because my vision has been rotated 180°.

I'd like my controls to "follow" my viewing angle. I found a Stack Overflow post suggesting I'd put it in a THREE.Object3D() so I can rotate the parent object, but I'm not sure this will be the desired effect, or will it?...

1

There are 1 best solutions below

0
On BEST ANSWER

I probably should've spent more time looking at the (many) three.js examples. There's an example for this available at https://threejs.org/examples/?q=poin#misc_controls_pointerlock