Next (Transactions) Previous (Animation)

Scene Graph

When working in, all objects are contained within a scene. These objects are organized in a network of connected objects or nodes. The scene graph is structured as a tree, where nodes (scene objects) are connected by parent-child relationships.

All scene graphs have one root node - in our case, this is the scene node. All nodes, except for the root, have a parent, and each node can have many children.

Nodes are every element in the scene: geometrical objects, cameras, lights, bones, and nulls are all nodes. There are also some less obvious nodes. Materials, renderers, and passes are nodes as well, since they are elements of a scene, although they do not contain any geometry information. Nodes are typically viewed in the Explorer panel on the left. implements virtual nodes to organize scene graph nodes by type. Developer cannot create virtual nodes, but they are useful to perform operations on regular nodes. These virtual nodes are: Objects, Material Library, Renderers, and Passes. These enables to efficiently access all scene graph nodes corresponding to each of the above categories.

To operate a node, we need to select that node. To perform a selection, we need to use ctx’s Selectors capability:

var myNodes = ctx(selector);

Here myNodes is an array, ctx selector will return a array of nodes that meet the selection criteria, wrapped in a ctx JavaScript object. To select a specific node, we must use the at function. For example, to get the first element of the array myNodes we employ:

var myNode =

For further discussion, let’s recall how to set the primitive of an object, the command looks like,

ctx('name#Plug[name=Operator]').set({"Primitive": value});

basiclly, every node in has the same data structure like

Parent Node------>Child Node1----->Plug1----->Primitive1
               |->Child Node2   |->Plug2   |->Primitive2
               |->Child Node3   |->Plug3   |->...
               |-> ...          |->...     |->Operator1

So, we can also reach a primitive of an object using the object-oriented type like,


Actually, the primitives are independent from the plugs, they store the related information of the object, but there are also a reference of primitives under plug, so we can access the primitives directly or through plug.

For example, if we want to get the translation of an object we can code like this:

var translation = ctx('Box')).at(0).plugs.Transform.primitive.translation;

Or you can use transform as a shortcut for plugs.Transform.primitive, like this:

var translation = ctx('Box').at(0).transform._translation;

To learn and explore the data structure of Node, you can use console.log() and browser developer tools or other debug tools to print and check the data structure of the object you want.

Next (Transactions) Previous (Animation)