ReadonlygeometryReadonlyindexReadonlyindexReadonlylayoutThe tree in the GPU layout. Its buffers are this object's own storage: refit writes them in place.
ReadonlypositionThe position attribute and index the tree was built from (or last refitted to), and their versions then.
Warned once that the geometry changed since the build.
The deepest box's depth, as traverse reports it (three-mesh-bvh's depth: the root's children are at 1).
Whether the tree holds a posed mesh's triangles (SkinnedMeshBVH): then acceleratedRaycast
walks it for a SkinnedMesh or a morphed mesh instead of falling back to three's raycast.
The geometry a hit's fields are read from (face corners and normal, uv, normal): the tree's own, or a posed view of it.
StaticbuildBuilds a tree with tinybvh (createTinyBvhBuilder()), on this thread. Keeps input as its source.
three-mesh-bvh's bvhcast(otherBvh, matrixToLocal, { intersectsRanges, intersectsTriangles })
with three's types: the triangles as ExtendedTriangle, the other's
moved into this space; offsets and indices are tree positions
(resolveTriangleIndex maps them, as with three-mesh-bvh's indirect).
three-mesh-bvh's closestPointToGeometry(geometry, geometryToBvh, target1, target2, minThreshold, maxThreshold):
the core's (CpuMeshBvh.closestPointToGeometry) against the
geometry's own tree when it has one of ours (geometry.boundsTree), else
against its triangles. A tree or { positions, indices } pass too.
Points are three Vector3s; target2 gets the other geometry's point,
in its space.
OptionalgeometryToBvh: BvhMatrix4Like | Matrix4 | nullthree-mesh-bvh's closestPointToPoint(point, target, minThreshold, maxThreshold):
the core's (CpuMeshBvh.closestPointToPoint), with the point a
three Vector3 (a new one when target has none). faceIndex is three's.
StaticcreateTrue when the geometry's positions and index are the ones the tree was built from (or refitted to).
Staticdeserializethree-mesh-bvh's MeshBVH.deserialize(data, geometry, { setIndex }):
a tree for geometry from three-mesh-bvh's serialized format (its
MeshBVH.serialize, or BvhBoundsTree.serialize), or from our
bytes (bvh.serialize()). For three-mesh-bvh's format, setIndex
(default true) sets the geometry's index from data.index as
three-mesh-bvh does (makes one when the geometry has none, else copies
into it); the tree's shape is kept and its boxes made exact
(meshBvhFromThreeMeshBvh). The other options are computeBoundsTree's.
Doesn't set geometry.boundsTree; setBoundsTree does.
Optionaloptions: BvhBoundsTreeOptions & { setIndex?: boolean }The core's form (CpuMeshBvh.deserialize(bytes, options)), for subclasses whose constructor takes a layout.
Optionaloptions: CpuMeshBvhOptionsBytes this object holds: the layout (nodes; triangles, 48-byte records or with corners: 'positions' 16 bytes;
parents), the one-instance top level and lookups made so far. Not the source geometry.
Box around every triangle, current after refit: into target
as [minX, minY, minZ, maxX, maxY, maxZ], or into its min and max
(a three Box3). Default a new Float32Array(6).
Optionaltarget: TThe corners of the triangle at a tree position, as the tree stores them: 9 numbers into target.
Where point lies on an original triangle: barycentrics, the corners,
the face normal, and any vertex attributes given, interpolated. The
vertex indices come from options.indices, else the source's index
buffer, else (a source without one) 3 * triangle + corner. A tree
without a source (deserialized, or made from a layout) has vertices
null unless options.indices is given, and then can't interpolate
attributes.
The inside test's votes for point: of the three rays
(INSIDE_TEST_DIRECTIONS), how many see it inside by parity (an
odd crossing count) and how many by winding (a non-zero signed sum).
The CPU twin of the GPU's bvhInsideVotes. Three full ray walks.
The walk under raycast: every hit (or the closest only) with t
in [tMin, tMax], in units of direction as given. side culls
natively in the walk (BVH_FRONT_SIDE front faces only,
BVH_BACK_SIDE back faces only; default BVH_DOUBLE_SIDE,
the WGSL walk's behaviour; CPU only). accept decides which of the rest
count (by original triangle and side), the others are passed through.
All hits come in walk order, not sorted. A closest-hit query without
accept runs the walk with no triangle filter at all.
Whether any triangle touches the box box placed by boxToMesh (into
this tree's space; default identity), three-mesh-bvh's intersectsBox:
an OrientedBox shapecast. A three Box3 and Matrix4 pass.
OptionalboxToMesh: BvhMatrix4Like | nullthree-mesh-bvh's intersectsGeometry(geometry, geometryToBvh): against
the geometry's own tree when it has one of ours (geometry.boundsTree),
else against its triangles. A tree or { positions, indices } pass too.
OptionalgeometryToBvh: BvhMatrix4Like | Matrix4 | nullWhether any triangle touches the sphere (three-mesh-bvh's intersectsSphere). A three Sphere passes.
Whether point is inside the mesh: at least two of three rays vote it
inside (insideVotes). rule is 'parity' (the default; odd
crossings, any winding) or 'winding' (non-zero signed crossings;
overlapping closed parts stay inside, triangles must be wound
consistently). Exact for a closed mesh away from its surface; on an open
mesh, rays through a hole disagree and the vote decides (docs/tracing/sdf.mdx).
The CPU twin of the GPU's bvhIsInside.
Every hit on the faces side selects, sorted by distance. The second
argument is the side (three's FrontSide/BackSide/DoubleSide
values), a BvhRaycastOptions, or anything with side (a three
material); near and far may follow, as in three-mesh-bvh.
OptionalmaterialOrSide: Optionalnear: numberOptionalfar: numberThe closest hit, or null. Arguments as raycast.
OptionalmaterialOrSide: Optionalnear: numberOptionalfar: numberIntersects a local-space ray (origin, direction: three's ray through the
inverse of the world matrix, not renormalized, so t is the world
distance) with the triangles three would test for material.
firstHitOnly: the closest only. Returns local hits, or null when a
range off a multiple of 3 needs a shifted tree and tinybvh isn't loaded.
Every triangle the ray from origin along direction crosses at
t >= 0, both faces: how many, and their signed sum (+1 for each
triangle the ray leaves through its front side, -1 for each it enters
through it). The CPU twin of the GPU's bvhRayCrossings: the same
watertight walk, in doubles. A ray exactly on a shared edge counts both
triangles, as the walk does.
Loads the corners at a tree position into a triangle (as the tree stores them) and sets its needsUpdate.
Refits the tree to the geometry's current positions, keeping its shape
(three-mesh-bvh's refit()). Raycasts use the tree again afterwards.
The index must be the same object and version: after an index change,
call computeBoundsTree again. With input, refits to those arrays
instead (as the core does) and leaves the geometry's versions alone.
Optionalinput: MeshInputThe original triangle index at a tree position (as traverse reports them).
Staticserializethree-mesh-bvh's MeshBVH.serialize(bvh, { cloneBuffers }): the tree
in three-mesh-bvh's serialized format (indirect mode, index a copy of
the geometry's), which its MeshBVH.deserialize reads
(serializeThreeMeshBvh). bvh.serialize() gives our own format.
The tree as bytes (serializeLayout's format). The source geometry isn't included.
three-mesh-bvh's shapecast with three's types: boxes as a Box3,
triangles as ExtendedTriangle (a three Triangle), the triangle's
original index. The core's cast underneath (CpuMeshBvh.shapecast).
Walks the tree, asking callbacks which boxes to enter and handing over
triangle ranges, with three-mesh-bvh's shapecast contract
(BvhTraverseCallbacks): depth first, the root's box never asked
about, each child scored once by boundsTraverseOrder and the lower
score visited first, a falsy intersectsBounds skipping the box, a
contained box reported as one range, and a truthy intersectsRange
stopping the walk. Returns true when it was stopped.
three-mesh-bvh's node walk (BVH.traverse(callback), 0.9.18), for the
debug utilities and the helper: every node in depth-first order, left
before right, starting with the root at depth 0 (its box the tree's
bounds; a one-leaf tree's root is that leaf). box is a new
Float32Array(6), [minX, minY, minZ, maxX, maxY, maxZ], per node. A
leaf gets its first tree position and triangle count; an inner node
gets its split axis (0, 1, 2), which our layout doesn't store: it is
taken as the axis along which the children's centres lie furthest
apart. A truthy return skips the node's children.
The tree position of an original triangle.
three-mesh-bvh's writePrimitiveRangeBounds: the box around the
triangles at tree positions offset to offset + count - 1, into
target at targetOffset as [minX, minY, minZ, maxX, maxY, maxZ].
Read from the source geometry when the tree has one (so edits made
since the build or the last refit show, as three-mesh-bvh reads
the geometry), else from the corners the tree stores.
A geometry's tree (three-mesh-bvh's
MeshBVH): the core CpuMeshBvh over all its triangles, in index order so a hit's triangle is three'sfaceIndex, with three's types on top.raycastandraycastFirsttake a threeRayand a side, a material or an array of materials (by group), and return three intersections in the geometry's space, as three-mesh-bvh's do. acceleratedRaycast runs the same walk forMesh.raycast.