examples/vr_crop/quickhull.js
function(newFaces) {
      if (this.unassigned.isEmpty() === false) {
        var vertex = this.unassigned.first();

        do {
          // buffer 'next' reference, see .deleteFaceVertices()

          var nextVertex = vertex.next;

          var maxDistance = this.tolerance;

          var maxFace = null;

          for (var i = 0; i < newFaces.length; i++) {
            var face = newFaces[i];

            if (face.mark === Visible) {
              var distance = face.distanceToPoint(vertex.point);

              if (distance > maxDistance) {
                maxDistance = distance;
                maxFace = face;
              }

              if (maxDistance > 1000 * this.tolerance) break;
            }
          }

          // 'maxFace' can be null e.g. if there are identical vertices

          if (maxFace !== null) {
            this.addVertexToFace(vertex, maxFace);
          }

          vertex = nextVertex;
        } while (vertex !== null);
      }

      return this;
    }
function(newFaces) {
      if (this.unassigned.isEmpty() === false) {
        var vertex = this.unassigned.first();

        do {
          // buffer 'next' reference, see .deleteFaceVertices()

          var nextVertex = vertex.next;

          var maxDistance = this.tolerance;

          var maxFace = null;

          for (var i = 0; i < newFaces.length; i++) {
            var face = newFaces[i];

            if (face.mark === Visible) {
              var distance = face.distanceToPoint(vertex.point);

              if (distance > maxDistance) {
                maxDistance = distance;
                maxFace = face;
              }

              if (maxDistance > 1000 * this.tolerance) break;
            }
          }

          // 'maxFace' can be null e.g. if there are identical vertices

          if (maxFace !== null) {
            this.addVertexToFace(vertex, maxFace);
          }

          vertex = nextVertex;
        } while (vertex !== null);
      }

      return this;
    }
function ( newFaces ) { if ( this . unassigned . isEmpty ( ) === false ) { var vertex = this . unassigned . first ( ) ; do { // buffer 'next' reference, see .deleteFaceVertices() var nextVertex = vertex . next ; var maxDistance = this . tolerance ; var maxFace = null ; for ( var i = 0 ; i < newFaces . length ; i ++ ) { var face = newFaces [ i ] ; if ( face . mark === Visible ) { var distance = face . distanceToPoint ( vertex . point ) ; if ( distance > maxDistance ) { maxDistance = distance ; maxFace = face ; } if ( maxDistance > 1000 * this . tolerance ) break ; } } // 'maxFace' can be null e.g. if there are identical vertices if ( maxFace !== null ) { this . addVertexToFace ( vertex , maxFace ) ; } vertex = nextVertex ; } while ( vertex !== null ) ; } return this ; }
Reassigns as many vertices as possible from the unassigned list to the new faces
Reassigns as many vertices as possible from the unassigned list to the new faces