Improve meshs

This commit is contained in:
2026-03-13 18:03:32 -03:00
parent 5348cd3d06
commit 6cc38e3317
2 changed files with 18 additions and 1 deletions
+15 -1
View File
@@ -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) {
+3
View File
@@ -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;
}