diff --git a/src/ui/ChunkLoader.js b/src/ui/ChunkLoader.js index 85c4531..dc08d00 100644 --- a/src/ui/ChunkLoader.js +++ b/src/ui/ChunkLoader.js @@ -123,8 +123,8 @@ class ChunkLoader { } }); this.bcRemoveChunks(remChunks); - // eslint-disable-next-line no-console - console.log(`GC cleaned ${remChunks.length} chunks.`); + // eslint-disable-next-line no-console,max-len + console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`); } } diff --git a/src/ui/Renderer2D.js b/src/ui/Renderer2D.js index 3e92ce1..17e3d24 100644 --- a/src/ui/Renderer2D.js +++ b/src/ui/Renderer2D.js @@ -272,20 +272,31 @@ class Renderer2D extends Renderer { cx, cy, ) { - if (cz !== this.tiledZoom) { + const { tiledZoom } = this; + if (cz > tiledZoom + 1) { return false; } + + let [xc, yc] = this.centerChunk; + let { relScale } = this; + // adjust for tiledZoom differences + if (cz !== tiledZoom) { + const zFac = TILE_ZOOM_LEVEL ** (cz - tiledZoom); + xc = Math.floor(xc * zFac); + yc = Math.floor(yc * zFac); + relScale *= zFac; + } + const { width, height } = this.viewport; const CHUNK_RENDER_RADIUS_X = Math.ceil( - width / TILE_SIZE / 2 / this.relScale, + width / TILE_SIZE / 2 / relScale, ); const CHUNK_RENDER_RADIUS_Y = Math.ceil( - height / TILE_SIZE / 2 / this.relScale, + height / TILE_SIZE / 2 / relScale, ); - const [xc, yc] = this.centerChunk; - if (Math.abs(cx - xc) - <= CHUNK_RENDER_RADIUS_X && Math.abs(cy - yc) - <= CHUNK_RENDER_RADIUS_Y + + if (Math.abs(cx - xc) <= CHUNK_RENDER_RADIUS_X + && Math.abs(cy - yc) <= CHUNK_RENDER_RADIUS_Y ) { return true; }