code: function intersectCheck(candidate) {
        var dist = r2;
        var half = candidate.half;
        if (cx < candidate.x - half) dist -= sqr(cx - (candidate.x - half));
        else if (cx > candidate.x + half) dist -= sqr(cx - (candidate.x + half));
  
        if (cy < candidate.y - half) dist -= sqr(cy - (candidate.y - half));
        else if (cy > candidate.y + half) dist -= sqr(cy - (candidate.y + half));
  
        if (cz < candidate.z - half) dist -= sqr(cz - (candidate.z - half));
        else if (cz > candidate.z + half) dist -= sqr(cz - (candidate.z + half));
        return dist > 0;
      }
docs: http://stackoverflow.com/questions/4578967/cube-sphere-intersection-test