stepDrive()
pixi-reels / index / stepDrive
Function: stepDrive()
function stepDrive(
state: ReelDriveState,
target: number,
config: ResolvedDriveConfig,
deltaMs: number
): ReelDriveState;
Defined in: core/ReelDrive.ts:212
Advance one drive tick: move state.speed toward target without exceeding
the configured acceleration (and, if set, jerk) bounds.
Writes into state and returns it, rather than allocating a new object.
Reel.update calls this every tick for every reel, so a fresh object per
call is 2 allocations x reels x 60fps of pure garbage for the life of the
session. Pure in every other sense: the result depends only on the
arguments, which is what lets it be property-tested off a ticker the way
ReelMotion is. Pass a copy if you need the old state.
Parameters#
| Parameter | Type | Description |
|---|---|---|
state | ReelDriveState | Current speed / acceleration. MUTATED. |
target | number | Speed the reel is being asked for, px/frame. |
config | ResolvedDriveConfig | Resolved bounds (see resolveDriveConfig). |
deltaMs | number | Elapsed time for this tick. |