Scheduler
- Last UpdatedDec 14, 2023
- 4 minute read
A Scheduler node instance contains a set of Time nodes that can trigger an event at a particular time. According to engine logic, this means assign a value to a parameter.
-
The parameter value assignment can be conditioned.
-
The scheduler node is one of the most useful nodes to use inside a script to define a behavior.
-
Usually, scheduler can be used to implement complex animation or transitions where the time scheduling is strict.
-
A scheduler is not active by default, but can be started, paused, and stopped. You can also set the current time from outside.
-
Schedulers do not have loop capabilities. However, you can configure the script to execute a scheduler in loop.
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 |
|
|
|
|
|
|
Absolute and relative times
Each time node instance inside a scheduler needs to indicate an alpha time. That alpha time is used by the scheduler to understand when the action contained in the time node has to be performed.
When a time node is placed in the scheduler container, its alpha refers to the scheduler currentAlpha time.
For example, if the alpha is set to 2, the time is evaluated for execution when the currentAlpha of the scheduler reaches 2.
By nesting a time inside another time, the alpha of a child node is not referred as absolute to the scheduler currentAlpha, but relative to the alpha of the parent node. This way the alpha can be seen as an increment rather than an absolute time position.
For example, if the parent time has the alpha set to 2 and the children set to 1, the child time node is evaluated for execution when the currentAlpha of the scheduler reaches 3 (and not 1).
Code example with absolute alpha
This is a code example for the Scheduler node showing absolute alpha.
<!— time with absolute alpha —!>
<scheduler name="jump_sched" alphaDiv="25" >
<time alpha="0" field="resetcam_b.execute" condition="@global.currentContext==setb"/>
<time alpha="25" field="Cam_b01.show" condition="@global.currentContext==setb"/>
<time alpha="25" field="Cam_c01.show" condition="@global.currentContext==setc"/>
<time alpha="25" field="Cam_d01.position" value="0 1 1" condition="@global.currentContext==setd"/>
</scheduler>
Code example with relative alpha
This is a code example for the Scheduler node showing relative alpha.
<!— time with relative alpha —!>
<scheduler name="jump_sched" alphaDiv="25" >
<time alpha="0" field="resetcam_b.execute" condition="@global.currentContext==setb">
<time alpha="25" field="Cam_b01.show" condition="@global.currentContext==setb">
<time alpha="25" field="Cam_c01.show" condition="@global.currentContext==setc">
<time alpha="25" field="Cam_d01.position" value="0 1 1" condition="@global.currentContext==setd"/>
</time>
</time>
</time>
</scheduler>
Position
The scheduler node can be anywhere inside a <ft> node. This means that it can be both inside or outside a Context node.
Scheduler fields
These are the fields for Scheduler node. Only the node-specific fields are indicated, not fields obtained by inheritance.
Field inheritance: NodeBase > Scheduler
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
alphaDiv |
sfloat |
Optional |
1 |
Defines the scheduler time unit measure. If set to 1, the scheduler time values are expressed in seconds. If set to framerate, the scheduler time values are expressed in frames. |
|
currentAlpha |
sfloat |
Read only |
Not set |
Returns the current scheduler time, expressed in the scheduler unit measure. |
|
duration |
sfloat |
Optional |
-1 |
Defines scheduler duration in schedule unitMeasure. When set to -1, the scheduler lasts until it executes its last time action. |
|
pause |
sevent |
Optional |
Not set |
Pauses the scheduler. |
|
set_currentAlpha |
sfloat |
Optional |
Not set |
Sets the current scheduler time, expressed in the scheduler unit measure. |
|
start |
sevent |
Optional |
Not set |
Enables scheduler to begin. |
|
startAlpha |
sfloat |
Optional |
0 |
Defines scheduler start alpha. Can be used to avoid executing some initial time action when starting. |
|
stop |
sevent |
Optional |
Not set |
Enables the scheduler to stop. It is also triggered by the scheduler when the scheduler reaches the end (scheduler duration or last time action executed). |
Time attributes
These are the attributes for time elements.
|
Attribute |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
alpha |
sfloat |
Mandatory |
-1 |
Defines the variable assignment time in the scheduler unit measure. |
|
condition |
sstring |
Optional |
Name of the linked XML file |
Can apply a condition to the parameter value assignment. |
|
field |
sstring |
Mandatory |
Name of the linked XML file |
Defines the node parameter to assign. The syntax is the usual one to indicate a node parameter. |
|
value |
sstring |
Optional |
Name of the linked XML file |
The value to be assigned to the parameter. If the parameter is a SEVENT field, there is no need to indicate a value because the scene manager assigns the timestamp. |