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

+8 -1
View File
@@ -438,6 +438,8 @@ export function createCesiumGlobe(
return progressListeners.on(cb);
},
};
if (can('globeVisibility'))
port.isGlobeVisible = () => scene.globe?.show === true;
if (can('splitSwipe')) {
// Cesium's split starts at the canvas's left edge, as the scene was
// made: a `left` layer shows once the split moves.
@@ -469,8 +471,13 @@ export function createCesiumGlobe(
// built over it: imagery and the sky as the renderer's would.
provideUnboundGlobe((viewer) => {
if (!viewer?.scene) return null;
// Visibility reads back only from a globe that keeps it: a scene made
// without one gives no reading, so its callers keep their own default.
const capabilities = new Set(['imageHooks', 'imageryOnTiles', 'splitSwipe']);
if (typeof viewer.scene.globe?.show === 'boolean')
capabilities.add('globeVisibility');
const { port, dispose } = createCesiumGlobe(viewer, {
capabilities: new Set(['imageHooks', 'imageryOnTiles', 'splitSwipe']),
capabilities,
requestRender: () => viewer.scene.requestRender?.(),
});
// A renderer bound later leaves it running: its layers keep following
+13 -1
View File
@@ -4,7 +4,13 @@ import * as Cesium from 'cesium';
import { createCesiumGlobe, markBaseTileset } from './globe.js';
import { hookProvider, TILE_RETRY_DELAY_MS, xyzTileUrl } from './imagery.js';
const ALL = new Set(['imageHooks', 'imageryOnTiles', 'splitSwipe', 'terrain']);
const ALL = new Set([
'imageHooks',
'imageryOnTiles',
'splitSwipe',
'terrain',
'globeVisibility',
]);
const url = (name) => `https://${name}.invalid/{z}/{x}/{y}.png`;
function fakeScene() {
@@ -458,8 +464,14 @@ test('globe visibility, settling and progress', () => {
const { scene, port, tick } = setup();
port.setGlobeVisible(false);
assert.equal(scene.globe.show, false);
assert.equal(port.isGlobeVisible(), false);
assert.equal(port.isSettled('terrain'), true, 'a hidden globe loads nothing');
port.setGlobeVisible(true);
assert.equal(port.isGlobeVisible(), true);
// It reads the scene, whoever changed it.
scene.globe.show = false;
assert.equal(port.isGlobeVisible(), false);
scene.globe.show = true;
scene.globe.tilesLoaded = false;
assert.equal(port.isSettled('terrain'), false);
assert.equal(port.isSettled('base'), false);
+1
View File
@@ -69,6 +69,7 @@ export const CESIUM_CHECKS = new Set([
'globe.imagery',
'globe.sky',
'globe.split',
'globe.visible',
'globe.withoutImageHooks',
'input.behaviours',
'input.clickPick',
+8 -1
View File
@@ -44,6 +44,7 @@ const GLOBE_CAPABILITIES = [
'imageryOnTiles',
'splitSwipe',
'imageHooks',
'globeVisibility',
];
/**
@@ -67,7 +68,13 @@ export function cesiumCapabilities(scene, only) {
...queryCapabilities(scene),
];
const allowed = only && new Set(only);
return all.filter((c) => !allowed || allowed.has(c));
return all.filter(
(c) =>
(!allowed || allowed.has(c)) &&
// Visibility reads back only from a globe that keeps it: a scene
// made without one gives no reading.
(c !== 'globeVisibility' || typeof scene?.globe?.show === 'boolean'),
);
}
/**
+9
View File
@@ -22,7 +22,14 @@ test('capabilities follow what the scene supports', () => {
'splitSwipe',
'imageHooks',
];
const globe = { show: true };
assert.deepEqual(cesiumCapabilities({}), ['models', ...effects]);
// A scene with a globe reads its visibility back.
assert.deepEqual(cesiumCapabilities({ globe }), [
'models',
...effects,
'globeVisibility',
]);
assert.deepEqual(cesiumCapabilities({ pickPositionSupported: true }), [
'models',
...effects,
@@ -30,12 +37,14 @@ test('capabilities follow what the scene supports', () => {
]);
assert.deepEqual(
cesiumCapabilities({
globe,
pickPositionSupported: true,
sampleHeightSupported: true,
}),
[
'models',
...effects,
'globeVisibility',
'pickPosition',
'sampleHeight',
'finestHeights',
+2 -1
View File
@@ -2,10 +2,11 @@
* @module render/cesium/unbound
* @description What to load, once, before handing the Cesium-free
* layers a Cesium viewer with no renderer bound: the factories
* that build a camera, credits, effects, draw, frame and query port over
* that build a camera, credits, effects, draw, frame, globe and query port over
* such a viewer when code first asks for one (`rendererOf.js`).
*/
import './camera.js';
import './effects.js';
import './frame.js';
import './globe.js';
import './query.js';