Skip to content

Script Object ​

An entity whose visual is built by a user ScriptObject script (custom shaders, procedural geometry, particles). Renders and animates in the editor AND at runtime. Starts as an empty THREE.Group; ScriptObjectSystem builds the visual once a script is linked.

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

export default class Spawner extends Behaviour {
  init() {
    const objects = this.world.getObjectManagementSystem();
    objects?.requestCreate("scriptObject", {
      name: "Wave",
      transform: { position: { x: 0, y: 0, z: -3 } },
      options: {
        scriptUrl: "localasset://.../scripts/WavePlane.js",
        className: "WavePlane",
      },
    });
  }
}

Payload ​

FieldTypeDefaultDescription
namestring"Script Object"Display name.
transformTransformDataidentityPosition / rotation (radians) / scale.
options.scriptUrlstring | nullnullCompiled script URL. Optional — can be assigned later in the inspector.
options.classNamestring | nullnullExported ScriptObject class name.
options.enabledbooleantrueWhen false, the visual isn't built/ticked.
options.dataRecord<string, unknown>{}Initial inspector data.

Components attached ​

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