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

NameTypeAccessDescription
RootNodeNodegetRoot node of the scene hierarchy
AssetInfoAssetInfoget/setAsset metadata such as author, creation date, and units
AnimationClipsList<AnimationClip>getAnimation clips defined in the scene
CurrentAnimationClipAnimationClipget/setThe currently active animation clip
LibraryIList<A3DObject>getUser-defined metadata objects attached to the scene
Namestringget/setName of the scene object
PropertiesPropertyCollectiongetCustom properties attached to the scene

Methods

MethodReturn TypeDescription
Open(string filePath)voidOpens a file into this scene; format inferred from extension
Open(string filePath, LoadOptions options)voidOpens a file with format-specific load options
Open(Stream stream)voidOpens from a stream with auto-detection
Open(Stream stream, LoadOptions options)voidOpens from a stream with format-specific load options
Open(Stream stream, string fileName)voidOpens from a stream, using the file name for format detection
Save(string filePath)voidSaves the scene to a file; format inferred from extension
Save(string filePath, FileFormat format)voidSaves the scene in the specified FileFormat
Save(string filePath, SaveOptions options)voidSaves using format-specific save options
Save(Stream stream, SaveOptions options)voidSaves to a stream using format-specific save options
CreateAnimationClip(string name)AnimationClipCreates a new named animation clip
GetAnimationClip(string name)AnimationClipFinds an existing animation clip by name, or null if not found
Clear()voidClears 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");

See Also