mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
refactor(street-level): no sequence image cache; one pose listener
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
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;
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user