Scene
Scene graph: a hierarchy of Nodes with Camera and Light components. Create a scene, add nodes/cameras/lights, then call draw() to render.
Scene.new()
Section titled “Scene.new()”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()addNode(name) / addCamera() / addLight()
Section titled “addNode(name) / addCamera() / addLight()”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).
getRoot()
Section titled “getRoot()”Returns: Node — The root node of the scene (all added nodes/cameras/lights are attached under this hierarchy).
attachNode(node)
Section titled “attachNode(node)”Parameters:
node(Node) — An existing node (e.g. from BlendResult.instantiate) to attach to the scene root.
Attach an existing node to the scene root so it is part of this scene.
draw()
Section titled “draw()”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. viasetTag("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