closestPointToPoint method

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

Implementation

Vector3 closestPointToPoint(Vector3 point, Vector3 target) {
  target.subVectors(point, origin);

  var directionDistance = target.dot(direction);

  if (directionDistance < 0) {
    return target.copy(origin);
  }

  return target.copy(direction).multiplyScalar(directionDistance).add(origin);
}