Scene — Aspose.3D FOSS for Java

Methods

Methods 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.

import com.aspose.threed.Scene;

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

// Access the root node via getter method
Node root = scene.getRootNode();

Methods

Methods Scene class can be instantiated with no arguments to create an empty scene, or with optional parameters.

MethodsMethodsMethods
entityEntityOptional entity to attach to the root node on creation
parentSceneSceneOptional parent scene (for sub-scenes); requires a name
nameStringScene name (only used with the two-argument Scene(Scene, String) constructor)
import com.aspose.threed.Scene;

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

// Scene with an initial entity
Scene scene = new Scene(new Mesh());

// Access the root node (getter method)
Node root = scene.getRootNode();

Metody třídy

MethodsReturn TypeMethods
Scene.fromFile(String filePath)SceneLoads a scene from the specified file path, detecting the format automatically.
Scene.fromFile(String filePath, LoadOptions options)SceneLoads a scene with format-specific load options.
import com.aspose.threed.Scene;


// Load from file (format detected from extension)
Scene scene = Scene.fromFile("model.obj");

// Load with options
ObjLoadOptions opts = new ObjLoadOptions();
Scene scene = Scene.fromFile("model.obj", opts);

Methods

Všechny vlastnosti jsou přístupné pomocí metod getter/setter.

MethodsMethodsMethodsMethodsMethods
rootNodeNodegetRootNode()Root node of the scene hierarchy
subScenesList<Scene>getSubScenes()Sub-scenes nested within this scene
assetInfoAssetInfogetAssetInfo()setAssetInfo(AssetInfo)Asset metadata such as author, creation date, and units
animationClipsList<AnimationClip>getAnimationClips()Animation clips defined in the scene
currentAnimationClipAnimationClipgetCurrentAnimationClip()setCurrentAnimationClip(AnimationClip)The currently active animation clip
libraryList<A3DObject>getLibrary()User-defined metadata objects attached to the scene
nameStringgetName()setName(String)Name of the scene object
propertiesPropertyCollectiongetProperties()Vlastní vlastnosti připojené k scéně

Methods

MethodsNávratový typMethods
save(String filePath)voidUloží scénu do souboru; formát je odvozen z přípony
save(String filePath, FileFormat format)voidUloží scénu do souboru ve specifikovaném FileFormat
save(String filePath, SaveOptions options)voidUloží scénu pomocí formátově specifických možností ukládání
open(String filePath)voidOtevře soubor v této scéně; formát je odvozen z přípony
open(String filePath, LoadOptions options)voidOtevře soubor s formátově specifickými možnostmi načítání
getProperty(String name)ObjectZíská hodnotu vlastnosti podle názvu
findProperty(String name)PropertyNajde vlastnost podle názvu
createAnimationClip(String name)AnimationClipVytvoří nový pojmenovaný animační klip a přidá jej do scény
getAnimationClip(String name)AnimationClipNajde existující animační klip podle názvu, nebo null pokud není nalezen
clear()voidVymaže veškerý obsah ze scény

Methods

Vytvořte scénu, přidejte uzel mesh a uložte do GLB:

import com.aspose.threed.Scene;
import com.aspose.threed.FileFormat;



// Create scene and mesh
Scene scene = new Scene();
Mesh mesh = new Mesh();
mesh.getControlPoints().add(new Vector4(0, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(1, 0, 0, 1));
mesh.getControlPoints().add(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);

// Add node to root
Node node = scene.getRootNode().createChildNode("triangle", mesh);

// Save as GLB
GltfSaveOptions glbOpts = new GltfSaveOptions();
glbOpts.setContentType(FileContentType.BINARY);
scene.save("triangle.glb", glbOpts);

Viz také

 Čeština