Node

Overview

The Node class represents a named element in the Aspose.3D scene graph. Each node can hold one Entity (such as a Mesh, Camera, or Light), maintains parent-child relationships with other nodes, and carries a local transform. Nodes are the primary way to organize 3D objects in a scene hierarchy.

from aspose.threed import Scene, Node

scene = Scene()

# Access the root node: root_node is a property on Scene
root = scene.root_node

# Create a child node
child = root.create_child_node("my_node")

# child_nodes is a property: access without parentheses
for node in root.child_nodes:
    print(node.name)

Constructor

The Node constructor initializes a node with an optional name.

ParameterTypeDescription
namestrOptional name for the node

Properties

All node attributes below are properties; access them without parentheses.

NameTypeDescription
namestrHuman-readable identifier for the node
entityEntity | NoneThe primary entity attached to this node (e.g., Mesh, Camera, Light). Shortcut for the first element of entities.
entitieslist[Entity]All entities attached to this node (read-only). A node may reference more than one entity.
materialMaterial | NoneThe primary material assigned to this node.
materialslist[Material]All materials assigned to this node (read-only).
child_nodeslist[Node]List of child nodes. Use child_nodes: not children
parent_nodeNode | NoneImmediate parent node in the scene hierarchy
parent_nodeslist[Node]All parent nodes (supports instancing)
visibleboolWhen False, the node and its subtree are hidden in viewers that respect visibility.
excludedboolWhen True, this node is excluded from rendering
transformTransformLocal transform (translation, rotation, scale)
global_transformGlobalTransformWorld-space transformation matrix
asset_infoAssetInfo | NoneAsset metadata attached to this node, if any.
propertiesPropertyCollectionCustom properties attached to this node

Methods

MethodReturn TypeDescription
create_child_node(name)NodeCreates and attaches a new child node with the given name
create_child_node(name, entity)NodeCreates a child node and assigns an entity to it
add_child_node(node)NoneAdds an existing node as a child of this node
get_child(name)Optional[Node]Finds a direct child node by name
find_node(name)Optional[Node]Recursively finds a descendant node by name
add_entity(entity)NoneAttaches an additional entity to this node
merge(node)NoneMerges another node’s children and entities into this node
evaluate_global_transform(with_geometric_transform)Matrix4Returns the world-space transform matrix; pass True to include geometric offsets
get_bounding_box()BoundingBoxComputes the axis-aligned bounding box of the node in world space
get_property(name)AnyGets a property value by name
find_property(name)Optional[Property]Finds a property by name

Example

Create a scene, attach a mesh to a node, and traverse the scene graph:

from aspose.threed import Scene, Node
from aspose.threed.entities import Mesh
from aspose.threed.utilities import Vector4

scene = Scene()
mesh = Mesh()
mesh.control_points.append(Vector4(0, 0, 0, 1))
mesh.control_points.append(Vector4(1, 0, 0, 1))
mesh.control_points.append(Vector4(0.5, 1, 0, 1))
mesh.create_polygon(0, 1, 2)

# Attach mesh to a child node
node = scene.root_node.create_child_node("triangle", mesh)

# Traverse child_nodes (property, not a method)
for child in scene.root_node.child_nodes:
    entity = child.entity
    if entity is not None:
        print(f"Node '{child.name}': {type(entity).__name__}")
        # excluded is a property
        print(f"  Excluded: {entity.excluded}")

See Also