Skip to content

Nodes

Nodes are the building blocks of the scene graph. Every object — mesh, light, camera — is attached to a node. Nodes form a tree via parent-child relationships.

local node = scene:create_node("MyObject")
PropertyTypeAccessDescription
namestringr/wHuman-readable name
visibleboolr/wWhether this node is rendered (default: true)

Transforms are local (relative to parent). World transforms are computed automatically.

-- Position, rotation, scale
node.position = { x = 1, y = 2, z = 3 }
node.rotation = { x = 0, y = 0, z = 0, w = 1 } -- quaternion
node.euler = { x = 0, y = 45, z = 0 } -- degrees (convenience)
node.scale = { x = 1, y = 1, z = 1 }
-- Full matrix access
node.local_transform -- mat4 (r/w), 16 floats column-major
node.world_transform -- mat4 (r/o), computed from parent chain
node.world_position -- vec3 (r/o), extracted from world transform
node:set_parent(parent_node) -- reparent (nil = make root)
node:add_child(child_node) -- add child
node:remove_child(child_node) -- remove child
node:get_parent() -- Node or nil
node:get_children() -- array of Nodes
node:set_mesh(mesh) -- attach a Mesh
node:get_mesh() -- Mesh or nil
node:set_skin(skin) -- attach a Skin (for skeletal animation)
node:get_skin() -- Skin or nil

Store arbitrary metadata on nodes. Imported properties from FBX/glTF extras are available here.

node:set_property("layer", "foreground")
node:set_property("intensity", 0.8)
local v = node:get_property("layer") -- "foreground"
local all = node:get_properties() -- table of all properties
local all = scene:get_nodes() -- array of all nodes
local node = scene:find_node("Head") -- by exact name, nil if not found
local nodes = scene:find_nodes("Light*") -- glob pattern match
node:destroy() -- removes from scene graph and all children