Skip to content

Scene

Scene graph: a hierarchy of Nodes with Camera and Light components. Create a scene, add nodes/cameras/lights, then call draw() to render.

Returns: Scene — A new empty scene.

Construct a new scene. Add nodes, cameras, and lights, then call draw each frame (typically after setting view/projection matrices on the graphics context).

_scene = Scene.new()
var cam = _scene.addCamera()
cam.setTag("main")
var light = _scene.addLight()
var node = _scene.addNode("Player")
_scene.draw()

Returns: Node, Camera, or Light — The new object added to the scene.

Parameters:

  • name (String, optional for addNode) — Name for the node. Can be empty string.

Add a node (with optional name), a camera, or a light. You can then set the camera/light tag and attach them to nodes via setNode(node).

Returns: Node — The root node of the scene (all added nodes/cameras/lights are attached under this hierarchy).

Parameters:

Attach an existing node to the scene root so it is part of this scene.

Draw the scene: render all geometry using the scene’s cameras and lights. Call after setting Graphics.setViewMatrix, Graphics.setProjectionMatrix, and Graphics.setViewProjectionEnabled(true) with the active camera’s matrices.

Graphics.setViewProjectionEnabled(true)
var view = _camera.getViewMatrix()
var proj = _camera.getProjectionMatrix(aspect)
Graphics.setViewMatrix(view)
Graphics.setProjectionMatrix(proj)
_scene.draw()

findCameraByTag(tag) / findLightByTag(tag)

Section titled “findCameraByTag(tag) / findLightByTag(tag)”

Returns: Camera or Light, or null if not found.

Parameters:

  • tag (String) — Tag string set on the camera or light (e.g. via setTag("main")).

Find a camera or light by its tag. Useful when loading a camera/light from a blend and you need to retrieve it by the tag configured in Blender.

var cam = _scene.findCameraByTag("main")
if (cam != null) _camera = cam

Returns: Node or null — Find a node by its node_id string (set in Blender via the Plume3D addon or via node.node_id in Wren).

var door = _scene.findNodeById("door_01")

createCharacterController(height, radius, x, y, z)

Section titled “createCharacterController(height, radius, x, y, z)”

Returns: CharacterController — A new capsule-based character controller placed at (x, y, z).

See CharacterController for the full API.

_controller = _scene.createCharacterController(1.8, 0.3, 0, 2, 0)
_controller.node = _playerNode

createParticleEmitter(name, maxBodies, size, mass, lifetime, emissionRate, x, y, z)

Section titled “createParticleEmitter(name, maxBodies, size, mass, lifetime, emissionRate, x, y, z)”

Returns: ParticleEmitter — A new Jolt-backed particle emitter.

See ParticleEmitter for the full API.

_emitter = _scene.createParticleEmitter("sparks", 128, 0.05, 0.1, 2.0, 50, 0, 3, 0)
_emitter.play()

Returns: InstancedMesh — A new instanced mesh registered with this scene.

Returns: InstancedMesh or null — Find an existing instanced mesh by name.

_trees = _scene.createInstancedMesh("trees")
_trees.setMesh(_treeMesh)
_trees.useGpuInstancing = true
for (i in 0...500) {
_trees.addInstance(Math.sin(i) * 30, 0, Math.cos(i) * 30)
}

See Node, Camera, and Light for those types. See Physics for addStaticBox, addDynamicBox, and body manipulation.