new BVHNode()
Constructs a BVH node.
Members
-
boundingVolume :AABB
-
The bounding volume of this BVH node.
-
centroids :Array.<Number>
-
The centroids of the node's triangles. Only filled for leaf nodes.
-
children :Array.<BVHNode>
-
The child BVH nodes.
-
parent :BVHNode
-
The parent BVH node.
- Default Value:
- null
-
primitives :Array.<Number>
-
The primitives (triangles) of this BVH node. Only filled for leaf nodes.
Methods
-
build(branchingFactor, primitivesPerNode, maxDepth, currentDepth) → {BVHNode}
-
Builds this BVH node. That means the respective bounding volume is computed and the node's primitives are distributed under new child nodes. This only happens if the maximum hierarchical depth is not yet reached and the node does contain enough primitives required for a split.
Parameters:
Name Type Description branchingFactor
Number The branching factor.
primitivesPerNode
Number The minimum amount of primitives per BVH node.
maxDepth
Number The maximum hierarchical depth.
currentDepth
Number The current hierarchical depth.
-
computeBoundingVolume() → {BVHNode}
-
Computes the AABB for this BVH node.
-
computeSplitAxis() → {Vector3}
-
Computes the split axis. Right now, only the cardinal axes are potential split axes.
-
getDepth() → {Number}
-
Returns the depth of this BVH node in its hierarchy.
Returns:
Number -The hierarchical depth of this BVH node.
-
intersectRay(ray, result) → {Vector3}
-
Performs a ray/BVH node intersection test and stores the closest intersection point to the given 3D vector. If no intersection is detected, null is returned.
-
intersectsRay(ray) → {boolean}
-
Performs a ray/BVH node intersection test. Returns either true or false if there is a intersection or not.
Parameters:
Name Type Description ray
Ray The ray.
Returns:
boolean -Whether there is an intersection or not.
-
leaf() → {Boolean}
-
Returns true if this BVH node is a leaf node.
Returns:
Boolean -Whether this BVH node is a leaf node or not.
-
root() → {Boolean}
-
Returns true if this BVH node is a root node.
Returns:
Boolean -Whether this BVH node is a root node or not.
-
split(branchingFactor) → {BVHNode}
-
Splits the node and distributes node's primitives over new child nodes.
Parameters:
Name Type Description branchingFactor
Number The branching factor.
-
traverse(callback) → {BVHNode}
-
Executes the given callback for this BVH node and its ancestors.
Parameters:
Name Type Description callback
function The callback to execute.