parent
a7e6a49a79
commit
f668c025f2
|
@ -123,8 +123,8 @@ class ChunkLoader {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.bcRemoveChunks(remChunks);
|
this.bcRemoveChunks(remChunks);
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console,max-len
|
||||||
console.log(`GC cleaned ${remChunks.length} chunks.`);
|
console.log(`GC cleaned ${remChunks.length} / ${chunks.size + remChunks.length} chunks`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -272,20 +272,31 @@ class Renderer2D extends Renderer {
|
||||||
cx,
|
cx,
|
||||||
cy,
|
cy,
|
||||||
) {
|
) {
|
||||||
if (cz !== this.tiledZoom) {
|
const { tiledZoom } = this;
|
||||||
|
if (cz > tiledZoom + 1) {
|
||||||
return false;
|
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 { width, height } = this.viewport;
|
||||||
const CHUNK_RENDER_RADIUS_X = Math.ceil(
|
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(
|
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)
|
if (Math.abs(cx - xc) <= CHUNK_RENDER_RADIUS_X
|
||||||
<= CHUNK_RENDER_RADIUS_X && Math.abs(cy - yc)
|
&& Math.abs(cy - yc) <= CHUNK_RENDER_RADIUS_Y
|
||||||
<= CHUNK_RENDER_RADIUS_Y
|
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user