Snapping in 3D is certainly not a trivial feature. It usually involves some sort of 3D spatial data query to figure out what the closest point is- Whether that’s a point on a polyline, a vertex in a mesh, or a point on a surface of a volume. The implementation will likely depend on your use case and what exactly you’re snapping to. There are some research papers on snapping out there which could point you in the right direction, such as this one.
If you do pursue a workflow or tool like this, we’d be interested in hearing how it goes!