fix(street-level): budgeted mesh sampling, in-place cones, date line, horizon

From the IC8 review of #768, each with tests that fail before:

- P1: a mesh batch no longer rebuilds the selected sequence's cones. The
  drawn cones are indexed by mesh cell; a batch that touches none of them
  is ignored and the affected cones are moved in place (no removeAll/add).
- P2: mesh sampling keeps to its 6 ms slices. Requests are taken in inside
  the budget, only cells within range of the camera are queued, the queue
  is a persistent min-heap re-ranked in one pass only after a 100 m camera
  move, and the deadline starts before any work. Coverage keeps a bounding
  box per line and densifies a line only once it comes within range. On a
  synthetic dense tile (600 x 40 points): slice median ~10 ms -> 5 ms, max
  18-30 ms -> 6.7 ms, refresh cost 11-24 ms -> 1.5-3 ms.
- P2: image cones and the photo marker are horizon-culled like the
  overview dots (one createHorizonCull in view.js, shared by all three).
- P2: a selection change recolours the previous zoom's lines still on
  screen and the old lines a cast swap keeps showing.
- P2: distances (metresBetween), line densification and ground-corner
  requests go the short way round +-180 deg (wrapLon in tileMath.js), so
  nearest ordering, cone thinning, mesh range and cast lines are right
  across the date line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Said TurkseverandClaude Opus 5.5 committed 2026-10-06 15:16:57 +01:00
1 parent 09fc10756c
commit bd97d38a99
15 files changed
+1085 -164

No files matched your search

+12
View File
@@ -9,6 +9,7 @@ import {
tileBounds,
tileLocalToLonLat,
tilesForBbox,
wrapLon,
} from './tileMath.js';
test('lon/lat to tile matches the Sacramento reference tile', () => {
@@ -125,3 +126,14 @@ test('a focus ranks tiles along the line of sight, not from the box centre (revi
assert.ok(keys.includes(centre), 'the tile at the centre of the screen');
assert.equal(ranked.total > 9, true);
});
test('wrapLon wraps longitudes and their differences into [-180, 180]', () => {
assert.equal(wrapLon(10.0005), 10.0005, 'in range: unchanged');
assert.equal(wrapLon(180), 180);
assert.equal(wrapLon(-180), -180);
assert.ok(Math.abs(wrapLon(180.001) - -179.999) < 1e-9);
assert.ok(Math.abs(wrapLon(-359.9998) - 0.0002) < 1e-9);
assert.ok(Math.abs(wrapLon(359.9998) - -0.0002) < 1e-9);
assert.ok(Math.abs(wrapLon(540.5) - -179.5) < 1e-9);
assert.ok(Number.isNaN(wrapLon(NaN)));
});