pxim
1
Now only can get node from the scene
scene.getTransformNodeByName("group_part")
Every time you have to traverse from scene root nodes .
This efficiency is too low .
And it is troublesome to use .
[three.js/Object3D.js at master · mrdoob/three.js · GitHub]
(three.js/Object3D.js at master · mrdoob/three.js · GitHub)
This is very good like threejs .
pxim
2
export function getObjectByName(node: BABYLON.TransformNode, name: string): BABYLON.Nullable<BABYLON.TransformNode> {
if (node.name === name) {
return node;
}
const children = node.getChildren();
for (let i = 0, len = children.length; i < len; i++) {
const childNode = children[i] as BABYLON.TransformNode;
const foundNode = getObjectByName(childNode, name);
if (foundNode) {
return foundNode;
}
}
return null;
}
Why not using transformNode.getChildren((node) => node.name === transformNode.name, false)
?
3 Likes