Skip to content

Cube

A unit 1×1×1 THREE.BoxGeometry mesh with a default white MeshStandardMaterial.

ts
import { Behaviour } from "@relu-interactives/spatial-ecs";

export default class SpawnCube extends Behaviour {
  init() {
    const objects = this.world.getObjectManagementSystem();
    objects?.requestCreate("cube", {
      name: "Crate",
      transform: { position: { x: 0, y: 1, z: 0 } },
    });
  }
}

Payload

FieldTypeDefaultDescription
namestring"Cube"Display name.
transformTransformDataidentityPosition / rotation (radians) / scale.
parentIdEntityId | nullnullOptional parent entity.

Default size is 1 along each axis — adjust by changing transform.scale after spawn (e.g. getComponent(id, TransformComponent).scale.x = 2).

Components attached

Transform, Object3DRef, Name, EntityType, ParentId, Selectable, Mesh, Material, MeshGeometry.