Scene

Methods

Methods Scene class in Aspose.3D serves as the root container for 3D content, managing top-level objects and enabling parent/child relationship management for the scene hierarchy. It provides access to root nodes and sub-scenes, forming the entry point for loading, constructing, and saving 3D scenes.

from aspose.threed import Scene

# Create an empty scene
scene = Scene()

# Access the root node: root_node is a property, not a method call
root = scene.root_node

Methods

Methods Scene class can be instantiated with no arguments to create an empty scene, or with optional parameters.

MethodsMethodsMethods
namestrOptional name of the scene
entityEntityOptional entity to attach to the root node on creation
parent_sceneSceneOptional parent scene (for sub-scenes)
from aspose.threed import Scene

# Empty scene
scene = Scene()

# Access the root node (property, not a method)
root = scene.root_node

Metode Kelas

MethodsTipe PengembalianMethods
Scene.from_file(file_path)SceneMemuat adegan dari jalur file yang ditentukan, mendeteksi format secara otomatis. Menerima tepat satu argumen.
from aspose.threed import Scene
from aspose.threed.formats import ObjLoadOptions

# Load from file (format detected from extension)
scene = Scene.from_file("model.obj")

# To pass load options, use scene.open() instead:
opts = ObjLoadOptions()
scene = Scene()
scene.open("model.obj", opts)

Methods

root_node dan atribut tingkat adegan lainnya adalah properti; akses mereka tanpa tanda kurung.

MethodsMethodsMethods
root_nodeNodeNode akar dari hierarki adegan. Diakses sebagai properti: scene.root_node
sub_sceneslist[Scene]Sub-adegan yang bersarang dalam adegan ini
asset_infoAssetInfoMetadata aset seperti penulis, tanggal pembuatan, dan satuan
animation_clipslist[AnimationClip]Klip animasi yang didefinisikan dalam adegan
current_animation_clip`AnimationClipNone`
librarylist[CustomObject]Objek metadata yang didefinisikan pengguna yang terlampir pada adegan.
namestrNama objek adegan
propertiesPropertyCollectionProperti khusus yang terlampir pada adegan

Methods

MethodsTipe PengembalianMethods
save(file_path)NoneMenyimpan adegan ke file; format diperkirakan dari ekstensi
save(file_path, format)NoneMenyimpan adegan ke file dalam yang ditentukan FileFormat
save(file_path, options)NoneMenyimpan adegan menggunakan opsi penyimpanan khusus format
get_property(name)AnyMendapatkan nilai properti berdasarkan nama
find_property(name)Optional[Property]Menemukan properti berdasarkan nama
create_animation_clip(name)AnimationClipMembuat klip animasi bernama baru dan menambahkannya ke adegan
get_animation_clip(name)`AnimationClipNone`
clear()NoneMenghapus semua konten dari adegan

Catatan: root_node adalah properti pada Scene kelas, bukan metode. Jangan menulis scene.root_node(); akses yang benar adalah scene.root_node.

Methods

Buat sebuah adegan, tambahkan node mesh, dan simpan ke GLB:

from aspose.threed import Scene
from aspose.threed.entities import Mesh
from aspose.threed.formats import GltfSaveOptions
from aspose.threed.utilities import Vector4

# Create scene and mesh
# Note: control_points returns a copy — use _control_points to add vertices
scene = Scene()
mesh = Mesh()
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)

# Add node to root: root_node is a property
node = scene.root_node.create_child_node("triangle", mesh)

# Save as GLB using GltfSaveOptions with binary_mode
opts = GltfSaveOptions()
opts.binary_mode = True
scene.save("triangle.glb", opts)

Lihat Juga

 Bahasa Indonesia