BVH(branchingFactor, primitivesPerNode, depth)

Class representing a bounding volume hierarchy. The current implementation represents single BVH nodes as AABBs. It accepts arbitrary branching factors and can subdivide the given geometry until a defined hierarchy depth has been reached. Besides, the hierarchy construction is performed top-down and the algorithm only performs splits along the cardinal axes.

Reference: Bounding Volume Hierarchies in Real-Time Collision Detection by Christer Ericson (chapter 6).

new BVH(branchingFactor, primitivesPerNode, depth)

Constructs a new BVH.

Parameters:
Name Type Default Description
branchingFactor Number 2

The branching factor.

primitivesPerNode Number 1

The minimum amount of primitives per BVH node.

depth Number 10

The maximum hierarchical depth.

Author:

Members

branchingFactor :Number

The branching factor (how many nodes per level).

Default Value:
  • 2

depth :Number

The maximum hierarchical depth.

Default Value:
  • 10

primitivesPerNode :Number

The minimum amount of primitives per BVH node.

Default Value:
  • 10

root :BVHNode

The root BVH node.

Default Value:
  • null

Methods

fromMeshGeometry(geometry) → {BVH}

Computes a BVH for the given mesh geometry.

Parameters:
Name Type Description
geometry MeshGeometry

The mesh geometry.

Returns:
BVH -

A reference to this BVH.

traverse(callback) → {BVH}

Executes the given callback for each node of the BVH.

Parameters:
Name Type Description
callback function

The callback to execute.

Returns:
BVH -

A reference to this BVH.