Entity — Aspose.3D FOSS for Java
Overview
The Entity class is the abstract base class for objects that can be attached to a Node in the Aspose.3D scene graph. Concrete subclasses include Mesh, Camera, Light, and Geometry. Entity provides access to the parent node hierarchy and exposes the getExcluded() method for visibility control.
import com.aspose.threed.Scene;
import com.aspose.threed.*;
Scene scene = Scene.fromFile("model.obj");
for (Node node : scene.getRootNode().getChildNodes()) {
Entity entity = node.getEntity();
if (entity != null) {
if (!entity.getExcluded()) {
Node parent = entity.getParentNode();
System.out.println("Active entity '" + entity.getName()
+ "', parent: " + (parent != null ? parent.getName() : "None"));
}
}
}Inheritance
A3DObject -> SceneObject -> Entity
Subclasses: Geometry -> Mesh, Camera, Light, and others.
Constructor
Entity is an abstract base class and is not instantiated directly. Use a concrete subclass such as Mesh.
Properties
| Name | Type | Getter | Setter | Description |
|---|---|---|---|---|
parentNodes | List<Node> | getParentNodes() | – | All parent nodes to which this entity is attached. Supports instancing (same entity referenced from multiple nodes). |
parentNode | Node | getParentNode() | setParentNode(Node) | The primary parent node, or null if the entity is not attached. |
excluded | boolean | getExcluded() | setExcluded(boolean) | When true, this entity is excluded from rendering. |
name | String | getName() | setName(String) | Human-readable name for this entity. |
properties | PropertyCollection | getProperties() | – | Collection of custom properties. |
Methods
| Method | Return Type | Description |
|---|---|---|
getProperty(String name) | Object | Gets a property value by name. |
findProperty(String name) | Property | Finds a property by name. |
Example
Inspect entity state after loading a scene:
import com.aspose.threed.Scene;
import com.aspose.threed.Node;
import com.aspose.threed.Entity;
import com.aspose.threed.*;
Scene scene = Scene.fromFile("model.stl");
for (Node node : scene.getRootNode().getChildNodes()) {
Entity entity = node.getEntity();
if (entity == null) continue;
System.out.println("Entity: " + (entity.getName().isEmpty() ? "(unnamed)" : entity.getName()));
System.out.println(" Type: " + entity.getClass().getSimpleName());
System.out.println(" Excluded: " + entity.getExcluded());
System.out.println(" Parent node: "
+ (entity.getParentNode() != null ? entity.getParentNode().getName() : "None"));
if (entity instanceof Mesh) {
Mesh mesh = (Mesh) entity;
System.out.println(" Vertices: " + mesh.getControlPoints().size());
System.out.println(" Polygons: " + mesh.getPolygonCount());
}
}