pixi-reels

SpinTextureCache

pixi-reels


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 on invalidate / 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

ParameterType
optionsSpinTextureCacheOptions

Returns

SpinTextureCache

Accessors

isDestroyed

Get Signature

get isDestroyed(): boolean;

Defined in: snapshot/SpinTextureCache.ts:242

Returns

boolean

Implementation of

Disposable.isDestroyed

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

ParameterType
symbolIdstring
widthnumber
heightnumber
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

ParameterType
symbolIdstring
sourceContainer
widthnumber
heightnumber

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

Disposable.destroy


getBlurred()

getBlurred(symbolId: string): Texture<TextureSource<any>> | null;

Defined in: snapshot/SpinTextureCache.ts:117

Parameters

ParameterType
symbolIdstring

Returns

Texture<TextureSource<any>> | null


getStatic()

getStatic(symbolId: string): Texture<TextureSource<any>> | null;

Defined in: snapshot/SpinTextureCache.ts:113

Parameters

ParameterType
symbolIdstring

Returns

Texture<TextureSource<any>> | null


hasBlurred()

hasBlurred(symbolId: string): boolean;

Defined in: snapshot/SpinTextureCache.ts:125

Parameters

ParameterType
symbolIdstring

Returns

boolean


hasStatic()

hasStatic(symbolId: string): boolean;

Defined in: snapshot/SpinTextureCache.ts:121

Parameters

ParameterType
symbolIdstring

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

ParameterType
symbolIdstring

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

ParameterType
symbolIdstring
textureTexture

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

ParameterType
symbolIdstring
textureTexture

Returns

void