examples/vr_crop/quickhull.js
function() {
      var min = new THREE.Vector3();
      var max = new THREE.Vector3();

      var minVertices = [];
      var maxVertices = [];

      var i, l, j;

      // initially assume that the first vertex is the min/max

      for (i = 0; i < 3; i++) {
        minVertices[i] = maxVertices[i] = this.vertices[0];
      }

      min.copy(this.vertices[0].point);
      max.copy(this.vertices[0].point);

      // compute the min/max vertex on all six directions

      for (i = 0, l = this.vertices.length; i < l; i++) {
        var vertex = this.vertices[i];
        var point = vertex.point;

        // update the min coordinates

        for (j = 0; j < 3; j++) {
          if (point.getComponent(j) < min.getComponent(j)) {
            min.setComponent(j, point.getComponent(j));
            minVertices[j] = vertex;
          }
        }

        // update the max coordinates

        for (j = 0; j < 3; j++) {
          if (point.getComponent(j) > max.getComponent(j)) {
            max.setComponent(j, point.getComponent(j));
            maxVertices[j] = vertex;
          }
        }
      }

      // use min/max vectors to compute an optimal epsilon

      this.tolerance =
        3 *
        Number.EPSILON *
        (Math.max(Math.abs(min.x), Math.abs(max.x)) +
          Math.max(Math.abs(min.y), Math.abs(max.y)) +
          Math.max(Math.abs(min.z), Math.abs(max.z)));

      return { min: minVertices, max: maxVertices };
    }
function() {
      var min = new THREE.Vector3();
      var max = new THREE.Vector3();

      var minVertices = [];
      var maxVertices = [];

      var i, l, j;

      // initially assume that the first vertex is the min/max

      for (i = 0; i < 3; i++) {
        minVertices[i] = maxVertices[i] = this.vertices[0];
      }

      min.copy(this.vertices[0].point);
      max.copy(this.vertices[0].point);

      // compute the min/max vertex on all six directions

      for (i = 0, l = this.vertices.length; i < l; i++) {
        var vertex = this.vertices[i];
        var point = vertex.point;

        // update the min coordinates

        for (j = 0; j < 3; j++) {
          if (point.getComponent(j) < min.getComponent(j)) {
            min.setComponent(j, point.getComponent(j));
            minVertices[j] = vertex;
          }
        }

        // update the max coordinates

        for (j = 0; j < 3; j++) {
          if (point.getComponent(j) > max.getComponent(j)) {
            max.setComponent(j, point.getComponent(j));
            maxVertices[j] = vertex;
          }
        }
      }

      // use min/max vectors to compute an optimal epsilon

      this.tolerance =
        3 *
        Number.EPSILON *
        (Math.max(Math.abs(min.x), Math.abs(max.x)) +
          Math.max(Math.abs(min.y), Math.abs(max.y)) +
          Math.max(Math.abs(min.z), Math.abs(max.z)));

      return { min: minVertices, max: maxVertices };
    }
Computes the extremes of a simplex which will be the initial hull