ReadonlygeometryReadonlylayoutStatic ReadonlysegmentHow this class pairs entries: 'segments'; LineLoopBVH 'loop', LineBVH 'strip'.
The deepest box's depth, as traverse reports it (the root's children at 1).
How the tree's entries pair up.
StaticbuildBuilds a tree over the input's segments (see the file comment); keeps input as its source.
The nearest point on any segment to point (geometry space): { point, distance, index }.
StaticdeserializeReads bytes from serialize, checked.
Bytes this object holds: nodes, records and bounds. Not the source.
Box around every primitive, current after refit, as CpuMeshBvh.getBoundingBox.
Optionaltarget: TThe segment at a tree position, as the tree stores it.
Optionaltarget: TEvery primitive within threshold of the ray, sorted by distance (then
entry): three's Points.raycast / Line.raycast in the tree's space.
The direction is normalized first unless it is unit length (three's rays are).
The closest primitive within threshold of the ray (ties: the lower entry), or null: three-mesh-bvh's firstHitOnly.
three's Line.raycast for object (whose geometry this tree is), over the tree: see the file comment.
Refits to the geometry's current positions (three-mesh-bvh's refit()); with input, to those arrays.
Optionalinput: BvhPointsInputThe entry of the primitive at a tree position (as traverse reports them).
The tree as bytes: a 64-byte header ("BVHP", format 1, kind, mode,
entry range, counts, bounds), the nodes, the records. CpuPointsBvh.deserialize
and CpuSegmentsBvh.deserialize read it back, checked.
three-mesh-bvh's LineSegmentsBVH.shapecast, with Box3 boxes and Line3 segments (scratch objects).
Walks the tree with CpuMeshBvh.traverse's contract (three-mesh-bvh's
shapecast): depth first, the root's box never asked about, each child
scored once by boundsTraverseOrder and the lower score first, a falsy
intersectsBounds skipping the box, a contained box reported as one
range, a truthy intersectsRange stopping the walk. Ranges are tree
positions: map them with resolvePrimitiveIndex. Returns true when stopped.
three-mesh-bvh's node walk, as CpuMeshBvh.traverseNodes (for the
helper and the debug functions): every node depth first, the root at
depth 0 with the tree's bounds; a leaf gets its first tree position and
count, an inner node the axis its children's centres lie furthest apart on.
The box around the primitives at tree positions offset to
offset + count - 1: read from the source when the tree has one (so
edits since the last refit show, as validateBounds wants),
else from the records.
three-mesh-bvh's
LineSegmentsBVH(and the base of BvhLineLoopBoundsTree and BvhLineBoundsTree): a tree over a line geometry's segments, the core'sCpuSegmentsBvhwith three's types. Build it withgeometry.computeBoundsTree({ type: LineSegmentsBVH })for aLineSegments.