Skip to content

Class: SsTextureLoader ​

Defined in: packages/react-native-spritestudio/src/core/SsTextureLoader.ts:78

Loads a pack's textures into an SsTextureRegistry.

The .ssab itself is read in C++ — this layer is handed SsTextureInfo[], never a buffer to parse. Two supply modes, routed per texture with embedded winning:

  • embedded — bytes came along inside the .ssab.
  • reference — the texture names a file, resolved against the .ssab's own location: the parent of baseUri, joined with imagePath.

Everything is registered under SsTextureInfo.textureHash, which DrawBatch.texture_hash can be looked up with directly.

Where reference mode reaches ​

Everywhere an SsSource can point, because all three kinds keep their directory: the app's asset directory, a real filesystem directory, or a server. The file is opened the way the .ssab was — resolveAgainst hands back a URI of the same kind, and schemeOf picks the door.

Constructors ​

Constructor ​

new SsTextureLoader(): SsTextureLoader

Returns ​

SsTextureLoader

Methods ​

load() ​

static load(registry, textures, readEmbedded, baseUri?, pass?): Promise<SsTextureLoadReport>

Defined in: packages/react-native-spritestudio/src/core/SsTextureLoader.ts:98

Decodes and registers every texture in textures.

readEmbedded hands over the encoded bytes of an atlas inside an Embedded pack — SsInternalPlayer.copyEmbeddedTexture for textures out of its getTextures(). It is asked only for an atlas the image cache does not already hold.

baseUri is the .ssab's own URI. Omit it to load embedded textures only.

A hash already in registry is skipped, so several packs sharing one registry (a root and its instance children routinely name the same atlas) decode it once, and a caller-supplied texture wins over the pack's. A runtime replacement does not count: the atlas goes in underneath it, or taking the replacement off would leave nothing to draw.

pass is for an owner that can replace a load while this one is still decoding — see SsTextureLoadPass.

Parameters ​

registry ​

SsTextureRegistry

textures ​

SsTextureInfo[]

readEmbedded ​

(textureHash) => ArrayBuffer

baseUri? ​

string

pass? ​

SsTextureLoadPass

Returns ​

Promise<SsTextureLoadReport>