Scene

패키지: @aspose/3d (v24.12.0)

Scene은 3D 씬 그래프의 루트 컨테이너입니다. @aspose/3d. 노드 계층 구조, 메타데이터 및 애니메이션 클립을 보유하며, 3D 파일을 로드하고 저장하기 위한 기본 I/O 인터페이스를 제공합니다.

export class Scene extends SceneObject

ColladaSaveOptions

A3DObject ← SceneObject ← Scene

ColladaSaveOptions

OBJ 파일을 로드하고 씬 그래프 루트의 자식 노드 수를 출력합니다.

import { Scene } from '@aspose/3d';

const scene = new Scene();
scene.open('model.obj');

function countNodes(node: any): number {
  let total = 1;
  for (const child of node.childNodes) {
    total += countNodes(child);
  }
  return total;
}

const nodeCount = countNodes(scene.rootNode);
console.log(`Total nodes in scene: ${nodeCount}`);

ColladaSaveOptions

NameTypeAccessDescription
VERSION``ReadGets the version.
rootNodeNodeReadGets the root node.
subScenesScene[]ReadGets the sub scenes.
libraryCustomObject[]ReadGets the library.
assetInfoAssetInfoRead/WriteGets the asset info.
animationClipsAnimationClip[]ReadGets the animation clips.
currentAnimationClip`AnimationClipnull`Read/Write
posesany[]ReadGets the poses.
SignatureDescription
constructor()Creates a scene containing the specified entity
constructor(entity: Entity)
constructor(parentScene: Scene, name: string)
constructor()
clear()Removes all nodes, assets and animation data from the scene
createAnimationClip(name: string)AnimationClipCreates a new animation clip with the given name
getAnimationClip(name: string) → `AnimationClipnull`
open(fileOrStream: any, options: any)Loads scene data from a file path or stream using options
`openFromBuffer(buffer: BufferUint8Array, options: any)`
save(fileOrStream: any, formatOrOptions: any, options: any)Writes the scene to a file or stream
saveToBuffer(format: string, _options: any)BufferReturns a Buffer containing the scene in the given format
render(_camera: any, _file_name_or_bitmap: any, _size: any, _format: any, _options: any)Not implemented in the FOSS edition — throws at runtime. Renders the scene with the camera to an image
fromFile(fileName: string)SceneLoads a scene from the specified file and returns the scene
toString()string

ColladaSaveOptions

open(fileOrStream, options?)

파일 경로 또는 Buffer 씬에 로드하여 기존 콘텐츠를 교체합니다.

open(fileOrStream: string | Buffer, options?: LoadOptions): void

ColladaSaveOptions

fileOrStream string | Buffer

소스 파일 경로 또는 Buffer 원시 파일 데이터를 포함하는.

options LoadOptions (옵션)

포맷별 로드 옵션. Pass undefined 기본값을 사용하려면.

ColladaSaveOptions

void

ColladaSaveOptions

const scene = new Scene(); scene.open(‘input.fbx’); console.log(Loaded scene with root node: ${scene.rootNode.name});


---

### openFromBuffer(buffer, options?)

메모리 내에서 3D 파일을 로드합니다 `Buffer`. 파일 데이터가 이미 메모리로 읽혀진 경우 선호되는 오버로드입니다.

```typescript
openFromBuffer(buffer: Buffer, options?: LoadOptions): void

ColladaSaveOptions

buffer Buffer

Node.js Buffer 전체 파일 내용을 포함합니다.

options LoadOptions (옵션)

포맷별 로드 옵션.

ColladaSaveOptions

void

ColladaSaveOptions

import { Scene } from '@aspose/3d';
import { readFileSync } from 'fs';

const data = readFileSync('model.glb');
const scene = new Scene();
scene.openFromBuffer(data);
console.log(`Animation clips: ${scene.animationClips.length}`);

save(fileOrStream, formatOrOptions?, options?)

씬을 파일에 저장합니다. 형식은 파일 확장자에서 추론되며, 형식에 특화된 SaveOptions 인스턴스(또는 FileFormat 싱글톤) 을 두 번째 인수로 전달합니다.

save(fileOrStream: string, formatOrOptions?: FileFormat | SaveOptions, options?: SaveOptions): void

ColladaSaveOptions

fileOrStream string

대상 파일 경로입니다. 확장자는 출력 형식을 결정합니다(예,., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (옵션)

형식 싱글톤 중 하나(예,., GltfFormat.getInstance()) SaveOptions 서브클래스.

options SaveOptions (옵션)

특정 형식에 대한 저장 옵션 when a FileFormat 두 번째 인수로 전달될 때.

ColladaSaveOptions

void

ColladaSaveOptions

const scene = new Scene(); scene.open(‘input.obj’);

// Format inferred from extension scene.save(‘output.glb’); console.log(‘Scene saved as GLB.’);


---

### createAnimationClip(name)

새로운 이름이 지정된 애니메이션 클립을 생성하고 이를 씬의 `animationClips` 컬렉션에.

```typescript
createAnimationClip(name: string): AnimationClip

ColladaSaveOptions

name string

Vector2 및 Vector4 — @aspose/3d에서 UV 좌표와 동차 위치에 사용되는 2·4 구성 요소의 배정밀도 벡터.

ColladaSaveOptions

AnimationClip

새로 생성된 AnimationClip 인스턴스.

ColladaSaveOptions

const scene = new Scene(); const clip = scene.createAnimationClip(‘WalkCycle’); console.log(Created clip: ${clip.name}); console.log(Total clips: ${scene.animationClips.length});

 한국어