Skip to content

DeviceOrientation+OrbitControls enable controlling the camera by both touch and device's orientation based on Three.js.

License

Notifications You must be signed in to change notification settings

mar-vn-nv-cie/Deviceorientation-orbitcontrols.js

Repository files navigation

DeviceOrientation+OrbitControls for Three.js

On the example of OrbitControls.js, the camera smoothly rotate but does not include the deviceorientation's control. When you need to control the camera with touch and deviceorientation (ex. for the mobile device's usage), DeviceorientationControls.js is also needed.

But the DeviceorientationControls rotate the camera only based on the device's orientation, so that the camera's direction is always initialized when DeviceorientationControls is activated, unless the camera's current direction.

For that reason, I wrote this script due to the need to link the DeviceorientationControls and OrbitControls especially for the reason of controlling the VR videos more well. (ref. VRTube) .

Function

Rotate Three.js object by the devicerientation and the touch/mousemove interaction.

Usage

On the default, DeviceorientationControls is inactive. So it is need to activate the deviceorientation event first. Other than that, it is almost the same as the OrbitControls.js (pan and keyboard event are commentouted by the default for vr usage).

var controls = new THREE.OrbitControls( camera );
controls.activateDeviceOrientation(true);

###Added parameter Can change the timing of end of the orbit by setting the minDelta.

var controls = new THREE.OrbitControls( camera );
controls.minDelta = 0.001;

Lisence

MIT

About

DeviceOrientation+OrbitControls enable controlling the camera by both touch and device's orientation based on Three.js.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published