SpinTextureCache
pixi-reels / index / SpinTextureCache
Class: SpinTextureCache
Defined in: snapshot/SpinTextureCache.ts:85
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 remembered together with the cell size they were taken at; capturing again at a different size regenerates. 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:93
Parameters
| Parameter | Type |
|---|---|
options | SpinTextureCacheOptions |
Returns
SpinTextureCache
Accessors
isDestroyed
Get Signature
get isDestroyed(): boolean;
Defined in: snapshot/SpinTextureCache.ts:242
Returns
boolean
Implementation of
Methods
captureBlurred()
captureBlurred(
symbolId: string,
width: number,
height: number,
blur?: MotionBlurOptions): Texture;
Defined in: snapshot/SpinTextureCache.ts:161
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; 'x' for a HorizontalReel) — 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.
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:137
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.
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
source | Container |
width | number |
height | number |
Returns
Texture
clear()
clear(): void;
Defined in: snapshot/SpinTextureCache.ts:231
Drop everything. Call when the cell size changes (responsive relayout).
Returns
void
destroy()
destroy(): void;
Defined in: snapshot/SpinTextureCache.ts:236
Returns
void
Implementation of
getBlurred()
getBlurred(symbolId: string): Texture<TextureSource<any>> | null;
Defined in: snapshot/SpinTextureCache.ts:117
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
Returns
Texture<TextureSource<any>> | null
getStatic()
getStatic(symbolId: string): Texture<TextureSource<any>> | null;
Defined in: snapshot/SpinTextureCache.ts:113
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
Returns
Texture<TextureSource<any>> | null
hasBlurred()
hasBlurred(symbolId: string): boolean;
Defined in: snapshot/SpinTextureCache.ts:125
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
Returns
boolean
hasStatic()
hasStatic(symbolId: string): boolean;
Defined in: snapshot/SpinTextureCache.ts:121
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
Returns
boolean
invalidate()
invalidate(symbolId: string): void;
Defined in: snapshot/SpinTextureCache.ts:225
Drop (and destroy, if cache-generated) both textures for one symbolId.
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
Returns
void
setBlurred()
setBlurred(symbolId: string, texture: Texture): void;
Defined in: snapshot/SpinTextureCache.ts:107
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:102
Provide a hand-authored static spin texture. Wins over captures.
Parameters
| Parameter | Type |
|---|---|
symbolId | string |
texture | Texture |
Returns
void