Closed andrewtheone closed 8 years ago
In that function, x,y,z
is the world-space location of each chunk and i,j,k
is the local position inside the chunk. So to set each block based on its global position, you want to look at i+x, j+y, k+z
.
Try something like this:
function decideBlock(x,y,z) {
// here xyz are world positions
if ((Math.abs(x) > 100) || (Math.abs(z) > 100)) return 0
if ((y >= -10) && (y < 1)) return grassID
return 0
}
for(var i = 0; i < data.shape[0]; i++) {
for(var j = 0; j < data.shape[1]; j++) {
for(var k = 0; k < data.shape[2]; k++) {
var block = decideBlock(x+i, y+j, z+k) // not (x,y,z) or (i,j,k) !
data.set(i,j,k, block)
}
}
}
Hey, merry christmas to you!
I'm trying to create a new world generation algorithm, I'd like to have a 200*200 flat space, the rest of the world should be "air" (hence: players could fall from the edges) My generation script is:
but I get strange effects, any idea?