code: function flatten(data) {
          var dim = data[0][0].length, result = { vertices: new Array(), holes: new Array(), dimensions: dim }, holeIndex = 0;
          for (var i = 0; i < data.length; i++) {
              for (var j = 0; j < data[i].length; j++) {
                  for (var d = 0; d < dim; d++)
                      result.vertices.push(data[i][j][d]);
              }
              if (i > 0) {
                  holeIndex += data[i - 1].length;
                  result.holes.push(holeIndex);
              }
          }
          return result;
      }
docs: turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts