Class Scene

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

Scene ist der Root-Container für einen 3D-Szenengraphen in @aspose/3d. Es enthält die Knotenhierarchie, Metadaten und Animationsclips und bietet die primäre I/O‑Schnittstelle zum Laden und Speichern von 3D‑Dateien.

export class Scene extends SceneObject

Enumerations

A3DObject ← SceneObject ← Scene

Enumerations

Lade eine OBJ‑Datei und gib die Anzahl der Kindknoten im Root des Szenengraphen aus.

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

EnumerationsEnumerationsEnumerations
rootNodeNodeDer Root-Knoten des Szenengraphen. Alle Geometrien, Lichter, Kameras und anderen Objekte sind unterhalb dieses Knotens angehängt.
assetInfoAssetInfoMetadaten über das Asset, einschließlich Ersteller, Erstellungszeit, Einheitinformationen und Koordinatensystem.
animationClipsAnimationClip[]Die Sammlung von in der Szene definierten Animationsclips. Jeder Clip enthält Animationskurven für Knoten und deren Eigenschaften.
subScenesScene[]Unter‑Szenen, die in dieser Szene eingebettet sind. Wird von Formaten wie FBX verwendet, die Szenenhierarchien unterstützen. Hinweis: Diese Eigenschaft ist in der aktuellen API-Oberfläche nicht bestätigt und möglicherweise nicht verfügbar.

Enumerations

open(fileOrStream, options?)

Lädt eine 3D-Datei von einem Dateipfad oder einer Buffer in die Szene, wobei vorhandener Inhalt ersetzt wird.

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

Enumerations

fileOrStream string | Buffer

Der Pfad zur Quelldatei, oder eine Buffer die die Rohdateidaten enthält.

options LoadOptions (optional)

Formatspezifische Ladeoptionen. Übergeben Sie undefined um die Standardwerte zu verwenden.

Enumerations

void

Enumerations

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

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

openFromBuffer(buffer, options?)

Lädt eine 3D-Datei aus einem im Speicher befindlichen Buffer. Dies ist die bevorzugte Überladung, wenn die Dateidaten bereits in den Speicher geladen wurden.

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

Enumerations

buffer Buffer

Ein Node.js Buffer die den vollständigen Dateinhalt enthält.

options LoadOptions (optional)

Formatspezifische Ladeoptionen.

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

Speichert die Szene in einer Datei. Das Format wird anhand der Dateierweiterung ermittelt, oder Sie können ein format-spezifisches SaveOptions Instanz (oder ein FileFormat Singleton) als zweites Argument.

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

Enumerations

fileOrStream string

Der Ziel-Dateipfad. Die Erweiterung bestimmt das Ausgabeformat (z. B., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (optional)

Entweder ein Format‑Singleton (z. B., GltfFormat.getInstance()) oder ein format‑spezifisches SaveOptions Unterklasse.

options SaveOptions (optional)

Format‑spezifische Speicheroptionen, wenn ein FileFormat wird als zweites Argument übergeben.

Enumerations

void

Enumerations

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

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

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

createAnimationClip(name)

Erstellt einen neuen benannten Animationsclip und fügt ihn zur Szene‑ animationClips Sammlung.

createAnimationClip(name: string): AnimationClip

Enumerations

name string

Ein beschreibender Name für den neuen Animationsclip.

Enumerations

AnimationClip

Der neu erstellte AnimationClip Instanz.

Enumerations

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

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