Class Node
パッケージ: @aspose/3d (v24.12.0)
ノードはシーン グラフ階層内の名前付き要素を表します。各ノードはローカルトランスフォームを持ち、子ノードを保持でき、0 個以上の Entity メッシュ、カメラ、またはライトなどのオブジェクトです。.
export class Node extends SceneObjectImageRenderOptions
A3DObject ← SceneObject ← Node
ImageRenderOptions
親ノードを作成し、2つの子ノードをその子として接続し、名前でフル階層を走査します。.
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
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
name | string | このノードの名前です。シーン グラフ内でノードを識別するために使用されます。. |
parentNode | `Node | null` |
childNodes | Node[] | このノードに接続された直接の子ノードの配列です。. |
entities | Entity[] | このノードに接続されたエンティティ(メッシュ、カメラ、ライト等)のリストです。. |
materials | Material[] | このノードに関連付けられたマテリアルのリストです。. |
transform | Transform | このノードのローカルトランスフォーム、 translation: Vector3, rotation: Quaternion,、および scaling: Vector3 コンポーネント。. |
globalTransform | GlobalTransform | 読み取り専用。ワールドスペースのトランスフォームで、ルートまでのすべての先祖トランスフォームを掛け合わせて計算されます。. |
visible | boolean | このノードとそのサブツリーがレンダリングされるかどうか。デフォルトは true. |
excluded | boolean | ImageRenderOptions true,、このノードとそのサブツリーはエクスポートから除外されます。デフォルトは false. |
entity | `Entity | undefined` |
ImageRenderOptions
addChildNode(node)
既存の Node インスタンスをこのノードの直接の子として追加します。.
addChildNode(node: Node): voidImageRenderOptions
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): 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)
このノードのワールド空間変換行列を計算し、返します。Pass 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
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)
別のノードの内容(エンティティ、マテリアル、子ノード)をこのノードにマージし、元のノードをシーンから削除します。.
merge(node: Node): voidImageRenderOptions
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}`);
}