The builder
What build() validates and constructs, in order.
Before a reel set can spin it needs to know a surprising number of things: how many columns there are, how many rows each column shows, how big a cell is, which symbols exist and how each one is drawn, which ticker drives the animation, and a long tail of optional details about curves, masks, gaps and timing. Many of those settings only make sense together. A symbol that spans two columns needs a mask that does not clip the gap between them. A curve drawn in "warp" mode needs a renderer to draw with. A list of per-reel values has to be exactly as long as the number of reels. If the library checked each value the moment you set it, it would have to guess at the values you had not set yet, and the first sign of a mistake would be a blank board on the first spin.
The builder solves this by splitting setup into two halves. While you call setters, it only writes values down. When you call build(), it checks everything at once, constructs the engine in a fixed order, and hands you back the ReelSet. The rule written in the source header is that the builder "throws at construction, not at first spin": a mistake surfaces as one error listing every problem, before a single symbol has been drawn.
The five things you must say
Every setter on the builder is optional except five. The table lists them in the order most people write them, but the order is free: each setter returns the builder, so you chain them however reads best.
| Call | What it tells the builder |
|---|---|
| .reels(n) | how many columns. pixi-reels calls a column a reel even when the set runs horizontally. |
| .visibleCells(n), .visibleCellsPerReel([...]) or .multiways({...}) | how many cells each reel shows inside the window. Exactly one of the three. |
| .symbolSize(w, h) | the size of one cell, in screen pixels. |
| .symbols(cb) | a callback that registers every symbol id together with the class that draws it. |
| .ticker(ticker) | the PixiJS ticker that drives every animation in the set. |
One ordering rule is worth knowing before anything else. A spin is made of stages called phases (start, spin, stop and so on), and .phases() lets you override how one of them behaves. The builder does not apply that override where it sits in your chain; it saves it and applies it at the very end of build(), after the default phases that tumble and MultiWays sets install. So your overrides always win, whether you write them first or last.
What build() does, in order
build() runs twenty-three steps in a fixed sequence. Figures 1 to 3 draw them in source order, read left to right and row by row. Look at the colours: the highlighted boxes near the start are gates that throw or decide and allocate nothing, the dark boxes are the moments an engine object is constructed, and the single primary box at the very end is the ReelSet itself. Everything that can fail does so in the first two steps, before anything exists that would need cleaning up.
The steps, in groups
Twenty-three steps are easier to hold as seven groups. Each paragraph below says what a group does and why it comes where it does; the exact formulas are collected in the table that follows, so the prose can stay readable. A few words first, since the rest of the page leans on them. The main axis is the direction a reel travels (down the screen on a vertical set, across it on a horizontal one) and the cross axis is the other one. A reel's extent is how long it is along the main axis, in pixels. A strip is the array of symbols a reel holds, which is longer than the window because of the buffer cells parked just outside it on either end.
Steps 1 and 2, the gates. The first step walks every validation rule, collects every message, and throws once with the header ReelSetBuilder validation failed: followed by one - message line per problem, so you fix a bad configuration in one round trip rather than one error at a time. The full list of messages is further down the page. Four checks are not folded into that list and throw on their own: the length of directionPerReel(), the length of curvePerReel(), warp curve mode without a renderer, and a zero end buffer on a set that is not a tumble set.
Steps 3 and 4, the geometry. The builder makes a set-level axis object from the orientation and uses it to translate every later size into screen x and y, which is why the same code lays out vertical and horizontal sets. On a vertical set the main cell size is the symbol height and the cross cell size is the symbol width; on a horizontal set they swap, and the gaps swap with them. It then works out how many cells each reel shows and how long each reel is, and records the tallest extent, because every shorter reel will be positioned inside that tallest box.
Steps 5 to 8, speed and symbols. If you registered no speed profile, the builder installs the normal preset so a set always has one; the first profile's spin speed becomes the reference speed each reel is handed later. It then builds a metadata record for every registered symbol id (weight, draw order, whether it may escape the mask, and its size in cells) with the defaults filled in. Symbols are pooled rather than allocated per spin, so the builder sizes the pool next: unless you set a capacity, it is large enough for every strip to show one id at once, with a floor of twenty. With those in hand it constructs the SymbolFactory, the object that hands out and takes back symbol instances. The symbols page has the pool in detail.
Steps 9 and 10, the frame pipeline. A frame is the list of symbol ids a reel will show after it lands, buffers included. The builder constructs the random provider that fills cells nobody has claimed, applies every random-draw pool and scope you registered, and then wraps it in the FrameBuilder, adding your frame middleware in the order you called it, after the two built-in stages. The frame pipeline page explains how a result grid becomes a frame.
Steps 11 to 13, the phases. Two features ship phases of their own. A tumble set (where winning symbols are removed and the ones above fall into the holes) gets three cascade phases: fall, place and drop-in. Gravity is deliberately left unresolved here and read per reel at runtime, because reels can run in different directions. A MultiWays set (where the server changes the number of cells per reel on each spin) gets an adjust phase that migrates pinned cells, with a duration that may be a per-reel function. Only after both defaults does the builder run your .phases() callbacks, so the last registration per phase key is always yours.
Steps 14 to 17, the viewport. The viewport is the window you see the reels through. Its size is the cross span of all reels by the tallest extent. The builder then chooses a mask (figure 4 below), computes how strongly a curve leans towards the centre of the set, and constructs the ReelViewport. In warp curve mode it also passes the bleed, an extra margin on the cross axis so a bent reel is not clipped at its edges. At this point no reel exists yet, so the viewport has no per-reel rectangles to mask with; it draws a bounding-box mask as a stand-in until step 21 replaces it.
Steps 18 to 21, the reels. If you supplied an initial frame, it is checked against the buffer counts and any big symbols are laid out now, so a block that does not fit throws before any reel exists. Every builder field the reel code needs is then copied into local constants (the section on the closure rule explains why), along with two helpers: perReel(), which reads a per-reel array and reuses its last entry for any index past the end, and mainOffsetFor(), which positions a short reel inside the tallest box according to the anchor you chose. The loop then creates one reel per index: it asks the frame builder for a seed strip, assembles the reel's config, constructs the Reel (which adds its own container to the viewport's masked layer), and sets the reel's reference speed before installing the drive, because a drive's profile-relative bounds resolve against that speed. When the loop ends, the viewport's mask is redrawn with one rectangle per reel.
Steps 22 and 23, the factory and the set. The reel-making code is bundled into a ReelFactory, an object of closures that addReels() and expand() call later, so a reel added at runtime is built exactly the way the originals were. Last of all the ReelSet is constructed with the config, the reels, the factory, the viewport, the symbol factory, the frame builder, the phase factory and the three modes (spinning, default spin and skip). The set builds its own speed manager, spin controller and spotlight; the classes page has that order.
The formulas, for when you need the exact number.
| Step | Quantity | How it is derived |
|---|---|---|
| 3 | setAxis | reelAxis(orientation, 'forward'); main cell = symbolHeight (vertical) or symbolWidth (horizontal), cross cell the other; gaps swap the same way; every later geometry number goes through setAxis.toScreen |
| 4 | cells per reel | MultiWays: maxCells on every reel; else visibleCellsPerReel; else visibleCells on every reel |
| 4 | extent per reel | MultiWays reelExtent, else reelExtents[i], else cells * mainCell + (cells - 1) * mainGap; tallest = max(extents) |
| 5 | speed | no profile registered: normal = SpeedPresets.NORMAL; defaultSpinSpeed = the first profile's spinSpeed |
| 6 | symbolsData[id] | weight = override.weight ?? weights[id] ?? 10; zIndex = override.zIndex ?? 1; unmask and size from symbolData() |
| 7 | pool capacity | poolCapacity ?? max(20, sum over reels of (cells + bufferStart + bufferEnd)) |
| 8 | SymbolFactory | new SymbolFactory(registry, poolCapacity, gsap, setAxis.mainProp) |
| 9 | random provider | new RandomSymbolProvider(symbolsData, rng), then set(pool, scope) for each .randomSymbols() call |
| 10 | FrameBuilder | over the provider; use(mw) for each .frameMiddleware() in call order, after the two built-ins |
| 11 | tumble phases | factories for cascade:fall, cascade:place, cascade:dropIn, only after .tumble() |
| 12 | adjust phase | registerFactory('adjust', ...) producing AdjustPhase(reel, speed, { durationMs, ease }) |
| 14 | viewport size | crossSpan = reelCount * (crossCell + crossGap) - crossGap; viewportSize = setAxis.toScreen(crossSpan, tallest) |
| 16 | curve focus | curveFocusWeight = CURVE_FOCUS_WEIGHT[focus] (reel 0, set-lean 0.5, set 1); setCentreCross = crossSpan / 2 |
| 17 | ReelViewport | new ReelViewport(w, h, undefined, maskStrategy, setAxis, warp ? curveBleed : 0) |
| 18 | initial frame | assertBufferCountsInRange(initialFrame, ...), then coordinateBigSymbols() gives one seed strip per reel |
| 19 | perReel(values, i) | values[i], or the last entry when i is past the end |
| 19 | mainOffsetFor(extent, tallest) | 'start' -> 0; 'end' -> tallest - extent; 'center' -> (tallest - extent) / 2 |
| 20 | cell main size | spinCellSize for MultiWays or when there are no explicit extents; otherwise (extent - (cells - 1) * mainGap) / cells |
| 20 | seed strip | frameBuilder.build(i, cells, bufferStart, bufferEnd, seed) |
| 20 | reel axis | reelAxis(orientation, perReel(directionPerReel) ?? direction) |
| 20 | reel curveFocus | crossCell / 2 + w * (setCentreCross - i * (crossCell + crossGap) - crossCell / 2) |
| 20 | the Reel | new Reel(config, symbolFactory, randomProvider, viewport); config also carries the per-reel curve, the warp renderer and ticker, bleed, stacking, gsap and symbolZIndex; reel.referenceSpeed = defaultSpinSpeed, then installDrive(drive) |
| 21 | mask | viewport.updateMaskSize(w, h, maskRects), one rect per reel; the rect formula is on the viewport page |
| 22 | ReelFactory | closures: extentFor, create (the same createReel), maskRect, mainOffset, viewportSize, poolCapacity |
| 23 | ReelSet | new ReelSet with config, reels, reelFactory, viewport, symbolFactory, frameBuilder, phaseFactory, spinningMode, defaultSpinMode, skipMode |
Mask auto-pick
The mask is the shape that decides which part of each strip the player can see; everything outside it, buffer cells included, is clipped. The default mask is one rectangle per reel, which is exactly right for a plain grid and wrong for two situations: a symbol that is wider than one reel would be clipped in the gap between columns, and a reel that leans towards the centre of the set (a curve with a set-wide focus) would be clipped at its own column edge. In both cases the builder quietly switches to one shared rectangle around the whole set. Figure 4 shows the decision: the questions are asked top to bottom, an explicit strategy short-circuits everything, both automatic rules land on the shared rectangle, and the default is the per-reel rectangle.
The first rule only fires when there is a gap between columns, because without a gap there is nothing to clip: a tall block that spans several cells in one reel never crosses a column edge, so it does not trigger the rule either. The second rule does not need a gap, because a set-focused curve leans receding cells out of their own column whether or not a gap is there. Both rules log an info notice named mask-auto-shared that says which reason fired, so you can tell from the console why your mask is not the default. The viewport page has every strategy you can choose explicitly.
Every setter, grouped by concern
The reference, for when you need a default or a constraint. Each card groups the setters that affect one concern; required calls are marked.
reels(count)required.visibleCells(n)uniform window; cannot be combined withvisibleCellsPerReel.visibleCellsPerReel([...])jagged or pyramid; length must equalreels().reelExtents([...])per-reel main-axis pixel box; combined withreelAnchor, extents win.reelAnchor('start'|'center'|'end')default'center': where short reels sit inside the tallest.multiways({ minCells, maxCells, reelExtent })per-spin shape; no big symbols, novisibleCellsPerReel.symbolSize(w, h)required, screen space.symbolGap(x, y)default{0, 0}, screen space.bufferSymbols(n | { start, end })default1 / 1; values below 1 are clamped to 1 with a one-timebuffer-clampedwarning;end: 0only on tumble sets.
orientation('vertical'|'horizontal')default'vertical'.direction('forward'|'reverse')default'forward';directionPerReel([...])per reel.cellStacking(order)default'ascending'; geometric, a reversed direction does not flip it.reelStacking(order)default'ascending', which draws the last reel in front.symbolZIndex(resolver)defaultnull; replaceszIndex * 100 + cellIndexas the only draw-order source.
curve(input),curvePerReel([...]).curveFocus('reel'|'set-lean'|'set')default'reel'; anything else auto-shares the mask.curveMode('symbol'|'warp')default'symbol'; warp needsrenderer(app.renderer).curveBleed(px)default0, warp only. See curvature.
maskStrategy(s)defaultnew RectMaskStrategy(); rejects null, objects withoutbuild/update, and anyversion !== 2. Marks the choice explicit.motionModel('tween')default, ormotionModel('drive', config); the config is validated byassertDriveConfigand there is no runtime toggle.speed(name, profile);initialSpeed(name)default'normal'.skipMode('slam'|'quicken')default'slam'.pinMigrationDuration(ms | fn)default200;pinMigrationEase(s)default'power2.out'. MultiWays AdjustPhase only.
symbols(cb)required; the registry is created eagerly andcbruns immediately.weights(record)default{}; unset ids weigh10.randomSymbols(pool, scope); buffer pools layer on top of spinning pools.symbolData(overrides)merges across calls:zIndex,unmask,weight,size. Guards against v1sizekeys.rng(fn)defaultMath.random;poolCapacity(n)default derived.initialFrame(ColumnTarget[])stored raw, validated at build.
spinningMode(mode)defaultnew StandardMode();frameMiddleware(mw)pushed in call order.phases(cb)deferred to the end ofbuild();tumble(config?)flips the default spin mode to'cascade'.ticker(t)required;gsap(instance)per set, read atbuild().visibleRows,visibleRowsPerReel,reelPixelHeightsare v1 stubs that always throw with a rename message.
Most setters only record a value, but a handful check their argument on the spot instead of waiting for build(), because a bad value there is unambiguous and the earlier error is more useful. Those are curveMode, curveBleed, curveFocus, maskStrategy, motionModel, symbolZIndex, tumble, initialFrame and the guards that catch v1 option names.
What _validate() can say
When step 1 throws, the message is this header followed by one line per problem. The lines appear in check order, so a long list is worth reading from the top: an early mistake (no reels, say) often explains the later ones.
reels() must be called with a positive number.
one of visibleCells(n) or visibleCellsPerReel([...]) or multiways({...}) must be called.
cannot call both visibleCells() and visibleCellsPerReel(). pick one.
cannot combine multiways() with visibleCellsPerReel(). MultiWays shapes are server-driven.
visibleCellsPerReel length X must equal reels(N).
visibleCellsPerReel[i] = v must be positive. (first bad entry only)
reelExtents length X must equal reels(N).
multiways({minCells, maxCells}) must both be positive.
multiways: minCells a cannot exceed maxCells b.
multiways({reelExtent}) must be positive.
cannot combine multiways({reelExtent}) with reelExtents([...]) ...
big symbol 'id' (size RxC) cannot be registered on a MultiWays slot... (first only)
big symbol 'id' (size RxC) must have weight 0. big symbols are placed by the server at anchor cells only...
big symbol 'id' spans R reels, which is not supported together with mixed directionPerReel([...])...
visibleCells() must be called with a positive number.
symbolSize() must be called with width and height.
symbols() must register at least one symbol.
ticker() must be called with a PixiJS Ticker.
initialSpeed 'x' does not match any registered speed profile. Available: ... (only when a speed is registered)The four checks from step 2 each throw on their own, with their own message: directionPerReel() length (a) must equal reels() (n)., curveMode('warp') renders each reel to a texture, so it needs a renderer: add .renderer(app.renderer)..., curvePerReel() length (a) must equal reels() (n). and bufferSymbols({ end: 0 }) is tumble-only....
Where each feature is wired
When you are chasing how a feature gets from the builder into the engine, this table says which steps touch it and what it turns into on the other side.
| Feature | Steps | What it becomes |
|---|---|---|
| Masks | 15, 17, 21 | the strategy handed to the viewport, then redrawn with per-reel rects |
| Phases | 11, 12, 13 | factories on the PhaseFactory, handed to ReelSet and on to SpinController |
| Modes | 23 | _spinningMode and _defaultSpinMode pass straight through |
| Speed profiles | 5 | the speeds map, then the SpeedManager inside ReelSet |
| Symbol registry | 6, 8 | SymbolFactory and symbolsData |
| Frame middleware | 10 | frameBuilder.use(mw) in call order |
| Tumble | 2, 11 | the cascade phase factories, plus the bufferEnd: 0 check |
| Big symbols | 1, 15, 18 | validation rules, the mask auto-pick, initial-frame seeding |
| Infinity / expand | 22 | the ReelFactory closure that addReels and expand call later |
| Curvature | 2, 16, 20 | the warp renderer check, focus weight, per-reel curveFocus |
| Orientation | 3 | setAxis; every geometry number goes through toScreen |
The closure rule
Step 19 looks like busywork: it copies a dozen builder fields into local constants before the reel loop runs. The reason is that the reel-making function outlives build(). The ReelSet keeps it inside the ReelFactory and calls it again whenever reels are added at runtime, which may be minutes later. If that function read the builder's fields directly, a builder you had since reused for a second set could change the way the first set builds its new reels. The source comment puts it plainly: a builder reused for another set must not reach into this one.
Defaults
Every default the builder fills in when you say nothing, with the file that defines it.
| Default | Value | Where |
|---|---|---|
| Buffer symbols | 1 per side | config/defaults.ts |
| Symbol gap | {0, 0} | config/defaults.ts |
| Initial speed | 'normal' | config/defaults.ts |
| Pool capacity | max(20, sum(cells + bufStart + bufEnd)); MultiWays counts maxCells | ReelSetBuilder.ts:1097 |
| Symbol weight | 10 | ReelSetBuilder.ts:1060 |
| Symbol zIndex | 1 | ReelSetBuilder.ts:1061 |
| SpeedPresets.NORMAL | spinDelay 100, spinSpeed 30, stopDelay 140, anticipationDelay 450, bounceDistance 56, bounceDuration 600, accelerationDuration 300, minimumSpinTime 500 | config/SpeedPresets.ts |
| Preset spinSpeed | 30 / 50 / 80 (Normal / Turbo / SuperTurbo) | ReelSetBuilder.ts:500 |
| Pin migration | 200 ms, 'power2.out' | ReelSetBuilder.ts:133 |
| CURVE_FOCUS_WEIGHT | reel 0, set-lean 0.5, set 1 | core/ReelCurve.ts:71 |
| curveBleed | 0 | ReelSetBuilder.ts:128 |
| Mask strategy | RectMaskStrategy, not explicit | ReelSetBuilder.ts |
| Motion model | 'tween' (no drive) | ReelSetBuilder.ts |
| rng | Math.random | ReelSetBuilder.ts:145 |
One documentation note, in case you read the source: the JSDoc block for curveFocus sits above curveMode, and the method itself is further down. The code is the source of truth here. For the guide-level walkthrough see your first reel set.