From ee22aace8dccb32516ae4ad5f7c47383b850084e Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Sat, 14 Nov 2026 19:30:17 -0800 Subject: [PATCH] Describe the view the camera stops at, after a jump too A share link or restored view moves the camera without a moveEnd, and the once-a-second read of camera changes dropped the last one, so Context named a point from the fly-in. A last read now follows the final change. Co-authored-by: Manjunath Paparaju --- src/ui/entityContextBridge.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ui/entityContextBridge.js b/src/ui/entityContextBridge.js index 59124951d..2f0370489 100644 --- a/src/ui/entityContextBridge.js +++ b/src/ui/entityContextBridge.js @@ -186,13 +186,26 @@ export function installEntityContext({ }; const removeMoveEnd = viewer.camera.moveEnd.addEventListener(readView); // A camera that keeps moving (following an aircraft, a long fly-to) never - // settles, so also read it on large changes, at most once a second. + // settles, and a jump (a share link, a restored view) raises no moveEnd, + // so also read it on large changes: at most once a second, and once more + // after the last change, so the view it stops at is the one described. let lastRead = 0; + let trailing = null; const removeChanged = viewer.camera.changed.addEventListener(() => { + clearTimeout(trailing); const now = performance.now(); - if (now - lastRead < 1000) return; - lastRead = now; - readView(); + if (now - lastRead >= 1000) { + lastRead = now; + readView(); + return; + } + trailing = setTimeout( + () => { + lastRead = performance.now(); + readView(); + }, + 1000 - (now - lastRead), + ); }); setTimeout(readView, 0); @@ -284,6 +297,7 @@ export function installEntityContext({ handler.destroy(); removeMoveEnd(); removeChanged(); + clearTimeout(trailing); removeTrackedChanged(); clearTimeout(trackCheck); globalThis.removeEventListener?.('gev:entity-selected', onSelected);