Scene Management

Scene Management

The Scene class is the entry point for all 3D content in Aspose.3D for .NET. It provides methods to create scenes from scratch, load existing files in any supported format, save to any target format, and inspect scene metadata.


Creating and Opening Scenes

Create an empty scene with new Scene(), or load from a file:

using Aspose.ThreeD;

// Empty scene
var empty = new Scene();

// Load from file — format is detected automatically
var scene = Scene.FromFile("model.fbx");

// Load using Scene.Open with explicit format
var scene2 = new Scene();
scene2.Open("model.obj", FileFormat.WavefrontOBJ);

// Load from a stream (useful when reading from memory or network)
using var stream = System.IO.File.OpenRead("model.stl");
var scene3 = new Scene();
scene3.Open(stream, FileFormat.STL);

Scene.FromFile auto-detects the format from the file extension and magic bytes. Use the FileFormat overload when the extension is ambiguous or absent.


Saving Scenes

Save a scene to a file or stream in any supported output format:

// Save to file — format determined from extension
scene.Save("output.gltf");

// Save with explicit format
scene.Save("output.bin", FileFormat.GLTF2_Binary);

// Save to a stream
using var output = System.IO.File.Create("output.fbx");
scene.Save(output, FileFormat.FBX7700Binary);

// Save with format-specific options
var opts = new Aspose.ThreeD.Formats.ObjSaveOptions();
opts.PointCloud = false;
scene.Save("output.obj", opts);

Clearing Scene Content

To remove all nodes and assets from a scene while retaining the Scene object:

// Remove all direct children of the root node
scene.RootNode.ChildNodes.Clear();

// Or replace the scene entirely
scene = new Scene();

Scene.Clear() is not available; create a new Scene instance or selectively remove nodes via Node.RemoveChildNode(node).


Scene Metadata

The AssetInfo property on a Scene exposes metadata embedded in supported formats (FBX, Collada, glTF):

var info = scene.AssetInfo;
Console.WriteLine("Creator:      " + info.Creator);
Console.WriteLine("Creation UTC: " + info.CreationTime);
Console.WriteLine("Units:        " + info.UnitName + " @ " + info.UnitScaleFactor);

Set metadata before saving to preserve it in the output file:

scene.AssetInfo.Creator = "My Application 1.0";
scene.AssetInfo.UnitName = "meter";
scene.AssetInfo.UnitScaleFactor = 1.0;
scene.Save("output_with_meta.fbx");

API Quick Reference

MemberDescription
new Scene()Create an empty scene
Scene.FromFile(path)Static helper: open a file and return the loaded scene
scene.Open(path, format?)Load a file into an existing scene
scene.Open(stream, format)Load from a stream
scene.Save(path, format?)Save to a file
scene.Save(stream, format)Save to a stream
scene.RootNodeRoot Node of the scene hierarchy
scene.AssetInfoMetadata block (creator, timestamps, units)
scene.AssetInfo.CreatorApplication name embedded in the file
scene.AssetInfo.UnitScaleFactorScene unit scale relative to meters

See Also