Resource
1.2.0+
Base class for engine resources, such as:
Static Members
- .constructor(engine, index) ⇒ Resource
Properties
- .engine
- .index
- .isDestroyed
- .origin
Methods
Constructor
.constructor(engine: WonderlandEngine, index: number) ⇒ Resource
| Param | Type | Description |
|---|---|---|
engine | WonderlandEngine | |
index | number |
Properties
.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
const prefab = await engine.loadPrefab('Prefab.bin');
const meshA = engine.meshes.create({vertexCount: 1});
console.log(meshA.origin === prefab); // false
const components = prefab.getComponents('mesh');
for (const component of components) {
const original = component.mesh.origin;
console.log(prefab === original); // true
}
Methods
.equals(other: undefined | null | Resource) ⇒ boolean
Checks equality by comparing ids and not the JavaScript reference.
Deprecated: Use JavaScript reference comparison instead:
const meshA = engine.meshes.create({vertexCount: 1});
const meshB = engine.meshes.create({vertexCount: 1});
const meshC = meshB;
console.log(meshA === meshB); // false
console.log(meshA === meshA); // true
console.log(meshB === meshC); // true
| Param | Type | Description |
|---|---|---|
other | undefined | null | Resource |