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.
| Methods | Methods | Methods |
|---|---|---|
entity | Entity | Optional entity to attach to the root node on creation |
parentScene | Scene | Optional parent scene (for sub-scenes); requires a name |
name | String | Scene 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
| Methods | Return Type | Methods |
|---|---|---|
Scene.fromFile(String filePath) | Scene | Loads a scene from the specified file path, detecting the format automatically. |
Scene.fromFile(String filePath, LoadOptions options) | Scene | Loads 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.
| Methods | Methods | Methods | Methods | Methods |
|---|---|---|---|---|
rootNode | Node | getRootNode() | – | Root node of the scene hierarchy |
subScenes | List<Scene> | getSubScenes() | – | Sub-scenes nested within this scene |
assetInfo | AssetInfo | getAssetInfo() | setAssetInfo(AssetInfo) | Asset metadata such as author, creation date, and units |
animationClips | List<AnimationClip> | getAnimationClips() | – | Animation clips defined in the scene |
currentAnimationClip | AnimationClip | getCurrentAnimationClip() | setCurrentAnimationClip(AnimationClip) | The currently active animation clip |
library | List<A3DObject> | getLibrary() | – | User-defined metadata objects attached to the scene |
name | String | getName() | setName(String) | Name of the scene object |
properties | PropertyCollection | getProperties() | – | Vlastní vlastnosti připojené k scéně |
Methods
| Methods | Návratový typ | Methods |
|---|---|---|
save(String filePath) | void | Uloží scénu do souboru; formát je odvozen z přípony |
save(String filePath, FileFormat format) | void | Uloží scénu do souboru ve specifikovaném FileFormat |
save(String filePath, SaveOptions options) | void | Uloží scénu pomocí formátově specifických možností ukládání |
open(String filePath) | void | Otevře soubor v této scéně; formát je odvozen z přípony |
open(String filePath, LoadOptions options) | void | Otevře soubor s formátově specifickými možnostmi načítání |
getProperty(String name) | Object | Získá hodnotu vlastnosti podle názvu |
findProperty(String name) | Property | Najde vlastnost podle názvu |
createAnimationClip(String name) | AnimationClip | Vytvoří nový pojmenovaný animační klip a přidá jej do scény |
getAnimationClip(String name) | AnimationClip | Najde existující animační klip podle názvu, nebo null pokud není nalezen |
clear() | void | Vymaž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);