mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 03:02:20 +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
@@ -149,13 +149,13 @@ const cancelledResult = () => ({
|
||||
/**
|
||||
* Build the runner's area services.
|
||||
* @param {object} options
|
||||
* @param {object} options.viewer
|
||||
* @param {object} options.engine The globe engine (view centre, credits).
|
||||
* @param {object|null} options.annotations Annotation engine.
|
||||
* @param {object} [options.placeSearch]
|
||||
* @param {object} [options.annotationResolver] The annotation outline ladder.
|
||||
*/
|
||||
export function createVoiceAreas({
|
||||
viewer,
|
||||
engine = null,
|
||||
annotations = null,
|
||||
placeSearch = unavailablePlaceSearch,
|
||||
annotationResolver = null,
|
||||
@@ -173,10 +173,10 @@ export function createVoiceAreas({
|
||||
|
||||
/** The ground at the centre of the view, else the camera's position. */
|
||||
function viewCenter() {
|
||||
const picked = annotationResolver?.pickWorldFromScreen?.(viewer, 0.5, 0.5);
|
||||
const picked = annotationResolver?.pickWorldFromScreen?.(engine, 0.5, 0.5);
|
||||
if (Number.isFinite(picked?.lat) && Number.isFinite(picked?.lon))
|
||||
return picked;
|
||||
const carto = viewer?.camera?.positionCartographic;
|
||||
const carto = engine?.camera.pose().cartographic;
|
||||
return carto
|
||||
? {
|
||||
lat: (carto.latitude * 180) / Math.PI,
|
||||
@@ -223,7 +223,7 @@ export function createVoiceAreas({
|
||||
try {
|
||||
resolved = await annotationResolver.resolveAnnotationTarget({
|
||||
placeSearch,
|
||||
viewer,
|
||||
engine,
|
||||
target: query,
|
||||
footprint: true,
|
||||
deferFootprint: true,
|
||||
@@ -405,7 +405,7 @@ export function createVoiceAreas({
|
||||
'us-census': US_CENSUS_CREDIT,
|
||||
wof: WOF_CREDIT,
|
||||
}[source];
|
||||
if (credit) registerDynamicCredit(viewer, credit);
|
||||
if (credit) registerDynamicCredit(engine, credit);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -632,7 +632,7 @@ export function createVoiceAreas({
|
||||
// OpenFreeMap area holding it) is a bounded extra.
|
||||
resolved = await annotationResolver.resolveAnnotationTarget({
|
||||
placeSearch,
|
||||
viewer,
|
||||
engine,
|
||||
target,
|
||||
footprint: true,
|
||||
deferFootprint: true,
|
||||
|
||||
@@ -113,7 +113,6 @@ function fakeAnnotations() {
|
||||
function makeAreas(overrides = {}) {
|
||||
const annotations = overrides.annotations || fakeAnnotations();
|
||||
const areas = createVoiceAreas({
|
||||
viewer: {},
|
||||
annotations,
|
||||
annotationResolver: fakeLadder(),
|
||||
findRegion: async () => null,
|
||||
@@ -181,7 +180,6 @@ test('draw failures stay honest in the result, spoken line, and card', async (t)
|
||||
for (const entry of cases) {
|
||||
await t.test(entry.name, async () => {
|
||||
const areas = createVoiceAreas({
|
||||
viewer: {},
|
||||
annotations: entry.annotations,
|
||||
annotationResolver: fakeLadder(),
|
||||
findRegion: async () => null,
|
||||
@@ -732,7 +730,6 @@ test('a clear during a slow lookup is not undone by a late outline', async () =>
|
||||
release = resolve;
|
||||
});
|
||||
const areas = createVoiceAreas({
|
||||
viewer: {},
|
||||
annotations,
|
||||
findRegion: async () => null,
|
||||
findAdminCandidates: async () => [],
|
||||
@@ -781,7 +778,6 @@ test('an outlined area keeps its full geometry past store eviction', async () =>
|
||||
test('an outline from before a page reload asks to resolve again, never counts its drawing', async () => {
|
||||
const annotations = fakeAnnotations();
|
||||
const first = createVoiceAreas({
|
||||
viewer: {},
|
||||
annotations,
|
||||
annotationResolver: fakeLadder(),
|
||||
findRegion: async () => null,
|
||||
@@ -792,7 +788,6 @@ test('an outline from before a page reload asks to resolve again, never counts i
|
||||
// outline stays on the map. A mic restart keeps the runner (and handles);
|
||||
// see integrationContract.test.mjs.
|
||||
const second = createVoiceAreas({
|
||||
viewer: {},
|
||||
annotations,
|
||||
findRegion: async () => null,
|
||||
findAdminCandidates: async () => [],
|
||||
|
||||
@@ -378,7 +378,7 @@ export function createGevActionRunner({
|
||||
// analyst's region/area/drawn scopes, find_imagery and osm_query all read
|
||||
// the same store.
|
||||
const voiceAreas = createVoiceAreas({
|
||||
viewer,
|
||||
engine,
|
||||
annotations,
|
||||
placeSearch,
|
||||
annotationResolver,
|
||||
@@ -1452,7 +1452,7 @@ export function createGevActionRunner({
|
||||
runOptions,
|
||||
),
|
||||
search: searchOsmFeatures,
|
||||
onCredit: () => registerDynamicCredit(viewer, OSM_PLACES_CREDIT),
|
||||
onCredit: () => registerDynamicCredit(engine, OSM_PLACES_CREDIT),
|
||||
// The listed places become the analyst's "last answer", so
|
||||
// "which of those…" filters them and never an older set.
|
||||
rememberResults: (rows, presentation, { truncated = false } = {}) => {
|
||||
|
||||
Reference in new issue
Block a user