Skip to content

Commit 567f837

Browse files
spepsgithub-actions[bot]
authored andcommitted
[GLJS-1474] Apply fix for model layer density reduction so when zoom is greater than maxZoom+2 it's disabled (internal-6259)
GitOrigin-RevId: f62fd20882630276351d42485fede88a0d0f34d9
1 parent 83cf0ec commit 567f837

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

3d-style/data/bucket/model_bucket.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ class ModelBucket implements Bucket {
137137
this.maxScale = 0;
138138
this.maxHeight = 0;
139139
// reduce density, more on lower zooms and almost no reduction in overscale range.
140-
// Heuristics is related to trees performance.
141-
this.lookupDim = this.zoom > this.canonical.z ? 256 : this.zoom > 15 ? 75 : 100;
140+
// Heuristics is related to trees performance. Disable density check after maxZoom + 2.
141+
// For vector tiles this means:
142+
// z15 and lower: lookup grid of size 75x75 per tile
143+
// z16: 100x100, z17: 256x256, z18: no density reduction.
144+
this.lookupDim = this.zoom > (this.canonical.z + 1) ? 0 : (this.zoom > this.canonical.z ? 256 : this.zoom > 15 ? 75 : 100);
142145
this.instanceCount = 0;
143146

144147
this.terrainElevationMin = 0;
@@ -380,13 +383,15 @@ class ModelBucket implements Bucket {
380383
continue; // Clip on tile borders to prevent duplicates
381384
}
382385
// reduce density
383-
const tileToLookup = (this.lookupDim - 1.0) / EXTENT;
384-
const lookupIndex = this.lookupDim * ((point.y * tileToLookup) | 0) + (point.x * tileToLookup) | 0;
385-
if (this.lookup) {
386-
if (this.lookup[lookupIndex] !== 0) {
387-
continue;
386+
if (this.lookupDim !== 0) {
387+
const tileToLookup = (this.lookupDim - 1.0) / EXTENT;
388+
const lookupIndex = this.lookupDim * ((point.y * tileToLookup) | 0) + (point.x * tileToLookup) | 0;
389+
if (this.lookup) {
390+
if (this.lookup[lookupIndex] !== 0) {
391+
continue;
392+
}
393+
this.lookup[lookupIndex] = 1;
388394
}
389-
this.lookup[lookupIndex] = 1;
390395
}
391396
this.instanceCount++;
392397
const i = instancedDataArray.length;

0 commit comments

Comments
 (0)