UserActivityModule
ClassExposes the user's current mode of action (e.g. stationary, walking) and posture (e.g. standing, sitting) to Lens developers.
- Snapchat: not supported
- SPECS: fully supported
- Camera Kit Web: not supported
- Camera Kit Mobile: not supported
- SnapchatNot supported — Available on SPECS only
- SPECSFully supported
- Camera Kit WebNot supported — Available on SPECS only
- Camera Kit MobileNot supported — Available on SPECS only
Since Lens Scripting v380
Exposes the user's current mode of action (e.g. stationary, walking) and posture (e.g. standing, sitting) to Lens developers. Accessible via require('LensStudio:UserActivityModule').
Index
Properties
Methods
Example
@component
export class ActivityExample extends BaseScriptComponent {
private activityModule: UserActivityModule = require('LensStudio:UserActivityModule');
onAwake() {
this.activityModule.onUserActivityChanged.add((modeOfAction, accuracy) => {
print("New mode of action: " + modeOfAction + ", accuracy: " + accuracy);
});
}
}
Extends
Properties
modeOfAction
readonlymodeOfAction:ModeOfAction
SPECS
The current activity state. Use this to initialize Lens state on launch; use UserActivityModule.onUserActivityChanged to react to subsequent changes.
Since
Lens Scripting Version 380
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
onPostureChanged
readonlyonPostureChanged:event1<Posture,void>
SPECS
Callback for change in posture. Event to notify when user changes posture.
Param
posture
The current posture UserActivityModule.Posture.
Since
Lens Scripting Version 380
onUserActivityChanged
readonlyonUserActivityChanged:event2<ModeOfAction,number,void>
SPECS
Callback for change in user activity. Event to notify when user changes activity.
Param
activity
The current activity state UserActivityModule.ModeOfAction.
Param
accuracy
The accuracy of the activity detected (between 0 and 1).
Since
Lens Scripting Version 380
posture
readonlyposture:Posture
SPECS
The current posture. Use this to initialize Lens state on launch; use UserActivityModule.onPostureChanged to react to subsequent changes.
Since
Lens Scripting Version 380
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
velocity
readonlyvelocity:number
SPECS
The current speed of the device in m/s.
Since
Lens Scripting Version 380
Methods
getTypeName()
staticgetTypeName():TypeName<UserActivityModule>
SPECS
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<UserActivityModule>
Since
Lens Scripting Version 380
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
Nested types
Enumerations
| Enumeration | Description |
|---|---|
| ModeOfAction | An enumeration describing which activity is currently performed by the user. |
| Posture | An enumeration describing the user's current posture. |