Skip to main content

AccelerometerInput

The AccelerometerInput class provides methods to capture and manage accelerometer input from the device.

start()

Starts capturing accelerometer input.

Example:

Input.accelerometer.start();

stop()

Stops capturing accelerometer input.

Example:

Input.accelerometer.stop();

isSupported(): boolean

Checks if the device supports accelerometer input.

Example:

if (Input.accelerometer.isSupported()) {
console.log('Accelerometer is supported');
}

acceleration(): THREE.Vector3

Returns the current acceleration of the device.

Example:

const accel = Input.accelerometer.acceleration();
console.log(accel.x, accel.y, accel.z);

accelerationIncludingGravity(): THREE.Vector3

Returns the current acceleration of the device, including gravity.

Example:

const accelG = Input.accelerometer.accelerationIncludingGravity();
console.log(accelG.x, accelG.y, accelG.z);

orientationRate(): DeviceOrientation

Returns the current rate of rotation of the device, including alpha, beta, and gamma angles.

Example:

const rate = Input.accelerometer.orientationRate();
console.log(rate.alpha, rate.beta, rate.gamma);