intersectLine method

Vector3? intersectLine(
  1. Line3 line,
  2. Vector3 target
)

Implementation

Vector3? intersectLine(Line3 line, Vector3 target) {
  var direction = line.delta(_vector1);

  var denominator = normal.dot(direction);

  if (denominator == 0) {
    // line is coplanar, return origin
    if (distanceToPoint(line.start) == 0) {
      return target.copy(line.start);
    }

    // Unsure if this is the correct method to handle this case.
    return null;
  }

  var t = -(line.start.dot(normal) + constant) / denominator;

  if (t < 0 || t > 1) {
    return null;
  }

  return target.copy(direction).multiplyScalar(t).add(line.start);
}