Scene

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

| ————————- | ————————- | —————————————————— | | name | str | Optional name of the scene | | entity | Entity | Optional entity to attach to the root node on creation | | parent_scene | Scene | Optional 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 klase

| ————————————- | ———– | ——————————————————————————- | | Scene.from_file(file_path) | Scene | Loads a scene from the specified file path, detecting the format automatically. | | Scene.from_file(file_path, options) | Scene | Loads a scene with format-specific load options. |

from aspose.threed import Scene
from aspose.threed.formats import ObjLoadOptions

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

# Load with options
opts = ObjLoadOptions()
scene = Scene.from_file("model.obj", opts)

root_node and other scene-level attributes are properties; access them without parentheses.

| ————————- | ————————- | ————————————————————————- | | root_node | Node | Root node of the scene hierarchy. Access as a property: scene.root_node | | sub_scenes | list[Scene] | Sub-scenes nested within this scene | | asset_info | AssetInfo | Asset metadata such as author, creation date, and units | | animation_clips | list[AnimationClip] | Animation clips defined in the scene | | current_animation_clip | AnimationClip | None | The currently active animation clip. Read/write. | | library | list[CustomObject] | Korisnički definirani objekti metapodataka priloženi sceni. | | name | str | Naziv objekta scene | | properties | PropertyCollection | Prilagođena svojstva priložena sceni |

| —————————– | ———————— | —————————————————————————— | | save(file_path) | None | Spremi scenu u datoteku; format se zaključuje iz ekstenzije | | save(file_path, format) | None | Spremi scenu u datoteku u navedenom FileFormat | | save(file_path, options) | None | Spremi scenu koristeći opcije specifične za format | | get_property(name) | Any | Dohvaća vrijednost svojstva po imenu | | find_property(name) | Optional[Property] | Pronalaže svojstvo po imenu | | create_animation_clip(name) | AnimationClip | Stvara novi animacijski isječak s imenom i dodaje ga u scenu | | get_animation_clip(name) | AnimationClip | None | Pronalaže postojeći animacijski isječak po imenu, ili None ako nije pronađen | | clear() | None | Čisti sav sadržaj iz scene |

Napomena: root_node je svojstvo na Scene klasi, a ne metodi. Nemojte pisati scene.root_node(); ispravan pristup je scene.root_node.

Stvorite scenu, dodajte mesh čvor i spremite u 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
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)

Vidi također

 Hrvatski