object3D.const e = world.createEntity(); const t = world.createTransformEntity(); // adds an Object3D and a Transform component
const child = world.createTransformEntity(undefined, { parent: t });
const persistent = world.createTransformEntity(undefined, { persistent: true }); // parented under scene
import { Mesh, BoxGeometry, MeshStandardMaterial } from '@iwsdk/core';
const geometry = new BoxGeometry(1, 1, 1);
const material = new MeshStandardMaterial({ color: 0x00ff00 });
const mesh = new Mesh(geometry, material);
const entity = world.createTransformEntity(mesh);
createTransformEntity is the recommended way to attach Three.js objects to entities. It ensures object3D is properly managed and detached when the entity is released.e.addComponent(Health, { current: 100 });
e.removeComponent(Health);
e.has(Health); // boolean
const v = e.getValue(Health, 'current'); // number | undefined e.setValue(Health, 'current', 75); // For vector fields (Types.Vec3) use a typed view: const pos = e.getVectorView(Transform, 'position'); // Float32Array pos[1] += 1; // move up
entity.destroy()object3D from the scene graph:entity.destroy();
entity.dispose()entity.dispose();
| Scenario | Method |
|---|---|
Removing an entity that uses shared/reusable assets | destroy() |
Removing an entity with unique, one-off geometry/materials | dispose() |
Level unloading with asset reuse | destroy() |
Full cleanup of procedurally generated content | dispose() |
// If you created unique resources, dispose them
const geometry = new BoxGeometry(1, 1, 1);
const material = new MeshStandardMaterial({ color: 0xff0000 });
const mesh = new Mesh(geometry, material);
const entity = world.createTransformEntity(mesh);
// Later: full cleanup since resources aren't shared
entity.dispose();
// If using loaded/shared assets, just destroy
const gltf = await AssetManager.loadGLTF('model.glb');
const entity = world.createTransformEntity(gltf.scene.clone());
// Later: don't dispose - other entities may use the same materials
entity.destroy();