Repository

Motion

Extends:

Component → Motion

Constructor Summary

Public Constructor
public

Motion gives access to the embbeded accelerometers data of you device.

Member Summary

Public Members
public

The accel values including gravity.

public
public

true if the acceloremeters are available on the device, false otherwise

public
public

the gravity orientation vector based on accel including gravity.

public
public

The accel rotation rate.

public

smoothedAcc: {"x": *, "y": *, "z": *}

public

The accel values without gravity.

Method Summary

Public Methods
public

Method to get the filtered accel including gravity.

public

off()

public

on()

public

onDeviceMotion(event: *)

public
Private Methods
private

Method to compute the gravity orientation vector based on accel including gravity.

private

Compute the values for the acc on devices that gives "undefined" for the event.acceleration prop (some Android)

Inherited Summary

From class Component
public
public
public

events: *

public

id: *

public

name: *

private

_nexts: *[]

private
public
public

chain(component: Component)

Adds a component to this chained component array

public

Returns the array of attached children components

public

off()

Deactivate the component

public

on()

Activate the component A call to this method calls the setup method if it has not been run yet

public

Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism

public

preLoad the component This empty method is usually overriden to perform preLoad actions for the component.

public

Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism

public

prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server.

public

Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly

public

Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism

Public Constructors

public constructor() source

Motion gives access to the embbeded accelerometers data of you device. !WARNING! On iOS 13+ you must call on() in a user interaction (i.e "touchend" on Mobile Safari). See examples!

Override:

Component#constructor

Public Members

public acc: Object source

The accel values including gravity. This can also be get through the event accelerationIncludingGravity

Properties:

NameTypeAttributeDescription
x*
y*
z*

public accel: number[] source

public available: Boolean source

true if the acceloremeters are available on the device, false otherwise

public gAccel: number[] source

public gravityVector: Object source

the gravity orientation vector based on accel including gravity. This can also be get through the event accelerationGravityVector

Properties:

NameTypeAttributeDescription
x*
y*
z*

public kFilteringFactor: number source

public rotationRate: Object source

The accel rotation rate. This can also be get through the event rotationRate

Properties:

NameTypeAttributeDescription
x*
y*
z*

public smoothedAcc: {"x": *, "y": *, "z": *} source

public userAcc: Object source

The accel values without gravity. This can also be get through the event acceleration

Properties:

NameTypeAttributeDescription
x*
y*
z*

Public Methods

public getSmoothedAcc(factor: Number): Object source

Method to get the filtered accel including gravity.

Params:

NameTypeAttributeDescription
factorNumber

The number to use for the filtering aglorithm (0.07 gives good results)

Return:

Object

smoothedAcc object composed by x, y & z components

public off() source

Deactivate the component

Override:

Component#off

public on() source

Activate the component A call to this method calls the setup method if it has not been run yet

Override:

Component#on

public onDeviceMotion(event: *) source

Params:

NameTypeAttributeDescription
event*

public setup() source

Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly

Override:

Component#setup

Private Methods

private computeGravityVector() source

Method to compute the gravity orientation vector based on accel including gravity. The result can also be get through the event onAccelerationGravityVector

private computeUserAcc() source

Compute the values for the acc on devices that gives "undefined" for the event.acceleration prop (some Android)