Speed profiles
The object that holds a spin's timing, such as stagger, speed and bounce, and how to tune it.
Ask a player what "turbo" means and they will tell you: the columns start together instead of one by one, they do not hang around, they drop together, and the bounce is a quick snap instead of a lazy settle. Every one of those is a number: how long each reel waits before it starts, how fast it spins, how long it must spin at minimum, how long each reel waits before stopping, how long a tease holds, how far and how long the bounce is. A speed profile is the object that holds all of those numbers in one place, so "turbo" is a different object rather than a scattering of if-statements.
A profile has two layers. The flat fields are the handful of numbers above, enough for most games and all that the presets use. On top of them, optional phase sections override a number for one phase only, set a timing for one step, and carry a whenAnticipated variant that only applies to reels that teased. The speed manager holds the profiles at runtime and lets you tune a phase without replacing the profile. ADR 021 (docs/adr/021-phase-sections-on-speed-profiles.md) is the design record.
The shape of a profile
Figure 1 is one profile laid out as a diagram. The flat fields sit across the top. Below them are eight optional sections, one per phase name; most profiles have none, and the presets have none. The stop section is highlighted because figure 2 opens it up.
Figure 2 is the stop section opened up. A section can do three things: set any of the flat timing fields again, for this phase only; give each of the phase's steps its own timing (an ease and a duration); and carry a whenAnticipated block that does both again, but only for a reel that teased to its end. Notice that whenAnticipated cannot contain another whenAnticipated.
In code, a stop section with every part in use looks like this. It removes the stop stagger, gives the bounce a springier ease, and makes the bounce slower on a reel that teased:
stop: {
stopDelay: 0,
steps: { bounce: { duration: 400, ease: 'back.out' } },
whenAnticipated: { steps: { bounce: { duration: 900 } } },
}The flat fields
The flat fields are what the player feels directly. spinDelay and stopDelay are the staggers between reel starts and reel stops; spinSpeed is how fast the strip moves; minimumSpinTime is how long each reel must blur before it may stop; anticipationDelay is how long a tease holds; bounceDistance and bounceDuration shape the landing. Alongside them are the optional eases and durations for the acceleration and the bounce, a name, and a tumble block: a per-speed TumbleConfig, deep-merged over the builder's base when a cascade phase enters, so a turbo profile can shorten fall.duration and dropIn.duration (both at 0 snaps the cascade). All fields are readonly. decelerationEase is deprecated and no phase reads it; the presets still carry a value for compatibility. One hedge from reading the code: spinSpeed is documented as pixels per frame, while StandardMode computes slotPitch * speed * deltaMs / 1000 with a half-cell cap per frame, so treat the unit note with care and see the motion page.
The presets
The three presets, field by field; the timeline page shows what the NORMAL column produces in milliseconds.
| Key | NORMAL | TURBO | SUPER_TURBO |
|---|---|---|---|
| name | 'normal' | 'turbo' | 'superTurbo' |
| spinDelay | 100 | 30 | 0 |
| spinSpeed | 30 | 50 | 80 |
| stopDelay | 140 | 0 | 0 |
| anticipationDelay | 450 | 250 | 0 |
| bounceDistance | 56 | 42 | 14 |
| bounceDuration | 600 | 200 | 120 |
| bounceEase | unset (power1.out) | unset (power1.out) | unset (power1.out) |
| accelerationEase | power2.in | power2.in | power1.in |
| decelerationEase | power2.out (unused) | power2.out (unused) | power1.out (unused) |
| accelerationDuration | 300 | 200 | 50 |
| minimumSpinTime | 500 | 300 | 100 |
| tumble | none | none | none |
| phase sections | none | none | none |
Three things fall out of the numbers. TURBO still teases, because its hold is 250 ms; SUPER_TURBO does not, unless setAnticipation is given a positive duration. All three have a bounceDistance above zero, so all three play the small backward pull at the start of a spin. And none of them has a phase section or a tumble block, so every preset resolves to its flat fields alone. The bounce values are tuned for symbols of about 120 to 200 px.
Phase sections and their types
Sections are typed so you cannot misspell a step. PhaseTiming is every flat field except name and tumble, all optional. A PhaseSection is that timing plus steps, a map from step name to one StepTiming or a list of them, plus whenAnticipated, the same body without another whenAnticipated inside. The PhaseProfiles registry names the eight phases in figure 1, and three interfaces list the step names: StartSteps (delay, launch, pull, accelerate, announce), AnticipationSteps (tease) and StopSteps (delay, spinOut, land, bounce). A game that adds its own phase or step extends them with declaration merging and gets typed sections for free:
declare module 'pixi-reels' {
interface PhaseProfiles { 'my:flourish': PhaseSection<{ sparkle: StepTiming }> }
interface StopSteps { settle: StepTiming }
}Which layer wins
With four places a number can come from, the question is which one wins. Figure 3 stacks them. Read the left column bottom to top: the flat field is the floor, the phase section overrides it, whenAnticipated overrides that but only for a reel that teased, and a runtime tune sits on top. The right column names the three functions that do the merging.
A new phase asks for its timing with resolvePhaseProfile(profile, phase, anticipated), which spreads the profile, then the section's timing fields, then the whenAnticipated fields if the reel teased. With no section it returns the same profile object, so a plain preset allocates nothing per phase. The spread drops steps, whenAnticipated and any undefined value, so a section cannot blank out a field the profile set. resolveStepTiming does the same for one step, merging the whenAnticipated entries over the step's list position by position; that list is ctx.step, and the built-in steps read step[0].
Tunes use the same rule: mergeSection folds one section over another (flat fields replace, step lists merge by position) and tuneProfile uses it to fold each runtime tune into the matching section before anything is resolved. ADR 021 states the order as flat field, section, whenAnticipated, tune; merging the tune first gives the same answer and keeps a tuned whenAnticipated restricted to reels that teased. configuredStepNames backs the one-time warning for a step name the phase does not have.
Which step reads which number
Figure 4 maps which number reaches which start and spin step. The one to notice is start.steps.delay.duration: a step-level duration on the delay replaces the per-reel stagger rather than adding to it, so setting it gives every reel the same delay and the staircase disappears. Launch and announce read nothing.
Figure 5 maps the tease and stop steps. The same replacement rule applies to stop.steps.delay.duration and the stop stagger. Spin-out and land read nothing from the profile: how long the spin-out takes is down to how many symbols must wrap and how fast the reel is going.
The exact lookup each step performs, for when you need to know which of two settings wins.
| Step | Reads, first match wins |
|---|---|
| start.delay | step[0].duration, else config.delay (the stagger, _staggerIndex(i) * spinDelay), else 0 |
| start.pull | exists only when the resolved bounceDistance > 0; step[0].duration else 50, step[0].ease else power1.out |
| start.accelerate | step[0].duration, else accelerationDuration, else 300; step[0].ease, else accelerationEase, else power2.in; targets spinSpeed |
| spin | config.minimumSpinTime (from setMinimumSpinTime), else timing.minimumSpinTime, else 500 |
| anticipation.tease | config.duration (from setAnticipation), else step[0].duration, else anticipationDelay |
| stop.delay | step[0].duration, else config.delay (from _stopDelayFor), else 0 |
| stop.bounce | step.ease and step.duration, else bounceEase (power1.out), bounceDuration; distance is bounceDistance |
The speed manager
The speed manager, reached as reelSet.speed, owns the named profiles, knows which is active, and layers tunes over it. What it does not do matters as much as what it does.
new SpeedManager(profiles: Map, initialSpeed): throws on an unknown initial nameactive: the active profile with tunes merged in, cached in_tunedactiveNameset(name): returns{ previous, current }, throws on an unknown nametune(phase, section): layers over whichever profile is active and survivesset()clearTune(phase?): one phase or alladdProfile(name, profile),getProfile(name),profileNames
- It emits nothing.
speed:changed(current, previous)comes fromReelSet.setSpeed, which also callsnotifyManualSpeedChange()on the controller. - It does not affect a running spin.
spin()readsactiveonce into_activeSpinSpeedand every phase of that spin gets the same object, so aset()ortune()takes effect on the next spin. - It does not know about skips. The round-ending skip boost calls
set()directly, which is why that boost emitsskip:boostedand notspeed:changed, and why the restore on the nextspin()is silent. AsetSpeed()in between cancels the restore.
A tune is for a feature that wants a different feel for a while, say a free-spins round with a softer bounce, without registering a whole profile. It sticks to whichever profile is active:
reelSet.speed.tune('stop', { steps: { bounce: { duration: 900 } } }); // next spin, and after setSpeed('turbo') too
reelSet.setSpeed('turbo'); // emits speed:changed; the tune above still applies
reelSet.speed.clearTune('stop');Defaults
The fallbacks when neither the profile nor a section sets a field.
| Setting | Default | Read by |
|---|---|---|
| initialSpeed | 'normal' | ReelSetBuilder via DEFAULTS |
| bounceEase | 'power1.out' | ReelPhase.bounce |
| accelerationEase | 'power2.in' | StartPhase accelerate |
| accelerationDuration | 300 | StartPhase accelerate |
| minimumSpinTime | 500 | SpinPhase |
| pull duration / ease / speed | 50 ms / 'power1.out' / -2 | StartPhase pull |
| curve segment ease | 'power2.inOut' | AnticipationPhase |
| tumble fall | 300 ms, 'sine.in', cellStagger 0 | CascadeFallPhase, overridable per profile |
| tumble dropIn | 600 ms, 'power2.out', cellStagger 60, distance 'perHole' | CascadeDropInPhase, overridable per profile |
| setDropOrder step | max(active.stopDelay, 150) | ReelSet.setDropOrder |
packages/pixi-reels/src/config/types.ts: SpeedProfileBase, PhaseTiming, StepTiming, PhaseSection, PhaseProfiles, the step-name interfacespackages/pixi-reels/src/config/phaseProfile.ts: resolvePhaseProfile, resolveStepTiming, mergeSection, mergeBody, tuneProfile, configuredStepNamespackages/pixi-reels/src/config/SpeedPresets.ts: NORMAL, TURBO, SUPER_TURBOpackages/pixi-reels/src/speed/SpeedManager.ts;ReelSet.setSpeedinpackages/pixi-reels/src/core/ReelSet.tsdocs/adr/021-phase-sections-on-speed-profiles.md. Guide: speed modes. Recipes: feel. Related: a spin in milliseconds, anticipation