Scene — Aspose.3D FOSS for Java

Example

Example Scene Aspose.3D의 클래스는 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 클래스는 인자를 제공하지 않아 빈 씬을 생성하거나, 선택적 매개변수를 사용하여 인스턴스화할 수 있습니다.

ExampleExampleExample
entityEntity생성 시 루트 노드에 연결할 선택적 엔티티
parentSceneScene선택적 부모 씬(서브 씬용); 이름이 필요합니다
nameString씬 이름(두 인자 생성자와 함께 사용할 때만 적용 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);

참고

 한국어