import Motion from '@mobilizing/library/js/Mobilizing/input/Motion.js'
Motion
Extends:
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 | getSmoothedAcc(factor: Number): Object Method to get the filtered accel including gravity. | |
public | off() | |
public | on() | |
public | onDeviceMotion(event: *) | |
public | setup() |
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 | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | 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() 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() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() 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() 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#constructorPublic Members
public acc: Object source
The accel values including gravity. This can also be get through the event accelerationIncludingGravity
Properties:
Name | Type | Attribute | Description |
x | * | ||
y | * | ||
z | * |
public available: Boolean source
true if the acceloremeters are available on the device, false otherwise
public gravityVector: Object source
the gravity orientation vector based on accel including gravity. This can also be get through the event accelerationGravityVector
Properties:
Name | Type | Attribute | Description |
x | * | ||
y | * | ||
z | * |
public rotationRate: Object source
The accel rotation rate. This can also be get through the event rotationRate
Properties:
Name | Type | Attribute | Description |
x | * | ||
y | * | ||
z | * |
public smoothedAcc: {"x": *, "y": *, "z": *} source
Public Methods
public getSmoothedAcc(factor: Number): Object source
Method to get the filtered accel including gravity.
Params:
Name | Type | Attribute | Description |
factor | Number | The number to use for the filtering aglorithm (0.07 gives good results) |
Return:
Object | smoothedAcc object composed by x, y & z components |
public on() source
Activate the component A call to this method calls the setup method if it has not been run yet
Override:
Component#onpublic onDeviceMotion(event: *) source
Params:
Name | Type | Attribute | Description |
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#setupPrivate 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)