API reference
SpinTextureCache
pixi-reels / index / SpinTextureCache
Defined in: snapshot/SpinTextureCache.ts:104
Per-symbolId cache of “spin textures”. flat snapshots a reel shows instead of the live symbol (Spine skeleton, animated sprite, …) while it spins.
Two flavors per symbolId:
- static. the symbol rendered once into a RenderTexture at cell size.
- blurred. the static snapshot smeared vertically through a one-time BlurFilter pass into a taller, padded RenderTexture. At spin time it’s an ordinary sprite texture: zero filters per frame.
Textures come from two sources, user-provided always winning:
setStatic(id, tex)/setBlurred(id, tex). hand-authored art from your atlas. Never destroyed by the cache.captureStatic/captureBlurred. generated on demand from a live symbol view. Owned by the cache and destroyed oninvalidate/clear/destroy.
Captures are keyed by symbolId AND the cell size they were taken at (plus
the smear axis, for blurred ones). A capture at a new size adds a texture;
it never replaces one, because another reel may be drawing it right now.
That is the MultiWays case: every reel sizes the same id differently, so
one id legitimately lives at several sizes at once. Memory is bounded by
the distinct cell sizes the set ever shows (a 2..7-cell MultiWays reel
has six), and clear() drops them all when the layout changes for good.
Share ONE cache across all reels/symbols of a reel set. that’s the point.
Implements#
Constructors#
Constructor#
new SpinTextureCache(options: SpinTextureCacheOptions): SpinTextureCache;
Defined in: snapshot/SpinTextureCache.ts:116
Parameters#
| Parameter | Type |
|---|---|
options | SpinTextureCacheOptions |
Returns#
SpinTextureCache
Accessors#
isDestroyed#
Get Signature#
get isDestroyed(): boolean;
Defined in: snapshot/SpinTextureCache.ts:286
Returns
boolean
Implementation of#
Methods#
captureBlurred()#
captureBlurred(
symbolId: string,
width: number,
height: number,
blur?: MotionBlurOptions
): Texture;
Defined in: snapshot/SpinTextureCache.ts:201
Bake a motion-blurred variant of the static snapshot for symbolId
(which must exist. call captureStatic or setStatic first) and
cache it. The smear runs along blur.axis — the reel’s travel
direction ('y' default when called directly; StaticSpinSymbol
derives it from the set’s orientation) — and the
result is 2 * padding larger than the cell on that axis only. Draw
it center-anchored at the cell center and the smear extends evenly
past the cell on both sides. Blurs the user-provided static texture, or
the capture taken at this same size: a capture at another size is never
stretched into this one, which would bake (and cache) a distorted blur.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
width | number |
height | number |
blur? | MotionBlurOptions |
Returns#
Texture
captureStatic()#
captureStatic(
symbolId: string,
source: Container,
width: number,
height: number
): Texture;
Defined in: snapshot/SpinTextureCache.ts:176
Snapshot source (a symbol’s view, already activated and resized to
the cell) into a widthxheight texture and cache it under symbolId.
Returns the cached texture if one already exists at this size; a
user-provided texture always short-circuits. Captures at other sizes
are kept: they may be on screen on another reel.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
source | Container |
width | number |
height | number |
Returns#
Texture
clear()#
clear(): void;
Defined in: snapshot/SpinTextureCache.ts:270
Drop everything. Call when the cell size changes (responsive relayout).
Returns#
void
destroy()#
destroy(): void;
Defined in: snapshot/SpinTextureCache.ts:280
Returns#
void
Implementation of#
getBlurred()#
getBlurred(
symbolId: string,
width?: number,
height?: number,
axis?: "x" | "y"
): Texture<TextureSource<any>> | null;
Defined in: snapshot/SpinTextureCache.ts:150
The blurred texture for symbolId: the user-provided one if set, else
the capture at widthxheight along axis (default 'y'). Without a
size, the most recent capture at any size. null when there is none.
Parameters#
| Parameter | Type | Default value |
|---|---|---|
symbolId | string | undefined |
width? | number | undefined |
height? | number | undefined |
axis? | "x" | "y" | 'y' |
Returns#
Texture<TextureSource<any>> | null
getStatic()#
getStatic(
symbolId: string,
width?: number,
height?: number
): Texture<TextureSource<any>> | null;
Defined in: snapshot/SpinTextureCache.ts:141
The static texture for symbolId: the user-provided one if set, else
the capture at widthxheight. Without a size, the most recent capture
at any size. null when there is none.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
width? | number |
height? | number |
Returns#
Texture<TextureSource<any>> | null
hasBlurred()#
hasBlurred(symbolId: string): boolean;
Defined in: snapshot/SpinTextureCache.ts:163
True if symbolId has a blurred texture at any size.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
Returns#
boolean
hasStatic()#
hasStatic(symbolId: string): boolean;
Defined in: snapshot/SpinTextureCache.ts:158
True if symbolId has a static texture at any size.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
Returns#
boolean
invalidate()#
invalidate(symbolId: string): void;
Defined in: snapshot/SpinTextureCache.ts:262
Drop both textures for one symbolId, at every size. Cache-generated ones are destroyed, so only call this when nothing is drawing them.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
Returns#
void
setBlurred()#
setBlurred(symbolId: string, texture: Texture): void;
Defined in: snapshot/SpinTextureCache.ts:130
Provide a hand-authored motion-blur texture. Wins over captures.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
texture | Texture |
Returns#
void
setStatic()#
setStatic(symbolId: string, texture: Texture): void;
Defined in: snapshot/SpinTextureCache.ts:125
Provide a hand-authored static spin texture. Wins over captures.
Parameters#
| Parameter | Type |
|---|---|
symbolId | string |
texture | Texture |
Returns#
void