Move scene effects and imported geometry behind the globe contract

Move Cesium viewer, map, sky, projection, trail and sonar internals into
its engine. Drive styles, bloom, sharpening and contact sonar through
engine.render. Count camera-input suspensions across all three engines
and migrate the feature callers. Preserve Cesium's effects and input
behaviour; fix transit lens clicks on Cesium and make zero sharpening on
Navara disable sharpening, as it does on Cesium.

Parse imported files into plain records and draw them through movers,
lines, ground and imagery on both engines. Follow Cesium's KML style
precedence, preserve local KMZ images and frame the drawable records.
Open overlays use imagery when the engine has no native map-overlay API.
Run every imported-display case on fake and headless Cesium engines.

The shared import path retains these known differences from Cesium's old
DataSources: wall fills, extruded prisms and gx:LatLonQuad are undrawn;
raised polygon fills drape while outlines retain altitude; GroundOverlay
rotation, altitude and RGB tint are not applied; rhumb lines become great
circles. Ground heights use the loaded surface synchronously instead of
waiting for most-detailed sampling. Supported KMZ ground overlays now
draw on Navara too. Document the limits rather than claiming full parity.

Combine batches B and C because their disjoint path manifests cannot
place the shared boundary and format files in a later commit while
keeping B independently valid. This combined commit owns the shared
docs, package boundaries, format scope, locale catalogs and coupling
baseline. Remove five obsolete import strings from all eleven catalogs.
Make the load-time source scan include new files and skip deleted paths
so the same checks work before and after recording the moves.

Coupling: Navara renderer lines fall from 1695 to 1294, Cesium import
files from 25 to 9, viewer lines from 1177 to 1026, SDK loads from 4 to 3
and engine-name lines from 62 to 42. No count grows.

The full unit suite and the boundary, format and coupling checks pass.
Browser validation remains to be run.

Browser checks to run
GOOGLE_MAPS_API_KEY= CESIUM_ION_TOKEN= npm run dev -- --port 4291
node scripts/qa-contract-suite.mjs http://localhost:4291
node scripts/qa-navara-visual-styles.mjs http://localhost:4291
node scripts/qa-navara-bloom.mjs http://localhost:4291
node scripts/qa-navara-sonar.mjs http://localhost:4291
QA_BASE_URL=http://localhost:4291 node scripts/qa-visual-effects.mjs
QA_BASE_URL=http://localhost:4291 node scripts/qa-zoom-out-guard.mjs
node scripts/qa-sky-model-lighting.mjs --url http://localhost:4291
node scripts/qa-geo-import.mjs http://localhost:4291
node scripts/qa-geo-import-regressions.mjs http://localhost:4291
node scripts/qa-geo-import-large.mjs http://localhost:4291
node scripts/qa-navara-geo-import.mjs http://localhost:4291

Use the keyless server for every check. Photoreal-only cases remain
unverified; do not enable paid tiles to run them.
This commit is contained in:
German Khokhlov committed 2026-11-07 12:45:21 +04:00
1 parent c079b329d0
commit 97c4dc76ce
130 files changed
+4763 -3495

No files matched your search

+57 -12
View File
@@ -1,6 +1,8 @@
// GlobeRender on the app's render governor, which owns Cesium's
// requestRenderMode and maximumRenderTimeChange; the engine only takes a
// hold under its own owner id.
// hold under its own owner id. The full-frame effects (visual styles,
// bloom, sharpening) are the scene's post stages (postStages.js), the
// contact sonar the scene's native draw commands (sonar.js).
import {
governorRequestRender,
@@ -8,16 +10,22 @@ import {
isRenderGovernorInstalled,
releaseContinuousRender,
} from '../../renderGovernor.js';
import { SHARPEN_INITIAL, mergeSharpen } from '../contract.js';
import { CONTACT_SONAR_INITIAL, mergeContactSonar } from '../contract.js';
import { createCesiumPostStages } from './postStages.js';
import { createCesiumSonar } from './sonar.js';
export const RENDER_OWNER = 'globe-engine';
/**
* @param {Cesium.Viewer} viewer
* @param {{ requestRender?: (reason: string) => void }} [options] Defaults to
* the render governor when it governs this viewer, else the scene itself
* (before the governor is installed, or on another viewer).
* @returns {{ render: import('../contract.js').GlobeRender, destroy: () => void }}
* @param {{ requestRender?: (reason: string) => void,
* createStage?: (options: object) => object,
* createSonar?: typeof createCesiumSonar }} [options] `requestRender`
* defaults to the render governor when it governs this viewer, else the
* scene itself (before the governor is installed, or on another viewer);
* `createStage` (postStages.js) and `createSonar` are test seams.
* @returns {{ render: import('../contract.js').GlobeRender,
* sonarDiagnostics: () => object, destroy: () => void }}
*/
export function createCesiumRender(
viewer,
@@ -26,10 +34,36 @@ export function createCesiumRender(
if (isRenderGovernorInstalled(viewer)) governorRequestRender(reason);
else viewer.scene.requestRender?.();
},
createStage,
createSonar = createCesiumSonar,
} = {},
) {
let held = false;
let sharpen = { ...SHARPEN_INITIAL };
const effects = createCesiumPostStages(viewer, {
requestRender,
...(createStage ? { createStage } : {}),
});
const sonar = createSonar(viewer);
let contactSonar = { ...CONTACT_SONAR_INITIAL };
// Whether Cesium is drawing a frame: a sonar change outside one asks for
// a frame, one inside it (the app's, every frame) draws in it.
let drawing = false;
let removeFrameWatch = null;
const watchFrames = () => {
const { scene } = viewer;
if (removeFrameWatch || !scene.preUpdate?.addEventListener) return;
const removers = [
scene.preUpdate.addEventListener(() => {
drawing = true;
}),
scene.postRender.addEventListener(() => {
drawing = false;
}),
];
removeFrameWatch = () => {
for (const remove of removers) remove();
};
};
const render = {
request(reason = RENDER_OWNER) {
requestRender(reason);
@@ -41,17 +75,28 @@ export function createCesiumRender(
},
// The scene's real mode: another owner's hold keeps it continuous.
isContinuous: () => viewer.scene.requestRenderMode === false,
// State only: in Cesium mode the app's own post stage sharpens
// (src/ui/visualEffects.js), and the scene stays as it was.
setSharpen(options) {
sharpen = mergeSharpen(sharpen, options);
...effects.render,
setContactSonar(options) {
const next = mergeContactSonar(contactSonar, options);
const changed = Object.keys(next).some(
(key) => next[key] !== contactSonar[key],
);
contactSonar = next;
if (!changed) return;
watchFrames();
sonar.set({ ...next });
if (!drawing) requestRender('cyber-sonar');
},
sharpen: () => ({ ...sharpen }),
contactSonar: () => ({ ...contactSonar }),
};
return {
render,
sonarDiagnostics: () => sonar.diagnostics(),
destroy() {
if (held) render.setContinuous(false);
removeFrameWatch?.();
sonar.destroy();
effects.destroy();
},
};
}