Class Node

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

گره نمایانگر یک عنصر نام‌دار در سلسله‌مراتب گراف صحنه است. هر گره یک تبدیل محلی دارد، می‌تواند گره‌های فرزند را نگه دارد و صفر یا بیشتر Entity اشیائی مانند مش‌ها، دوربین‌ها یا نورها.

export class Node extends SceneObject

ImageRenderOptions

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

ImageRenderOptionsImageRenderOptionsImageRenderOptions
namestringنام این گره. برای شناسایی گره درون گراف صحنه استفاده می‌شود.
parentNode`Nodenull`
childNodesNode[]آرایه‌ای از گره‌های فرزند مستقیم که به این گره متصل هستند.
entitiesEntity[]فهرست موجودیت‌ها (مش‌ها، دوربین‌ها، نورها و غیره) که به این گره متصل هستند.
materialsMaterial[]فهرست مواد مرتبط با این گره.
transformTransformتبدیل محلی این گره، با translation: Vector3, rotation: Quaternion, و scaling: Vector3 اجزاء.
globalTransformGlobalTransformفقط-خواندنی. تبدیل فضای جهان، که با ضرب تمام تبدیل‌های اجدادی تا ریشه محاسبه می‌شود.
visiblebooleanاینکه آیا این گره و زیردرخت آن رندر می‌شوند یا نه. مقدار پیش‌فرض true.
excludedbooleanImageRenderOptions true,، گره و زیردرخت آن از خروجی حذف می‌شوند. مقدار پیش‌فرض false.
entity`Entityundefined`

ImageRenderOptions

addChildNode(node)

یک موجود موجود را اضافه می‌کند Node نمونه به‌عنوان فرزند مستقیم این گره.

addChildNode(node: Node): void

ImageRenderOptions

node Node

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

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

یک مورد جدید ایجاد می‌کند Node,، به‌صورت اختیاری با یک نام، یک موجودیت و یک ماده، و آن را به‌عنوان فرزند این گره اضافه می‌کند.

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

ImageRenderOptions

name string (اختیاری)

نام گره فرزند جدید.

entity Entity (اختیاری)

یک موجودیت برای اتصال به گره جدید، برای مثال یک Mesh نمونه.

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

ماتریس تبدیل فضای جهانی برای این گره را محاسبه و برمی‌گرداند. Pass true برای شامل کردن جابجایی تبدیل هندسی ذخیره‌شده در گره (که توسط برخی صادرکنندگان FBX استفاده می‌شود).

evaluateGlobalTransform(withGeometricTransform: boolean): Matrix4

ImageRenderOptions

withGeometricTransform boolean

ImageRenderOptions true, شامل تبدیل هندسی در نتیجه است.

ImageRenderOptions

Matrix4

ماتریس تبدیل فضای جهانی ۴×۴.

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

جعبهٔ محدود‌کنندهٔ axis-aligned این گره و تمام فرزندان آن را در فضای جهانی محاسبه می‌کند.

getBoundingBox(): BoundingBox

ImageRenderOptions

BoundingBox

جعبهٔ محدود‌کنندهٔ axis-aligned که تمام هندسه‌های زیر این گره را در بر می‌گیرد.

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)

محتویات یک گرهٔ دیگر (نهادها، materialها و فرزندان آن) را در این گره ادغام می‌کند و گرهٔ منبع را از صحنه حذف می‌نماید.

merge(node: Node): void

ImageRenderOptions

node Node

گره منبعی که محتوا در این گره ادغام می‌شود.

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}`);
}
 فارسی