3D biomes

This commit is contained in:
2026-11-07 12:13:43 -03:00
parent b726ce9695
commit 22191d260c
53 changed files with 874 additions and 316 deletions
+3 -9
View File
@@ -27,13 +27,8 @@ async function mesh_block(id: string, x: number, middle: Colors, west: Colors |
const empty = () => new Uint32Array(DEFAULT_SHAPE.volume);
const chunks = [empty(), empty(), empty(), empty(), chunk, empty(), empty(), empty(), empty()];
const colors = chunks.map(() => null as Uint32Array | null);
const biome_colors = ({ grass, foliage, water = 0 }: Colors) => {
const array = new Uint32Array(CHUNK_AREA * 3);
array.fill(grass, 0, CHUNK_AREA);
array.fill(foliage, CHUNK_AREA, CHUNK_AREA * 2);
array.fill(water, CHUNK_AREA * 2);
return array;
};
// the colors of each chunk's one biome
const biome_colors = ({ grass, foliage, water = 0 }: Colors) => Uint32Array.of(grass, foliage, water);
colors[4] = biome_colors(middle);
if (west) colors[3] = biome_colors(west);
@@ -105,8 +100,7 @@ Deno.test("every column the overworld generates has a biome with grass, foliage
blocks.forEach((b, nid) => block_ids[b.id] = nid);
for (const [x, z] of [[0, 0], [30, -12], [-80, 45]]) {
const { biomes } = generate_raw_chunk(x, z, game.world.seed, block_ids, game.world.worldgen).column;
assertEquals(biomes.length, CHUNK_AREA);
for (const biome of biomes) {
for (const biome of biomes.palette) {
const { colors } = get_biome(biome)!;
assert(colors.grass !== undefined, `${biome} has no grass color`);
assert(colors.foliage !== undefined, `${biome} has no foliage color`);