three-mesh-bvh
Version:
A BVH implementation to speed up raycasting against three.js meshes.
18 lines (11 loc) • 406 B
JavaScript
// converts the given BVH raycast intersection to align with the three.js raycast
// structure (include object, world space distance and point).
export function convertRaycastIntersect( hit, object, raycaster ) {
if ( hit === null ) {
return null;
}
hit.point.applyMatrix4( object.matrixWorld );
hit.distance = hit.point.distanceTo( raycaster.ray.origin );
hit.object = object;
return hit;
}