Entities
Introduction
An entity by itself has no behavior or appearance; it simply acts as a container to which components can be attached.Creating an Entity
The following code shows how to create a new entity without any components
Example
import * as ecs from '@8thwall/ecs'
const eid = world.createEntity()
Deleting an Entity
The following code shows how to delete an existing entity given its id:
Example
import * as ecs from '@8thwall/ecs'
world.deleteEntity(eid)
Adding Components to an Entity
The following code shows how to add a built-in component to an entity at runtime.
Example
const box = world.createEntity()
ecs.BoxGeometry.set(world, box, {
width: 1,
height: 1,
depth: 1,
})
ecs.Material.set(world, box, {
r: 255,
g: 255,
b: 255,
})