Skip to content

Commit e1c8150

Browse files
committed
fix blockUpdate
1 parent 46ad55c commit e1c8150

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/client/scripts/World/World.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var World = class World {
5959
},
6060
});
6161
this.lastPlayerChunk = "";
62+
this.blocksUpdate = false;
6263
}
6364
/**
6465
* Updates render order of chunk meshes
@@ -98,6 +99,7 @@ var World = class World {
9899
voxelX = parseInt(voxelX);
99100
voxelY = parseInt(voxelY);
100101
voxelZ = parseInt(voxelZ);
102+
this.blocksUpdate = true;
101103
if (this.cellTerrain.getVoxel(voxelX, voxelY, voxelZ) !== value) {
102104
this.chunkWorker.postMessage({
103105
type: "setVoxel",
@@ -290,7 +292,13 @@ var World = class World {
290292
Math.floor(pos.y + 0.5),
291293
Math.floor(pos.z + 0.5)
292294
);
293-
if (this.lastPlayerChunk != JSON.stringify(cell)) {
295+
if (this.blocksUpdate) {
296+
this.blocksUpdate = false;
297+
this.chunkWorker.postMessage({
298+
type: "updateCellsAroundPlayer",
299+
data: [cell, radius],
300+
});
301+
} else if (this.lastPlayerChunk != JSON.stringify(cell)) {
294302
if (
295303
this.cellUpdateTime !== null &&
296304
performance.now() - this.cellUpdateTime > this.renderTime

0 commit comments

Comments
 (0)