Resource
Base class for engine resources, such as:
- Resource
- .constructor(engine, index) ⇒ Resource
- .engine
- .index
- .isDestroyed
- .origin
.equals(other) ⇒ boolean
.constructor(engine: WonderlandEngine, index: number) ⇒ Resource
| Param | Type | Description |
|---|---|---|
| engine | WonderlandEngine | |
| index | number |
.engine: WonderlandEngine
Hosting engine instance.
.index: number
Index of this resource in the Scene’s manager.
.isDestroyed: boolean
true if the object is destroyed, false otherwise.
If erasePrototypeOnDestroy is true,
reading a class attribute / method will throw.
.origin: null | Prefab
1.5.0+Scene with which the resource was originally loaded.
Note: If the scene has since been destroyed, returns null.
Example
1const prefab = await engine.loadPrefab('Prefab.bin');
2
3const meshA = engine.meshes.create({vertexCount: 1});
4console.log(meshA.origin === prefab); // false
5
6const components = prefab.getComponents('mesh');
7for (const component of components) {
8 const original = component.mesh.origin;
9 console.log(prefab === original); // true
10}.equals(other: undefined | null | Resource) ⇒ boolean
Checks equality by comparing ids and not the JavaScript reference.
Deprecated: Use JavaScript reference comparison instead:
| Param | Type | Description |
|---|---|---|
| other | undefined | null | Resource |