scene node

Summary

The scene node represents the root node in the scene. It is primarily used for looking up nodes in the scene by ID and for adding new nodes to the scene.

Constructor

The scene node is available as a global variable, scene, and cannot be created or destroyed.

Example C.48. Use of the scene global variable

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
		
	</script>
	
	<object id="myobject" .../>
	
</scene>

Functions

node:getById( id )

Returns an variable that represents the node identified by id. If no node with the ID specified exists, the function returns nil.

Example C.49. Use of getById

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
		
	</script>
	
	<object id="myobject" .../>
	
</scene>


Functions common to nodes that group nodes

node:appendNode( newchild )

Adds the passed node to this group in the scene.

Example C.50. Use of appendNode

<scene>
	<script type="text/x-lua">
		
		myplane = object.new("primitives://plane.aro")
		
		mygroup = scene:getById("mygroup")
		mygroup:appendNode(myplane)
		
	</script>
	
	<group id="mygroup">
		<!-- object will be added here by script -->
	</group>
	
</scene>


node:replaceChildren( newchild )

Removes all children from this group and replaces them with the passed node.

Example C.51. Use of replaceChildren

<scene>
	<script type="text/x-lua">
		
		myplane = object.new("primitives://plane.aro")
		
		mygroup = scene:getById("mygroup")
		mygroup:replaceChildren(myplane)
		
	</script>
	
	<group id="mygroup">
		
		<!-- this object will be removed by script -->
		<object type="primitives://plane.aro" color="1 0 0 1"/>
		
	</group>
	
</scene>