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 は引数なしでインスタンス化して空のシーンを作成することも、オプションのパラメータを指定してインスタンス化することもできます。.

ExampleExampleExample
entityEntity作成時にルートノードに添付するオプションのエンティティ
parentSceneSceneオプションの親シーン(サブシーン用);名前が必要です
nameStringシーン名(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 メソッドを通じてアクセスされます。.

ExampleExampleExampleExampleExample
rootNodeNodegetRootNode()シーン階層のルートノード
subScenesList<Scene>getSubScenes()このシーンにネストされたサブシーン
assetInfoAssetInfogetAssetInfo()setAssetInfo(AssetInfo)作者、作成日、単位などのアセットメタデータ
animationClipsList<AnimationClip>getAnimationClips()シーンで定義されたアニメーションクリップ
currentAnimationClipAnimationClipgetCurrentAnimationClip()setCurrentAnimationClip(AnimationClip)現在アクティブなアニメーションクリップ
libraryList<A3DObject>getLibrary()シーンに添付されたユーザー定義のメタデータオブジェクト
nameStringgetName()setName(String)シーンオブジェクトの名前
propertiesPropertyCollectiongetProperties()シーンに添付されたカスタムプロパティ

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

参照

 日本語