intersectsPlane method

bool intersectsPlane(
  1. Plane plane
)

Implementation

bool intersectsPlane(Plane plane) {
  // check if the ray lies on the plane first

  var distToPoint = plane.distanceToPoint(origin);

  if (distToPoint == 0) {
    return true;
  }

  var denominator = plane.normal.dot(direction);

  if (denominator * distToPoint < 0) {
    return true;
  }

  // ray origin is behind the plane (and is pointing behind it)

  return false;
}