From 6e03871d5affb93d5e96b937d4aa66589dfc77ee Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Mon, 16 Nov 2026 14:02:50 -0800 Subject: [PATCH] Mark the card followed only while the camera follows its own pick Tracking set by another control or by voice for another craft no longer shows Following on the open card: the card remembers the entity its own pick started tracking, and any other tracked entity clears Following. Co-authored-by: Manjunath Paparaju --- src/ui/entityContextBridge.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ui/entityContextBridge.js b/src/ui/entityContextBridge.js index 2f0370489..43aac3059 100644 --- a/src/ui/entityContextBridge.js +++ b/src/ui/entityContextBridge.js @@ -223,14 +223,30 @@ export function installEntityContext({ // the layers above starts following from its own click, the card says so. // A layer switching what it follows lets go for a moment and takes hold // again in the same turn, so this is checked once that settles. + // The entity the camera follows for the card: taken when the card's own + // pick starts the tracking, so tracking something else (another control, + // another craft) is not mistaken for following the card. let trackCheck = 0; + let cardTracked = null; + let pickedAt = -Infinity; const removeTrackedChanged = viewer.trackedEntityChanged.addEventListener( () => { clearTimeout(trackCheck); trackCheck = setTimeout(() => { - if (!viewer.trackedEntity) store.following = null; - else if (CLICK_FOLLOWS.has(store.card?.layerId)) - store.following = store.card.key; + const tracked = viewer.trackedEntity; + if (!tracked) { + cardTracked = null; + store.following = null; + return; + } + const card = store.card; + const fromPick = performance.now() - pickedAt < 1500; + if (fromPick && card && (store.following === card.key || CLICK_FOLLOWS.has(card.layerId))) { + cardTracked = tracked; + store.following = card.key; + } else if (tracked !== cardTracked) { + store.following = null; + } }, 250); }, ); @@ -268,6 +284,7 @@ export function installEntityContext({ // These layers start following on their own click; following again // from here would fight them (the flights layer reads a second track // of the same plane as a click on empty map and lets go). + pickedAt = performance.now(); store.select(identity, { follow: !CLICK_FOLLOWS.has(identity.layerId) }); return; }