mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +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
02d492a079
commit
9bdeffeca3
32 files changed
+704
-210
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
TILE_CACHE_MAX_ENTRIES,
|
||||
FAST_FETCH_ALTITUDE,
|
||||
} from './policy.js';
|
||||
import { heightsFor } from '../../queries/heights.js';
|
||||
|
||||
/** Retain complete parsed snapshots under both an LRU entry cap and a byte budget. */
|
||||
export function cacheRoadSnapshot(
|
||||
@@ -273,16 +274,15 @@ export function createIngestion({
|
||||
const scene = layerState._viewer?.scene;
|
||||
const location = Cesium.Cartographic.fromDegrees(centerLon, centerLat);
|
||||
let estimated = services.ground?.cachedGroundFloor?.(centerLat, centerLon);
|
||||
if (!Number.isFinite(estimated)) {
|
||||
try {
|
||||
estimated = scene?.globe?.show
|
||||
? scene.globe.getHeight?.(location)
|
||||
: scene?.sampleHeightSupported
|
||||
? scene.sampleHeight(location, [layerState._pointCollection])
|
||||
: undefined;
|
||||
} catch {
|
||||
/* the local mesh can still be loading */
|
||||
}
|
||||
// A miss is the local mesh still loading.
|
||||
if (!Number.isFinite(estimated) && scene) {
|
||||
estimated = scene.globe?.show
|
||||
? heightsFor(scene).now(location, { against: 'terrain' })
|
||||
: scene.sampleHeightSupported
|
||||
? heightsFor(scene).now(location, {
|
||||
exclude: [layerState._pointCollection],
|
||||
})
|
||||
: undefined;
|
||||
}
|
||||
if (Number.isFinite(estimated) && Math.abs(estimated) <= 9000)
|
||||
layerState._viewHeightEstimate = estimated;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { phaseTiming } from '../../sources/phaseTiming.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { DOT_HEIGHT_OFFSET, MAX_WAYPOINTS_PER_ROAD } from './policy.js';
|
||||
import { heightsFor } from '../../queries/heights.js';
|
||||
|
||||
function surfaceTilesReady(scene) {
|
||||
if (scene.globe?.show) return scene.globe.tilesLoaded !== false;
|
||||
@@ -333,7 +334,8 @@ export async function prepareRoadSurfaces(
|
||||
let sampled;
|
||||
// sampleHeight reads the locally rendered mesh, not unresolved/offscreen
|
||||
// tiles. Global tilesLoaded can stay false while this street is usable.
|
||||
if (scene.globe?.show) sampled = scene.globe.getHeight?.(carto);
|
||||
if (scene.globe?.show)
|
||||
sampled = heightsFor(scene).now(carto, { against: 'terrain' });
|
||||
else {
|
||||
const estimate = Cesium.Cartographic.fromCartesian(
|
||||
road.waypoints[i],
|
||||
@@ -351,9 +353,8 @@ export async function prepareRoadSurfaces(
|
||||
const shown = (excluded || []).filter((p) => p?.show);
|
||||
for (const primitive of shown) primitive.show = false;
|
||||
try {
|
||||
sampled = scene.sampleHeight(carto, excluded);
|
||||
} catch {
|
||||
/* local mesh missing */
|
||||
// A miss is the local mesh still missing.
|
||||
sampled = heightsFor(scene).now(carto, { exclude: excluded });
|
||||
} finally {
|
||||
for (const primitive of shown) primitive.show = true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user