closestPointToPoint method

Vector3 closestPointToPoint(
  1. Vector3 point,
  2. Vector3 target
)

Implementation

Vector3 closestPointToPoint(Vector3 point, Vector3 target) {
  target.sub2(point, origin);
  final directionDistance = target.dot(direction);
  if (directionDistance < 0) {
    return target.setFrom(origin);
  }
  return target.setFrom(direction).scale(directionDistance).add(origin);
}