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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AssetManager():
AssetManager
Returns
Section titled “Returns”AssetManager
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: AssetManager.ts:111
Unload every cached asset outright, ignoring reference counts.
Returns
Section titled “Returns”void
get<
T>(handle):T
Defined in: AssetManager.ts:28
Retrieve a loaded asset. Throws if not loaded.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”handle
Section titled “handle”AssetHandle<T>
Returns
Section titled “Returns”T
has(
handle):boolean
Defined in: AssetManager.ts:38
Check if an asset is loaded.
Parameters
Section titled “Parameters”handle
Section titled “handle”AssetHandle<unknown>
Returns
Section titled “Returns”boolean
loadAll()
Section titled “loadAll()”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.
Parameters
Section titled “Parameters”handles
Section titled “handles”readonly AssetHandle<unknown>[]
onProgress?
Section titled “onProgress?”(ratio) => void
Returns
Section titled “Returns”Promise<void>
registerLoader()
Section titled “registerLoader()”registerLoader(
type,loader):void
Defined in: AssetManager.ts:23
Register a loader for a given asset type. Called by plugins during install().
Parameters
Section titled “Parameters”string
loader
Section titled “loader”Returns
Section titled “Returns”void
unload()
Section titled “unload()”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.
Parameters
Section titled “Parameters”handle
Section titled “handle”AssetHandle<unknown>
Returns
Section titled “Returns”void