refactor(street-level): no sequence image cache; one pose listener

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
German KhokhlovandClaude Opus 5.5 committed 2026-10-08 15:16:29 +04:00
1 parent 1db3290e0b
commit 09e2fd96a4
4 files changed
+11 -51

No files matched your search

@@ -27,7 +27,8 @@ export function createMapillaryViewer({ source, render } = {}) {
let renderMode = 'letterbox';
/** Metadata of the image on screen; pov/position events reuse it. */
let current = null;
const listeners = new Set();
/** The pose listener (the viewer host); one at a time. */
let poseListener = null;
function requestRender() {
render?.governorRequestRender?.('mapillary-viewer');
@@ -52,12 +53,10 @@ export function createMapillaryViewer({ source, render } = {}) {
}
function emit(pose) {
for (const listener of [...listeners]) {
try {
listener(pose);
} catch {
/* listener errors are the core's to log */
}
try {
poseListener?.(pose);
} catch {
/* listener errors are the core's to log */
}
}
@@ -201,8 +200,10 @@ export function createMapillaryViewer({ source, render } = {}) {
},
onPose(listener) {
listeners.add(listener);
return () => listeners.delete(listener);
poseListener = listener;
return () => {
if (poseListener === listener) poseListener = null;
};
},
};
}