Skip to content

Camera

Spawn an additional camera entity. Useful for cinematics, picture-in-picture, or AR cameras.

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

export default class SpawnCamera extends Behaviour {
  init() {
    const objects = this.world.getObjectManagementSystem();
    objects?.requestCreate("camera", {
      name: "Cinematic",
      transform: { position: { x: 0, y: 2, z: 5 } },
      options: {
        type: "3d",
        projection: "perspective",
        fov: 50,
        near: 0.1,
        far: 1000,
      },
    });
  }
}

Payload

FieldTypeDefaultDescription
namestring"Camera"Display name.
transformTransformDataidentityPosition / rotation / scale.
useWorldCamerabooleanfalseReuse the existing world camera object instead of creating a new one (only honored at runtime, not in the editor).
parentIdEntityId | nullnullOptional parent entity.

options

OptionTypeDefaultDescription
type"3d" | "ar""3d"Logical camera type (used by tracking systems).
isDefaultbooleanfalseMark this camera as the default render camera.
projection"perspective" | "orthographic""perspective"Projection model.
fovnumber60Vertical field of view (degrees). Perspective only.
nearnumber0.1Near clip plane.
farnumber1000Far clip plane.
left / right / top / bottomnumber±half-heightOrthographic frustum edges.
zoomnumber1Orthographic zoom.

Components attached

Transform, Object3DRef, Name, EntityType, ParentId, Selectable, Camera.