Node
Methods
Methods Node class mewakili elemen bernama dalam Aspose.3D scene graph. Setiap node dapat menampung satu Entity (seperti sebuah Mesh, Camera, atau Light), mempertahankan hubungan parent-child dengan node lain, dan membawa transformasi lokal. Node adalah cara utama untuk mengatur objek 3D dalam 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)Methods
Methods Node constructor menginisialisasi node dengan nama opsional.
| Methods | Methods | Methods |
|---|---|---|
name | str | Nama opsional untuk node |
Methods
Semua atribut node di bawah ini adalah properti; akses mereka tanpa tanda kurung.
| Methods | Methods | Methods |
|---|---|---|
name | str | Pengidentifikasi yang dapat dibaca manusia untuk node |
entity | `Entity | None` |
entities | list[Entity] | Semua entitas yang terlampir pada node ini (hanya-baca). Sebuah node dapat merujuk lebih dari satu entitas. |
material | `Material | None` |
materials | list[Material] | Semua material yang ditetapkan untuk node ini (hanya-baca). |
child_nodes | list[Node] | Daftar node anak. Gunakan child_nodes: tidak children |
parent_node | `Node | None` |
parent_nodes | list[Node] | Semua node induk (diturunkan dari Entity; mendukung instansi) |
visible | bool | Methods False, node dan subpohon‑nya disembunyikan di penampil yang menghormati visibilitas. |
excluded | bool | Methods True, node ini dikecualikan dari rendering |
transform | Transform | Transformasi lokal (translasi, rotasi, skala) |
global_transform | GlobalTransform | Matriks transformasi ruang‑dunia |
asset_info | `AssetInfo | None` |
properties | PropertyCollection | Properti khusus yang terlampir pada node ini |
Methods
| Methods | Tipe Pengembalian | Methods |
|---|---|---|
create_child_node(name) | Node | Membuat dan melampirkan node anak baru dengan nama yang diberikan |
create_child_node(name, entity) | Node | Membuat node anak dan menetapkan entitas padanya |
add_child_node(node) | None | Menambahkan node yang ada sebagai anak dari node ini |
get_child(name) | Optional[Node] | Menemukan node anak langsung berdasarkan nama |
add_entity(entity) | None | Melampirkan entitas tambahan ke node ini |
merge(node) | None | Menggabungkan anak dan entitas node lain ke dalam node ini |
evaluate_global_transform(with_geometric_transform) | Matrix4 | Mengembalikan matriks transformasi ruang‑dunia; lewati True untuk menyertakan offset geometris |
get_bounding_box() | BoundingBox | Menghitung kotak pembatas yang sejajar sumbu dari node dalam ruang‑dunia |
get_property(name) | Any | Mendapatkan nilai properti berdasarkan nama |
find_property(name) | Optional[Property] | Menemukan properti berdasarkan nama |
Methods
Buat sebuah scene, lampirkan mesh ke sebuah node, dan telusuri grafik adegan:
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}")