docsby gkjohnson
Casting a thousand rays at a mesh every frame
Data courtesy of Stanford 3D Scanning Repository
On this page

Properties

resolveTriangleIndex: function

readonly

Methods

new MeshBVH(
	geometry: BufferGeometry,

	// Same options as GeometryBVH.
	options?: Object
)

serialize

static
static serialize(
	// The BVH to serialize.
	bvh: MeshBVH,
	options?: {
		// If `true`, the index and BVH root buffers are cloned so the serialized data is independent of the live BVH.
		cloneBuffers: boolean = true
	}
): SerializedBVH
static deserialize(
	// Serialized BVH data.
	data: SerializedBVH,

	// The geometry the BVH was originally built from.
	geometry: BufferGeometry,
	options?: {
		// If `true`, sets `geometry.index` from the serialized index buffer (creating one if none exists).
		setIndex: boolean = true
	}
): MeshBVH
shiftTriangleOffsets( offset: number ): void
raycastObject3D(
	object: Object3D,
	raycaster: Raycaster,
	intersects: Array<Intersection> = []
): Array<Intersection>
refit( nodeIndices: Set<number> | Array<number> | null = null ): void
raycast(
	ray: Ray,
	materialOrSide: number | Material | Array<Material> = FrontSide,
	near: number = 0,
	far: number = Infinity
): Array<Intersection>
raycastFirst(
	ray: Ray,
	materialOrSide: number | Material | Array<Material> = FrontSide,
	near: number = 0,
	far: number = Infinity
): Intersection | null
intersectsGeometry(
	otherGeometry: BufferGeometry,

	// Transform of `otherGeometry` into the local space of this BVH.
	geometryToBvh: Matrix4
): boolean
shapecast(
	callbacks: {
		intersectsBounds: ( box: Box3, isLeaf: boolean, score: number | undefined, depth: number, nodeIndex: number ) => number,
		intersectsTriangle?: ( triangle: ExtendedTriangle, triangleIndex: number, contained: boolean, depth: number ) => boolean,
		intersectsRange?: ( offset: number, count: number, contained: boolean, depth: number, nodeIndex: number, box: Box3 ) => boolean,
		boundsTraverseOrder?: ( box: Box3 ) => number
	}
): boolean
bvhcast(
	otherBvh: MeshBVH,

	// Transforms `otherBvh` into the local space of this BVH.
	matrixToLocal: Matrix4,
	callbacks: {
		intersectsRanges?: ( offset1: number, count1: number, offset2: number, count2: number, depth1: number, nodeIndex1: number, depth2: number, nodeIndex2: number ) => boolean,
		intersectsTriangles?: ( triangle1: ExtendedTriangle, triangle2: ExtendedTriangle, triangleIndex1: number, triangleIndex2: number, depth1: number, nodeIndex1: number, depth2: number, nodeIndex2: number ) => boolean
	}
): boolean
intersectsBox(
	box: Box3,

	// Transform of the box in the local space of this BVH.
	boxToBvh: Matrix4
): boolean
intersectsSphere( sphere: Sphere ): boolean
closestPointToGeometry(
	otherGeometry: BufferGeometry,

	// Transform of `otherGeometry` into the local space of this BVH.
	geometryToBvh: Matrix4,
	target1: HitPointInfo = {},
	target2: HitPointInfo = {},
	minThreshold: number = 0,
	maxThreshold: number = Infinity
): HitPointInfo | null
closestPointToPoint(
	point: Vector3,
	target: HitPointInfo = {},
	minThreshold: number = 0,
	maxThreshold: number = Infinity
): HitPointInfo | null
Finding the closest point on a mesh

Inherited