Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Threejs Rotating object with device orientation control

I am trying to achieve an effect similar to one of the cardboard app examples that Google has put out with their cardboard app called the 'exhibit'. I have a 3D object that I want to rotate using device orientation control. Right now with just the device orientation control, I can view the 3D object but when I turn around, the camera rotates (it seems) causing the object to fall out of view until I turn all the way back around to where it was in the beginning. In other words the camera seems to rotate in its axis as I look around. What I want is to be able to rotate the object as I turn around.

Kinda like this example http://threejs.org/examples/#misc_controls_orbit except I want to rotate using device orientation control.

Any idea how I can incorporate this feature?

Thank you for your assistance.

like image 772
sandav Avatar asked Sep 28 '14 04:09

sandav


1 Answers

The answer to my own question for future seekers is to replace camera in

controls = new THREE.DeviceOrientationControls(camera, true);

with the 3D object you are trying to rotate.

like image 181
sandav Avatar answered Nov 02 '22 11:11

sandav