/** * Safari/Firefox-compatible BVH closest point implementation with normal output. * * Legacy packed-buffer query that returns both signed distance and surface * normal for callers that have not migrated to BVHComputeData yet. * * Returns vec4(signedDistance, normalX, normalY, normalZ) for direct use * in particle boundary constraints without SDF precomputation. */ import type { NodeBuilder } from 'three/webgpu'; import type { TSLFloatNode, TSLFunction, TSLStorageNode, TSLVec3Node, TSLVec4Node } from '../../types/tsl.js'; export interface TriangleClosestPointParameters { p: TSLVec3Node; v0: TSLVec3Node; v1: TSLVec3Node; v2: TSLVec3Node; } export interface TriangleDistanceSqToBoundsParameters { point: TSLVec3Node; boundsMin: TSLVec3Node; boundsMax: TSLVec3Node; } export interface TriangleClosestPointWGSLFunction { (parameters: TriangleClosestPointParameters): TSLVec4Node; build(builder: NodeBuilder): void; } export interface TriangleDistanceSqToBoundsWGSLFunction { (parameters: TriangleDistanceSqToBoundsParameters): TSLFloatNode; build(builder: NodeBuilder): void; } export type BVHClosestPointWithNormalArguments = [ point: TSLVec3Node, maxDistance: TSLFloatNode ]; export type BVHClosestPointWithNormalFunction = TSLFunction; /** * Computes the closest point on a triangle to a given point. * Returns vec4(closestPoint.xyz, unused). */ export declare const closestPointToTriangleWGSL: TriangleClosestPointWGSLFunction; /** * Computes the squared distance from a point to an AABB. */ export declare const distanceSqToBoundsWGSL: TriangleDistanceSqToBoundsWGSLFunction; /** * Creates a BVH closest point function that returns signed distance AND surface normal. * * This extended version is designed for constraint systems where you need * both the penetration depth and the push direction. * * Uses the TSL Fn() pattern which: * 1. Accesses storage buffers via .element() - generates NodeBuffer_XXX.value[i] syntax * 2. Avoids ptr in function signatures * 3. Works on Safari/Firefox WebGPU * * @param {StorageBufferNode} bvhIndexBuffer - Storage buffer for triangle indices (uvec3) * @param {StorageBufferNode} bvhPositionBuffer - Storage buffer for vertex positions (vec3f) * @param {StorageBufferNode} bvhNodeBuffer - Storage buffer for BVH nodes (flat f32 array) * @returns {Function} A TSL function that computes closest point with normal * @deprecated Use `BVHComputeData` from `three-mesh-bvh/webgpu` with the three-blocks boundary-pass overloads. */ export declare function createBVHClosestPointWithNormalFn(bvhIndexBuffer: TSLStorageNode<'uvec3'>, bvhPositionBuffer: TSLStorageNode<'vec3'>, bvhNodeBuffer: TSLStorageNode<'float'>): BVHClosestPointWithNormalFunction;