sud.onDeviceMotionChange
JS
sud.onDeviceMotionChange(function callback)Listens for device motion change events. Each call to this api sets an independent listener callback and does not overwrite previous ones.
The interval follows the interval parameter of startDeviceMotionListening(). Listening starts automatically after the interface is called.
Parameters
- function callback: Callback function for device motion change events
Parameters of the callback function
- Object res: Returns device motion data
Properties of the device motion data:
| Property | Type | Description |
|---|---|---|
| alpha | number | When the phone coordinates X/Y coincide with the earth X/Y, alpha is the rotation angle around the Z axis, ranging in [0, 2*PI). Rotating counterclockwise decreases the alpha value. |
| beta | number | When the phone coordinates Y/Z coincide with the earth Y/Z, beta is the rotation angle around the X axis, ranging in [-1*PI, PI). |
| gamma | number | When the phone X/Z coincide with the earth X/Z, gamma is the rotation angle around the Y axis, ranging in [-1*PI/2, PI/2). |
