Skip to main content

Function: enableAcceleratedRaycast()

enableAcceleratedRaycast(): Promise<boolean>

Defined in: src/utils/BVHRaycast.ts:79

Dynamically import three-mesh-bvh and install the prototype patches that route THREE.Mesh.raycast through the accelerated path when the target mesh has a computed bounds tree. Adds computeBoundsTree / disposeBoundsTree helpers to THREE.BufferGeometry.

Async because the BVH module is loaded on demand (same pattern as troika-three-text). Resolves to true if the module loaded and patches were applied, false if the module isn't available — in which case meshes continue to use the stock raycaster.

Safe to call multiple times. The first call kicks off the import, subsequent calls share the same promise.

Returns

Promise<boolean>