Scene

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

Scene je korijenski kontejner za 3D graf scene u @aspose/3d. Sadrži hijerarhiju čvorova, metapodatke i animacijske isječke te pruža primarno I/O sučelje za učitavanje i spremanje 3D datoteka.

export class Scene extends SceneObject

ColladaSaveOptions

A3DObject ← SceneObject ← Scene

ColladaSaveOptions

Učitaj OBJ datoteku i ispiši broj podčvorova u korijenu grafa scene.

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

Učita 3D datoteku iz putanje datoteke ili a Buffer u scenu, zamjenjujući sav postojeći sadržaj.

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

ColladaSaveOptions

fileOrStream string | Buffer

Putanja do izvorne datoteke, ili a Buffer koja sadrži sirove podatke datoteke.

options LoadOptions (opcionalno)

Opcije učitavanja specifične za format. Proslijedi undefined za korištenje zadane vrijednosti.

ColladaSaveOptions

void

ColladaSaveOptions

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


---

### openFromBuffer(buffer, options?)

Učita 3D datoteku iz memorije `Buffer`. Ovo je preferirani preopterećenje kada su podaci datoteke već učitani u memoriju.

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

ColladaSaveOptions

buffer Buffer

Node.js Buffer koji sadrži cijeli sadržaj datoteke.

Opcije učitavanja specifične za format.

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

Spremi scenu u datoteku. Format se zaključuje iz ekstenzije datoteke, ili možete proslijediti format-specifični SaveOptions instancu (ili FileFormat singleton) kao drugi argument.

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

ColladaSaveOptions

fileOrStream string

Odredišna putanja datoteke. Ekstenzija određuje izlazni format (npr., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (opcionalno)

Ili format singleton (npr., GltfFormat.getInstance()) SaveOptions podklasu.

options SaveOptions (opcionalno)

Opcije spremanja specifične za format kada je FileFormat proslijeđen kao drugi argument.

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)

Stvara novi imenovani animacijski isječak i dodaje ga u `animationClips` kolekciju.

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

ColladaSaveOptions

name string

Opisno ime za novi animacijski isječak.

ColladaSaveOptions

AnimationClip

Novo stvoreni AnimationClip instancu.

ColladaSaveOptions

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

 Hrvatski