Node — Aspose.3D FOSS for Java

Overview

The Node class represents a named element in the Aspose.3D scene graph. Each node can hold one Entity (such as a Mesh or Camera), 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.

import com.aspose.threed.Scene;
import com.aspose.threed.Node;

Scene scene = new Scene();

// Access the root node via getter
Node root = scene.getRootNode();

// Create a child node
Node child = root.createChildNode("my_node");

// Iterate child nodes via getter
for (Node node : root.getChildNodes()) {
    System.out.println(node.getName());
}

Constructor

The Node constructor initializes a node with an optional name.

ParameterTypeDescription
nameStringOptional name for the node

Properties

All node attributes are accessed via getter/setter methods.

NameTypeGetterSetterDescription
nameStringgetName()setName(String)Human-readable identifier for the node
entityEntitygetEntity()setEntity(Entity)The primary entity attached to this node (e.g., Mesh, Camera). Shortcut for the first element of getEntities().
entitiesList<Entity>getEntities()All entities attached to this node (read-only)
materialMaterialgetMaterial()setMaterial(Material)The primary material assigned to this node
materialsList<Material>getMaterials()All materials assigned to this node (read-only)
childNodesList<Node>getChildNodes()List of child nodes
parentNodeNodegetParentNode()setParentNode(Node)Immediate parent node in the scene hierarchy
parentNodesList<Node>getParentNodes()All parent nodes (inherited from Entity; supports instancing)
visiblebooleangetVisible()setVisible(boolean)When false, the node and its subtree are hidden
excludedbooleangetExcluded()setExcluded(boolean)When true, this node is excluded from rendering
transformTransformgetTransform()Local transform (translation, rotation, scale)
globalTransformGlobalTransformgetGlobalTransform()World-space transformation matrix
assetInfoAssetInfogetAssetInfo()setAssetInfo(AssetInfo)Asset metadata attached to this node, if any
propertiesPropertyCollectiongetProperties()Custom properties attached to this node

Methods

MethodReturn TypeDescription
createChildNode(String name)NodeCreates and attaches a new child node with the given name
createChildNode(String name, Entity entity)NodeCreates a child node and assigns an entity to it
addChildNode(Node node)voidAdds an existing node as a child of this node
getChild(String name)NodeFinds a direct child node by name
addEntity(Entity entity)voidAttaches an additional entity to this node
merge(Node node)voidMerges another node’s children and entities into this node
evaluateGlobalTransform(boolean withGeometricTransform)Matrix4Returns the world-space transform matrix; pass true to include geometric offsets
getBoundingBox()BoundingBoxComputes the axis-aligned bounding box of the node in world space
getProperty(String name)ObjectGets a property value by name
findProperty(String name)PropertyFinds a property by name

Example

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

import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.*;


Scene scene = new Scene();
Mesh mesh = new Mesh();
mesh.getControlPoints().add(new Vector4(0, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(1, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);

// Attach mesh to a child node
Node node = scene.getRootNode().createChildNode("triangle", mesh);

// Traverse child nodes using getter
for (Node child : scene.getRootNode().getChildNodes()) {
    Entity entity = child.getEntity();
    if (entity != null) {
        System.out.println("Node '" + child.getName() + "': " + entity.getClass().getSimpleName());
        System.out.println("  Excluded: " + child.getExcluded());
    }
}

See Also