tiramisu/dev/runtime

Instance-scoped runtime for Tiramisu web components.

Each <tiramisu-renderer> owns one runtime value containing the root scene, renderer, active camera, and registered objects.

This module is intended for extension authors. It exposes the capabilities an extension needs to interact with the runtime without exposing the runtime’s internal storage layout.

Types

Instance-scoped runtime. One per <tiramisu-renderer>.

pub opaque type Runtime

Values

pub fn activate_camera(
  runtime: Runtime,
  id: String,
  camera: camera.Camera,
) -> Runtime

Mark a camera as the active camera for the runtime.

pub fn active_camera(
  runtime: Runtime,
) -> Result(camera.Camera, Nil)

Get the currently active camera, if one is set.

pub fn add_object(
  runtime: Runtime,
  id: String,
  object object: object.Object3D,
  parent_id parent_id: String,
  tag tag: String,
) -> Runtime

Register an object and add it to the scene graph under its parent. Sets the object’s name via savoiardi for debugging in Three.js inspector.

pub fn deactivate_camera(runtime: Runtime, id: String) -> Runtime

Clear the active camera if the given node currently owns it.

pub fn object(
  runtime: Runtime,
  id: String,
) -> Result(object.Object3D, Nil)

Get a registered object by its node id.

Extension authors should prefer this over inspecting internal entries.

pub fn remove_object(
  runtime: Runtime,
  id: String,
  parent_id: String,
  object: object.Object3D,
) -> Runtime

Remove an object from the scene graph and dispose its resources.

pub fn reparent_object(
  runtime: Runtime,
  id: String,
  parent_id: String,
) -> Runtime

Move an existing object under a new parent.

pub fn replace_object(
  runtime: Runtime,
  id: String,
  new_object: object.Object3D,
) -> Runtime

Replace an existing object’s 3D model with a newly loaded one. Preserves position, rotation, scale, and visibility from the old object. Updates the registry entry to point to the new object.

pub fn scene(runtime: Runtime) -> scene.Scene

Get the root scene owned by this runtime.

pub fn threejs_renderer(runtime: Runtime) -> renderer.Renderer

Get the Three.js renderer owned by this runtime.

Search Document