Scene Entities
Overview
Entity is the base class for everything a Node can carry: a Mesh, a Camera, a Light, or one of the parametric primitives (Box, Sphere, Cylinder, and related shapes). Every Entity shares the same property set — name, scene, properties, excluded, parent_node, parent_nodes — and the same get_bounding_box() / get_entity_renderer_key() methods.
Mesh: the core geometry entity
Mesh holds raw geometry as control_points (vertex positions) and polygons built with create_polygon(). The primitive classes construct a Mesh for you via to_mesh():
from aspose.threed.entities import Box
box = Box(10, 20, 30)
mesh = box.to_mesh()
print(f"Control points: {len(mesh.control_points)}")Mesh also exposes polygon_count, deformers, and vertex_elements for reading data loaded from a file — see Deformers for the deformer-reading workflow.
Parametric primitives
Box, Sphere, and Cylinder are Primitive subclasses with dimension properties you set at construction or afterward:
from aspose.threed import Scene
from aspose.threed.entities import Cylinder
from aspose.threed.utilities import Vector3
scene = Scene()
cylinder = Cylinder()
node = scene.root_node.create_child_node("Post", entity=cylinder.to_mesh())
node.transform.translation = Vector3(0.0, 1.0, 0.0)
node.transform.scaling = Vector3(0.5, 2.0, 0.5)
scene.save("post.obj")Each primitive has its own dimension properties: Box has length, width, height; Sphere has radius; Cylinder has radius_top, radius_bottom, and height.
Camera
Camera is an Entity with projection and framing properties (field_of_view, near_plane, far_plane, aspect, projection_type) rather than any geometry. It is attached to a node the same way a Mesh is:
from aspose.threed.entities import Camera
cam = Camera("main")
print(cam.name)Light
Light extends Camera and adds no geometry of its own either — a scene file that defines lights stores direction and target information on the Light entity, read the same way as any other Entity property.
Tips and Best Practices
- Always check
node.entity is not Nonebefore assuming a node carries geometry — many nodes in a scene graph are pure grouping nodes with no entity. - Use
type(node.entity).__name__to branch logic by entity type when traversing an unfamiliar scene file. - Call to_mesh() once per primitive instance and reuse the Mesh if you need the same geometry on more than one node.
- Camera and Light entities carry no control_points — do not call Mesh-only methods like create_polygon() on them.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
| AttributeError calling control_points on a Camera | Camera is not a Mesh and has no vertex geometry | Check the entity type with type(node.entity).name before calling Mesh-specific methods |
| Box/Sphere/Cylinder look the same size regardless of arguments | Dimension arguments passed positionally in the wrong order | Use keyword arguments matching the documented property names (length, width, height for Box; radius for Sphere) |
| to_mesh() called repeatedly is slow | Each to_mesh() call rebuilds geometry from the primitive’s parameters | Call to_mesh() once and reuse the resulting Mesh object |
FAQ
Is every Node’s entity guaranteed to be a Mesh?
No. node.entity can be a Mesh, a Camera, a Light, or None for a pure grouping node. Always check the type before assuming Mesh-specific methods are available.
Do primitives like Box store their geometry directly?
No — Box, Sphere, and Cylinder store only their shape parameters (length, radius, and so on). Calling to_mesh() generates the actual Mesh with control_points and polygons on demand.
Can a Camera or Light have its own child nodes?
Yes — any Node can have child nodes regardless of what entity, if any, it carries; the entity and the node hierarchy are independent concerns.
API Reference Summary
| Class/Method | Description |
|---|---|
| Entity | Base class for Mesh, Camera, Light, and all primitives |
| Entity.get_bounding_box() | Axis-aligned bounding box for the entity |
| Mesh | Geometry entity: control_points, polygons, vertex_elements |
| Mesh.create_polygon() | Build a polygon from control-point indices |
| Box, Sphere, Cylinder | Parametric primitives; call to_mesh() to get a Mesh |
| Camera | Projection/framing entity: field_of_view, near_plane, far_plane |
| Light | Camera subclass used for scene lighting data |