refactor: Optimize rendering with chunk canvas caching and performance improvements

This commit is contained in:
Kacper Kostka (aider)
2025-04-05 15:49:13 +02:00
parent d87105baad
commit bb45c9fba8
3 changed files with 170 additions and 113 deletions

View File

@@ -528,11 +528,11 @@ function generateChunksAroundPlayer() {
const key = getChunkKey(chunkX, chunkY);
// Always generate stone layer chunks
const isNewChunk = !chunks.has(key);
getOrCreateChunk(chunkX, chunkY);
// Mark as dirty only if it's a new chunk or if it's visible
if (!chunks.has(key) || visibleChunks.some(chunk =>
chunk.chunkX === chunkX && chunk.chunkY === chunkY && chunk.isVisible)) {
// Mark as dirty only if it's a new chunk
if (isNewChunk) {
dirtyChunks.add(key);
}
}