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
@@ -14,6 +14,8 @@
|
||||
* - `selectionOrigin`: what started the selection (`'user'`, …).
|
||||
* - `sprite`: a tracked billboard's pushed `{ width, height, scale, scaleByDistance }`, for
|
||||
* the close-range camera guard and the screen annotations' tracked footprint.
|
||||
* - `groundSets()`: the draw set ids a height sample under the contact sees through (its own
|
||||
* icons and models), for Cockpit's ground probe.
|
||||
*
|
||||
* A layer's private per-entity state goes in its own store ({@link createEntityStore}).
|
||||
*/
|
||||
|
||||
@@ -526,6 +526,10 @@ test('real civil track path creates no native label and publishes every cached h
|
||||
);
|
||||
assert.ok(entity.position, 'Cockpit sees a contact it can fly');
|
||||
assert.equal(readEntityRecord(entity).drawn(), true);
|
||||
assert.ok(
|
||||
Array.isArray(readEntityRecord(entity).groundSets()),
|
||||
'Cockpit asks which draw sets its ground probe sees through',
|
||||
);
|
||||
assert.equal(entity.show, true);
|
||||
assert.equal(entity.label, undefined);
|
||||
assert.ok(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -448,6 +448,10 @@ test('real military track path creates no native label and publishes every cache
|
||||
);
|
||||
assert.ok(entity.position, 'Cockpit sees a contact it can fly');
|
||||
assert.equal(readEntityRecord(entity).drawn(), true);
|
||||
assert.ok(
|
||||
Array.isArray(readEntityRecord(entity).groundSets()),
|
||||
'Cockpit asks which draw sets its ground probe sees through',
|
||||
);
|
||||
assert.equal(entity.show, true);
|
||||
assert.equal(entity.label, undefined);
|
||||
assert.ok(
|
||||
|
||||
@@ -4,6 +4,9 @@ import https from 'node:https';
|
||||
import { Readable } from 'node:stream';
|
||||
import test from 'node:test';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
// A viewer of the test's own, with no renderer bound: its factories load
|
||||
// as the package's `./render/cesium/unbound` export loads them.
|
||||
import '../render/cesium/unbound.js';
|
||||
import { fetchPinnedRadioResponse } from '../../server/providers/radio/transport.js';
|
||||
import {
|
||||
createRadioProxyMiddleware,
|
||||
|
||||
@@ -164,7 +164,8 @@ if (typeof globalThis.window === 'undefined') {
|
||||
|
||||
/** A viewer stub whose camera altitude the test can move between evaluations.
|
||||
* Its renderer has a fake draw port (`viewer.draw`) the layer's model sets
|
||||
* are made on, and a query port whose height samples are `sampleHeight`'s. */
|
||||
* are made on, a globe whose drawn tiles settle as `viewer.tileset` says, and
|
||||
* a query port whose height samples are `sampleHeight`'s. */
|
||||
function viewerAtHeight(height, { tilesLoaded = true, sampleHeight = () => undefined } = {}) {
|
||||
const tileset = { show: true, tilesLoaded };
|
||||
const draw = fakeDrawPort();
|
||||
@@ -177,7 +178,6 @@ function viewerAtHeight(height, { tilesLoaded = true, sampleHeight = () => undef
|
||||
scene: {
|
||||
canvas: { clientHeight: 900 },
|
||||
frameState: { frameNumber: 1 },
|
||||
primitives: { length: 1, get() { return tileset; } },
|
||||
sampleHeight,
|
||||
},
|
||||
tileset,
|
||||
@@ -187,6 +187,7 @@ function viewerAtHeight(height, { tilesLoaded = true, sampleHeight = () => undef
|
||||
};
|
||||
return bindFakeCesiumCamera(viewer, {
|
||||
draw,
|
||||
globe: { isSettled: (kind) => kind !== 'tiles' || tileset.tilesLoaded },
|
||||
query: { sampleHeightNow: () => sampleHeight() },
|
||||
canvas: viewer.scene.canvas,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user