Skip to content
ClassCore & Lifecycle@public

FixedStepAccumulator

Converts variable display-frame durations into deterministic simulation updates. Rendering may consume alpha, but simulation must not.

ts
export declare class FixedStepAccumulator

Constructors

ts
constructor(options?: FixedStepAccumulatorOptions)

Constructs a new instance of the FixedStepAccumulator class

ParameterTypeDescription
optionsFixedStepAccumulatorOptions-

Properties

PropertyModifiersTypeDescription
alphareadonlynumberCurrent interpolation fraction in the half-open range [0, 1).
maxCatchUpStepsreadonlynumberMaximum authoritative updates allowed for one display frame.
pausedreadonlybooleanWhether display time is currently ignored.
stepSecondsreadonlynumberAuthoritative simulation-step duration, in seconds.

Methods

advance()

ts
advance(elapsedSeconds: number, update: (stepSeconds: number) => void): FixedStepAdvanceResult

Advances the clock and invokes update once per authoritative step. Excess elapsed time is discarded to prevent a spiral of death.

Parameters:

ParameterTypeDescription
elapsedSecondsnumber-
update(stepSeconds: number) => void-

Returns: FixedStepAdvanceResult

reset()

ts
reset(): void

Clears interpolation and elapsed-time debt without changing pause state.

Returns: void

setPaused()

ts
setPaused(paused: boolean): void

Pauses or resumes the clock. Changing state clears accumulated time so a hidden tab cannot trigger a catch-up burst when it becomes visible.

Parameters:

ParameterTypeDescription
pausedboolean-

Returns: void

Released under the MIT License.