is there a easy formula to calculate this? i\'ve been working on some math but i can only find a way to calculate the distance directed to the center of the box, not direct
For AABBs:
Maybe not the best performing, but certainly the simplest method:
p = your point
c = centre of the cube
s = half size of the cube
r = the point we are looking for
v = p - c; m = max_abs(v); r = c + ( v / m * s );