mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
23d56f8393
commit
2e91579f8f
23 files changed
+140
-29
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { findGlobe } from '../../render/rendererOf.js';
|
||||
import {
|
||||
SUPPORT_KEYS,
|
||||
planeSupportPoints,
|
||||
@@ -13,7 +14,7 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
const { resolveEllipsoidalGround } = services.terrain;
|
||||
|
||||
/**
|
||||
* Task 5 (height-datum fix): maps the scene's `globe.show` flag to the surface
|
||||
* Task 5 (height-datum fix): maps whether the renderer shows the globe to the surface
|
||||
* regime key the per-camera ground cache is keyed by (spec §2 "cache by
|
||||
* surface regime", collapsed to two keys — ion World Terrain and Re:Earth
|
||||
* globe terrain get the same handling):
|
||||
@@ -26,7 +27,8 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
* Only an explicit `false` (the photoreal stack hides the globe) selects
|
||||
* `google-3d`; undefined/null (no viewer / torn down) must fall to the regime
|
||||
* that never touches the scene. Pure — exported for the unit suite.
|
||||
* @param {boolean|undefined|null} globeShow - `viewer.scene.globe.show`.
|
||||
* @param {boolean|undefined|null} globeShow - Whether the renderer shows the
|
||||
* globe (`globe.isGlobeVisible()`).
|
||||
* @returns {'google-3d'|'terrain-globe'}
|
||||
*/
|
||||
|
||||
@@ -36,15 +38,15 @@ export function createGround({ state: layerState, services, parts, source }) {
|
||||
|
||||
/**
|
||||
* Task 5: the surface regime the scene is CURRENTLY rendering, derived live
|
||||
* from `globe.show` (mapStackController's `_activatePhotoreal` /
|
||||
* `_activateGlobeStack` flip exactly this flag). Reading scene state directly
|
||||
* from whether the renderer shows the globe (mapStackController's
|
||||
* `_activatePhotoreal` / `_activateGlobeStack` flip exactly this). Reading it live
|
||||
* — rather than caching the map-stack id — means the regime is correct even
|
||||
* for stack changes this module never got an event for.
|
||||
* @returns {'google-3d'|'terrain-globe'}
|
||||
*/
|
||||
|
||||
function currentSurfaceRegime() {
|
||||
return surfaceRegimeKey(layerState._viewer?.scene?.globe?.show);
|
||||
return surfaceRegimeKey(findGlobe(layerState._viewer)?.isGlobeVisible?.());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ import { toColor } from '../../render/cesium/draw.js';
|
||||
// Loads the factory a viewer of a caller's own gets its camera port from,
|
||||
// which the rest of the layer reads the eye through.
|
||||
import '../../render/cesium/camera.js';
|
||||
import '../../render/cesium/globe.js';
|
||||
|
||||
// The policy's renderer colours as the Cesium colours the icons and lines take.
|
||||
const ACTIVE_CAMERA_COLOR = toColor(ACTIVE_CAMERA_RGBA);
|
||||
|
||||
@@ -175,7 +175,7 @@ export function createState({ services }) {
|
||||
|
||||
// Task 5: last surface regime the record geometry was recomputed for. The
|
||||
// map-stack change listener compares the CURRENT regime (derived live from
|
||||
// scene.globe.show) against this so bing→osm switches (same 'terrain-globe'
|
||||
// whether the renderer shows the globe) against this so bing→osm switches (same 'terrain-globe'
|
||||
// regime) don't trigger a pointless full-catalog rewrite.
|
||||
|
||||
layerState._lastAppliedRegime = null;
|
||||
|
||||
@@ -15,14 +15,14 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
|
||||
|
||||
init(viewer) {
|
||||
state._viewer = viewer;
|
||||
state._clampTo = cableClassificationTypeForScene(viewer?.scene);
|
||||
state._clampTo = cableClassificationTypeForScene(viewer);
|
||||
parts.rendering.attach(viewer);
|
||||
if (!state._mapStackListener && mapStackEventTarget?.addEventListener) {
|
||||
state._mapStackListener = (event) => {
|
||||
parts.rendering.applyCableClassification(
|
||||
event?.detail?.activeId
|
||||
? cableClassificationTypeForStack(event.detail.activeId)
|
||||
: cableClassificationTypeForScene(state._viewer?.scene),
|
||||
: cableClassificationTypeForScene(state._viewer),
|
||||
);
|
||||
};
|
||||
mapStackEventTarget.addEventListener(
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { findGlobe } from '../../render/rendererOf.js';
|
||||
import { CABLE_GLOBE_STACK_IDS } from './policy.js';
|
||||
|
||||
/**
|
||||
@@ -20,15 +21,18 @@ export function cableClassificationTypeForStack(activeId) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive the active surface from live scene state. The boot-time
|
||||
* Derive the active surface from what the renderer draws. The boot-time
|
||||
* `setStack(..., { silent: true })` fires no 'gev:map-stack-changed' event,
|
||||
* so the initial surface is read the way the height-datum listeners do: the
|
||||
* photoreal regime is exactly "globe hidden".
|
||||
* @param {{globe?: {show?: boolean}}|null|undefined} scene
|
||||
* @param {object|null|undefined} host The scene object the renderer is bound
|
||||
* to (the viewer); `both` when it has none, or one that cannot say whether
|
||||
* the globe is shown.
|
||||
* @returns {'tiles'|'terrain'|'both'}
|
||||
*/
|
||||
|
||||
export function cableClassificationTypeForScene(scene) {
|
||||
if (!scene?.globe) return 'both';
|
||||
return scene.globe.show === false ? 'tiles' : 'terrain';
|
||||
export function cableClassificationTypeForScene(host) {
|
||||
const visible = findGlobe(host)?.isGlobeVisible?.();
|
||||
if (typeof visible !== 'boolean') return 'both';
|
||||
return visible ? 'terrain' : 'tiles';
|
||||
}
|
||||
Reference in new issue
Block a user