feat(cockpit): ride the selected vessel from its bridge

With no aircraft tracked, Cockpit can ride the selected AIS vessel. Entry
needs only Live AIS Vessels and a selected vessel; C, double-click and the
entry buttons (reading BRIDGE with a ship icon) enter it, while voice stays
aircraft-only.

The eye sits on the AIS position at a representative bridge height for the
vessel's type family, looks along true heading and moves along course over
ground. The last fix is dead-reckoned for up to 180 s between the layer's
refreshes, and on rivers and lakes the waterline is read from the rendered
surface around the ship rather than the geoid.

The bridge HUD shows speed and course over ground, a straight heading
tape, window mullions, the AIS destination as a reported voyage and a
heading-up radar of nearby ships (3 to 24 NM). The arrow keys look around,
Home or 0 looks ahead again. The vessel layer hides the ridden ship's
sprite and card, ignores scene clicks while held, and returns the camera
to the vessel's map view on exit.
This commit is contained in:
Denis Groshev committed 2026-11-07 19:52:30 +01:00
1 parent 52187c91d1
commit 72112ecb45
58 files changed
+5313 -137

No files matched your search

+40 -12
View File
@@ -2,6 +2,7 @@ import { nextTick } from 'vue';
import { CockpitViewController, CockpitDisplayPortal } from './cockpit.js';
import {
COCKPIT_AIRCRAFT_LAYER_IDS,
bridgeEntryAllowed,
cockpitEntryAllowed,
} from '../contextModePolicy.js';
import { formatAwarenessLabel } from '../data/militaryAwarenessEngine.js';
@@ -40,6 +41,7 @@ export class CockpitCoordinator {
const {
flightsLayer,
militaryFlightsLayer,
aisLiveVesselsLayer,
isTr3b,
toggleTr3b,
militaryAwarenessLayer,
@@ -60,6 +62,7 @@ export class CockpitCoordinator {
services: {
flightsLayer,
militaryFlightsLayer,
aisLiveVesselsLayer,
isTr3b,
toggleTr3b,
militaryAwarenessLayer,
@@ -93,6 +96,11 @@ export class CockpitCoordinator {
contextModeChanging: this._contextModeChanging,
});
},
isBridgeEntryAllowed: () =>
bridgeEntryAllowed({
vesselsEnabled: !!this._dataManager?.isEnabled('ais-live-vessels'),
contextModeChanging: this._contextModeChanging,
}),
publish: this.publishCockpit,
isUtilityDisclosureOpen: () => !!this.readUtilityDisclosureOpen?.(),
onEntered: () => this.enterPanels(),
@@ -129,15 +137,21 @@ export class CockpitCoordinator {
return Boolean(layerId) && !!this._dataManager?.isEnabled(layerId);
}
/**
* Make the ridden aircraft's layer the user's own while Contacts is on.
* Contacts may have turned that layer on, and it releases the layers it
* owns when it goes off; the Cockpit must outlive Contacts, so riding an
* aircraft adopts its layer as a direct selection does. Contacts then stops
* owning it and the Context restore keeps it (session `userAdded`).
* @param {string|null} layerId The ridden aircraft's layer.
* Make the ridden layer the user's own while Contacts is on. Contacts may
* have turned that layer on (an aircraft layer, or Live AIS Vessels), and
* it releases the layers it owns when it goes off; the Cockpit must outlive
* Contacts, so riding an aircraft or a vessel adopts its layer as a direct
* selection does. Contacts then stops owning it and the Context restore
* keeps it (session `userAdded`).
* @param {string|null} layerId The ridden aircraft's layer, or
* 'ais-live-vessels' on a bridge.
*/
_adoptRiddenLayer(layerId) {
if (!COCKPIT_AIRCRAFT_LAYER_IDS.includes(layerId)) return;
if (
!COCKPIT_AIRCRAFT_LAYER_IDS.includes(layerId) &&
layerId !== 'ais-live-vessels'
)
return;
if (!this._isLayerEnabled('military-awareness')) return;
this._dataManager?.adoptLayerVisibility?.(layerId, true, {
origin: 'user',
@@ -167,6 +181,11 @@ export class CockpitCoordinator {
const snapshot = militaryAwarenessLayer.getContextSnapshot?.();
const info = this.cockpitView?.readAircraftInfo?.();
const active = Boolean(this.cockpitView?.active);
// Voice enters aircraft only; a bridge in use is still reported as it is.
const vessel =
active && this.cockpitView?.subjectKind === 'vessel'
? this.cockpitView.readVesselInfo?.()
: null;
const gateOpen = Boolean(this.cockpitView?.isEntryAllowed?.());
// "Could Cockpit be ENTERED right now" — so it is false while already
// inside, unconditionally. Cockpit takes the entity off
@@ -195,13 +214,22 @@ export class CockpitCoordinator {
? 'subject-layer-off'
: 'no-tracked-aircraft',
visionMode: this.cockpitView?.visionMode || null,
subject: info
subject: vessel
? {
id: info.icao24 || info.id || null,
layerId: info.layerId || null,
callsign: info.callsign || null,
kind: 'vessel',
id: vessel.mmsi,
layerId: vessel.layerId,
callsign: null,
name: vessel.name,
}
: null,
: info
? {
kind: 'aircraft',
id: info.icao24 || info.id || null,
layerId: info.layerId || null,
callsign: info.callsign || null,
}
: null,
navigation: snapshot
? {
canPrevious: Boolean(snapshot.navigation?.canPrevious),