English
Class: SSWebGLResourceManager
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:27
One player's textures, keyed by the cell-map hash the core asks for.
URL-loaded atlases are delegated to the surface's SSWebGLTextureCache when there is one, so several players showing the same character upload it once. This manager still keeps its own hash → texture mapping, because the hash is only unique within one .ssab while the cache is shared across all of them (see the note on keying there).
Embedded (--embedded) and caller-supplied textures are never shared: they came from this player's bytes, and two .ssab files can carry the same cell-map name with completely different pixels.
Implements
Constructors
Constructor
new SSWebGLResourceManager(
gl,shared?):SSWebGLResourceManager
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:43
Parameters
gl
WebGLRenderingContext | WebGL2RenderingContext
shared?
Returns
SSWebGLResourceManager
Methods
bindTextureSource()
bindTextureSource(
source,hash,width,height):void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:75
Parameters
source
TexImageSource
hash
number
width
number
height
number
Returns
void
clearOverrideTexture()
clearOverrideTexture(
hash):void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:165
Drop the override for hash, restoring the originally loaded texture.
Parameters
hash
number
Returns
void
Implementation of
IResourceManager.clearOverrideTexture
destroy()
destroy():
void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:241
Delete the textures this player uploaded itself. Shared ones are left alone — a sibling player is probably still drawing with them, and the surface deletes the cache when it goes.
Returns
void
Implementation of
getOverrideTexture()
getOverrideTexture(
hash):SSTextureEntry|undefined
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:170
The current override for hash (never the original), or undefined.
Parameters
hash
number
Returns
SSTextureEntry | undefined
Implementation of
IResourceManager.getOverrideTexture
getTexture()
getTexture(
hash):SSTextureEntry|undefined
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:130
Gets a loaded texture by its hash.
Parameters
hash
number
The hash of the texture.
Returns
SSTextureEntry | undefined
The engine-specific texture object (e.g. PIXI.Texture).
Implementation of
loadTexture()
loadTexture(
url,hash):Promise<void>
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:48
Loads a texture from the given URL and associates it with the given hash.
Parameters
url
string
The URL of the texture to load.
hash
number
The cell-map name hash — a slot in one .ssab, not an image.
Returns
Promise<void>
Implementation of
loadTextureFromBytes()
loadTextureFromBytes(
bytes,hash):Promise<void>
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:68
Decode raw (encoded) image bytes — e.g. a PNG embedded in the SSAB via the converter's --embedded mode — and upload them as a texture under hash.
Never shared: these bytes belong to one .ssab, and a cell-map name is not unique across files.
Parameters
bytes
Uint8Array
hash
number
Returns
Promise<void>
Implementation of
IResourceManager.loadTextureFromBytes
reset()
reset():
void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:229
Optional: forget every texture bound for the previously bound pack, so the next one loads its own from scratch. Called by the core from bindResource; a manager that caches by hash must implement it. Must also drop any runtime texture overrides — they belong to the previous pack's hashes.
Returns
void
Implementation of
restoreContext()
restoreContext():
Promise<void>
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:204
Rebuild every texture after a GL context loss. The old WebGLTexture handles died with the context, so drop them and re-create from the retained creation info. URL / bytes sources re-decode asynchronously; caller-owned TexImageSources re-upload synchronously (skipped if the caller let the source go — e.g. a closed ImageBitmap — so one dead source can't abort the whole restore).
The surface invalidates the shared cache before calling this, so the first player to ask for a URL re-uploads it and the rest reuse that.
Returns
Promise<void>
setOverrideTexture()
setOverrideTexture(
hash,entry):void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:145
Runtime texture replacement: bind a ready SSTextureEntry for hash, shadowing the originally loaded texture. The entry's WebGLTexture is caller-owned — this manager never deletes it. For the common case of replacing from an image/canvas/video, prefer setOverrideTextureFromSource, which uploads (and owns) the GL texture for you.
The entry's width/height are what the renderer normalizes UVs by, so a replacement of a different size than the original samples a shifted region — pass a same-size, same-layout atlas.
Parameters
hash
number
entry
Returns
void
Implementation of
IResourceManager.setOverrideTexture
setOverrideTextureFromSource()
setOverrideTextureFromSource(
hash,source,width,height):void
Defined in: ssplayer-webgl/src/SSWebGLResourceManager.ts:157
Runtime texture replacement from a raw image source (an ImageBitmap, HTMLImageElement, HTMLCanvasElement, HTMLVideoElement, …). Uploads it with the same premultiplied-alpha path as the initial textures and binds it for hash. The uploaded GL texture is owned by this manager and freed on clearOverrideTexture, replacement, or reset/destroy.
Parameters
hash
number
source
TexImageSource
width
number
height
number
Returns
void