Intersection intersect(Ray r, num prevBestDistance)

Performs a ray - primitive intersection test. Returns an Intersection object with the associated information.

If the ray did not hit the primitive, the distance will be negative.

Source

Intersection intersect(Ray r, num prevBestDistance) {
  Intersection intRet = _xAxis.intersect(r, prevBestDistance);
  // check if hitpoint is near x axis;
  if (intRet.distance > 0 && intRet.hitPoint.z.abs() < THRESH && intRet.hitPoint.y.abs() < THRESH) {
    return intRet;
  }

  intRet = _yAxis.intersect(r, prevBestDistance);
  // check if hitpoint is near y axis;
  if (intRet.distance > 0 && intRet.hitPoint.x.abs() < THRESH && intRet.hitPoint.z.abs() < THRESH) {
    return intRet;
  }

  intRet = _zAxis.intersect(r, prevBestDistance);
  // check if hitpoint is near z axis;
  if (intRet.distance > 0 && intRet.hitPoint.x.abs() < THRESH && intRet.hitPoint.y.abs() < THRESH) {
    return intRet;
  }

  // no hit at all..
  return new Intersection();
}