DeepAR Scripting API v5.6.4

Namespace: Utility

Utility

Collection of useful utility functions.

Members

(static, readonly) TriggerType :uint

Trigger type.
Type:
  • uint
Properties:
Name Type Description
MOUTH_OPEN uint Trigger that gets fired when the mouth is open.
MOUTH_CLOSED uint Trigger that gets fired when the mouth is closed.
MOUTH_OPEN_SENSITIVE uint Trigger that gets fired when the mouth is open with a lower threshold lip distance.
MOUTH_CLOSED_SENSITIVE uint Trigger that gets fired when the mouth is closed with a lower threshold lip distance.
BLINK uint Trigger that gets fired when the eye is closed (blinking).
FACE_APPEARED uint Trigger that gets fired when the face is visible.
FACE_DISAPPEARED uint Trigger that gets fired when the face is not visible.
EYEBROWS_RAISE uint Trigger that gets fired when the eyebrows are raised.
SMILE uint Trigger that gets fired when the face is smiling.
NEUTRAL uint Trigger that gets fired when the face is neutral.
HAPPINESS uint Trigger that gets fired when the face is happy.
SURPRISE uint Trigger that gets fired when the face is surprised.
SADNESS uint Trigger that gets fired when the face is sad.
ANGER uint Trigger that gets fired when the face is angry.
NEUTRAL_END uint Trigger that gets fired when the face is not neutral.
HAPPINESS_END uint Trigger that gets fired when the face is not happy.
SURPRISE_END uint Trigger that gets fired when the face is not surprised.
SADNESS_END uint Trigger that gets fired when the face is not sad.
ANGER_END uint Trigger that gets fired when the face is not angry.

Methods

(static) changeParameter(nodeName, componentName, parameterName, …params)

Changes a node or component parameter. Equivalent of the changeParameter() API call.
Parameters:
Name Type Attributes Description
nodeName string Name of the node. If multiple nodes share the same name, only the first one will be affected.
componentName string Name of the component. If the name of the component is null or an empty string, the node itself will be affected.
parameterName string Name of the parameter. See the documentation for more info.
params any <repeatable>
New parameter value. See the examples below.
Examples
// Sets the 'face1' node 'u_color' shader vec4 uniform to (1.0, 0.5, 0.0, 1.0).
Utility.changeParameter('face1', 'MeshRenderer', 'u_color', 1.0, 0.5, 0.0, 1.0);
// Sets the 'mesh.04' node position to (1, 3.5, -2.82).
Utility.changeParameter('mesh.04', null, 'position', 1, 3.5, -2.82);
// Disables the 'my_node' node.
Utility.changeParameter('my_node', '', 'enabled', false);

(static) findFaceIdInHierarchy() → {uint}

Gets the face index from the node hierarchy.
Returns:
The face index. Possible values are 0 (first face), 1 (second face), 2 (third face) and 3 (fourth face).
Type
uint

(static) fireTrigger(triggerName)

Fires a custom trigger. Only one trigger can be fired each frame.
Parameters:
Name Type Description
triggerName string Name of the custom trigger.
Throws:
When the trigger name is empty.
Type
Error

(static) getFiredCustomTriggerName() → {string}

Gets the name of the fired custom trigger.
Throws:
When the custom trigger was not fired.
Type
Error
Returns:
The name of the fired custom trigger.
Type
string

(static) getTriggerState(triggerType, faceIdopt) → {bool}

Gets the trigger state.
Parameters:
Name Type Attributes Description
triggerType TriggerType The trigger type.
faceId int <optional>
The face index. Accepted values are -1 (auto face), 0 (first face), 1 (second face), 2 (third face) and 3 (fourth face).
Returns:
True if a given trigger type state is set for the given face index, false otherwise.
Type
bool

(static) getTriggerStateChanged(triggerType, faceIdopt) → {bool}

Checks if the trigger state has changed.
Parameters:
Name Type Attributes Description
triggerType TriggerType The trigger type.
faceId int <optional>
The face index. Accepted values are -1 (auto face), 0 (first face), 1 (second face), 2 (third face) and 3 (fourth face).
Returns:
True if a given trigger type state has changed for the given face index, false otherwise.
Type
bool

(static) isCustomTriggerFired() → {bool}

Checks if a custom trigger was fired.
Returns:
True if a custom trigger was fired, false otherwise.
Type
bool

(static) setViewCleared(viewId, colorFlagEnabled, depthFlagEnabled)

Sets the color and depth flags for the specified view/effect layer.
Parameters:
Name Type Description
viewId uint View ID of the view/layer.
colorFlagEnabled bool Determines whether the color buffer should be cleared.
depthFlagEnabled bool Determines whether the depth buffer should be cleared.