Scene — Aspose.3D FOSS for .NET
Overview
The 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.
using Aspose.ThreeD;
// Create an empty scene
var scene = new Scene();
// Access the root node
Node root = scene.RootNode;Constructor
The Scene class can be instantiated with no arguments to create an empty scene.
using Aspose.ThreeD;
// Empty scene
var scene = new Scene();
// Set name via property
scene.Name = "myScene";
// Access the root node
Node root = scene.RootNode;Properties
| Name | Type | Access | Description |
|---|---|---|---|
RootNode | Node | get | Root node of the scene hierarchy |
AssetInfo | AssetInfo | get/set | Asset metadata such as author, creation date, and units |
AnimationClips | List<AnimationClip> | get | Animation clips defined in the scene |
CurrentAnimationClip | AnimationClip | get/set | The currently active animation clip |
Library | IList<A3DObject> | get | User-defined metadata objects attached to the scene |
Name | string | get/set | Name of the scene object |
Properties | PropertyCollection | get | Custom properties attached to the scene |
Methods
| Method | Return Type | Description |
|---|---|---|
Open(string filePath) | void | Opens a file into this scene; format inferred from extension |
Open(string filePath, LoadOptions options) | void | Opens a file with format-specific load options |
Open(Stream stream) | void | Opens from a stream with auto-detection |
Open(Stream stream, LoadOptions options) | void | Opens from a stream with format-specific load options |
Open(Stream stream, string fileName) | void | Opens from a stream, using the file name for format detection |
Save(string filePath) | void | Saves the scene to a file; format inferred from extension |
Save(string filePath, FileFormat format) | void | Saves the scene in the specified FileFormat |
Save(string filePath, SaveOptions options) | void | Saves using format-specific save options |
Save(Stream stream, SaveOptions options) | void | Saves to a stream using format-specific save options |
CreateAnimationClip(string name) | AnimationClip | Creates a new named animation clip |
GetAnimationClip(string name) | AnimationClip | Finds an existing animation clip by name, or null if not found |
Clear() | void | Clears all content from the scene |
Example
Create a scene, add a box node, and save to GLB:
using Aspose.ThreeD;
using Aspose.ThreeD.Entities;
using Aspose.ThreeD.Formats;
// Create scene with a box primitive
var scene = new Scene();
var box = new Box(2, 2, 2);
var node = scene.RootNode.CreateChildNode("BoxNode", box);
// Save as GLB (format inferred from .glb extension)
scene.Save("box.glb");