Scene — Aspose.3D FOSS for Java
Example
Example Scene Aspose.3D の class は 3D コンテンツのルートコンテナとして機能し、トップレベルオブジェクトを管理し、シーン階層の親子関係管理を可能にします。ルートノードとサブシーンへのアクセスを提供し、3D シーンのロード、構築、保存のエントリーポイントを形成します。.
import com.aspose.threed.Scene;
// Create an empty scene
Scene scene = new Scene();
// Access the root node via getter method
Node root = scene.getRootNode();Example
Example Scene class は引数なしでインスタンス化して空のシーンを作成することも、オプションのパラメータを指定してインスタンス化することもできます。.
| Example | Example | Example |
|---|---|---|
entity | Entity | 作成時にルートノードに添付するオプションのエンティティ |
parentScene | Scene | オプションの親シーン(サブシーン用);名前が必要です |
name | String | シーン名(2 引数の Scene(Scene, String) コンストラクタ) |
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();クラスメソッド
| Example | 戻り値の型 | Example |
|---|---|---|
Scene.fromFile(String filePath) | Scene | 指定されたファイルパスからシーンをロードし、フォーマットを自動的に検出します。. |
Scene.fromFile(String filePath, LoadOptions options) | Scene | フォーマット固有のロードオプションでシーンをロードします。. |
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);Example
すべてのプロパティは getter / setter メソッドを通じてアクセスされます。.
| Example | Example | Example | Example | Example |
|---|---|---|---|---|
rootNode | Node | getRootNode() | – | シーン階層のルートノード |
subScenes | List<Scene> | getSubScenes() | – | このシーンにネストされたサブシーン |
assetInfo | AssetInfo | getAssetInfo() | setAssetInfo(AssetInfo) | 作者、作成日、単位などのアセットメタデータ |
animationClips | List<AnimationClip> | getAnimationClips() | – | シーンで定義されたアニメーションクリップ |
currentAnimationClip | AnimationClip | getCurrentAnimationClip() | setCurrentAnimationClip(AnimationClip) | 現在アクティブなアニメーションクリップ |
library | List<A3DObject> | getLibrary() | – | シーンに添付されたユーザー定義のメタデータオブジェクト |
name | String | getName() | setName(String) | シーンオブジェクトの名前 |
properties | PropertyCollection | getProperties() | – | シーンに添付されたカスタムプロパティ |
Example
| Example | 戻り値の型 | Example |
|---|---|---|
save(String filePath) | void | シーンをファイルに保存します。形式は拡張子から推測されます |
save(String filePath, FileFormat format) | void | 指定された形式でシーンをファイルに保存します FileFormat |
save(String filePath, SaveOptions options) | void | 形式固有の保存オプションを使用してシーンを保存します |
open(String filePath) | void | このシーンにファイルを開きます。形式は拡張子から推測されます |
open(String filePath, LoadOptions options) | void | 形式固有のロードオプションでファイルを開きます |
getProperty(String name) | Object | 名前でプロパティ値を取得します |
findProperty(String name) | Property | 名前でプロパティを検索します |
createAnimationClip(String name) | AnimationClip | 新しい名前付きアニメーションクリップを作成し、シーンに追加します |
getAnimationClip(String name) | AnimationClip | 名前で既存のアニメーションクリップを検索し、または null 見つからない場合 |
clear() | void | シーンからすべてのコンテンツをクリアします |
Example
シーンを作成し、メッシュノードを追加して、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);