Scene

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

Scene yra šakninis konteineris 3D scenų grafui @aspose/3d. Jis saugo mazgų hierarchiją, metaduomenis ir animacijos klipus bei suteikia pagrindinę I/O sąsają 3D failų įkėlimui ir išsaugojimui.

export class Scene extends SceneObject

ColladaSaveOptions

A3DObject ← SceneObject ← Scene

ColladaSaveOptions

Įkelkite OBJ failą ir išveskite vaikų mazgų skaičių scenos grafų šakniniame mazge.

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

Įkelia 3D failą iš failo kelio arba Buffer į sceną, pakeičiant bet kokį esamą turinį.

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

ColladaSaveOptions

fileOrStream string | Buffer

Kelias į šaltinio failą arba Buffer turintį neapdorotus failo duomenis.

options LoadOptions (neprivaloma)

Formato specifinės įkėlimo parinktys. Praleiskite undefined naudoti numatytąsias reikšmes.

ColladaSaveOptions

void

ColladaSaveOptions

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


---

### openFromBuffer(buffer, options?)

Įkelia 3D failą iš atminties `Buffer`. Tai yra pageidaujama perkrova, kai failo duomenys jau yra perskaityti į atmintį.

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

ColladaSaveOptions

buffer Buffer

A Node.js Buffer turintį visą failo turinį.

options LoadOptions (nebūtina)

Formato specifinės įkėlimo parinktys.

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

Išsaugo sceną į failą. Formatas nustatomas pagal failo plėtinį, arba galite perduoti formatui specifinį SaveOptions objektą (arba FileFormat singletoną) kaip antrąjį argumentą.

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

ColladaSaveOptions

fileOrStream string

Tikslinio failo kelias. Plėtinys nustato išvesties formatą (pvz., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (nebūtina)

Arba formatų singletonas (pvz., GltfFormat.getInstance()) SaveOptions pakaitinė klasė.

options SaveOptions (nebūtina)

Formato specifinės išsaugojimo parinktys, kai FileFormat yra perduodamas kaip antras argumentas.

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)

Sukuria naują pavadintą animacijos klipą ir prideda jį prie scenos `animationClips` kolekcijos.

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

ColladaSaveOptions

name string

Aprašomasis pavadinimas naujam animacijos klipui.

ColladaSaveOptions

AnimationClip

Naujai sukurtas AnimationClip instancija.

ColladaSaveOptions

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

 Lietuvių