Get the closest point of an object's surface from any Vector3

I need to get the closest point of an object’s surface from any Vector3.

It is basically this question :

https://codepen.io/maurizzzio/pen/pERqxV?editors=0010

Unfornunatly the algorythm in the answer is outdated because it uses legacy Geomerties

I need this to work with today’s BufferGeometry

Thank you.

see pathfinding3d
Are you seeking to identify the nearest triangle based on known coordinates? In pathfinding3d, the get_closest_node function might be of assistance. I recommend exploring this library; it is remarkably efficient.

The get_closest_node_id function can be of assistance. By setting the final parameter, check_polygon, to false, the returned result need not be restricted to a node on the navmesh; instead, it will identify the nearest node in the entire space. During the algorithm’s construction phase, a k-d tree is employed to optimize spatial searches, ensuring exceptional speed. Furthermore, as it is implemented in WebAssembly (WASM), its performance is 10 to 20 times faster than that of JavaScript.