ResourceManager
1.2.0+
Manager for resources.
Resources are accessed via the engine they belong to.
See: textures, meshes, and materials.
Properties
Methods
Properties
.allocatedCount: number
Number of textures allocated in the manager.
.count: number
Number of resources in the manager.
Note: For performance reasons, avoid calling this method when possible.
.engine: WonderlandEngine
Hosting engine instance.
Methods
.all() ⇒ T[]
1.5.0+
Retrieves non-destroyed resources.
To retrieve resources loaded by a specific scene, use loadedFromScene.
Example
// All texture resources currently alive
const textures = engine.textures.all();
...
await engine.textures.create('my.png');
// `textures` now includes 'my.png'
const textures = engine.textures.all();
Returns: Array of all resources.
.get(index: number) ⇒ null | T
Retrieve the resource at the given index.
Note: The index is relative to the host, i.e., doesn’t pack the host index.
| Param | Type | Description |
|---|---|---|
index | number |
.loadedFromScene(prefab: Prefab) ⇒ T[]
1.5.0+
Return all resources loaded from a given scene
Note: Resources created at runtime are retrieved using:
// All textures loaded from the current active scene
const mainTextures = engine.textures.loadedFromScene(engine.scene);
const prefab = await engine.loadPrefab('Prefab.bin');
// All textures loaded from the prefab
const prefabTextures = engine.textures.loadedFromScene(prefab);
Returns: Array of resources loaded from the given prefab.
| Param | Type | Description |
|---|---|---|
prefab | Prefab | The prefab |
.wrap(index: number) ⇒ null | T
Wrap the index into a resource instance.
Note: The index is relative to the host, i.e., doesn’t pack the host index (if any).
Returns:
| Param | Type | Description |
|---|---|---|
index | number | The resource index. |