Skip to main content

Abstract Class: MasterClock

Defined in: platform/master-clock.ts:25

Platform-agnostic base class for driving animation playback.

Subclasses implement the actual frame loop (e.g. requestAnimationFrame in the browser, a setInterval loop in Node) and call setCurrentTime / tick each frame. MasterClock owns the subscriber lists and the shared playback state so that renderers and UI controls can coordinate without knowing about each other.

Lifecycle:

  1. Set total duration with setDuration.
  2. Register listeners via onTick / onPlay / onPause / onTime.
  3. Call play, pause, or seek to control playback.
  4. Call dispose when the clock is no longer needed to prevent leaks.

Constructors

Constructor

new MasterClock(): MasterClock

Returns

MasterClock

Accessors

currentTime

Get Signature

get currentTime(): number

Defined in: platform/master-clock.ts:35

Current playhead position in seconds.

Returns

number


duration

Get Signature

get duration(): number

Defined in: platform/master-clock.ts:40

Total animation duration in seconds.

Returns

number


isPlaying

Get Signature

get isPlaying(): boolean

Defined in: platform/master-clock.ts:30

Returns

boolean

Methods

dispose()

dispose(): void

Defined in: platform/master-clock.ts:85

Clears all registered callbacks. Call when tearing down a scene to avoid memory leaks.

Returns

void


onPause()

onPause(callback): void

Defined in: platform/master-clock.ts:100

Parameters

callback

() => void

Returns

void


onPlay()

onPlay(callback): void

Defined in: platform/master-clock.ts:96

Parameters

callback

PlayCallback

Returns

void


onTick()

onTick(callback): void

Defined in: platform/master-clock.ts:92

Parameters

callback

TickCallback

Returns

void


onTime()

onTime(callback): void

Defined in: platform/master-clock.ts:104

Parameters

callback

TimeCallback

Returns

void


pause()

pause(): void

Defined in: platform/master-clock.ts:71

Pauses playback and notifies all pause listeners.

Returns

void


play()

play(speed, reverse): void

Defined in: platform/master-clock.ts:60

Starts playback at the given speed and direction, notifying all play listeners.

Parameters

speed

number

reverse

boolean

Returns

void


seek()

abstract seek(t): void

Defined in: platform/master-clock.ts:77

Moves the playhead to t (seconds). Subclasses decide whether this also triggers a tick.

Parameters

t

number

Returns

void


setDuration()

setDuration(duration): void

Defined in: platform/master-clock.ts:44

Parameters

duration

number

Returns

void