parent 属性是 BVHNode 类的一个实例变量,用于存储当前节点的父节点。
node.parent
无
BVHNode | null
当前节点的父节点。如果当前节点是根节点,则返回 null
。
const bvh = new BVH();
// 构建 BVH 树
const root = bvh.build();
// 获取 root 的父节点
console.log(root.parent); // null
// 获取 root 的子节点
const children = root.children;
console.log(children[0].parent); // root
在 BVH 树中的节点间,会存在父子节点的关系。parent
属性用于存储当前节点的父节点。如果当前节点是根节点,则其 parent
属性值为 null
。