Node
Methods
Methods Node class đại diện cho một phần tử có tên trong đồ thị cảnh Aspose.3D. Mỗi node có thể chứa một Entity (như một Mesh, Camera, hoặc Light), duy trì quan hệ cha-con với các node khác, và mang một phép biến đổi cục bộ. Các node là cách chính để tổ chức các đối tượng 3D trong một cây phân cấp cảnh.
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)Methods
Methods Node constructor khởi tạo một node với tên tùy chọn.
| Methods | Methods | Methods |
|---|---|---|
name | str | Tên tùy chọn cho node |
Methods
Tất cả các thuộc tính của node bên dưới là các thuộc tính; truy cập chúng mà không cần dấu ngoặc đơn.
| Methods | Methods | Methods |
|---|---|---|
name | str | Định danh có thể đọc được cho node |
entity | `Entity | None` |
entities | list[Entity] | Tất cả các thực thể được gắn vào node này (chỉ đọc). Một node có thể tham chiếu nhiều hơn một thực thể. |
material | `Material | None` |
materials | list[Material] | Tất cả các vật liệu được gán cho node này (chỉ đọc). |
child_nodes | list[Node] | Danh sách các node con. Sử dụng child_nodes: không children |
parent_node | `Node | None` |
parent_nodes | list[Node] | Tất cả các nút cha (kế thừa từ Entity; hỗ trợ instancing) |
visible | bool | Methods False, nút và cây con của nó bị ẩn trong các trình xem tôn trọng tính hiển thị. |
excluded | bool | Methods True, nút này bị loại trừ khỏi việc render |
transform | Transform | Biến đổi cục bộ (dịch chuyển, quay, tỷ lệ) |
global_transform | GlobalTransform | Ma trận biến đổi không gian thế giới |
asset_info | `AssetInfo | None` |
properties | PropertyCollection | Thuộc tính tùy chỉnh được gắn vào nút này |
Methods
| Methods | Kiểu trả về | Methods |
|---|---|---|
create_child_node(name) | Node | Tạo và gắn một nút con mới với tên đã cho |
create_child_node(name, entity) | Node | Tạo một nút con và gán một thực thể cho nó |
add_child_node(node) | None | Thêm một nút hiện có làm con của nút này |
get_child(name) | Optional[Node] | Tìm một nút con trực tiếp theo tên |
add_entity(entity) | None | Gắn một thực thể bổ sung vào nút này |
merge(node) | None | Hợp nhất các nút con và thực thể của một nút khác vào nút này |
evaluate_global_transform(with_geometric_transform) | Matrix4 | Trả về ma trận biến đổi không gian thế giới; truyền True để bao gồm các độ dịch hình học |
get_bounding_box() | BoundingBox | Tính hộp bao trục trục của nút trong không gian thế giới |
get_property(name) | Any | Lấy giá trị thuộc tính theo tên |
find_property(name) | Optional[Property] | Tìm thuộc tính theo tên |
Methods
Tạo một scene, gắn một mesh vào node, và duyệt đồ thị cảnh:
from aspose.threed import Scene, Node
from aspose.threed.entities import Mesh
from aspose.threed.utilities import Vector4
scene = Scene()
mesh = Mesh()
# Use _control_points to mutate the backing list (control_points returns a copy)
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}")