pixi-reels

stepDrive()

pixi-reels


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#

ParameterTypeDescription
stateReelDriveStateCurrent speed / acceleration. MUTATED.
targetnumberSpeed the reel is being asked for, px/frame.
configResolvedDriveConfigResolved bounds (see resolveDriveConfig).
deltaMsnumberElapsed time for this tick.

Returns#

ReelDriveState