The world hierarchy

../_images/world-tree.svg

The world has a tree structure maintaining spatial relationships between objects called Nodes. Some Nodes exist in the world by default, and others can be created through BBI in notebooks.

Tip: View the world tree

Use world.show() to visualize the world tree in the notebook. This is useful for debugging and understanding the hierarchical relationships between objects.

Examples of Nodes

Most commonly used classes are in fact Nodes, including:

What do nodes do?

As part of the world tree, Nodes are unique, exist in 3D space, and can have children. This is why all Nodes have:

  • node_id, a unique string identifier

  • A Transform that defines their position, rotation, and scale

  • A reference to a parent Node, and a list of children Nodes

class Node(node_id: str, transform: Transform)

A scriptable node in the scene hierarchy.

Scriptable nodes have transforms and can have parents and children.

Parameters:
  • node_id (str) – The user defined unique id of the node.

  • transform (Transform) – The transform of the node.

What happens when Nodes have the same node_id?

Different Nodes can be created with the same node_id. However, when they’re added to the world, the last added Node will replace any existing ones with the same ID.

add(self, node: Node) None

Adds a node to the world.

Use this method to add new Asset and SpawnZone objects in the world. Existing nodes with the same node_id will be deleted and replaced with the incoming node. All existing parent-child relationships will be lost.

Parameters:

node (Node) – The node to add to the World.