mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Keep the annotation board across engine switches and draw it again on Cesium
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.
This commit is contained in:
1 parent
05578c61b9
commit
111ba1626c
6 files changed
+239
-28
No files matched your search
+29
-11
@@ -16,21 +16,39 @@ export function initAnnotations({
|
||||
placeSearch,
|
||||
resolver,
|
||||
}) {
|
||||
// World-space footprint draping; clamped marks can use the photoreal tiles.
|
||||
if (tileset) {
|
||||
try {
|
||||
tileset.enableCollision = true;
|
||||
} catch {
|
||||
/* older tileset */
|
||||
}
|
||||
}
|
||||
const renderer = createHybridAnnotationRenderer(viewer);
|
||||
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({
|
||||
viewer,
|
||||
renderer,
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user