Skip to content

FixedAccumulatorTickSource

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:38

Fixed-timestep tick source with an interpolation factor. Consumes real elapsed frame time via advance(frameDeltaMs) and emits zero or more ticks, each advancing the world by a constant fixedDtMs. Suitable for:

  • Physics that must be frame-rate-independent and deterministic while the display refresh rate varies.
  • Render loops that want to draw between the last two simulation states.

Caller-pumped: advance() is called from the app’s existing render loop (typically an AnimationFrameTickSource subscriber), so this source owns no timer of its own. start() / stop() are no-ops for interface parity with time-driven sources, mirroring ManualTickSource.

Emits TickInfo { kind: 'fixed', deltaMs: fixedDtMs, tickNumber }. The leftover time is exposed as alpha (in [0, 1)), which the renderer reads at draw time to interpolate between simulation states.

maxStepsPerFrame caps catch-up ticks per call; excess accumulated time is dropped, not carried, so a slow frame cannot cascade into an ever-growing backlog.

new FixedAccumulatorTickSource(options): FixedAccumulatorTickSource

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:45

FixedAccumulatorTickSourceOptions

FixedAccumulatorTickSource

get alpha(): number

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:79

Leftover accumulated time as a fraction of fixedDtMs, in [0, 1).

number


get tickNumber(): number

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:101

number

advance(frameDeltaMs): void

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:62

Fold real elapsed frame time into the accumulator and emit up to maxStepsPerFrame fixed steps. Non-finite or non-positive deltas are ignored.

number

void


start(): void

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:92

void

TickSource.start


stop(): void

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:94

void

TickSource.stop


subscribe(handler): () => void

Defined in: src/modules/tick/fixed-accumulator-tick-source.ts:96

(info) => void

() => void

TickSource.subscribe