Threejs Rotating object with device orientation control
Asked Answered
F

1

5

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.

Factfinding answered 28/9, 2014 at 4:42 Comment(3)
You should be able to do what you want by modifying threejs.org/examples/misc_controls_deviceorientation.html to control the box mesh, instead of the camera.Fadden
WestLangley, I followed your suggestion and took a guess to replace "camera" in "controls = new THREE.DeviceOrientationControls(camera, true);" with my 3D object and it worked! This is just amazing. Thank you for your basic push to reconsider the device orientation example. I had seen that example before but struggled to understand how it could be manipulated to get what I wanted partly because of documentation still under construction I believe. Anyway, thank you for your help!Factfinding
I have a question regarding this. The 3d object starts rotating but ina very inintuitive way,do you know what I mean? Do you know a way to make it rotate a the same way as the vr.chromeexperiments.com does in one of the examples? Specifically the one that has a sphere in the middle.Diapositive
F
7

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.

Factfinding answered 29/9, 2014 at 20:42 Comment(1)
DeviceOrientationControls has been removed so unfortunately this is not relevant any more. github.com/mrdoob/three.js/wiki/Migration-Guide#133--134Jaella

© 2022 - 2024 — McMap. All rights reserved.