ExRatatui.ThreeD.Node (ExRatatui v0.11.0)

Copy Markdown View Source

A node in a transform hierarchy that flattens to a flat ExRatatui.ThreeD.Scene.

ExRatatui.ThreeD.Scene has no scene graph — every object carries its own world-space transform. Node lets an application express an articulated model as a tree of local transforms and bake it into world-space objects each frame.

Fields

  • :transform - the node's local frame, relative to its parent
  • :visual - an optional ExRatatui.ThreeD.Object rendered at this node; the object's own transform is treated as a local offset/scale within the frame
  • :children - child nodes

Composition contract

Frames compose via ExRatatui.ThreeD.Transform.compose/2. Keep intermediate nodes rigid (scale: {1.0, 1.0, 1.0}) and put scale only on leaf visual objects; then every baked object is exactly one Transform (no shear).

Examples

iex> alias ExRatatui.ThreeD.{Node, Object, Mesh}
iex> tree = %Node{visual: %Object{mesh: Mesh.cube()}}
iex> length(ExRatatui.ThreeD.Node.flatten(tree))
1

Summary

Functions

Flatten the tree into a list of world-space ExRatatui.ThreeD.Objects.

Flatten the tree and wrap it in a Scene.

Types

t()

@type t() :: %ExRatatui.ThreeD.Node{
  children: [t()],
  transform: ExRatatui.ThreeD.Transform.t(),
  visual: ExRatatui.ThreeD.Object.t() | nil
}

Functions

flatten(node)

@spec flatten(t()) :: [ExRatatui.ThreeD.Object.t()]

Flatten the tree into a list of world-space ExRatatui.ThreeD.Objects.

to_scene(node, opts \\ [])

@spec to_scene(
  t(),
  keyword()
) :: ExRatatui.ThreeD.Scene.t()

Flatten the tree and wrap it in a Scene.

Options: :lights, :background, :sky (passed straight to the Scene).