From 6cc38e3317035b9afc37d9472031c91f17e5530b Mon Sep 17 00:00:00 2001 From: paulaboks Date: Fri, 13 Mar 2026 18:03:32 -0300 Subject: [PATCH] Improve meshs --- client/components/dimension.ts | 16 +++++++++++++++- client/systems/rendering/dimension.ts | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client/components/dimension.ts b/client/components/dimension.ts index 2e4eb34..9a6a9b6 100644 --- a/client/components/dimension.ts +++ b/client/components/dimension.ts @@ -73,7 +73,7 @@ export class Dimension extends Component { ); if (!chunk) { - return 0; + return -1; } const lx = x - chunk_x * CHUNK_SIZE; @@ -114,6 +114,20 @@ export class Dimension extends Component { chunk.generated = true; chunk.dirty = true; } + + const neighbors = [ + [cx - 1, cz], + [cx + 1, cz], + [cx, cz - 1], + [cx, cz + 1], + ]; + + for (const [nx, nz] of neighbors) { + const neighbor = this.chunks.find((c) => c.x === nx && c.z === nz); + if (neighbor && neighbor.generated) { + neighbor.dirty = true; + } + } } unload_chunk(cx: number, cz: number) { diff --git a/client/systems/rendering/dimension.ts b/client/systems/rendering/dimension.ts index c11b7a6..ecddf73 100644 --- a/client/systems/rendering/dimension.ts +++ b/client/systems/rendering/dimension.ts @@ -82,6 +82,9 @@ function make_chunk_mesh(chunk: Chunk, dimension: Dimension, camera: Camera) { const show_face = (x: number, y: number, z: number) => { const block = dimension.get_block(x, y, z); + if (block === -1) { + return false; + } if (block === 0) { return true; }