mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The marks belong to the page session; only their drawing belongs to the attached viewer. A switch takes the drawing off, keeps the marks, and the next Cesium attachment draws them again. Without a viewer the board refuses new annotations instead of failing in the resolver.
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
import { createAnnotationEngine } from './annotationEngine.js';
|
|
import { createHybridAnnotationRenderer } from './hybridAnnotationRenderer.js';
|
|
|
|
/**
|
|
* Initialize the map-annotation engine and expose it for the voice agent and
|
|
* for manual/dev use via `window.__gevAnnotations`.
|
|
*
|
|
* This module is the single swap point between annotation rendering strategies.
|
|
* This branch (Direction C) uses the HYBRID renderer: world-space draping for
|
|
* footprints + screen-space SVG for callouts/rings/arrows. The engine, resolver,
|
|
* and voice tool wiring are identical to the other two branches.
|
|
*/
|
|
export function initAnnotations({
|
|
viewer,
|
|
tileset = null,
|
|
placeSearch,
|
|
resolver,
|
|
}) {
|
|
const engine = createSessionAnnotations({ placeSearch, resolver });
|
|
engine.attachScene({ viewer, tileset });
|
|
return engine;
|
|
}
|
|
|
|
/**
|
|
* The page's annotation board, kept across globe engine switches: the marks
|
|
* belong to the page session, their drawing to the attached globe.
|
|
* `attachScene({ viewer, tileset })` draws the board on a Cesium viewer (an
|
|
* engine without one keeps the marks undrawn); `detachScene()` releases the
|
|
* drawing and keeps the marks.
|
|
*/
|
|
export function createSessionAnnotations({ placeSearch, resolver }) {
|
|
const engine = createAnnotationEngine({
|
|
placeSearch,
|
|
resolveTarget: resolver?.resolveAnnotationTarget,
|
|
});
|
|
engine.attachScene = ({ viewer = null, tileset = null } = {}) => {
|
|
if (!viewer) return engine.detachRenderer();
|
|
// World-space footprint draping; clamped marks can use the photoreal tiles.
|
|
if (tileset) {
|
|
try {
|
|
tileset.enableCollision = true;
|
|
} catch {
|
|
/* older tileset */
|
|
}
|
|
}
|
|
engine.attachRenderer({
|
|
viewer,
|
|
renderer: createHybridAnnotationRenderer(viewer),
|
|
});
|
|
};
|
|
engine.detachScene = () => engine.detachRenderer();
|
|
window.__gevAnnotations = engine;
|
|
return engine;
|
|
}
|