Class Scene

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

Scene is de hoofdcontainer voor een 3D-scènegrafiek in @aspose/3d. Het bevat de knooppunt-hiërarchie, metadata en animatieclips, en biedt de primaire I/O-interface voor het laden en opslaan van 3D-bestanden.

export class Scene extends SceneObject

BoundingBoxExtent

Properties

BoundingBoxExtent

Laad een OBJ‑bestand en print het aantal kindknooppunten in de root van de scènegraph.

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

BoundingBoxExtent

BoundingBoxExtentBoundingBoxExtentBoundingBoxExtent
rootNodeNodeHet hoofdknopunt van de scènegrafiek. Alle geometrie, verlichting, camera’s en andere objecten worden onder dit knooppunt gekoppeld.
assetInfoAssetInfoMetadata over het asset, inclusief maker, aanmaaktijd, eenheidsinformatie en coördinatensysteem.
animationClipsAnimationClip[]De verzameling animatieclips die in de scène zijn gedefinieerd. Elke clip bevat animatiecurves voor knooppunten en hun eigenschappen.
subScenesScene[]Sub-scènes ingebed in deze scène. Wordt gebruikt door formaten zoals FBX die scène-hiërarchieën ondersteunen. Opmerking: Deze eigenschap is niet bevestigd in de huidige API-oppervlakte en is mogelijk niet beschikbaar.

BoundingBoxExtent

open(fileOrStream, options?)

Laadt een 3D-bestand vanaf een bestandspad of een Buffer in de scène, waarbij bestaande inhoud wordt vervangen.

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

BoundingBoxExtent

fileOrStream string | Buffer

Het pad naar het bronbestand, of een Buffer bevat de ruwe bestandsgegevens.

options LoadOptions (optioneel)

Formaat‑specifieke laadopties. Geef undefined om de standaardwaarden te gebruiken.

BoundingBoxExtent

void

BoundingBoxExtent

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

Laadt een 3D-bestand vanuit het geheugen Buffer. Dit is de voorkeurs‑overload wanneer de bestandsgegevens al in het geheugen zijn gelezen.

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

BoundingBoxExtent

buffer Buffer

Een Node.js Buffer die de volledige bestandsinhoud bevat.

options LoadOptions (optioneel)

Formaat‑specifieke laadopties.

BoundingBoxExtent

void

BoundingBoxExtent

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

Slaat de scène op naar een bestand. Het formaat wordt afgeleid van de bestandsextensie, of je kunt een formaat‑specifieke SaveOptions instantie (of een FileFormat singleton) als tweede argument.

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

BoundingBoxExtent

fileOrStream string

Het bestemmingspad van het bestand. De extensie bepaalt het uitvoerformaat (bijv., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (optioneel)

Of een formaat‑singleton (bijv., GltfFormat.getInstance()) SaveOptions subklasse.

options SaveOptions (optioneel)

Formaat-specifieke opslaanopties wanneer een FileFormat wordt doorgegeven als het tweede argument.

BoundingBoxExtent

void

BoundingBoxExtent

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)

Maakt een nieuwe benoemde animatieclip aan en voegt deze toe aan de scene’s animationClips collectie.

createAnimationClip(name: string): AnimationClip

BoundingBoxExtent

name string

Een beschrijvende naam voor de nieuwe animatieclip.

BoundingBoxExtent

AnimationClip

De nieuw aangemaakte AnimationClip instantie.

BoundingBoxExtent

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