Skip to content

Commit eebc537

Browse files
committed
replace flatMap() and update logic to count all meshes in tile
1 parent 7baed5e commit eebc537

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/labels/main_pass.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export default async function mainThreadLabelCollisionPass (tiles, view_zoom, hi
2424
// Adaptive collision grid, using a heuristic based on the tile with the most labels
2525
const max_tile_label_count =
2626
Math.max(0, ...Object.values(tiles)
27-
.flatMap(t => Object.values(t.meshes))
28-
.map(m => m[0].labels && Object.keys(m[0].labels).length)
29-
.filter(x => x)
27+
.map(t => Object.values(t.meshes))
28+
.flat()
29+
.map(meshes => Math.max(0, ...meshes.map(mesh => mesh.labels ? Object.keys(mesh.labels).length : 0)))
3030
);
3131

3232
const grid_divs = Math.floor(max_tile_label_count / Geo.tile_size); // heuristic of label density to tile size

0 commit comments

Comments
 (0)