pixi-reels

SpinTextureCache

pixi-reels


pixi-reels / index / SpinTextureCache

Class: SpinTextureCache

Defined in: snapshot/SpinTextureCache.ts:86

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:94

Parameters#

ParameterType
optionsSpinTextureCacheOptions

Returns#

SpinTextureCache

Accessors#

isDestroyed#

Get Signature#

get isDestroyed(): boolean;

Defined in: snapshot/SpinTextureCache.ts:244

Returns

boolean

Implementation of#

Disposable.isDestroyed

Methods#

captureBlurred()#

captureBlurred(
   symbolId: string, 
   width: number, 
   height: number, 
   blur?: MotionBlurOptions
): Texture;

Defined in: snapshot/SpinTextureCache.ts:163

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.

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:138

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:233

Drop everything. Call when the cell size changes (responsive relayout).

Returns#

void


destroy()#

destroy(): void;

Defined in: snapshot/SpinTextureCache.ts:238

Returns#

void

Implementation of#

Disposable.destroy


getBlurred()#

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

Defined in: snapshot/SpinTextureCache.ts:118

Parameters#

ParameterType
symbolIdstring

Returns#

Texture<TextureSource<any>> | null


getStatic()#

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

Defined in: snapshot/SpinTextureCache.ts:114

Parameters#

ParameterType
symbolIdstring

Returns#

Texture<TextureSource<any>> | null


hasBlurred()#

hasBlurred(symbolId: string): boolean;

Defined in: snapshot/SpinTextureCache.ts:126

Parameters#

ParameterType
symbolIdstring

Returns#

boolean


hasStatic()#

hasStatic(symbolId: string): boolean;

Defined in: snapshot/SpinTextureCache.ts:122

Parameters#

ParameterType
symbolIdstring

Returns#

boolean


invalidate()#

invalidate(symbolId: string): void;

Defined in: snapshot/SpinTextureCache.ts:227

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:108

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:103

Provide a hand-authored static spin texture. Wins over captures.

Parameters#

ParameterType
symbolIdstring
textureTexture

Returns#

void