Improve a buuuunch of textures and some reworks
This commit is contained in:
@@ -45,6 +45,8 @@ export interface Chunk {
|
||||
// blocks its generation put in neighboring chunks (leaves), as x, y, z, numeric id. kept so a neighbor that
|
||||
// generates later, or unloads and comes back, still gets them
|
||||
spills?: Int32Array;
|
||||
// each column's biome grass then foliage color, once it's generated
|
||||
biome_colors?: Uint32Array;
|
||||
}
|
||||
|
||||
export interface ChunkMesh {
|
||||
@@ -446,9 +448,12 @@ export class ClientLevel {
|
||||
chunk.mesh_version += 1;
|
||||
// copies, the worker lights the whole 3x3 area
|
||||
const chunks: (Uint32Array | null)[] = [];
|
||||
const biome_colors: (Uint32Array | null)[] = [];
|
||||
for (let dz = -1; dz <= 1; dz++) {
|
||||
for (let dx = -1; dx <= 1; dx++) {
|
||||
chunks.push(this.get_chunk(chunk.x + dx, chunk.z + dz)?.blocks.slice() ?? null);
|
||||
const neighbor = this.get_chunk(chunk.x + dx, chunk.z + dz);
|
||||
chunks.push(neighbor?.blocks.slice() ?? null);
|
||||
biome_colors.push(neighbor?.biome_colors ?? null);
|
||||
}
|
||||
}
|
||||
this.workers.post({
|
||||
@@ -457,6 +462,7 @@ export class ClientLevel {
|
||||
chunk_z: chunk.z,
|
||||
version: chunk.mesh_version,
|
||||
chunks,
|
||||
biome_colors,
|
||||
camera: [camera.x, camera.y, camera.z],
|
||||
}, chunks.filter((blocks) => blocks !== null).map((blocks) => blocks.buffer));
|
||||
}
|
||||
@@ -487,7 +493,7 @@ export class ClientLevel {
|
||||
|
||||
#on_worker_message(message: FromChunkWorker) {
|
||||
if (message.type === "generated") {
|
||||
this.#on_generated(message.chunk_x, message.chunk_z, message.blocks, message.spills);
|
||||
this.#on_generated(message.chunk_x, message.chunk_z, message.blocks, message.spills, message.biome_colors);
|
||||
} else if (message.type === "meshed") {
|
||||
this.#on_meshed(message);
|
||||
} else {
|
||||
@@ -495,7 +501,7 @@ export class ClientLevel {
|
||||
}
|
||||
}
|
||||
|
||||
#on_generated(cx: number, cz: number, blocks: Uint32Array, spills: Int32Array) {
|
||||
#on_generated(cx: number, cz: number, blocks: Uint32Array, spills: Int32Array, biome_colors: Uint32Array) {
|
||||
const key = chunk_key(cx, cz);
|
||||
// unloaded or cancelled while the worker was busy
|
||||
if (!this.pending_generation.delete(key)) {
|
||||
@@ -517,6 +523,7 @@ export class ClientLevel {
|
||||
chunk.generated = true;
|
||||
chunk.dirty = true;
|
||||
chunk.spills = spills;
|
||||
chunk.biome_colors = biome_colors;
|
||||
|
||||
// the same rules as the server (server/game/world.ts): a chunk's own blocks, then what its neighbors'
|
||||
// features put in it, only where it has air. both ways, since the neighbors may have generated first
|
||||
|
||||
Reference in New Issue
Block a user