Scene

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

Scene ir saknes konteiners 3D ainas grafam @aspose/3d. Tas satur mezglu hierarhiju, metadatus un animācijas klipus, un nodrošina galveno I/O interfeisu 3D failu ielādēšanai un saglabāšanai.

export class Scene extends SceneObject

ColladaSaveOptions

A3DObject ← SceneObject ← Scene

ColladaSaveOptions

Ielādējiet OBJ failu un izdrukājiet bērna mezglu skaitu saknē ainas grafā.

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

Ielādē 3D failu no faila ceļa vai Buffer ainas, aizstājot jebkuru esošu saturu.

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

ColladaSaveOptions

fileOrStream string | Buffer

Ceļš uz avota failu, vai Buffer kas satur neapstrādātos faila datus.

options LoadOptions (pēc izvēles)

Formāta specifiskas ielādes iespējas. Pāriet undefined lai izmantotu noklusējuma vērtības.

ColladaSaveOptions

void

ColladaSaveOptions

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


---

### openFromBuffer(buffer, options?)

Ielādē 3D failu no atmiņas `Buffer`. Tas ir vēlamais pārlādētais variants, kad faila dati jau ir nolasīti atmiņā.

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

ColladaSaveOptions

buffer Buffer

Node.js Buffer kas satur pilnu faila saturu.

Formāta specifiskās ielādes opcijas.

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

Saglabā ainu failā. Formāts tiek noteikts no faila paplašinājuma, vai arī varat nodot formāta specifisku SaveOptions instanci (vai FileFormat singleton) kā otro argumentu.

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

ColladaSaveOptions

fileOrStream string

Mērķa faila ceļš. Paplašinājums nosaka izvades formātu (piemēram,., .glb → GLB, .gltf → glTF JSON, .stl → STL).

formatOrOptions FileFormat | SaveOptions (pēc izvēles)

Vai nu formāta vienīgais (piemēram,., GltfFormat.getInstance()) vai formāta specifisks SaveOptions apakšklase.

options SaveOptions (pēc izvēles)

Formāta specifiskās saglabāšanas iespējas, kad a FileFormat tiek nodots kā otrais arguments.

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)

Izveido jaunu nosauktu animācijas klipu un pievieno to scene's `animationClips` kolekcija.

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

ColladaSaveOptions

name string

Vector2 un Vector4 — dubultas precizitātes 2‑ un 4‑komponentu vektori, ko izmanto UV koordinātām un homogēnām pozīcijām pakotnē @aspose/3d.

ColladaSaveOptions

AnimationClip

Jaunizveidotais AnimationClip instance.

ColladaSaveOptions

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

 Latviešu