mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Ground snapping and mesh floor sampling through the renderer ports, off the Cesium list
src/services/groundSnap.js and src/services/meshFloorSampler.js no longer reach Cesium. Whether the surface has streamed comes from the globe port (the snap waits for the 'tiles' and 'surface' settle kinds; the sampler runs only with the globe hidden and 'surface' settled), the camera height gate from camera.pose(), heights from the query port, and the maths from src/geo/ellipsoid.js. The raw exclusion path is gone: callers see through their own draw sets by id. Cockpit's ground probe names the tracked contact's icon and model sets, which the flights and military layers keep on its entity record (groundSets), instead of the tracked holder object. Probing is unchanged: at the caller's point, up to eight readings per cell about 17 m apart, a read answering from the nearest one. The application operations entry is now Cesium-free: a viewer with no renderer bound needs ./render/cesium/unbound loaded first. Tests that used to get the adapter's factories through ground snapping load it themselves.
This commit is contained in:
1 parent
9d4e438e63
commit
f53f691a80
20 files changed
+296
-199
No files matched your search
@@ -4,7 +4,7 @@
|
||||
// The sampler's acceptance rule was previously covered only through
|
||||
// `reportValidatedMeshFloorCell` directly, which proves the gate but not the
|
||||
// decision that feeds it. These tests call `sampleMeshFloorCells` with a fake
|
||||
// scene whose `sampleHeight` returns exactly what Cesium can return — a number,
|
||||
// renderer whose height query returns what a renderer can return — a number,
|
||||
// `undefined`, NaN, or a throw — and assert that a cell latches if and only if
|
||||
// a REAL DEM prior exists and the sample fits its window.
|
||||
//
|
||||
@@ -47,20 +47,35 @@ async function seedDem(cell, ellipsoid) {
|
||||
}
|
||||
}
|
||||
|
||||
/** A scene the sampler accepts: low camera, one visible tileset reporting
|
||||
* tilesLoaded, and a `sampleHeight` under the test's control. */
|
||||
function fakeScene(sampleHeight, { cameraHeightM = 900, tilesLoaded = true, show = true } = {}) {
|
||||
// instanceof-compatible without running Cesium's constructor; `tilesLoaded` is
|
||||
// a prototype getter, so it has to be shadowed with an own data property.
|
||||
const tileset = Object.create(Cesium.Cesium3DTileset.prototype);
|
||||
Object.defineProperty(tileset, 'tilesLoaded', { value: tilesLoaded, configurable: true });
|
||||
Object.defineProperty(tileset, 'show', { value: show, configurable: true });
|
||||
return {
|
||||
sampleHeightSupported: true,
|
||||
sampleHeight,
|
||||
camera: { positionCartographic: { height: cameraHeightM } },
|
||||
primitives: { length: 1, get: () => tileset },
|
||||
};
|
||||
/** A viewer the sampler accepts: bound to a renderer with a low camera,
|
||||
* drawn tiles that have settled, and heights under the test's control
|
||||
* (`sampleHeight` is handed the point in radians, as a cartographic).
|
||||
* Clearing `sampleHeightSupported` takes the renderer's `sampleHeight`
|
||||
* capability away; `asked` records each probe. */
|
||||
function fakeScene(
|
||||
sampleHeight,
|
||||
{ cameraHeightM = 900, tilesLoaded = true, show = true, globeShown = false } = {},
|
||||
) {
|
||||
const viewer = { sampleHeightSupported: true, asked: [] };
|
||||
bindRenderer(viewer, {
|
||||
capabilities: { has: (name) => name === 'sampleHeight' && viewer.sampleHeightSupported },
|
||||
camera: { pose: () => ({ lon: 0, lat: 0, height: cameraHeightM }) },
|
||||
globe: {
|
||||
isGlobeVisible: () => globeShown,
|
||||
// The globe's terrain while it is shown, else the drawn tiles.
|
||||
isSettled: (kind) => kind !== 'surface' || (globeShown || (show && tilesLoaded)),
|
||||
},
|
||||
query: {
|
||||
sampleHeightNow(point, options) {
|
||||
viewer.asked.push({ point: { ...point }, options });
|
||||
return sampleHeight({
|
||||
longitude: Cesium.Math.toRadians(point.lon),
|
||||
latitude: Cesium.Math.toRadians(point.lat),
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
return viewer;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
@@ -117,6 +132,10 @@ test('sampler: a high camera or unloaded tiles produce no records at all', async
|
||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), null, 'coarse LOD under a high camera');
|
||||
sampleMeshFloorCells(fakeScene(() => 138.0, { tilesLoaded: false }), [cell], opts);
|
||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), null, 'mid-stream tiles read coarse');
|
||||
sampleMeshFloorCells(fakeScene(() => 138.0, { show: false }), [cell], opts);
|
||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), null, 'no drawn surface, nothing to read');
|
||||
sampleMeshFloorCells(fakeScene(() => 121.0, { globeShown: true }), [cell], opts);
|
||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), null, 'the globe is not the mesh');
|
||||
});
|
||||
|
||||
test('sampler: outside the google-3d regime nothing is sampled at all', () => {
|
||||
@@ -140,7 +159,7 @@ test('sampler: a cell just across the antimeridian is still near the viewer', ()
|
||||
assert.equal(calls, 2, 'about 200 m apart, so both cells are probed');
|
||||
});
|
||||
|
||||
test('sampler: a scene without depth-texture support is never probed', async () => {
|
||||
test('sampler: a renderer without depth-texture support is never probed', async () => {
|
||||
reset();
|
||||
const cell = nextSite();
|
||||
await seedDem(cell, 120.0);
|
||||
@@ -155,24 +174,12 @@ test('sampler: a scene without depth-texture support is never probed', async ()
|
||||
assert.equal(cachedMeshFloor(cell.lat, cell.lon), null);
|
||||
});
|
||||
|
||||
test('sampler: with `sets` the probe asks the query port, naming those sets', async () => {
|
||||
test('sampler: the probe sees through the caller’s `sets`', async () => {
|
||||
reset();
|
||||
const cell = nextSite();
|
||||
await seedDem(cell, 120.0);
|
||||
const scene = fakeScene(() => {
|
||||
throw new Error('the scene is not asked when sets are named');
|
||||
});
|
||||
const viewer = { scene };
|
||||
const asked = [];
|
||||
bindRenderer(viewer, {
|
||||
capabilities: new Set(['sampleHeight']),
|
||||
query: {
|
||||
sampleHeightNow(point, options) {
|
||||
asked.push({ point: { ...point }, options });
|
||||
return 138.0;
|
||||
},
|
||||
},
|
||||
});
|
||||
const viewer = fakeScene(() => 138.0);
|
||||
const { asked } = viewer;
|
||||
sampleMeshFloorCells(viewer, [cell], {
|
||||
sets: ['flights-models:1', 'flights-icons:1'],
|
||||
viewerLat: cell.lat,
|
||||
|
||||
Reference in new issue
Block a user