mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
Hand features the engine instead of guessing it from a viewer
No code outside src/globe calls isGlobeEngine or engineFromViewer any more (14 calls left before this). The features that still sniffed take the engine from their caller: - Projection and surface helpers (focus de-emphasis, icon orientation, ground snap, the mesh floor sampler, ground picks) take the engine; the engine view's scene carries its projector instead of registering itself as a viewer. - Credits go only through engine.credits, so annotations and layers share one OSM credit state on Cesium too (it could show twice). - The annotation board and the resolver work on the engine: camera assists, visibility and picks go through engine.camera, engine.projector and src/geo, without Cesium. - The Recent Imagery box tool has one implementation for both engines, on capture-phase canvas pointer events with the layer's engine.ground preview; the Navara copy goes. On Cesium the preview outline is solid now, as on Navara. - Scene interactions take the engine, and the render governor has an engine variant beside the Cesium one. Remaining engine-specific features stay behind explicit seams until the contract covers them: the draw tool's Cesium surface (stock click actions cannot be suspended), the annotation drapes (animated materials), share follow, Cesium post effects and cyber sonar, and data packs (meshes). Coupling: Cesium-importing files fall from 31 to 27, `viewer` lines from 1367 to 1234, engine sniffing calls from 14 to 0.
This commit is contained in:
1 parent
406dd9122e
commit
f1ec9d4a22
61 files changed
+823
-1230
No files matched your search
@@ -47,7 +47,6 @@
|
||||
*/
|
||||
|
||||
import * as geo from '../geo/index.js';
|
||||
import { engineFromViewer } from '../globe/cesium/engineFromViewer.js';
|
||||
import { acceptedSurfaceHeight } from '../globe/surfaceDetail.js';
|
||||
import { MAX_FLOOR_TILE_SIZE_M } from './meshFloorSampler.js';
|
||||
|
||||
@@ -155,7 +154,7 @@ export function firstVisibleTileset(primitives) {
|
||||
/**
|
||||
* Create a per-layer ground-snap cache.
|
||||
* @returns {{
|
||||
* heightFor: (target: object, icao: string, pos: Cesium.Cartesian3,
|
||||
* heightFor: (engine: object, icao: string, pos: Cesium.Cartesian3,
|
||||
* getExclusions?: () => Array<unknown>) => number|null,
|
||||
* forget: (icao: string) => void,
|
||||
* clear: () => void,
|
||||
@@ -266,9 +265,8 @@ export function createGroundSnap({ groundFloor }) {
|
||||
* A contact that HAS resolved once keeps that answer through a resample outage;
|
||||
* see `heldSnapM`.
|
||||
*
|
||||
* @param {object} target - The globe engine (`engine.surface`:
|
||||
* sampleHeightDetailed and tilesLoaded), or a viewer whose engine is
|
||||
* registered (engineFromViewer); without one, no sample.
|
||||
* @param {object} engine - The globe engine (`engine.surface`:
|
||||
* sampleHeightDetailed and tilesLoaded); without one, no sample.
|
||||
* @param {string} icao - Cache key (per-layer icao space).
|
||||
* @param {Cesium.Cartesian3} pos - Current display position. Cache movement
|
||||
* is measured after projecting this input to the WGS84 ellipsoid, so a
|
||||
@@ -279,8 +277,7 @@ export function createGroundSnap({ groundFloor }) {
|
||||
* lands on its icon/model otherwise). Only invoked when a sample fires.
|
||||
* @returns {number|null}
|
||||
*/
|
||||
function heightFor(target, icao, pos, getExclusions) {
|
||||
const engine = engineFromViewer(target);
|
||||
function heightFor(engine, icao, pos, getExclusions) {
|
||||
const surfacePos = geo.ellipsoid.WGS84.scaleToGeodeticSurface(
|
||||
pos,
|
||||
scratchSurfacePos,
|
||||
|
||||
@@ -52,9 +52,7 @@ test('on a globe engine loading tiles or a miss return null without a sample cac
|
||||
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');
|
||||
test('a coarse tile answer or only terrain is a miss', async () => {
|
||||
const snap = createGroundSnap({ groundFloor: groundFloor() });
|
||||
const engine = createFakeEngine();
|
||||
engine.fake.script('sampleHeightDetailed', () => ({
|
||||
@@ -73,14 +71,8 @@ test('a coarse tile answer or only terrain is a miss; a viewer reaches its engin
|
||||
source: 'tiles',
|
||||
tileSizeM: 241,
|
||||
}));
|
||||
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');
|
||||
assert.equal(snap.heightFor(engine, 'd3', KAUS), 122.5);
|
||||
assert.equal(snap.heightFor(null, 'd4', KAUS), null, 'no engine: no sample');
|
||||
});
|
||||
|
||||
const atDenverAirport = geo.cartesian3.fromDegrees(-104.6737, 39.8561, 0);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as geo from '../geo/index.js';
|
||||
import { engineFromViewer } from '../globe/cesium/engineFromViewer.js';
|
||||
import { acceptedSurfaceHeight } from '../globe/surfaceDetail.js';
|
||||
|
||||
/** Answers from tiles larger than this are too coarse to latch (m).
|
||||
@@ -86,9 +85,8 @@ export function createMeshFloorSampler({
|
||||
* layer poll (never per contact, never per frame). Synchronous — Cesium's
|
||||
* sampleHeight is a CPU-side query against loaded tiles.
|
||||
*
|
||||
* @param {object|undefined} target - The globe engine (engine.surface,
|
||||
* camera.height, maps.photorealActive), or a viewer or scene whose
|
||||
* engine is registered (engineFromViewer); without one, nothing.
|
||||
* @param {object|undefined} engine - The globe engine (engine.surface,
|
||||
* camera.height, maps.photorealActive); without one, nothing.
|
||||
* @param {Array<{lat: number, lon: number}>} points - Contact/waypoint coords.
|
||||
* @param {object} [options]
|
||||
* @param {Array<object>} [options.excludeObjects] - What the probe passes
|
||||
@@ -98,12 +96,11 @@ export function createMeshFloorSampler({
|
||||
* Viewer subpoint (computed once by the caller's poll).
|
||||
*/
|
||||
function sampleMeshFloorCells(
|
||||
target,
|
||||
engine,
|
||||
points,
|
||||
{ excludeObjects = [], viewerLat, viewerLon } = {},
|
||||
) {
|
||||
if (!meshFloorPreferred()) return;
|
||||
const engine = engineFromViewer(target);
|
||||
if (!engine || engine.isDestroyed?.() || !engine.surface.supported) return;
|
||||
if (!Array.isArray(points) || !points.length) return;
|
||||
// Round-5 hardening (the CCTV projectionTilesReady lesson, ported late):
|
||||
|
||||
Reference in new issue
Block a user