Ask for heights through one service per scene

About 20 sites called scene.sampleHeight, globe.getHeight,
scene.clampToHeight or the MostDetailed variants directly, each with its own
idea of a miss (undefined, NaN, a throw). They now ask heightsFor(scene) in
src/queries/heights.js:

- now(point, { against, exclude }) answers from what is loaded, or null;
  against is 'surface' (what is drawn) or 'terrain' (loaded terrain only).
- clampNow(position) moves a position onto the drawn surface, or null.
- batch() and clampBatch() wait for the most detailed tiles: null per
  missed point, a rejection when the whole query fails.
- supported() reports { surface, clamp } without allocating.

Cesium still answers now() synchronously, so nothing changes on screen and
nothing is slower: in the live app 1,000 calls cost the same through the
service as direct (terrain 0.5-0.7 ms, surface 2-6 ms a call, run-to-run
noise larger than the difference). Every site already treated a miss as
"hold the last value or fall back"; a renderer that can only answer from a
cache or asynchronously can now plug in at one place.

- A Bhote Koshi evidence point whose terrain sample misses stays at its
  fallback elevation instead of reading the miss as sea level.
- The mesh floor sampler skips a scene without depth-texture support
  instead of spending its budget on probes that throw.
- The world annotation probe's trace reads hit/missed.
- A source scan forbids direct height calls outside the service.

The service is exported as ./queries/heights and documented in
docs/APPLICATION.md.
This commit is contained in:
Sameh Khamis committed 2026-11-04 09:24:30 -08:00
1 parent b51f1bf7c5
commit d51ea4007b
32 files changed
+704 -210

No files matched your search

+2
View File
@@ -47,6 +47,8 @@
"src/input/testDoubles.mjs",
"src/input/sensorPick.js",
"src/input/dispatcher.js",
"src/queries/heights.js",
"src/queries/heights.test.mjs",
"docs/CODE-BOUNDARIES.md",
"src/main.js",
"docs/APPLICATION.md",
+27 -11
View File
@@ -15,7 +15,8 @@
"src/input/dispatcher.js",
"src/input/sensorPick.js",
"src/data/infrastructureOverlayEntry.js",
"src/sources/infrastructureData.js"
"src/sources/infrastructureData.js",
"src/queries/heights.js"
],
"external": ["cesium"]
},
@@ -1859,7 +1860,8 @@
"src/i18n/locales/ru.json",
"src/i18n/locales/uk.json",
"src/i18n/locales/zh-CN.json",
"src/i18n/locales/zh-Hant.json"
"src/i18n/locales/zh-Hant.json",
"src/queries/heights.js"
],
"external": ["cesium", "pbf", "@mapbox/vector-tile"]
},
@@ -1900,7 +1902,8 @@
"src/input/sensorPick.js",
"src/data/scenePick.js",
"src/data/pickRegistry.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium"]
},
@@ -2046,7 +2049,8 @@
"src/data/scenePick.js",
"src/input/sensorPick.js",
"src/data/pickRegistry.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium", "pbf", "@mapbox/vector-tile", "mapillary-js"]
},
@@ -2089,7 +2093,8 @@
"src/input/sensorPick.js",
"src/data/scenePick.js",
"src/data/pickRegistry.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium", "@mapbox/vector-tile", "pbf"]
},
@@ -3327,7 +3332,8 @@
"src/data/local_data/wof_neighborhoods/files.js",
"src/data/entityRecords.js",
"src/input/sensorPick.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": [
"hls.js",
@@ -3952,7 +3958,8 @@
"src/data/local_data/wof_neighborhoods/files.js",
"src/data/entityRecords.js",
"src/input/sensorPick.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": [
"hls.js",
@@ -4039,7 +4046,8 @@
"src/data/placeBoundaries.js",
"src/data/placeNames.js",
"src/data/local_data/us_census_places/files.js",
"src/data/local_data/wof_neighborhoods/files.js"
"src/data/local_data/wof_neighborhoods/files.js",
"src/queries/heights.js"
],
"external": [
"cesium",
@@ -4647,7 +4655,8 @@
"src/i18n/locales/zh-CN.json",
"src/i18n/locales/zh-Hant.json",
"src/input/sensorPick.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium", "egm96-universal", "pbf"]
},
@@ -4703,7 +4712,8 @@
"src/input/sensorPick.js",
"src/data/scenePick.js",
"src/data/pickRegistry.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium", "pbf"]
},
@@ -4869,7 +4879,8 @@
"src/data/scenePick.js",
"src/input/sensorPick.js",
"src/data/pickRegistry.js",
"src/input/dispatcher.js"
"src/input/dispatcher.js",
"src/queries/heights.js"
],
"external": ["cesium"]
},
@@ -5101,5 +5112,10 @@
"src/i18n/marker.js"
],
"external": ["cesium"]
},
"heights": {
"exports": ["./queries/heights"],
"modules": ["src/queries/heights.js"],
"external": ["cesium"]
}
}