AnimationClip
- Last UpdatedMay 21, 2025
- 6 minute read
The AnimationClip node enables you to create complex animations based on a timeline. Using AnimationClip nodes, you can animate any node transform field, and also trigger commands that do the following:
-
Update text
-
Drive interpolators
-
Drive imported animations
Platform support
This node is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-Portable WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
Channels and keyframes
The AnimationClip node is based on channels. Each channel represents a field of a node that the AnimationClip is going to manipulate against its timeline. For example, to enable a clip to move a mesh, its position or positionOffset field must be added as a channel.
Keyframes represents specific points on the timeline of a channel in which the channel field must be set to a specific value. Each channel has its own specific set of keyframes.
Curve and impulse channels
You can set up a channel to work into two different ways, by setting its mode field.
-
Curve—The values of the channel fields are interpolated between two keyframes. This means that the field value is set in every frame (including the keyframes).
-
Impulse—The value of the channel field is set only in the keyframes.
Due to these differences, curve channels can handle movements or states, while the impulse channels are suited to implement calls to commands or coroutines.
Different interpolation curves
When using curve type channels, it’s possible to define the interpolation type between a keyframe and the following keyframe. This is done by setting the keyFrame curve field.
This is the list of currently supported interpolation types.
|
Curve type |
Description |
|---|---|
|
linear |
The values are linearly interpolated between the start and end keyframes. |
|
square |
The value is set to start keyframe value in every frame between start and end keyframes. |
|
easein |
The interpolation starts slow and then accelerates. |
|
easeout |
The interpolation slows down at the end. |
|
easeinout |
Interpolation first accelerates and then slows down. |
Supported field types
The Impulse channel can be set to manipulate all the node fields; however, the Curve channel can be set to manipulate node fields of the following types only:
-
sint
-
sbool
-
sfloat
-
svec2
-
svec3
-
svec4
-
squat
-
smatrix
SMATRIX animations
SMATRIX animations can be performed correctly only on transformation matrices, and they are interpolated as follows.
-
Linear interpolation on the translation part
-
Spheric interpolation on the matrix quaternion
-
Linear interpolation on the scale part
SQUAT fields
SQUAT fields can be animated using Quaternion values or the corresponding Eulerian representation of the quaternion using the following Channel types.
-
SQUAT
-
SEULER_XYZ
-
SEULER_XZY
-
SEULER_YXZ
-
SEULER_YZX
-
SEULER_ZXY
-
SEULER_ZYX
Using a Eulerian representation of the Quaternion rotation allows us to make animations of a rotation that spans beyond -180° and +180° more easily. For example, if the users want to animate a bolt unscrewing (rotating around its local Y axis counter-clockwise multiple times) they can more easily animate the bolt’s mesh rotation or rotationOffset fields using a Euler channel.
Using a SQUAT or SMATRIX channel to achieve the same animation would be quite complex, not only because Quaternions are difficult to understand, but also because a keyframe every 180° of rotation would be required. This also means that the same animation created with a SQUAT or SMATRIX channel could never be eased in the same way it can be eased using a Eulerian representation of it, since the latter would require only a starting keyFrame and an ending keyFrame, allowing to ease the overall animation curve as a whole.
For more information on how to create Euler channels for SQUAT fields, see Add Node fields in the Animation Clip Editor section.
Using AnimationClip
The AnimationClip node offers a simple and powerful interface to handle the animation execution.
-
start, stop, and pause—These events are used to drive clip execution.
-
setCurrentFrameAt—Sets animation to a specific frame when paused or stopped.
-
loop—A loop is used to let a clip automatically replay from the beginning when it arrives to the last keyframe.
-
rangeStart and rangeEnd—These fields enable you to restrict clip execution within a specific frame range. This can be useful if used together with the loop. Both rangeStart and rangeEnd frames are executed.
Code example
This is a code example for an AnimationClip. Note that the AnimationClip definition is based on nested channels and keyFrames.
<AnimationClip name="proc_animation" fps="60" length="600" loop="true" >
<channel name="mBox001_pos" type="svec3" field="mBox001.position_offset" active="true" mode="curve">
<keyFrame key="0" value="0 0 0" />
<keyFrame key="120" value="0 0.2 0" curve="linear" />
<keyFrame key="240" value="0 0.4 0" curve="linear" />
<keyFrame key="360" value="0 0.2 0" curve="linear"/>
<keyFrame key="480" value="0 0.0 0" curve="linear" />
</channel>
<channel name="blink" type="sstring" field="apm_crt_changeBlink.execute" active="true" mode="impulse">
<keyFrame key="0" value="scene|Box002;scene|Box003" />
<keyFrame key="120" value="scene|Box001" />
<keyFrame key="240" value="scene|Box002" />
<keyFrame key="360" value="scene|Box003" />
<keyFrame key="480" value="scene|Box004" />
</channel>
</AnimationClip>
AnimationClip fields
These are the fields for the AnimationClip node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > AnimationClip
|
Fields |
Type |
Use |
Default Value |
Description |
|---|---|---|---|---|
|
active |
sbool |
Optional |
true |
Enables or disables a clip. |
|
currentFrame |
sfloat |
Read Only |
Internally calculated |
The currently shown frame. As the interpolation proceeds, depending on the game loop delta time, the current frame is an sfloat value rather then an integer value. |
|
fps |
sint |
Optional |
60 |
Defines the animation speed in frames per second. It also supports negative fps to play the timeline in reverse direction, which reduces the efforts to create assemble-disassemble, ping-pong like scenarios. |
|
length |
sint |
Optional |
60 |
The total length of the animation clip. |
|
loop |
sbool |
Optional |
false |
Activates loop. |
|
pause |
sevent |
Optional |
No default |
Pauses playback. |
|
rangeEnd |
sint |
Optional |
-1 |
Sets the last clip frame. Set to -1 to automatically run the clip till the last frame. |
|
rangeStart |
sint |
Optional |
0 |
Sets the clip initial frame. Set to 0 to start from the first frame. |
|
setCurrentFrameAt |
sfloat |
Optional |
0 |
Sets the currentFrame to a specific position when the animation is paused or stopped. |
|
start |
sevent |
Optional |
No default |
Starts playback. |
|
state |
senum |
Read Only |
Internally calculated |
Shows current playback state, which can be one of the following states: running, pause, or stop. |
|
stop |
sevent |
Optional |
No default |
Stops playback. |
Channel fields
These are the fields supported by the channel. Channel fields can be accessed through the AnimationClip node that the channel is in.
|
Fields |
Type |
Use |
Default Value |
Description |
|---|---|---|---|---|
|
active |
sbool |
Optional |
true |
Enables/disables a specific channel. This can be useful for debugging and also for implementing conditional animations. |
|
field |
sstring |
Mandatory |
No default |
The node field to be managed by the channel. |
|
mode |
senum |
Mandatory |
No default |
Defines whether the channel is curve or impulse type. |
|
type |
senum |
Mandatory |
No default |
The type must correspond to one of the supported field types. |
Keyframe fields
These are the fields supported by the keyFrame. KeyFrame fields can be accessed through the AnimationClip node that the keyFrame is grouped in under the corresponding channel.
|
Fields |
Type |
Use |
Default Value |
Description |
|---|---|---|---|---|
|
curve |
senum |
Optional |
No default |
Used for curve type channels only. Can be assigned to any supported curve interpolation style. This field is mandatory for curve type channels. |
|
key |
sint |
Mandatory |
No default |
Defines the keyframe frame number. |
|
value |
sstring |
Mandatory |
No default |
The value the channel field MUST be set to when executing this frame. The value type must correspond to the type set for the channel. |