Appearance
Class: AssetStore
Loads and caches assets by path. res.get(Assets).load('models/ship.glb') returns a handle at once; loading happens in the background (tracked by app.idle()). Paths are relative to the game's public/ folder.
Constructors
Constructor
ts
new AssetStore(app, options): AssetStore;Parameters
| Parameter | Type |
|---|---|
app | App |
options | AssetOptions |
Returns
AssetStore
Accessors
pending
Get Signature
ts
get pending(): number;Number of assets still loading.
Returns
number
Methods
load()
ts
load<T>(path, kind?): AssetHandle<T>;Starts loading (once per path) and returns the handle.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
path | string |
kind | AssetKind |
Returns
AssetHandle<T>
gltf()
ts
gltf(path): AssetHandle<GLTF>;Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
AssetHandle<GLTF>
texture()
ts
texture(path): AssetHandle<Texture<unknown, TextureEventMap>>;Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
AssetHandle<Texture<unknown, TextureEventMap>>
json()
ts
json<T>(path): AssetHandle<T>;Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
AssetHandle<T>
release()
ts
release(path): Promise<boolean>;Replays: finishes a held load (waiting for it if needed). False if the game never requested it.
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
Promise<boolean>
get()
ts
get<T>(path): AssetHandle<T> | undefined;The handle for a path if it was requested.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
path | string |
Returns
AssetHandle<T> | undefined
instantiate()
ts
instantiate(handle): Object3D<Object3DEventMap> | null;A new instance of a loaded model's scene. Geometry and materials are shared with the cache.
Parameters
| Parameter | Type |
|---|---|
handle | AssetHandle<GLTF> |
Returns
Object3D<Object3DEventMap> | null
dispose()
ts
dispose(): void;Frees GPU resources for everything loaded. Called when the app is disposed.
Returns
void