Seasons api

This commit is contained in:
2026-10-08 13:42:18 -03:00
parent 7e7ac8f6f4
commit dd66d6caa7
16 changed files with 231 additions and 10 deletions
+12
View File
@@ -52,6 +52,8 @@ export interface Chunk {
max_y: number;
// only for translucent meshes that have to be sorted again as the camera moves
translucent_sort?: TranslucentSort;
// each column's biome id, x then z
biomes: string[];
// each column's biome grass color, x then z, then each column's foliage color, then water color
biome_colors: Uint32Array;
// from its last mesh, see get_light. undefined until it's been meshed
@@ -189,6 +191,7 @@ export class ClientLevel {
if (chunk) {
// its old mesh stays up until the new one is ready
chunk.blocks = blocks;
chunk.biomes = biomes;
chunk.biome_colors = biome_colors;
this.#mark_dirty(chunk);
} else {
@@ -196,6 +199,7 @@ export class ClientLevel {
x,
z,
blocks,
biomes,
biome_colors,
dirty: true,
mesh_version: 0,
@@ -330,6 +334,14 @@ export class ClientLevel {
return block ? collision_shape_at(block, value) : true;
}
// the column's biome, undefined in unloaded chunks
biome_at(x: number, z: number): string | undefined {
const chunk_x = Math.floor(x / CHUNK_SIZE);
const chunk_z = Math.floor(z / CHUNK_SIZE);
return this.get_chunk(chunk_x, chunk_z)
?.biomes[(z - chunk_z * CHUNK_SIZE) * CHUNK_SIZE + (x - chunk_x * CHUNK_SIZE)];
}
// the biome's water color at a column as 0xRRGGBB, see "tint". plains' in unloaded chunks
water_color(x: number, z: number) {
const chunk_x = Math.floor(x / CHUNK_SIZE);