Skip to content

Documentation / scene / AnimationTimelineRunner

Class: AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:415

Runtime interpreter for an AnimationTimeline.

The interpreter is a synchronous frame-stack state machine advanced by AnimationTimelineRunner.tick, which is driven by AnimationSet.update(dt) on the same logical clock as the animations. There is no async/await in the control flow, so the runtime state can be serialized and replayed.

Extends

Constructors

Constructor

new AnimationTimelineRunner(animationSet, timeline): AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:448

Create a stopped runner for a timeline.

Parameters

animationSet

AnimationSet

Animation set that owns clips and playbacks referenced by the timeline.

timeline

AnimationTimeline

Timeline definition to interpret.

Returns

AnimationTimelineRunner

Overrides

Observable<AnimationTimelineRunnerEventMap>.constructor

Properties

animationSet

readonly animationSet: AnimationSet

Defined in: libs/scene/src/animation/animationtimeline.ts:419

Animation set used to start, stop, and query animation playbacks.


timeline

readonly timeline: AnimationTimeline

Defined in: libs/scene/src/animation/animationtimeline.ts:423

Timeline definition interpreted by this runner.

Accessors

currentPlayback

Get Signature

get currentPlayback(): AnimationPlayback

Defined in: libs/scene/src/animation/animationtimeline.ts:472

Playback currently referenced by the active main-flow scope.

Returns

AnimationPlayback

The current playback, or null when the main flow has no active playback reference.


stopped

Get Signature

get stopped(): boolean

Defined in: libs/scene/src/animation/animationtimeline.ts:485

Whether this runner is stopped.

Returns

boolean

True when the runner is stopped; otherwise false.


lastCompletedPlaybackId

Get Signature

get lastCompletedPlaybackId(): string

Defined in: libs/scene/src/animation/animationtimeline.ts:494

Playback id for the most recent playback that completed naturally.

Returns

string

The playback id, or null when no owned playback has completed.

Methods

on()

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:594

IEventTarget.on

Type Parameters

K

K extends keyof AnimationTimelineRunnerEventMap

Parameters

type

K

listener

EventListener<AnimationTimelineRunnerEventMap, K>

context?

unknown

Returns

void

Inherited from

Observable.on


once()

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:598

IEventTarget.once

Type Parameters

K

K extends keyof AnimationTimelineRunnerEventMap

Parameters

type

K

listener

EventListener<AnimationTimelineRunnerEventMap, K>

context?

unknown

Returns

void

Inherited from

Observable.once


off()

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:602

IEventTarget.off

Type Parameters

K

K extends keyof AnimationTimelineRunnerEventMap

Parameters

type

K

listener?

EventListener<AnimationTimelineRunnerEventMap>

context?

unknown

Returns

void

Inherited from

Observable.off


dispatchEvent()

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:606

IEventTarget.dispatchEvent

Type Parameters

K

K extends keyof AnimationTimelineRunnerEventMap

Parameters

type

K

args

...AnimationTimelineRunnerEventMap[K]

Returns

void

Inherited from

Observable.dispatchEvent


start()

start(): AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:503

Start or restart the runner from the beginning of the timeline.

Returns

AnimationTimelineRunner

This runner for chaining.


stop()

stop(options?): AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:523

Stop the runner and all playbacks it owns.

Parameters

options?

StopAnimationOptions

Optional stop behavior applied to owned playbacks.

Returns

AnimationTimelineRunner

This runner for chaining.


enqueue()

enqueue(steps): void

Defined in: libs/scene/src/animation/animationtimeline.ts:558

Append a batch of steps to run after the main stack drains.

If the runner has already completed, enqueueing steps revives it and registers it for ticking.

Parameters

steps

AnimationTimelineStep[]

Steps to run as the next queued batch.

Returns

void

void


runConcurrent()

runConcurrent(steps): void

Defined in: libs/scene/src/animation/animationtimeline.ts:580

Run steps concurrently with the current control flow (a true parallel branch). Unlike AnimationTimelineRunner.enqueue, these do not wait for the main stack to drain.

Parameters

steps

AnimationTimelineStep[]

Steps to run immediately in an independent concurrent branch.

Returns

void

void


dispatch()

dispatch(event, payload?): AnimationTimelineEventResult

Defined in: libs/scene/src/animation/animationtimeline.ts:604

Dispatch an event to this runner.

Waiting waitEvent frames consume matching events first. If no waiter consumes the event, the timeline response table is evaluated.

Parameters

event

string

Event name to dispatch.

payload?

unknown

Optional payload returned in the result.

Returns

AnimationTimelineEventResult

The resolved handling result for the event.


flush()

flush(): AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:654

Run pending non-blocking work synchronously (a zero-delta tick), without advancing any time-based waits. Lets start()/dispatch() take effect immediately while keeping all runtime state in the serializable frame stack.

Returns

AnimationTimelineRunner

This runner for chaining.


tick()

tick(deltaInSeconds): void

Defined in: libs/scene/src/animation/animationtimeline.ts:669

Advance the timeline by deltaInSeconds. Called by AnimationSet.update.

Parameters

deltaInSeconds

number

Elapsed time in seconds for this tick.

Returns

void

void


serialize()

serialize(): AnimationTimelineRunnerState

Defined in: libs/scene/src/animation/animationtimeline.ts:719

Export the runtime state as plain data.

Returns

AnimationTimelineRunnerState

A serializable snapshot of the runner state.


deserialize()

static deserialize(animationSet, timeline, state): AnimationTimelineRunner

Defined in: libs/scene/src/animation/animationtimeline.ts:742

Restore runtime state previously produced by AnimationTimelineRunner.serialize.

Re-create the relevant active playbacks on the AnimationSet before calling this so that playback-bound frames (play-wait, waitMarker, waitFrame) can re-attach by id.

Parameters

animationSet

AnimationSet

Animation set containing any live playbacks referenced by the state.

timeline

AnimationTimeline

Timeline definition to bind to the restored runner.

state

AnimationTimelineRunnerState

Serialized state previously returned by AnimationTimelineRunner.serialize.

Returns

AnimationTimelineRunner

A runner restored to the supplied runtime state.

Released under the MIT License.