Skip to content

AssetManager

Defined in: AssetManager.ts:16

Orchestrates asset loading across plugin-provided loaders. Core owns the “when” and “what”; plugins own the “how”.

Loads are reference-counted by type:path: every handle passed to loadAll adds a reference (even when the asset is already cached), and unload only fires the loader’s unload once the last reference is released. Without this, two scenes preloading the same asset share one cache entry, so the first unload would tear the asset out from under the other — the underlying Pixi Assets/BitmapFont registries dedupe by key and are not ref-counted, so the destruction would be real. clear ignores the counts and frees everything outright.

new AssetManager(): AssetManager

AssetManager

clear(): void

Defined in: AssetManager.ts:111

Unload every cached asset outright, ignoring reference counts.

void


get<T>(handle): T

Defined in: AssetManager.ts:28

Retrieve a loaded asset. Throws if not loaded.

T

AssetHandle<T>

T


has(handle): boolean

Defined in: AssetManager.ts:38

Check if an asset is loaded.

AssetHandle<unknown>

boolean


loadAll(handles, onProgress?): Promise<void>

Defined in: AssetManager.ts:51

Load all assets, adding a reference to each and loading only the ones not already cached. Reports progress via optional callback (0→1).

Every distinct handle in handles adds one reference, whether it was freshly loaded or already cached — so two scenes preloading the same asset each hold a reference and a single unload won’t free it under the other. Duplicate handles within one call count once.

readonly AssetHandle<unknown>[]

(ratio) => void

Promise<void>


registerLoader(type, loader): void

Defined in: AssetManager.ts:23

Register a loader for a given asset type. Called by plugins during install().

string

AssetLoader

void


unload(handle): void

Defined in: AssetManager.ts:95

Release one reference to an asset. The loader’s unload runs and the cache entry is dropped only when the last reference is released; earlier calls just decrement. A no-op for handles that were never loaded.

AssetHandle<unknown>

void