Scene

بسته: @aspose/3d (v24.12.0)

Scene ریشهٔ مخزن برای یک گراف صحنهٔ سه‌بعدی در @aspose/3d. این سلسله‌مراتب گره‌ها، فراداده‌ها و کلیپ‌های انیمیشن را نگه می‌دارد و رابط I/O اصلی برای بارگذاری و ذخیره‌سازی فایل‌های سه‌بعدی را فراهم می‌کند.

export class Scene extends SceneObject

ColladaSaveOptions

A3DObject ← SceneObject ← Scene

ColladaSaveOptions

یک فایل OBJ را بارگذاری کنید و تعداد گره‌های فرزند در ریشهٔ گراف صحنه را چاپ کنید.

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

یک فایل 3D را از مسیر فایل یا یک Buffer به صحنه بارگذاری می‌کند و محتوای موجود را جایگزین می‌کند.

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

ColladaSaveOptions

fileOrStream string | Buffer

مسیر فایل منبع، یا یک Buffer حاوی داده‌های خام فایل.

options LoadOptions (اختیاری)

گزینه‌های بارگذاری مخصوص فرمت. ارسال کنید undefined برای استفاده از پیش‌فرض‌ها.

ColladaSaveOptions

void

ColladaSaveOptions

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


---

### openFromBuffer(buffer, options?)

فایلی 3D را از حافظهٔ درون‌حافظه‌ای بارگذاری می‌کند `Buffer`. این بارگذاری ترجیحی است زمانی که داده‌های فایل قبلاً در حافظه خوانده شده‌اند.

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

ColladaSaveOptions

buffer Buffer

یک Node.js Buffer حاوی محتوای کامل فایل.

گزینه‌های بارگذاری مخصوص فرمت.

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

صحنه را در یک فایل ذخیره می‌کند. قالب از پسوند فایل استخراج می‌شود، یا می‌توانید یک قالب‌خاص SaveOptions نمونه (یا یک FileFormat singleton) به عنوان آرگومان دوم.

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

ColladaSaveOptions

fileOrStream string

مسیر فایل مقصد. پسوند تعیین‌کنندهٔ فرمت خروجی است (مثلاً., .glb → GLB, .gltf → glTF JSON،, .stl → STL).

formatOrOptions FileFormat | SaveOptions (اختیاری)

یا یک تک‌نماد فرمت (مثلاً., GltfFormat.getInstance()) یا یک فرمت‌خاص SaveOptions زیرکلاس.

options SaveOptions (اختیاری)

گزینه‌های ذخیره‌سازی مخصوص فرمت هنگامیکه یک FileFormat به عنوان آرگومان دوم ارسال می‌شود.

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)

یک کلیپ انیمیشن نام‌دار جدید ایجاد می‌کند و آن را به صحنهٔ `animationClips` مجموعه.

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

ColladaSaveOptions

name string

یک نام توصیفی برای کلیپ انیمیشن جدید.

ColladaSaveOptions

AnimationClip

مورد تازه ایجاد شده AnimationClip نمونه.

ColladaSaveOptions

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

 فارسی