Account for terrain setup work and verify sampler restoration

This commit is contained in:
n30nex committed 2026-09-12 22:03:07 -04:00
1 parent 21049a51a9
commit 2a32409b93
2 files changed
+12 -1

No files matched your search

+11
View File
@@ -20,6 +20,17 @@ describe('historical route WebGL geometry', () => {
const sample = terrainBatchSampler({ getCenter: () => ({ lng: 0, lat: 0 }), queryTerrainElevation: () => 75 });
expect(sample([0, 0])).toBe(75);
});
it('restores the native method when the calibration query fails', () => {
const terrain = { getElevationForLngLatZoom: () => 25 };
const original = Object.getOwnPropertyDescriptor(terrain, 'getElevationForLngLatZoom');
let failing = true;
const sample = terrainBatchSampler({
terrain, getCenter: () => ({ lng: 0, lat: 0 }),
queryTerrainElevation: () => { if (failing) { failing = false; throw new Error('not ready'); } return 25; },
});
expect(Object.getOwnPropertyDescriptor(terrain, 'getElevationForLngLatZoom')).toEqual(original);
expect(sample([0, 0])).toBe(25);
});
it('removes redundant straight subdivisions without flattening relief or reversing a path', () => {
expect(collapseCollinearPositions([[0, 0, 0], [0.5, 0.5, 0.5], [1, 1, 1]])).toEqual([[0, 0, 0], [1, 1, 1]]);
expect(collapseCollinearPositions([[0, 0, 0], [0.5, 0.5, 0.6], [1, 1, 1]])).toHaveLength(3);
+1 -1
View File
@@ -215,7 +215,7 @@ export class HistoricalRouteLayer implements CustomLayerInterface {
if (packedOffset === GPU_CHUNK_FLOATS) { chunks.push(packed); packed = undefined; packedOffset = 0; }
}
};
let sliceStarted = performance.now();
let sliceStarted = started;
let maximumSlice = 0;
let workMs = 0;
for (const route of routes) {