docsby gkjohnson
Ray tracing a mesh's BVH in a compute shader
On this page

Methods

new BVHComputeData(
	// Scene objects to include. A single item or array of Object3D, BufferGeometry, or GeometryBVH instances are all accepted and wrapped automatically in a BVH.
	objects: Object3D | BufferGeometry | GeometryBVH | Array,
	options?: {
		// WGSL type map for the interleaved per-vertex attribute buffer. Keys are geometry attribute names; values are WGSL type strings (e.g. `'vec3f'`, `'vec4f'`).
		attributes: Record<string, string> = { position: 'vec4f' },

		// When true, a MeshBVH is automatically built for any object that does not already have `geometry.boundsTree` set.
		autogenerateBvh: boolean = true
	}
)
getRootObject(): Object3D
getShapecastFn(
	options: {
		// Function name. Defaults to a random identifier.
		name?: string,

		// TSL struct or definition describing the query shape.
		shapeStruct: StructTypeNode,

		// TSL struct for the accumulated result, or null.
		resultStruct?: StructTypeNode | null,

		// function node that runs before the bvh traversal - useful for resetting or initializing necessary module variables.
		prefixFn?: function | null,

		// function node controlling left/right child traversal order.
		boundsOrderFn?: function | null,

		// function node testing the shape against a BVH node's bounds.
		intersectsBoundsFn: function,

		// function node testing the shape against a leaf triangle range.
		intersectRangeFn: function,

		// function node that transforms the shape into object local space.
		transformShapeFn?: function | null,

		// function node that transforms a hit result back to world space.
		transformResultFn?: function | null,

		// function node called after each BLAS traversal to reset any per-object state set by `transformShapeFn`.
		resetShapeFn?: function | null
	}
): function
update(): void
updateTransforms(): void
dispose(): void