Expose scoped domain geometry in the existing Cesium renderer

This commit is contained in:
Codex
2026-11-16 15:23:12 +03:00
parent f8aa8022f1
commit f4e7369eec
7 changed files with 39 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@nodedc/map-cesium-react",
"version": "0.1.0",
"version": "0.1.1",
"description": "Shared credential-free Cesium adapter for NODE.DC Map Page consumers.",
"type": "module",
"main": "./dist/index.js",
@@ -60,10 +60,13 @@ export const CesiumMapRenderer = forwardRef<
className,
onRuntimeStateChange,
onCameraChange,
onSceneReady,
}, forwardedRef) {
const containerRef = useRef<HTMLDivElement | null>(null);
const stateCallbackRef = useRef(onRuntimeStateChange);
const cameraCallbackRef = useRef(onCameraChange);
const sceneCallbackRef = useRef(onSceneReady);
sceneCallbackRef.current = onSceneReady;
const runtimeRef = useRef<RendererRuntime | null>(null);
const settingsRef = useRef(settings);
const layersRef = useRef(layers);
@@ -116,6 +119,7 @@ export const CesiumMapRenderer = forwardRef<
const abortController = new AbortController();
let disposed = false;
let viewer: CesiumModule.Viewer | null = null;
let disposeConsumer: (() => void) | void;
let removeCameraListener: (() => void) | undefined;
let removeRenderListener: (() => void) | undefined;
let runtimeState = initialMapRuntimeState();
@@ -191,6 +195,8 @@ export const CesiumMapRenderer = forwardRef<
);
removeRenderListener = bindRenderRecovery(viewer, publish);
disposeConsumer = sceneCallbackRef.current?.({Cesium, viewer, signal: abortController.signal});
const providerJobs = (["imagery", "terrain", "buildings"] as const).map(
async (providerId) => {
const visible = layers[providerId];
@@ -265,6 +271,7 @@ export const CesiumMapRenderer = forwardRef<
return () => {
disposed = true;
abortController.abort();
try { disposeConsumer?.(); } finally {
removeCameraListener?.();
removeRenderListener?.();
runtimeRef.current?.stopGhostPinAnimation?.();
@@ -272,6 +279,7 @@ export const CesiumMapRenderer = forwardRef<
viewer?.destroy();
viewer = null;
container.replaceChildren();
}
};
}, [
runtimeConfigUrl,
@@ -1,3 +1,4 @@
import type * as Cesium from "cesium";
export const MAP_RUNTIME_SCHEMA_VERSION = "missioncore.map-runtime/v1" as const;
export const MAP_PAGE_VERSION = "0.1.0" as const;
export const CESIUM_RENDERER_VERSION = "1.143.0" as const;
@@ -159,7 +160,16 @@ export type MapCacheIntent = {
no_overwrite: boolean;
};
/** A consumer may attach domain objects to this renderer-owned scene. It must
* remove its objects/listeners in the returned synchronous cleanup. Pending
* work must observe signal; it may never destroy the viewer or change providers. */
export type MapSceneContext = {
Cesium: typeof Cesium;
viewer: Cesium.Viewer;
signal: AbortSignal;
};
export type CesiumMapRendererProps = {
onSceneReady?: (context: MapSceneContext) => (() => void) | void;
runtimeConfigUrl: string;
camera: MapCamera | null;
layers: MapLayerVisibility;
+1
View File
@@ -7,6 +7,7 @@ export {
export type {
CesiumMapRendererHandle,
CesiumMapRendererProps,
MapSceneContext,
MapCacheIntent,
MapCamera,
MapGeoPoint,