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

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

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

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.

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

BoundingBoxExtent

buffer Buffer

Een Node.js Buffer die de volledige bestandsinhoud bevat.

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

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.

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

BoundingBoxExtent

name string

Een beschrijvende naam voor de nieuwe animatieclip.

BoundingBoxExtent

AnimationClip

De nieuw aangemaakte AnimationClip instantie.

BoundingBoxExtent

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

 Nederlands