code: function computeMesh(array, voxelSideTextureIDs, voxelSideTextureSizes) {
    var shp = array.shape.slice(0)
    var nx = (shp[0]-2)|0
    var ny = (shp[1]-2)|0
    var nz = (shp[2]-2)|0
    var sz = nx * ny * nz
    var scratch0 = pool.mallocInt32(sz)
    var scratch1 = pool.mallocInt32(sz)
    var scratch2 = pool.mallocInt32(sz)
    var rshp = [nx, ny, nz]
    var ao0 = ndarray(scratch0, rshp)
    var ao1 = ndarray(scratch1, rshp)
    var ao2 = ndarray(scratch2, rshp)
    
    //Calculate ao fields
    surfaceStencil(ao0, ao1, ao2, array)
    
    //Build mesh slices
    meshBuilder.ptr = 0
    meshBuilder.voxelSideTextureIDs = voxelSideTextureIDs
    meshBuilder.voxelSideTextureSizes = voxelSideTextureSizes
    
    var buffers = [ao0, ao1, ao2]
    for(var d=0; d<3; ++d) {
      var u = (d+1)%3
      var v = (d+2)%3
      
      //Create slice
      var st = buffers[d].transpose(d, u, v)
      var slice = st.pick(0)
      var n = rshp[d]|0
      
      meshBuilder.d = d
      meshBuilder.u = v
      meshBuilder.v = u
      
      //Generate slices
      for(var i=0; i<n; ++i) {
        meshBuilder.z = i
        meshSlice(slice)
        slice.offset += st.stride[0]
      }
    }
    
    //Release buffers
    pool.freeInt32(scratch0)
    pool.freeInt32(scratch1)
    pool.freeInt32(scratch2)
    
    //Release uint8 array if no vertices were allocated
    if(meshBuilder.ptr === 0) {
      return null
    }
    
    //Slice out buffer
    var rbuffer = meshBuilder.buffer
    var rptr = meshBuilder.ptr
    meshBuilder.buffer = pool.mallocUint8(1024)
    meshBuilder.ptr = 0
    return rbuffer.subarray(0, rptr)
  }
docs: Compute a mesh