Add a globe visibility getter to the renderer contract

The globe port could show or hide the globe surface but not say whether it
is shown. It now has an optional isGlobeVisible(), gated by a new
globeVisibility capability, in the Cesium adapter, the stub and a
conformance check. A Cesium scene without a globe does not offer it, so
callers keep their own default for an unknown surface.

The OSM overlays, the CCTV ground regime and the submarine cable drape now
read the getter instead of the scene's globe. cableClassificationTypeForScene
takes the viewer rather than its scene.
This commit is contained in:
Sameh Khamis committed 2026-11-07 19:44:15 -08:00
1 parent 23d56f8393
commit 2e91579f8f
23 files changed
+140 -29

No files matched your search

+2 -2
View File
@@ -85,12 +85,12 @@ export function createOsmOverlayLayer(overlay, { globeOf = findGlobe } = {}) {
/**
* What the overlay drapes on: the map stack's record, or with no map
* stack, whether the viewer's globe is shown.
* stack, whether the renderer shows the globe.
*/
function drapeSurface() {
const recorded = mapStack?.getDrapeSurface?.();
if (recorded) return recorded;
return viewer?.scene?.globe?.show === true ? 'globe' : 'none';
return globeOf(viewer)?.isGlobeVisible?.() === true ? 'globe' : 'none';
}
/** Add or remove the owned imagery layer to match the state. */
+9 -4
View File
@@ -14,6 +14,10 @@ function fakeGlobe() {
const layers = [];
return {
layers,
visible: true,
isGlobeVisible() {
return this.visible;
},
imagery: {
add(spec) {
const layer = {
@@ -52,7 +56,7 @@ function fakeMapStack() {
function setup(overlay = OSM_OVERLAYS[0]) {
const globe = fakeGlobe();
const viewer = { scene: { globe: { show: true } } };
const viewer = {};
const layer = createOsmOverlayLayer(overlay, {
globeOf: (given) => (given === viewer ? globe : null),
});
@@ -152,14 +156,15 @@ test('with no surface to drape on the row explains itself, and recovers when one
test('without a map stack, the viewer’s globe decides, polled by the stats', () => {
const globe = fakeGlobe();
const viewer = { scene: { globe: { show: false } } };
globe.visible = false;
const viewer = {};
const layer = createOsmOverlayLayer(OSM_OVERLAYS[0], {
globeOf: () => globe,
});
layer.init(viewer);
layer.enable();
assert.equal(layer.getStats().error, NO_IMAGERY_HOST);
viewer.scene.globe.show = true;
globe.visible = true;
assert.equal(layer.getStats().error, null);
});
@@ -177,7 +182,7 @@ test('an overlay enabled before its viewer has a globe port adds it once one doe
const globe = fakeGlobe();
let port = null;
const layer = createOsmOverlayLayer(OSM_OVERLAYS[0], { globeOf: () => port });
layer.init({ scene: { globe: { show: true } } });
layer.init({});
layer.enable();
assert.equal(layer.diagnostics().ownedCount, 0);
port = globe;
+21 -3
View File
@@ -4,6 +4,7 @@ import { readFileSync } from 'node:fs';
import * as Cesium from 'cesium';
import { MAP_STACKS } from '../mapStackController.js';
import { fromDegrees, toLonLatH } from '../geo/ellipsoid.js';
import { bindRenderer } from '../render/rendererOf.js';
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
import { fakeSceneFrame } from '../testSupport/fakeCesiumScene.mjs';
@@ -216,15 +217,32 @@ test('cable ground lines drape on exactly the active surface on every stack', ()
// Boot fires no stack event; the initial value derives from live scene
// state exactly like the height-datum listeners: photoreal ⇔ globe hidden.
let globeShown = false;
const host = {};
const unbind = bindRenderer(host, {
globe: { isGlobeVisible: () => globeShown },
});
assert.equal(cableClassificationTypeForScene(host), 'tiles');
globeShown = true;
assert.equal(cableClassificationTypeForScene(host), 'terrain');
unbind();
assert.equal(cableClassificationTypeForScene(null), 'both');
// A scene that cannot say whether the globe is shown: every surface.
const other = {};
const unbindOther = bindRenderer(other, { globe: {} });
assert.equal(cableClassificationTypeForScene(other), 'both');
unbindOther();
// A viewer of its own with no renderer bound reads its globe through the
// unbound port; with no globe it gives no reading.
assert.equal(
cableClassificationTypeForScene({ globe: { show: false } }),
cableClassificationTypeForScene({ scene: { globe: { show: false } } }),
'tiles',
);
assert.equal(
cableClassificationTypeForScene({ globe: { show: true } }),
cableClassificationTypeForScene({ scene: { globe: { show: true } } }),
'terrain',
);
assert.equal(cableClassificationTypeForScene(null), 'both');
assert.equal(cableClassificationTypeForScene({ scene: {} }), 'both');
});
test('cable reference sweep gate is dirty-only — no timer path', () => {