Node

패키지: @aspose/3d (v24.12.0)

Node는 씬 그래프 계층 구조에서 이름이 지정된 요소를 나타냅니다. 각 노드는 로컬 변환을 가지고 있으며, 자식 노드를 보유할 수 있고, 하나 이상 또는 전혀 없는 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

NameTypeAccessDescription
parentNode`Nodenull`Read/Write
childNodesNode[]ReadGets the child nodes.
entitiesEntity[]ReadGets the entities.
entity`Entityundefined`Read/Write
materialsMaterial[]ReadGets the materials.
material`Materialnull`Read/Write
transformTransformReadGets the transform.
globalTransformGlobalTransformReadGets the global transform.
visiblebooleanRead/WriteGets the visible.
excludedbooleanRead/WriteGets the excluded.
assetInfoanyRead/WriteGets the asset info.
metaDatasany[]ReadGets the meta datas.
SignatureDescription
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)NodeCreates a new child node with name, entity, and material, and returns it
`getChild(indexOrName: numberstring)Node
merge(node: Node)Incorporates the contents of another node into this node
evaluateGlobalTransform(withGeometricTransform: boolean)Matrix4Computes the node’s global transform matrix, optionally including geometric transform
getBoundingBox()BoundingBoxReturns the bounding box.
selectSingleObject(_path: string)anyNot 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 instance를 이 노드의 직접 자식으로 추가합니다.

addChildNode(node: Node): void

ImageRenderOptions

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`, 선택적으로 이름, entity, material을 지정하고, 이를 이 노드의 자식으로 추가합니다.

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

ImageRenderOptions

name string (옵션)

새로운 자식 노드의 이름입니다.

entity Entity (옵션)

새 노드에 연결할 entity, 예를 들어 Mesh instance.

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

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

ImageRenderOptions

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): void

ImageRenderOptions

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}); }

 한국어