mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Find a selected vessel or aircraft again from its card
While a selected vessel, aircraft or military aircraft is off screen, behind the globe or out of its layer's feed, its Context card shows Find it. One still in its feed is flown to (an aircraft followed). One out of its feed is looked up on its own track at the layer's time (the world clock's while the layer follows it), the card moves to that reading and says how old it is, and the camera flies there; once the feed has it again its layer selects it again. With no reading at or before the time the card says so and the camera stays. A vessel its layer announces is named by its own id, as a click names it, not by the context store's.
This commit is contained in:
1 parent
b57d50fe18
commit
22e9c58d84
27 files changed
+833
-22
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { resolvePickedContext } from '../data/pickedContext.js';
|
||||
import { onScreen } from '../data/locate.js';
|
||||
import { clickCard } from '../data/pickRegistry.js';
|
||||
import { followedOf, onFollowChanged } from '../data/followed.js';
|
||||
import { fromDegreesInto } from '../geo/ellipsoid.js';
|
||||
@@ -136,6 +137,21 @@ export function installEntityContext({
|
||||
}
|
||||
}
|
||||
|
||||
// An item back in its feed after it left it is selected again in its layer,
|
||||
// as the click that picked it: a vessel is highlighted with its trail, and
|
||||
// an aircraft found again (`follow`) is followed.
|
||||
function reselect(card, { follow: andFollow = false } = {}) {
|
||||
const layer = getDataManager()?.layers?.get?.(card?.layerId)?.module;
|
||||
const id = card?.identity?.id;
|
||||
if (!layer || !id) return;
|
||||
try {
|
||||
if (card.layerId === 'ais-live-vessels') layer.selectById?.(id);
|
||||
else if (andFollow && FOLLOWABLE.has(card.layerId)) follow(card);
|
||||
} catch {
|
||||
// A layer going away meanwhile has nothing to select.
|
||||
}
|
||||
}
|
||||
|
||||
// Aircraft can be flown from, and a satellite ridden in the orbital view:
|
||||
// track the craft, then enter Cockpit on it. Only layers the tracking
|
||||
// action can follow are offered (local ADS-B cannot be tracked).
|
||||
@@ -197,6 +213,14 @@ export function installEntityContext({
|
||||
flyTo,
|
||||
follow,
|
||||
letGo,
|
||||
reselect,
|
||||
// Whether the camera shows the card's item; null when it cannot tell.
|
||||
onScreen: (card) => {
|
||||
const pose = camera()?.pose();
|
||||
if (!pose || !Number.isFinite(card?.lat) || !Number.isFinite(card?.lon))
|
||||
return null;
|
||||
return onScreen(pose, card.lat, card.lon, card.altitudeM ?? 0);
|
||||
},
|
||||
isOpen,
|
||||
regionalBrief,
|
||||
// The renderer's card previews, when it has them.
|
||||
@@ -343,7 +367,12 @@ export function installEntityContext({
|
||||
if (!record?.layerId || inCockpit()) return;
|
||||
store.select({
|
||||
layerId: record.layerId,
|
||||
id: record.id,
|
||||
// A vessel goes by its own id, as a click on it names it, not by the
|
||||
// context store's (src/data/pickedContext.js).
|
||||
id:
|
||||
record.layerId === 'ais-live-vessels' && record.properties?.vesselId
|
||||
? String(record.properties.vesselId)
|
||||
: record.id,
|
||||
label: record.label || record.properties?.name,
|
||||
lat: record.latitude,
|
||||
lon: record.longitude,
|
||||
|
||||
Reference in new issue
Block a user