refactor(credits): use the globe engine

Map credits (maps/credits.js) are shown through a credits capability
(engine.credits.addStatic) instead of the scene's credit display; the
shared map scene takes the engine's credits, so the Cesium engine's maps
and its credits part share one owner. Data credits (registerDataCredits,
registerDynamicCredit, show/hideOsmCredit) take the globe engine and keep
accepting a viewer from layers that still hold one; the scene registers
the data credits on its engine. The Cesium credits part reads
Viewer.creditDisplay, else the scene frame state display it aliases.
This commit is contained in:
German Khokhlov committed 2026-10-15 18:37:02 +04:00
1 parent be56144d75
commit 83c13f330d
11 files changed
+169 -59

No files matched your search

+11 -11
View File
@@ -1,21 +1,21 @@
import * as Cesium from 'cesium';
/** Static credits follow the source actually on screen, including fallback. */
export function createMapCredits(viewer) {
let active = null;
/**
* Static credits follow the source actually on screen, including fallback.
* @param {{ addStatic: (html: string, options?: { onScreen?: boolean }) => () => void }} credits
* A globe engine's credits capability.
*/
export function createMapCredits(credits) {
let remove = null;
let markup = null;
return {
show(html) {
if (html === markup) return;
const display = viewer?.scene?.frameState?.creditDisplay;
if (!display) return;
try {
if (active) display.removeStaticCredit(active);
active = html ? new Cesium.Credit(html, true) : null;
remove?.();
remove = null;
if (html) remove = credits.addStatic(html, { onScreen: true });
markup = html;
if (active) display.addStaticCredit(active);
} catch {
/* Switching remains usable on older credit displays. */
/* Switching remains usable without a credit display. */
}
},
destroy() {