Scene — Aspose.3D FOSS for .NET

Example

Example Scene class in Aspose.3D 充当 3D 内容的根容器,管理顶层对象并实现场景层次结构的父子关系管理。它提供对根节点和子场景的访问,构成加载、构建和保存 3D 场景的入口点。.

using Aspose.ThreeD;

// Create an empty scene
var scene = new Scene();

// Access the root node
Node root = scene.RootNode;

Example

Example 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;

Example

ExampleExampleExampleExample
RootNodeNode获取场景层次结构的根节点
AssetInfoAssetInfo获取/设置资产元数据,例如作者、创建日期和单位
AnimationClipsList<AnimationClip>获取场景中定义的动画剪辑
CurrentAnimationClipAnimationClip获取/设置当前激活的动画剪辑
LibraryIList<A3DObject>获取附加到场景的用户自定义元数据对象
Namestring获取/设置场景对象的名称
PropertiesPropertyCollection获取附加到场景的自定义属性

Example

Example返回类型Example
Open(string filePath)void在此场景中打开文件;格式根据扩展名推断
Open(string filePath, LoadOptions options)void使用特定格式的加载选项打开文件
Open(Stream stream)void从流中打开,自动检测
Open(Stream stream, LoadOptions options)void从流中打开,使用特定格式的加载选项
Open(Stream stream, string fileName)void从流中打开,使用文件名进行格式检测
Save(string filePath)void将场景保存到文件;格式根据扩展名推断
Save(string filePath, FileFormat format)void在指定的(位置)保存场景 FileFormat
Save(string filePath, SaveOptions options)void使用特定格式的保存选项进行保存
Save(Stream stream, SaveOptions options)void使用特定格式的保存选项保存到流
CreateAnimationClip(string name)AnimationClip创建一个新的具名动画剪辑
GetAnimationClip(string name)AnimationClip按名称查找已有的动画剪辑,或 null 如果未找到
Clear()void清除场景中的所有内容

Example

创建一个场景,添加一个盒子节点,并保存为 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");

另见

 中文