DeviceMotionModule Module

The DeviceMotionModule class enables device movement detection.

Usage

To use the DeviceMotion class you must add the Device Motion effect capability to your project manifest. Once added, include access the class in your script with the following code:

const DeviceMotion = require('DeviceMotion');

Properties

PropertyDescription

worldTransform

read-only: TransformSignal

Specifies a TransformSignal representing the device transformation relative to world coordinate system.

Methods

This class exposes no methods.

Example

The following example binds a plane in the scene to the device orientation. The Device Motion effect capability must be added the project manifest for this example to work.

const Reactive = require('Reactive');
const DeviceMotion = require('DeviceMotion');
const Scene = require('Scene');

var boundPlane = Scene.root.child('Device').child('Camera').child('Focal Distance').child('boundPlane');

boundPlane.transform.rotationX = DeviceMotion.worldTransform.rotationX;
boundPlane.transform.rotationY = DeviceMotion.worldTransform.rotationY;
boundPlane.transform.rotationZ = DeviceMotion.worldTransform.rotationZ;