function drawTiles(ctx, tiles) {
ctx.clearRect(0, 0, width, height);
let scale = tiles.scale;
const tx = Math.round(tiles.translate[0] * scale) / scale;
const ty = Math.round(tiles.translate[1] * scale) / scale;
for (const [x, y, z] of tiles) {
const [xw, yw, zw] = d3.tileWrap([x, y, z]);
let tileBox = cache.retrieve([zw, xw, yw]);
if (!tileBox) continue;
drawTileBox(ctx, tileBox, x + tx, y + ty, scale);
}
}