Class Node

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

Nodul reprezintă un element denumit în ierarhia graficului de scenă. Fiecare nod are o transformare locală, poate conține noduri copil și transportă zero sau mai multe Entity obiecte precum meshes, camere sau lumini.

export class Node extends SceneObject

ImageRenderOptions

A3DObject ← SceneObject ← Node

ImageRenderOptions

Creează un nod părinte, atașează-i două noduri copil și parcurge întreaga ierarhie după nume.

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

ImageRenderOptionsImageRenderOptionsImageRenderOptions
namestringNumele acestui nod. Folosit pentru a identifica nodul în cadrul graficului de scenă.
parentNode`Nodenull`
childNodesNode[]Un tablou de noduri copil directe atașate acestui nod.
entitiesEntity[]Lista de entități (meshes, camere, lumini etc.) atașate acestui nod.
materialsMaterial[]Lista de materiale asociate cu acest nod.
transformTransformTransformarea locală a acestui nod, cu translation: Vector3, rotation: Quaternion, și scaling: Vector3 componente.
globalTransformGlobalTransformDoar citire. Transformarea în spațiul mondial, calculată prin înmulțirea tuturor transformărilor strămoșilor până la rădăcină.
visiblebooleanDacă acest nod și subarborele său sunt randate. Valoarea implicită este true.
excludedbooleanImageRenderOptions true, nodul și subarborele său sunt excluse din export. Valoarea implicită este false.
entity`Entityundefined`

ImageRenderOptions

addChildNode(node)

Adaugă un element existent Node instanță ca un copil direct al acestui nod.

addChildNode(node: Node): void

ImageRenderOptions

node Node

Nodul de atașat. Nodul este reparentat de la părintele său curent la acest nod.

ImageRenderOptions

void

ImageRenderOptions

import { Scene, Node } from '@aspose/3d';

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

Creează un nou Node, opțional cu un nume, o entitate și un material, și îl adaugă ca un copil al acestui nod.

createChildNode(name?: string, entity?: Entity, material?: Material): Node

ImageRenderOptions

name string (opțional)

Numele pentru noul nod copil.

entity Entity (opțional)

O entitate de atașat la nodul nou, de exemplu un Mesh instanță.

material Material (opțional)

Un material de asociat cu nodul nou.

ImageRenderOptions

Node

Nodul copil creat recent.

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)

Calculează și returnează matricea de transformare în spațiul global pentru acest nod. Transmite true pentru a include decalajul de transformare geometrică stocat pe nod (utilizat de unele exportatoare FBX).

evaluateGlobalTransform(withGeometricTransform: boolean): Matrix4

ImageRenderOptions

withGeometricTransform boolean

ImageRenderOptions true, include transformarea geometrică în rezultat.

ImageRenderOptions

Matrix4

Matricea de transformare în spațiul mondial 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()

Calculează cutia de delimitare aliniată pe axe a acestui nod și a tuturor descendenților săi în spațiul mondial.

getBoundingBox(): BoundingBox

ImageRenderOptions

BoundingBox

Cutia de delimitare aliniată pe axe care înconjoară toată geometria de sub acest nod.

ImageRenderOptions

import { Scene } from '@aspose/3d';

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)

Îmbină conținutul unui alt nod (entitățile, materialele și copiii săi) în acest nod și elimină nodul sursă din scenă.

merge(node: Node): void

ImageRenderOptions

node Node

Nodul sursă al cărui conținut este fuzionat în acest nod.

ImageRenderOptions

void

ImageRenderOptions

import { Scene } from '@aspose/3d';

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}`);
}
 Română