Scene
पैकेज: @aspose/3d (v24.12.0)
Scene 3D सीन ग्राफ़ के लिए मूल कंटेनर है @aspose/3d. यह नोड पदानुक्रम, मेटाडेटा, और एनीमेशन क्लिप्स को रखता है, और 3D फ़ाइलों को लोड और सेव करने के लिए मुख्य I/O इंटरफ़ेस प्रदान करता है।.
export class Scene extends SceneObjectColladaSaveOptions
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
| Name | Type | Access | Description |
|---|---|---|---|
VERSION | `` | Read | Gets the version. |
rootNode | Node | Read | Gets the root node. |
subScenes | Scene[] | Read | Gets the sub scenes. |
library | CustomObject[] | Read | Gets the library. |
assetInfo | AssetInfo | Read/Write | Gets the asset info. |
animationClips | AnimationClip[] | Read | Gets the animation clips. |
currentAnimationClip | `AnimationClip | null` | Read/Write |
poses | any[] | Read | Gets the poses. |
| Signature | Description |
|---|---|
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) → AnimationClip | Creates a new animation clip with the given name |
getAnimationClip(name: string) → `AnimationClip | null` |
open(fileOrStream: any, options: any) | Loads scene data from a file path or stream using options |
| `openFromBuffer(buffer: Buffer | Uint8Array, options: any)` |
save(fileOrStream: any, formatOrOptions: any, options: any) | Writes the scene to a file or stream |
saveToBuffer(format: string, _options: any) → Buffer | Returns 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) → Scene | Loads a scene from the specified file and returns the scene |
toString() → string |
ColladaSaveOptions
open(fileOrStream, options?)
फ़ाइल पाथ या एक Buffer सीन में लोड करता है, मौजूदा सामग्री को बदलते हुए।.
open(fileOrStream: string | Buffer, options?: LoadOptions): voidColladaSaveOptions
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): voidColladaSaveOptions
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 सिंगलटन) को दूसरे तर्क के रूप में पास कर सकते हैं।.
save(fileOrStream: string, formatOrOptions?: FileFormat | SaveOptions, options?: SaveOptions): voidColladaSaveOptions
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): AnimationClipColladaSaveOptions
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});