fix(cockpit): double-clicking a ship that the first click moved enters without dropping the follow

Selecting a ship re-centres the camera, so by the second press of a
double-click the ship is drawn elsewhere. The Cockpit remembers where it
was and still enters there. On Cesium it then kept the stock double-click
follow from running; on the input port the hold was taken only for a press
where the ship is drawn now, so the stock follow ran first and could let
go of the ship. A press where the ship was as the gesture began now holds
it off too.
This commit is contained in:
Sameh Khamis committed 2026-11-14 00:57:31 -08:00
1 parent b754418706
commit 22952f8f16
2 files changed
+68 -11

No files matched your search

+21 -7
View File
@@ -96,12 +96,26 @@ export function onScenePointerDown(nowMs = performance.now()) {
* refused by the gate: the caller does nothing else with it.
*/
export function onSceneDoubleClick(position, nowMs = performance.now()) {
const start = this.doubleClickStart;
const hit = hitsFollowedTrack.call(this, position, nowMs);
this.doubleClickStart = null;
if (this.active || this.destroyed || !isPointerFree()) return false;
if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y))
return false;
const hit =
if (!hit) return false;
this.enter();
return true;
}
/**
* Whether `position` is on the followed track: where it is drawn now, or
* where a ship was drawn as this gesture's first press began (its click
* may have moved it).
*/
function hitsFollowedTrack(position, nowMs) {
if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y))
return false;
const start = this.doubleClickStart;
return (
doubleClickHitsSubject(position, subjectCanvasPosition.call(this)) ||
(Boolean(start) &&
nowMs - start.atMs <= DOUBLE_CLICK_MEMORY_MS &&
@@ -109,10 +123,8 @@ export function onSceneDoubleClick(position, nowMs = performance.now()) {
// aircraft, another ship) is hit only where it is drawn.
this.resolveEntryKind() === 'vessel' &&
start.vesselId === (this.readVesselInfo()?.id ?? null) &&
doubleClickHitsSubject(position, start));
if (!hit) return false;
this.enter();
return true;
doubleClickHitsSubject(position, start))
);
}
/** Hold the renderer's own double-click follow off; returns the release. */
@@ -178,7 +190,9 @@ export function routeSceneDoubleClick() {
isPointerFree() &&
(this.active
? Boolean(this.orbitalSiteUnder?.(position))
: doubleClickHitsSubject(position, subjectCanvasPosition.call(this)));
: // Where the ship was as the gesture began counts too: the first
// click may have moved it, and the double-click still enters.
hitsFollowedTrack.call(this, position, performance.now()));
endsDouble =
!!last?.onSubject &&
at - last.at <= SUBJECT_PRESS_HOLD_MS &&