mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-12 06:12:18 +00:00
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:
1 parent
b51f1bf7c5
commit
d51ea4007b
32 files changed
+704
-210
No files matched your search
+10
-16
@@ -29,6 +29,7 @@ import {
|
||||
holdContinuousRender,
|
||||
releaseContinuousRender,
|
||||
} from './renderGovernor.js';
|
||||
import { heightsFor } from './queries/heights.js';
|
||||
|
||||
let _isCockpitActive = null;
|
||||
/** °/s by speed word — orbit; pan uses fractions of view height/s. */
|
||||
@@ -559,25 +560,18 @@ function acquireCorridorFloor(state, takeWhole) {
|
||||
export function probeMeshFloorM(scene, cells) {
|
||||
const requested = Array.isArray(cells) ? cells.length : 0;
|
||||
const empty = { heightM: Number.NaN, sampled: 0, requested };
|
||||
if (!scene || typeof scene.sampleHeight !== 'function' || !requested)
|
||||
return empty;
|
||||
if (!scene || !requested) return empty;
|
||||
const heights = heightsFor(scene);
|
||||
let heightM = Number.NaN;
|
||||
let sampled = 0;
|
||||
for (const cell of cells) {
|
||||
try {
|
||||
const carto = Cesium.Cartographic.fromDegrees(
|
||||
cell.lon,
|
||||
cell.lat,
|
||||
0,
|
||||
_probeCarto,
|
||||
);
|
||||
const height = scene.sampleHeight(carto);
|
||||
if (!Number.isFinite(height)) continue;
|
||||
sampled += 1;
|
||||
heightM = Number.isFinite(heightM) ? Math.max(heightM, height) : height;
|
||||
} catch {
|
||||
/* tiles not ready for this cell */
|
||||
}
|
||||
// A miss is a cell whose tiles are not ready.
|
||||
const height = heights.now(
|
||||
Cesium.Cartographic.fromDegrees(cell.lon, cell.lat, 0, _probeCarto),
|
||||
);
|
||||
if (height === null) continue;
|
||||
sampled += 1;
|
||||
heightM = Number.isFinite(heightM) ? Math.max(heightM, height) : height;
|
||||
}
|
||||
return { heightM, sampled, requested };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user