Improve meshs
This commit is contained in:
@@ -73,7 +73,7 @@ export class Dimension extends Component {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!chunk) {
|
if (!chunk) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lx = x - chunk_x * CHUNK_SIZE;
|
const lx = x - chunk_x * CHUNK_SIZE;
|
||||||
@@ -114,6 +114,20 @@ export class Dimension extends Component {
|
|||||||
chunk.generated = true;
|
chunk.generated = true;
|
||||||
chunk.dirty = 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) {
|
unload_chunk(cx: number, cz: number) {
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ function make_chunk_mesh(chunk: Chunk, dimension: Dimension, camera: Camera) {
|
|||||||
|
|
||||||
const show_face = (x: number, y: number, z: number) => {
|
const show_face = (x: number, y: number, z: number) => {
|
||||||
const block = dimension.get_block(x, y, z);
|
const block = dimension.get_block(x, y, z);
|
||||||
|
if (block === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (block === 0) {
|
if (block === 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user