mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): surface height quality
engine.surface.sampleHeightDetailed(place, { exclude, lod }) answers
{ height, source: 'tiles' | 'terrain', tileSizeM? } (src/globe/surfaceDetail.js).
On Navara tileSizeM is the extent of the tile that answered and
lod 'finest' takes the finest loaded tile, drawn or not; Cesium answers
tiles without a size, else the globe's terrain. acceptedSurfaceHeight()
turns an answer into a height or a miss: tiles larger than
MAX_FLOOR_TILE_SIZE_M (4 km) are too coarse, terrain is not the mesh.
The mesh floor sampler and the ground snap are engine-only now (a viewer
or scene reaches its engine through engineFromViewer, which also registers
the scene) and treat a coarse answer as a miss, as they treat undefined.
Measured on Navara at Austin: while the tiles stream, a 27.9 km tile reads
143.2 m where the ground is 122.5 m (a 1.8 km tile).
`exclude` takes the engine's own mover sets (MoverSet.id): Cesium hides a
set's primitive for the synchronous sample (Cesium matches excluded objects
per billboard, not per collection); Navara's ray only meets tiles.
"sampleHeight undefined in the app on Navara" did not reproduce: the
startup Austin sample is 121.9 m (tile 889 m) on Navara and 122.4 m on
Cesium; one ModelMesh class is patched.
S2 QA (scripts/qa-surface-heights.mjs, 20 places at JFK, SFO, AUS, roofs
and streets): Navara within 2 m of Cesium at 19/20 from 800 m and 18/20
from 15 km with lod 'finest' (gates 18 and 15); offsets per region
-0.21 / +0.4 / +0.1 m; the Empire State roof differs by 39 m (spire
geometry). Navara tile sizes at 800 m: 112-314 m.
This commit is contained in:
1 parent
f640890cf6
commit
645f042450
20 files changed
+635
-244
No files matched your search
@@ -23,9 +23,9 @@ test('on a globe engine a snap samples engine.surface once and caches it', () =>
|
||||
};
|
||||
assert.equal(snap.heightFor(engine, 'a1', KAUS, exclude), 138.5);
|
||||
assert.equal(snap.heightFor(engine, 'a1', KAUS, exclude), 138.5);
|
||||
const calls = engine.fake.callsOf('surface.sampleHeight');
|
||||
const calls = engine.fake.callsOf('surface.sampleHeightDetailed');
|
||||
assert.equal(calls.length, 1, 'one sample, then the cache');
|
||||
assert.deepEqual(calls[0].args[1], ['own-model']);
|
||||
assert.deepEqual(calls[0].args[1].exclude, ['own-model']);
|
||||
assert.equal(exclusions, 1);
|
||||
assert.ok(
|
||||
Math.abs(geo.math.toDegrees(calls[0].args[0].latitude) - 30.19) < 1e-9,
|
||||
@@ -39,15 +39,46 @@ test('on a globe engine loading tiles or a miss return null without a sample cac
|
||||
engine.fake.script('tilesLoaded', false);
|
||||
engine.fake.script('sampleHeight', () => 10);
|
||||
assert.equal(snap.heightFor(engine, 'b1', KAUS), null);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeight').length, 0);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeightDetailed').length, 0);
|
||||
engine.fake.script('tilesLoaded', true);
|
||||
engine.fake.script('sampleHeight', () => undefined);
|
||||
assert.equal(snap.heightFor(engine, 'c1', KAUS), null);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeight').length, 1);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeightDetailed').length, 1);
|
||||
assert.equal(
|
||||
snap.heightFor(engine, 'c1', KAUS),
|
||||
null,
|
||||
'backoff after a miss',
|
||||
);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeight').length, 1);
|
||||
assert.equal(engine.fake.callsOf('surface.sampleHeightDetailed').length, 1);
|
||||
});
|
||||
|
||||
test('a coarse tile answer or only terrain is a miss; a viewer reaches its engine', async () => {
|
||||
const { registerViewerEngine } =
|
||||
await import('../globe/cesium/engineFromViewer.js');
|
||||
const snap = createGroundSnap({ groundFloor: groundFloor() });
|
||||
const engine = createFakeEngine();
|
||||
engine.fake.script('sampleHeightDetailed', () => ({
|
||||
height: 143.2,
|
||||
source: 'tiles',
|
||||
tileSizeM: 27_914,
|
||||
}));
|
||||
assert.equal(snap.heightFor(engine, 'd1', KAUS), null, 'coarse');
|
||||
engine.fake.script('sampleHeightDetailed', () => ({
|
||||
height: 121,
|
||||
source: 'terrain',
|
||||
}));
|
||||
assert.equal(snap.heightFor(engine, 'd2', KAUS), null, 'terrain');
|
||||
engine.fake.script('sampleHeightDetailed', () => ({
|
||||
height: 122.5,
|
||||
source: 'tiles',
|
||||
tileSizeM: 1_797,
|
||||
}));
|
||||
const viewer = {};
|
||||
const unregister = registerViewerEngine(viewer, engine);
|
||||
try {
|
||||
assert.equal(snap.heightFor(viewer, 'd3', KAUS), 122.5);
|
||||
} finally {
|
||||
unregister();
|
||||
}
|
||||
assert.equal(snap.heightFor({}, 'd4', KAUS), null, 'no engine: no sample');
|
||||
});
|
||||
Reference in new issue
Block a user