Find the closest point position

I’m having a project with 4 planes with an image on it. I’m using orbitcontrols to move around the 4 planes. The 2 pictures here give you and idea what I mean:


What I want now is that when you stop dragging with the orbitcontrols and for example, you end up with the camera position (4, 0, -4) like in the example, the camera needs to snap to the closest plane position. My question is how I need to calculate this with a Vector3, so it returns the position of the plane that is the closets to the stop point.

Have you considered to compute the (squared) euclidian distance from your stop point to all plane positions and then choose the plane with the smallest distance?

function get_info(c_p) {
var ps = [ [0, 0, 0], [10, 0, -10], [0, 0, -20], [-10, 0, -10] ];
function g_dis(pos) { return Math.hypot( pos[0] - c_p[0], pos[1] - c_p[1], pos[2] - c_p[2] ); };
ps.forEach( (_, i) => ps[i] = [i+1,_, g_dis(_)] );
return ps.sort( (a,b) => a[2] - b[2] );
}
Ex: alert( get_info( [4, 0, -4] ).join('\n') );

The get_info function takes an array of [x,y,z] and returns a two dimensional array sorted by shortest distance.