Some of you asked for a more complete example
of the use of the IMU together with my modeler.
You can use the following code as a template:
CT.imu = { alpha:null, beta:null, gamma:null };
if (window.DeviceOrientationEvent)
window.addEventListener('deviceorientation', function(event) {
CT.imu.alpha = event.alpha; // PHONE DIRECTION IN DEGREES
CT.imu.beta = event.beta; // TILT FRONT-BACK IN DEGREES
CT.imu.gamma = event.gamma; // TILT LEFT-RIGHT IN DEGREES
});
...
if (CT.imu.alpha != null)
root.identity().rotateX( CT.imu.gamma * Math.PI / 180 + Math.PI/2)
.rotateZ( CT.imu.beta * Math.PI / 180)
.rotateY(-CT.imu.alpha * Math.PI / 180);