Skip to content

AnimationFrameTickSource

Defined in: src/modules/tick/animation-frame-tick-source.ts:33

Time-driven tick source that fires once per requestAnimationFrame (typically ~60 Hz, matching the display refresh rate). Suitable for:

  • Render loops where the game draws on every frame.
  • Edge-clearing for input that wants per-frame resolution.
  • Variable-rate simulations that integrate with deltaMs.

Emits TickInfo { kind: 'variable', deltaMs: wall-time, tickNumber }. deltaMs is the measured wall-clock interval between frames (0 on the very first tick since there is no previous frame to measure against). Frames are delivered paused while the tab is in the background on most browsers — consumers that need catch-up semantics should layer a fixed accumulator on top.

start() / stop() are idempotent. stop() cancels the pending rAF and resets the internal timing baseline, so the next start() begins cleanly.

new AnimationFrameTickSource(options?): AnimationFrameTickSource

Defined in: src/modules/tick/animation-frame-tick-source.ts:63

AnimationFrameTickSourceOptions = {}

AnimationFrameTickSource

get tickNumber(): number

Defined in: src/modules/tick/animation-frame-tick-source.ts:100

number

start(): void

Defined in: src/modules/tick/animation-frame-tick-source.ts:81

void

TickSource.start


stop(): void

Defined in: src/modules/tick/animation-frame-tick-source.ts:87

void

TickSource.stop


subscribe(handler): () => void

Defined in: src/modules/tick/animation-frame-tick-source.ts:95

(info) => void

() => void

TickSource.subscribe