pixi-wheels
API

Spin profiles

interface SpinProfile {
  spinSpeed: number;          // deg/s at cruise. The only required field
  accelerationMs?: number;    // rest to cruise. 900
  accelerationEase?: Ease;    // 'power2.in'
  minimumSpinTime?: number;   // the stop may not begin before this many ms since spin(). 0
  minCruiseMs?: number;       // nor before this long at cruise. 0
  stopDuration?: number;      // what the deceleration should take. 4200
  stopEase?: Ease;            // an ease-out. 'power3.out'
  minTurns?: number;          // fewest full turns while stopping. 1
  maxTurns?: number;          // most. 8
  skipDuration?: number;      // the fast-forward on skip. 450
}

builder.speed(name, profile) and ring.addSpeed() fill the gaps from DEFAULT_PROFILE and throw on a bad field. ring.profile and the speed:changed event carry the filled-in ResolvedSpinProfile.

PresetspinSpeedaccelmin spinstopturns
NORMAL54090014004200 power3.out1-8
TURBO7204006002000 power3.out1-4
CINEMATIC450140022008000 power4.out1-6
QUICK9002504001300 power2.out1-3

How the stop duration is chosen#

The planner matches the ease’s start slope to the cruise speed so the hand-off has no velocity step. That fixes the duration for any distance: a stop of turns full turns lasts turns * 360 * slope / spinSpeed seconds, where slope is the ease’s start slope (2 for power1.out, 3 for power2.out, 4 for power3.out, 5 for power4.out, about 7 for expo.out). The planner tries every count from minTurns to maxTurns and keeps the one closest to stopDuration; spin:stopping reports the actual duration. Keep stopDuration inside the range the turn counts span, or the nearest count wins silently. The presets are tested for it.

An inOut ease starts at slope 0 and is clamped with a one-time warning; use an out curve.

Eases#

GSAP names without the dependency: none, linear, power1..4.in|out|inOut (quad, cubic, quart, quint are aliases), sine.*, expo.*, circ.*, back.in|out(1.7). Or a (t) => number. EASE_NAMES lists them; resolveEase(name) throws on a typo with the list.