Scene

Paket: @aspose/3d (v24.12.0)

Scene, bir 3D sahne grafiği için kök kapsayıcıdır @aspose/3d. Düğüm hiyerarşisini, meta verileri ve animasyon kliplerini tutar ve 3D dosyalarını yüklemek ve kaydetmek için birincil G/Ç arayüzünü sağlar.

export class Scene extends SceneObject

Enumerations

A3DObject ← SceneObject ← Scene

Enumerations

Bir OBJ dosyası yükleyin ve sahne grafiğinin kökündeki alt düğüm sayısını yazdırın.

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

Enumerations

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

Enumerations

open(fileOrStream, options?)

Bir dosya yolundan veya bir Buffer sahneye yükler, mevcut içeriği değiştirir.

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

Enumerations

fileOrStream string | Buffer

Kaynak dosyanın yolu, veya bir Buffer ham dosya verilerini içeren.

options LoadOptions (isteğe bağlı)

Biçime özgü yükleme seçenekleri. Geç undefined varsayılanları kullanmak için.

Enumerations

void

Enumerations

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


---

### openFromBuffer(buffer, options?)

Bellekteki bir 3D dosyasını yükler `Buffer`. Dosya verileri zaten belleğe okunmuş olduğunda tercih edilen aşırı yüklemedir.

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

Enumerations

buffer Buffer

Bir Node.js Buffer tam dosya içeriğini içeren.

Biçime özgü yükleme seçenekleri.

Enumerations

void

Enumerations

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

Sahneyi bir dosyaya kaydeder. Biçim dosya uzantısından çıkarılır, ya da bir biçim‑özel SaveOptions örnek (veya bir FileFormat tekil) ikinci argüman olarak.

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

Enumerations

fileOrStream string

Hedef dosya yolu. Uzantı çıktı biçimini belirler (örneğin,., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (isteğe bağlı)

Ya bir biçim tekili (örneğin,., GltfFormat.getInstance()) SaveOptions alt sınıf.

options SaveOptions (isteğe bağlı)

Biçim-özel kaydetme seçenekleri bir FileFormat ikinci argüman olarak geçirildiğinde.

Enumerations

void

Enumerations

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

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


---

### createAnimationClip(name)

Yeni adlandırılmış bir animasyon klibi oluşturur ve sahnenin `animationClips` koleksiyonuna.

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

Enumerations

name string

Yeni animasyon klibi için açıklayıcı bir ad.

Enumerations

AnimationClip

Yeni oluşturulan AnimationClip örnek.

Enumerations

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

 Türkçe