Node
पैकेज: @aspose/3d (v24.12.0)
नोड दृश्य ग्राफ़ पदानुक्रम में एक नामित तत्व का प्रतिनिधित्व करता है। प्रत्येक नोड का एक स्थानीय ट्रांसफ़ॉर्म होता है, यह चाइल्ड नोड्स रख सकता है, और शून्य या अधिक Entity ऑब्जेक्ट्स जैसे meshes, cameras, या lights.
export class Node extends SceneObjectImageRenderOptions
A3DObject ← SceneObject ← Node
ImageRenderOptions
एक पैरेंट नोड बनाएं, उसके साथ दो चाइल्ड नोड्स संलग्न करें, और नाम द्वारा पूरी पदानुक्रम को ट्रैवर्स करें।.
import { Scene, Node } from '@aspose/3d';
const scene = new Scene();
const root = scene.rootNode;
const vehicle = root.createChildNode('vehicle');
const body = vehicle.createChildNode('body');
const wheel = vehicle.createChildNode('wheel_front_left');
function traverse(node: Node, depth = 0): void {
console.log(' '.repeat(depth * 2) + node.name);
for (const child of node.childNodes) {
traverse(child, depth + 1);
}
}
traverse(root);
// Output:
// vehicle
// body
// wheel_front_left
ImageRenderOptions
| Name | Type | Access | Description |
|---|---|---|---|
parentNode | `Node | null` | Read/Write |
childNodes | Node[] | Read | Gets the child nodes. |
entities | Entity[] | Read | Gets the entities. |
entity | `Entity | undefined` | Read/Write |
materials | Material[] | Read | Gets the materials. |
material | `Material | null` | Read/Write |
transform | Transform | Read | Gets the transform. |
globalTransform | GlobalTransform | Read | Gets the global transform. |
visible | boolean | Read/Write | Gets the visible. |
excluded | boolean | Read/Write | Gets the excluded. |
assetInfo | any | Read/Write | Gets the asset info. |
metaDatas | any[] | Read | Gets the meta datas. |
| Signature | Description |
|---|---|
constructor(name: string, entity: Entity) | Creates a node with the specified name and initial entity |
addEntity(entity: Entity) | Attaches the given entity to the node’s entity collection |
removeEntity(entity: Entity) | Detaches the specified entity from the node |
clearEntities() | Removes all entities from the node |
addChildNode(node: Node) | Adds an existing node as a child of this node |
createChildNode(nodeName: string, entity: Entity, material: Material) → Node | Creates a new child node with name, entity, and material, and returns it |
| `getChild(indexOrName: number | string) → Node |
merge(node: Node) | Incorporates the contents of another node into this node |
evaluateGlobalTransform(withGeometricTransform: boolean) → Matrix4 | Computes the node’s global transform matrix, optionally including geometric transform |
getBoundingBox() → BoundingBox | Returns the bounding box. |
selectSingleObject(_path: string) → any | Not implemented in the FOSS edition — throws at runtime. Selects a single object in the node hierarchy using the provided path |
selectObjects(_path: string) → any[] | Not implemented in the FOSS edition — throws at runtime. Selects all objects matching the given path and returns them as an array |
toString() → string |
ImageRenderOptions
addChildNode(node)
एक मौजूदा को जोड़ता है Node इंस्टेंस को इस नोड का प्रत्यक्ष चाइल्ड बनाता है।.
addChildNode(node: Node): voidImageRenderOptions
node Node
संलग्न करने के लिए नोड। नोड को उसके वर्तमान पैरेंट से हटाकर इस नोड के अंतर्गत पुनः पैरेंट किया जाता है।.
ImageRenderOptions
void
ImageRenderOptions
const scene = new Scene();
const parent = scene.rootNode.createChildNode(‘parent’);
const child = new Node(‘child’);
parent.addChildNode(child);
console.log(Children of parent: ${parent.childNodes.length}); // 1
---
### createChildNode(name?, entity?, material?)
एक नया बनाता है `Node`, वैकल्पिक रूप से एक नाम, एक एंटिटी, और एक मैटेरियल के साथ, और इसे इस नोड के चाइल्ड के रूप में जोड़ता है।.
```typescript
createChildNode(name?: string, entity?: Entity, material?: Material): NodeImageRenderOptions
name string (वैकल्पिक)
नए चाइल्ड नोड के लिए नाम।.
entity Entity (वैकल्पिक)
नए नोड से संलग्न करने के लिए एक एंटिटी, उदाहरण के लिए एक Mesh इंस्टेंस।.
material Material (वैकल्पिक)
नए नोड के साथ संबद्ध करने के लिए एक सामग्री।.
ImageRenderOptions
Node
नया निर्मित चाइल्ड नोड।.
ImageRenderOptions
import { Scene } from '@aspose/3d';
import { Mesh } from '@aspose/3d/entities';
const scene = new Scene();
const mesh = new Mesh();
// ... populate mesh ...
const meshNode = scene.rootNode.createChildNode('geometry', mesh);
console.log(`Node name: ${meshNode.name}`);
console.log(`Entities attached: ${meshNode.entities.length}`);evaluateGlobalTransform(withGeometricTransform)
इस नोड के लिए वर्ल्ड-स्पेस ट्रांसफ़ॉर्मेशन मैट्रिक्स की गणना करता है और रिटर्न करता है। पास करें true नोड पर संग्रहीत ज्योमेट्रिक ट्रांसफ़ॉर्म ऑफ़सेट को शामिल करने के लिए (कुछ FBX एक्सपोर्टर्स द्वारा उपयोग किया जाता है)।.
evaluateGlobalTransform(withGeometricTransform: boolean): Matrix4ImageRenderOptions
withGeometricTransform boolean
ImageRenderOptions true, परिणाम में ज्यामितीय रूपांतरण शामिल है।.
ImageRenderOptions
Matrix4
4×4 विश्व-स्थान परिवर्तन मैट्रिक्स।.
ImageRenderOptions
import { Scene } from '@aspose/3d';
const scene = new Scene();
scene.open('model.fbx');
const node = scene.rootNode.childNodes[0];
const matrix = node.evaluateGlobalTransform(false);
console.log('World transform matrix computed.');getBoundingBox()
विश्व स्थान में इस नोड और उसके सभी वंशजों का अक्ष-समरेखित बाउंडिंग बॉक्स गणना करता है।.
getBoundingBox(): BoundingBoxImageRenderOptions
BoundingBox
इस नोड के अंतर्गत सभी ज्यामिति को घेरने वाला अक्ष-समरेखित बाउंडिंग बॉक्स।.
ImageRenderOptions
const scene = new Scene();
scene.open(‘model.obj’);
const bbox = scene.rootNode.getBoundingBox();
console.log(Min: ${JSON.stringify(bbox.minimum)});
console.log(Max: ${JSON.stringify(bbox.maximum)});
---
### merge(node)
दूसरे नोड की सामग्री (उसकी इकाइयाँ, सामग्री, और चाइल्ड) को इस नोड में मिलाता है और स्रोत नोड को दृश्य से हटा देता है।.
```typescript
merge(node: Node): voidImageRenderOptions
node Node
वह स्रोत node जिसकी सामग्री इस node में मिलाई जाती है।.
ImageRenderOptions
void
ImageRenderOptions
const scene = new Scene(); scene.open(‘multi_part.fbx’);
const root = scene.rootNode;
if (root.childNodes.length >= 2) {
root.childNodes[0].merge(root.childNodes[1]);
console.log(Children after merge: ${root.childNodes.length});
}