closestPointToPointParameter method

double closestPointToPointParameter(
  1. Vector3 point,
  2. bool clampToLine
)

Implementation

double closestPointToPointParameter(Vector3 point, bool clampToLine) {
  _startP.subVectors(point, start);
  _startEnd.subVectors(end, start);

  final startEnd2 = _startEnd.dot(_startEnd);
  final startEndStartP = _startEnd.dot(_startP);

  var t = startEndStartP / startEnd2;

  if (clampToLine) {
    t = MathUtils.clamp(t, 0, 1);
  }

  return t;
}