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
// To fix the display gaps, we need to pad the bounds
lo[0]--
lo[1]--
lo[2]--
hi[0]++
hi[1]++
hi[2]++
e.g., with 32x chunks, game.voxels.getBounds(0,0,0) is from [0,32), (1,1,1) is from [32,64), etc — but the voxel array is actually 34x, with the voxels on each side one outside of the chunk bounds. -1, 0, ... 32, 33. The boundary voxels are generated twice, in each adjacent chunk.
Generating twice is fine for the simple example generators but causes difficulty in adapting voxel-land for ndarray. Not sure how to best handle this, currently it generates 32x chunks (opts.chunkSize) but this creates empty voxel face borders at chunk boundaries since 34x is expected. Padding the boundaries with air:
for (var k = lo[2]+1; k < hi[2]-1; k++)
for (var j = lo[1]+1; j < hi[1]-1; j++)
for(var i = lo[0]+1; i < hi[0]-1; i++) {
data.set(k-lo[2], j-lo[1], i-lo[0], fn(i, j, k))
}
with https://github.com/deathcap/voxel-land/issues/12
voxel-mesher/mesh.js:
so voxel/index.js generate() (ndarray version https://github.com/maxogden/voxel/pull/18) does:
e.g., with 32x chunks,
game.voxels.getBounds(0,0,0)
is from[0,32)
,(1,1,1)
is from[32,64)
, etc — but the voxel array is actually 34x, with the voxels on each side one outside of the chunk bounds. -1, 0, ... 32, 33. The boundary voxels are generated twice, in each adjacent chunk.Generating twice is fine for the simple example generators but causes difficulty in adapting voxel-land for ndarray. Not sure how to best handle this, currently it generates 32x chunks (
opts.chunkSize
) but this creates empty voxel face borders at chunk boundaries since 34x is expected. Padding the boundaries with air:alters ambient occlusion: