mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
52187c91d1
commit
72112ecb45
58 files changed
+5313
-137
No files matched your search
@@ -361,6 +361,7 @@ export class StyleManager extends ShellFacade {
|
||||
services: {
|
||||
flightsLayer: services.flightsLayer,
|
||||
militaryFlightsLayer: services.militaryFlightsLayer,
|
||||
aisLiveVesselsLayer: services.aisLiveVesselsLayer,
|
||||
isTr3b: services.isTr3b,
|
||||
toggleTr3b: services.toggleTr3b,
|
||||
militaryAwarenessLayer: services.militaryAwarenessLayer,
|
||||
@@ -400,6 +401,8 @@ export class StyleManager extends ShellFacade {
|
||||
useCockpitStore(applicationPinia()).publishVision(view),
|
||||
signals: (rows) =>
|
||||
useCockpitStore(applicationPinia()).publishSignals(rows),
|
||||
radar: (view) =>
|
||||
useCockpitStore(applicationPinia()).publishRadar(view),
|
||||
utilityLayout: (layout) =>
|
||||
useCockpitStore(applicationPinia()).publishUtilityLayout(layout),
|
||||
},
|
||||
|
||||
@@ -52,7 +52,7 @@ function cockpitBodyClasses() {
|
||||
|
||||
test('the Cockpit adds its subject classes to <body>', () => {
|
||||
const classes = cockpitBodyClasses();
|
||||
for (const name of ['cockpit-mode']) {
|
||||
for (const name of ['cockpit-mode', 'cockpit-bridge']) {
|
||||
assert.ok(classes.includes(name), `${name} is not added to <body>`);
|
||||
}
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -156,7 +156,7 @@ export function maybeRefreshRegionalBrief(info) {
|
||||
!Number.isFinite(info.longitude)
|
||||
)
|
||||
return;
|
||||
const subjectId = `${info.layerId || 'aircraft'}:${info.icao24 || info.registration || info.callsign || 'unknown'}`;
|
||||
const subjectId = `${info.layerId || 'aircraft'}:${info.icao24 || info.mmsi || info.registration || info.callsign || 'unknown'}`;
|
||||
if (subjectId !== this.regionalBriefSubjectId) {
|
||||
this.regionalBriefAbort?.abort();
|
||||
this.regionalBriefAbort = null;
|
||||
|
||||
+221
-9
@@ -7,6 +7,15 @@ import {
|
||||
cockpitUiUpdateDue,
|
||||
slewHeading,
|
||||
} from '../cockpitMath.js';
|
||||
import {
|
||||
VESSEL_DEAD_RECKON_MAX_S,
|
||||
VESSEL_WATERLINE_REFRESH_MS,
|
||||
deadReckonVesselFix,
|
||||
vesselCameraProfile,
|
||||
vesselWaterlineM,
|
||||
waterlineProbePoints,
|
||||
} from '../cockpitSubjects.js';
|
||||
import { easeLook } from '../cockpitLook.js';
|
||||
import {
|
||||
COCKPIT_HEADING_SLEW_DPS,
|
||||
COCKPIT_FORWARD_OFFSET_M,
|
||||
@@ -44,6 +53,10 @@ export function update() {
|
||||
}
|
||||
|
||||
const nowMs = performance.now();
|
||||
if (this.subjectKind === 'vessel') {
|
||||
updateVessel.call(this, nowMs);
|
||||
return;
|
||||
}
|
||||
const info = this.readAircraftInfo();
|
||||
|
||||
// Adopt a newly selected track before the camera cadence gate. A context
|
||||
@@ -86,17 +99,208 @@ export function update() {
|
||||
placeCamera.call(this, target, info, nowMs, dtSec, AIRCRAFT_CAMERA_PROFILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* The surface the ridden ship floats on: the layer's geoid sea surface, or
|
||||
* the water read off the rendered scene when that sits higher (a river or
|
||||
* lake above sea level). The read runs in the background every
|
||||
* VESSEL_WATERLINE_REFRESH_MS. The full-detail read can take many seconds
|
||||
* from cold tiles, so a new ship's first read starts from the tiles already
|
||||
* on screen; until any read lands the sea surface stands. Only one
|
||||
* full-detail read runs at a time (each is nine picks Cesium traverses
|
||||
* every frame until it settles): while one is still running, a refresh
|
||||
* reads the loaded tiles instead, and the slow read applies whenever it
|
||||
* lands unless a newer one has.
|
||||
* @param {{latitude: number, longitude: number}} [at] Where to read the
|
||||
* water: the dead-reckoned position the camera rides.
|
||||
* @returns {number} Ellipsoidal metres.
|
||||
*/
|
||||
function vesselSurfaceM(info, nowMs, at = info) {
|
||||
const seaM = Number.isFinite(info.seaSurfaceHeightM)
|
||||
? info.seaSurfaceHeightM
|
||||
: 0;
|
||||
const scene = this.viewer.scene;
|
||||
let read =
|
||||
this.vesselWaterline?.mmsi === info.mmsi ? this.vesselWaterline : null;
|
||||
if (
|
||||
typeof scene?.sampleHeightMostDetailed === 'function' &&
|
||||
(!read || nowMs - read.sampledMs >= VESSEL_WATERLINE_REFRESH_MS)
|
||||
) {
|
||||
const probes = waterlineProbePoints(at.latitude, at.longitude).map(
|
||||
({ lat, lon }) => Cesium.Cartographic.fromDegrees(lon, lat),
|
||||
);
|
||||
if (!read) {
|
||||
read = {
|
||||
mmsi: info.mmsi,
|
||||
heightM: loadedWaterlineM(scene, probes, seaM),
|
||||
sampledMs: nowMs,
|
||||
// Full-detail reads by number: the last started, the last applied.
|
||||
startedSeq: 0,
|
||||
landedSeq: 0,
|
||||
inFlight: false,
|
||||
};
|
||||
this.vesselWaterline = read;
|
||||
} else {
|
||||
read.sampledMs = nowMs;
|
||||
if (read.inFlight) {
|
||||
const loadedM = loadedWaterlineM(scene, probes, seaM);
|
||||
if (Number.isFinite(loadedM)) read.heightM = loadedM;
|
||||
}
|
||||
}
|
||||
if (!read.inFlight) readWaterline.call(this, read, scene, probes, seaM);
|
||||
}
|
||||
return read && Number.isFinite(read.heightM)
|
||||
? Math.max(seaM, read.heightM)
|
||||
: seaM;
|
||||
}
|
||||
|
||||
/** Start one full-detail water read for `read`; its answer lands on it. */
|
||||
function readWaterline(read, scene, probes, seaM) {
|
||||
const seq = ++read.startedSeq;
|
||||
read.inFlight = true;
|
||||
Promise.resolve()
|
||||
.then(() => scene.sampleHeightMostDetailed(probes))
|
||||
.then(
|
||||
(samples) => {
|
||||
if (this.vesselWaterline !== read) return;
|
||||
read.inFlight = false;
|
||||
// However late it lands, it applies unless a newer read has.
|
||||
if (seq <= read.landedSeq) return;
|
||||
read.landedSeq = seq;
|
||||
read.heightM = vesselWaterlineM(
|
||||
seaM,
|
||||
(samples || []).map((sample) => sample?.height),
|
||||
);
|
||||
},
|
||||
() => {
|
||||
if (this.vesselWaterline === read) read.inFlight = false;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The waterline from the tiles already loaded, read at once: a first answer
|
||||
* while the full-detail read loads. Null when the scene cannot sample or no
|
||||
* probe met loaded geometry: nothing sampled is no answer, not the sea, so it
|
||||
* never undoes a river height a full read set.
|
||||
*/
|
||||
function loadedWaterlineM(scene, probes, seaM) {
|
||||
if (typeof scene.sampleHeight !== 'function') return null;
|
||||
if (scene.sampleHeightSupported === false) return null;
|
||||
try {
|
||||
const heights = probes.map((probe) => scene.sampleHeight(probe));
|
||||
if (!heights.some(Number.isFinite)) return null;
|
||||
return vesselWaterlineM(seaM, heights);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drive the bridge camera from the selected vessel. The vessel layer redraws
|
||||
* a ship only when its feed refreshes, so the target is the last fix advanced
|
||||
* along course over ground; the shared anchor smoothing then absorbs the
|
||||
* correction each new fix brings.
|
||||
*/
|
||||
function updateVessel(nowMs) {
|
||||
// Tracking an aircraft from the bridge clears the vessel selection; end the
|
||||
// bridge and leave Cesium tracking with that aircraft.
|
||||
if (this.viewer.trackedEntity?.position) {
|
||||
this.exit({ restoreTracking: false });
|
||||
return;
|
||||
}
|
||||
const info = this.readVesselInfo();
|
||||
if (!info || info.mmsi !== this.subjectId) {
|
||||
this.exit({ restoreTracking: false });
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!cockpitUiUpdateDue(
|
||||
nowMs,
|
||||
this.lastCameraUpdateMs,
|
||||
COCKPIT_CAMERA_UPDATE_MS,
|
||||
)
|
||||
)
|
||||
return;
|
||||
this.lastCameraUpdateMs = nowMs;
|
||||
|
||||
const fix = deadReckonVesselFix(
|
||||
{
|
||||
latitude: info.latitude,
|
||||
longitude: info.longitude,
|
||||
courseDeg: info.motionCourse,
|
||||
speedMps: info.velocityMps,
|
||||
fixEpochMs: info.fixEpochMs,
|
||||
receivedAtMs: info.receivedAtMs,
|
||||
feedEpochMs: info.feedEpochMs,
|
||||
},
|
||||
Date.now(),
|
||||
);
|
||||
const target = Cesium.Cartesian3.fromDegrees(
|
||||
fix.longitude,
|
||||
fix.latitude,
|
||||
// Read the water where the ship is now, not at its last report.
|
||||
vesselSurfaceM.call(this, info, nowMs, fix),
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
this.scratchTarget,
|
||||
);
|
||||
// The target advances in wall-clock time, so the anchor must too: the
|
||||
// aircraft path's 0.1 s step cap would leave a slow-frame or hitching bridge
|
||||
// falling ever further behind its own ship.
|
||||
const dtSec = Math.min(
|
||||
VESSEL_DEAD_RECKON_MAX_S,
|
||||
Math.max(0, (nowMs - this.lastFrameMs) / 1000),
|
||||
);
|
||||
this.lastFrameMs = nowMs;
|
||||
if (Number.isFinite(info.track)) {
|
||||
this.heading = slewHeading(
|
||||
this.heading ?? info.track,
|
||||
info.track,
|
||||
COCKPIT_HEADING_SLEW_DPS * dtSec,
|
||||
);
|
||||
}
|
||||
// Past the projection limit the target stops advancing; hold on it rather
|
||||
// than let the inertial anchor sail on alone.
|
||||
const projectionExpired =
|
||||
Number.isFinite(fix.ageSec) && fix.ageSec > VESSEL_DEAD_RECKON_MAX_S;
|
||||
// The look eases on its own clock: the anchor's step is capped differently.
|
||||
this.lookView = easeLook(
|
||||
this.lookView,
|
||||
this.lookTarget,
|
||||
nowMs - (this.lookLastMs || nowMs),
|
||||
);
|
||||
this.lookLastMs = nowMs;
|
||||
// A ship reporting neither course nor heading has no direction to move
|
||||
// in: its anchor stays on the fix, as the dead reckoning does.
|
||||
const ridden = Number.isFinite(info.motionCourse)
|
||||
? info
|
||||
: { ...info, velocityMps: 0 };
|
||||
placeCamera.call(
|
||||
this,
|
||||
target,
|
||||
projectionExpired ? { ...ridden, stale: true } : ridden,
|
||||
nowMs,
|
||||
dtSec,
|
||||
vesselCameraProfile(info),
|
||||
this.lookView,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Place the camera for one update: advance the inertial anchor, clamp it and
|
||||
* the eye against the rendered surface, and look along the slewed heading.
|
||||
* @param {Cesium.Cartesian3} target Authoritative subject position.
|
||||
* @param {object} info Subject info.
|
||||
* @param {object} info Subject info; `motionCourse` (when present) is the
|
||||
* direction the subject moves, otherwise it moves where it faces.
|
||||
* @param {number} nowMs Frame time.
|
||||
* @param {number} dtSec Seconds since the previous camera update.
|
||||
* @param {{forwardM: number, upM: number, pitchDeg: number,
|
||||
* minClearanceM: number}} profile Eye offsets for the subject kind.
|
||||
* @param {?{yawDeg: number, pitchDeg: number}} [look] A bridge view turned
|
||||
* off the bow: yaw relative to the heading and absolute pitch. It turns
|
||||
* only the view; the eye and its motion keep the heading and course.
|
||||
* Aircraft pass none and look along the heading at the profile pitch.
|
||||
*/
|
||||
function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
|
||||
if (!this.cockpitAnchorValid) {
|
||||
Cesium.Cartesian3.clone(target, this.cockpitAnchor);
|
||||
this.cockpitAnchorValid = true;
|
||||
@@ -110,7 +314,15 @@ function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
// 15/30-second interpolation and per-frame cache without exposing its
|
||||
// sample-boundary corrections to the camera.
|
||||
const headingRad = Cesium.Math.toRadians(this.heading ?? 0);
|
||||
const pitchRad = Cesium.Math.toRadians(profile.pitchDeg);
|
||||
const courseRad = Number.isFinite(info.motionCourse)
|
||||
? Cesium.Math.toRadians(info.motionCourse)
|
||||
: headingRad;
|
||||
const pitchRad = Cesium.Math.toRadians(
|
||||
look ? look.pitchDeg : profile.pitchDeg,
|
||||
);
|
||||
const viewHeadingRad = look
|
||||
? Cesium.Math.toRadians((this.heading ?? 0) + look.yawDeg)
|
||||
: headingRad;
|
||||
const speedMps = Number.isFinite(info.velocityMps)
|
||||
? Math.max(0, info.velocityMps)
|
||||
: 0;
|
||||
@@ -126,8 +338,8 @@ function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
this.scratchEnu,
|
||||
);
|
||||
this.scratchLocal.x = Math.sin(headingRad);
|
||||
this.scratchLocal.y = Math.cos(headingRad);
|
||||
this.scratchLocal.x = Math.sin(courseRad);
|
||||
this.scratchLocal.y = Math.cos(courseRad);
|
||||
this.scratchLocal.z = 0;
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
this.scratchEnu,
|
||||
@@ -296,8 +508,8 @@ function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
);
|
||||
Cesium.Cartesian3.normalize(this.scratchHorizontal, this.scratchHorizontal);
|
||||
|
||||
this.scratchLocal.x = Math.sin(headingRad) * Math.cos(pitchRad);
|
||||
this.scratchLocal.y = Math.cos(headingRad) * Math.cos(pitchRad);
|
||||
this.scratchLocal.x = Math.sin(viewHeadingRad) * Math.cos(pitchRad);
|
||||
this.scratchLocal.y = Math.cos(viewHeadingRad) * Math.cos(pitchRad);
|
||||
this.scratchLocal.z = Math.sin(pitchRad);
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
this.scratchEnu,
|
||||
@@ -306,8 +518,8 @@ function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
);
|
||||
Cesium.Cartesian3.normalize(this.scratchForward, this.scratchForward);
|
||||
|
||||
this.scratchLocal.x = -Math.sin(headingRad) * Math.sin(pitchRad);
|
||||
this.scratchLocal.y = -Math.cos(headingRad) * Math.sin(pitchRad);
|
||||
this.scratchLocal.x = -Math.sin(viewHeadingRad) * Math.sin(pitchRad);
|
||||
this.scratchLocal.y = -Math.cos(viewHeadingRad) * Math.sin(pitchRad);
|
||||
this.scratchLocal.z = Math.cos(pitchRad);
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
this.scratchEnu,
|
||||
|
||||
+116
-5
@@ -1,6 +1,7 @@
|
||||
/** Coordinate Cockpit lifecycle through supplied aircraft, terrain, rendering and briefing operations. */
|
||||
import {
|
||||
readAircraftInfo,
|
||||
readVesselInfo,
|
||||
readSubjectLayerId,
|
||||
resolveEntryKind,
|
||||
dispatchCockpitModeChanged,
|
||||
@@ -19,6 +20,8 @@ import {
|
||||
publishRouteView,
|
||||
updateHud,
|
||||
updateRoute,
|
||||
updateRadar,
|
||||
presentLook,
|
||||
syncWeatherToggle,
|
||||
setVisionMode,
|
||||
cycleVisionMode,
|
||||
@@ -67,10 +70,21 @@ import {
|
||||
import {
|
||||
onKeyDown,
|
||||
onSceneDoubleClick,
|
||||
onScenePointerDown,
|
||||
routeSceneDoubleClick,
|
||||
} from './cockpitInput.js';
|
||||
import { DEFAULT_RADAR_RANGE_NM, nextRadarRange } from '../cockpitRadar.js';
|
||||
import { VESSEL_BRIDGE_PITCH_DEG } from '../cockpitSubjects.js';
|
||||
import { stepLook } from '../cockpitLook.js';
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
/** Whether the user asked for reduced motion: look turns then jump. */
|
||||
function prefersReducedMotion() {
|
||||
return Boolean(
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches,
|
||||
);
|
||||
}
|
||||
|
||||
export class CockpitViewController {
|
||||
constructor(
|
||||
viewer,
|
||||
@@ -80,6 +94,7 @@ export class CockpitViewController {
|
||||
getInitialVisionMode = null,
|
||||
onCameraTakeover = null,
|
||||
isEntryAllowed = null,
|
||||
isBridgeEntryAllowed = null,
|
||||
isUtilityDisclosureOpen = null,
|
||||
onEntered = null,
|
||||
onExited = null,
|
||||
@@ -93,6 +108,10 @@ export class CockpitViewController {
|
||||
this.destroyed = false;
|
||||
this.disposed = false;
|
||||
this.active = false;
|
||||
/** 'aircraft' or 'vessel' while active; which subject the camera rides. */
|
||||
this.subjectKind = null;
|
||||
/** The vessel subject's MMSI; aircraft are identified by trackedEntity. */
|
||||
this.subjectId = null;
|
||||
this.trackedEntity = null;
|
||||
this.trackedEntityWasShown = true;
|
||||
this.heading = null;
|
||||
@@ -105,6 +124,14 @@ export class CockpitViewController {
|
||||
this.surfaceWaitStartedMs = 0;
|
||||
this.surfaceAcquiring = false;
|
||||
this.surfaceFallback = false;
|
||||
/**
|
||||
* Where the bridge view is turned to (`lookTarget`) and where the camera
|
||||
* looks on its way there (`lookView`): yaw off the bow, starboard
|
||||
* positive, and absolute pitch. Aircraft never turn it.
|
||||
*/
|
||||
this.lookTarget = { yawDeg: 0, pitchDeg: VESSEL_BRIDGE_PITCH_DEG };
|
||||
this.lookView = { ...this.lookTarget };
|
||||
this.lookLastMs = 0;
|
||||
this.entry = document.getElementById('cockpit-entry');
|
||||
this.tr3bToggle = document.getElementById('tr3b-toggle');
|
||||
this._tr3bSignature = null;
|
||||
@@ -130,6 +157,11 @@ export class CockpitViewController {
|
||||
: () => false;
|
||||
this.isEntryAllowed =
|
||||
typeof isEntryAllowed === 'function' ? isEntryAllowed : () => true;
|
||||
// Without a supplied gate there is no vessel layer to ride either.
|
||||
this.isBridgeEntryAllowed =
|
||||
typeof isBridgeEntryAllowed === 'function'
|
||||
? isBridgeEntryAllowed
|
||||
: () => false;
|
||||
this.isUtilityDisclosureOpen =
|
||||
typeof isUtilityDisclosureOpen === 'function'
|
||||
? isUtilityDisclosureOpen
|
||||
@@ -164,9 +196,15 @@ export class CockpitViewController {
|
||||
this.publishVision = publish.vision ?? (() => {});
|
||||
this.publishSignals = publish.signals ?? (() => {});
|
||||
this.publishUtilityLayout = publish.utilityLayout ?? (() => {});
|
||||
this.publishRadar = publish.radar ?? (() => {});
|
||||
/** The bridge radar's range in nautical miles; kept across bridges. */
|
||||
this.radarRangeNm = DEFAULT_RADAR_RANGE_NM;
|
||||
this.presence = {
|
||||
active: false,
|
||||
entryAvailable: false,
|
||||
// Which subject the entry button would enter, and the active subject.
|
||||
entryKind: null,
|
||||
subjectKind: null,
|
||||
tr3b: null,
|
||||
context: false,
|
||||
// The Contact and briefing cards' collapse, which their toggles show.
|
||||
@@ -216,9 +254,15 @@ export class CockpitViewController {
|
||||
);
|
||||
this._listen(this.entry, 'click', () => this.enter());
|
||||
// Double-clicking the followed track is a third way in.
|
||||
this._listen(
|
||||
viewer.scene?.canvas,
|
||||
'pointerdown',
|
||||
() => this.onScenePointerDown(),
|
||||
true,
|
||||
);
|
||||
this._listenerRemovers.push(routeSceneDoubleClick.call(this));
|
||||
// The readout's entry renders inside the Intel HUD, which may mount after
|
||||
// this controller, so its clicks are delegated.
|
||||
// this controller; delegated like the radar's range button.
|
||||
this._listen(document, 'click', (event) => {
|
||||
if (event.target?.closest?.('#cockpit-entry-readout')) this.enter();
|
||||
});
|
||||
@@ -248,6 +292,15 @@ export class CockpitViewController {
|
||||
this._listen(window, 'gev:cockpit-weather-state', (event) => {
|
||||
this.syncWeatherToggle(event?.detail?.enabled !== false);
|
||||
});
|
||||
// The radar mounts only on a bridge, so its range button is delegated.
|
||||
this._listen(document, 'click', (event) => {
|
||||
if (event.target?.closest?.('#cockpit-radar-range'))
|
||||
this.cycleRadarRange();
|
||||
});
|
||||
// The look-ahead button shows only on a turned bridge view; delegated.
|
||||
this._listen(document, 'click', (event) => {
|
||||
if (event.target?.closest?.('#cockpit-look-ahead')) this.lookAhead();
|
||||
});
|
||||
this._listen(this.signalToggle, 'click', () =>
|
||||
this.setSignalCollapsed(!this.signalCollapsed, { user: true }),
|
||||
);
|
||||
@@ -289,6 +342,9 @@ export class CockpitViewController {
|
||||
readAircraftInfo() {
|
||||
return readAircraftInfo.call(this);
|
||||
}
|
||||
readVesselInfo() {
|
||||
return readVesselInfo.call(this);
|
||||
}
|
||||
readSubjectLayerId() {
|
||||
return readSubjectLayerId.call(this);
|
||||
}
|
||||
@@ -316,8 +372,8 @@ export class CockpitViewController {
|
||||
_adoptTrackedEntity(nowMs, suppliedInfo) {
|
||||
return _adoptTrackedEntity.call(this, nowMs, suppliedInfo);
|
||||
}
|
||||
enter() {
|
||||
return enter.call(this);
|
||||
enter(options) {
|
||||
return enter.call(this, options);
|
||||
}
|
||||
exit(options) {
|
||||
return exit.call(this, options);
|
||||
@@ -337,6 +393,58 @@ export class CockpitViewController {
|
||||
updateRoute(info) {
|
||||
return updateRoute.call(this, info);
|
||||
}
|
||||
updateRadar(info) {
|
||||
return updateRadar.call(this, info);
|
||||
}
|
||||
/** Step the bridge radar to its next range and redraw it at once. */
|
||||
cycleRadarRange() {
|
||||
this.radarRangeNm = nextRadarRange(this.radarRangeNm);
|
||||
if (this.active && this.subjectKind === 'vessel' && this.lastAircraftInfo)
|
||||
this.updateRadar(this.lastAircraftInfo);
|
||||
}
|
||||
presentLook() {
|
||||
return presentLook.call(this);
|
||||
}
|
||||
/**
|
||||
* Turn the bridge view one arrow step (see `lookKeyStep`). The camera
|
||||
* eases there unless the user prefers reduced motion.
|
||||
* @param {{axis: 'yaw'|'pitch', sign: number, stepDeg: number}} step
|
||||
* @returns {boolean} True when a bridge view was turned.
|
||||
*/
|
||||
turnLook(step) {
|
||||
if (!this.active || this.subjectKind !== 'vessel' || !step) return false;
|
||||
this.lookTarget = stepLook(this.lookTarget, step);
|
||||
if (prefersReducedMotion()) this.lookView = { ...this.lookTarget };
|
||||
this.presentLook();
|
||||
this.publishInstrumentsView();
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Point the bridge view back over the bow at the rest pitch.
|
||||
* @param {{immediate?: boolean}} [options] Jump there instead of easing,
|
||||
* as entry and exit do.
|
||||
*/
|
||||
resetLook({ immediate = false } = {}) {
|
||||
this.lookTarget = { yawDeg: 0, pitchDeg: VESSEL_BRIDGE_PITCH_DEG };
|
||||
if (immediate || prefersReducedMotion())
|
||||
this.lookView = { ...this.lookTarget };
|
||||
this.lookLastMs = performance.now();
|
||||
this.presentLook();
|
||||
this.publishInstrumentsView();
|
||||
}
|
||||
/**
|
||||
* The LOOK AHEAD control and the Home and 0 keys: ease the bridge view
|
||||
* back over the bow. Focus leaves the button before it hides.
|
||||
* @returns {boolean} True on a bridge.
|
||||
*/
|
||||
lookAhead() {
|
||||
if (!this.active || this.subjectKind !== 'vessel') return false;
|
||||
const button = document.getElementById('cockpit-look-ahead');
|
||||
const hadFocus = !!button && button.contains(document.activeElement);
|
||||
this.resetLook();
|
||||
if (hadFocus) this.mapViewButton?.focus({ preventScroll: true });
|
||||
return true;
|
||||
}
|
||||
syncWeatherToggle(enabled) {
|
||||
return syncWeatherToggle.call(this, enabled);
|
||||
}
|
||||
@@ -426,8 +534,11 @@ export class CockpitViewController {
|
||||
onKeyDown(event) {
|
||||
return onKeyDown.call(this, event);
|
||||
}
|
||||
onSceneDoubleClick(position) {
|
||||
return onSceneDoubleClick.call(this, position);
|
||||
onSceneDoubleClick(position, nowMs) {
|
||||
return onSceneDoubleClick.call(this, position, nowMs);
|
||||
}
|
||||
onScenePointerDown(nowMs) {
|
||||
return onScenePointerDown.call(this, nowMs);
|
||||
}
|
||||
|
||||
handleSignalClick(event) {
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -86,6 +86,7 @@ function fixture(
|
||||
services: {
|
||||
flightsLayer: { getTrackedInfo: trackedFrom('flights') },
|
||||
militaryFlightsLayer: { getTrackedInfo: trackedFrom('military') },
|
||||
aisLiveVesselsLayer: { getCockpitSubject: () => null },
|
||||
militaryAwarenessLayer: { getContextSnapshot: () => null },
|
||||
isTr3b: () => false,
|
||||
holdContinuousRender() {},
|
||||
@@ -120,7 +121,7 @@ function fixture(
|
||||
t.after(() => {
|
||||
coordinator.stop();
|
||||
app.unmount();
|
||||
document.body.classList.remove('cockpit-mode');
|
||||
document.body.classList.remove('cockpit-mode', 'cockpit-bridge');
|
||||
});
|
||||
/** Turn a layer off and tell the Context owner, as the data manager does. */
|
||||
const disable = (layerId) => {
|
||||
@@ -157,6 +158,7 @@ test('a civilian aircraft enters with Live Flights alone: no Contacts, no Milita
|
||||
assert.equal(state.entryAllowed, true);
|
||||
assert.equal(state.entryBlockedReason, null);
|
||||
assert.equal(cockpit.enter(), true);
|
||||
assert.equal(cockpit.subjectKind, 'aircraft');
|
||||
});
|
||||
|
||||
test('a military aircraft enters with Military Flights alone', (t) => {
|
||||
@@ -439,6 +441,22 @@ test('a ride handed to an aircraft on a layer Contacts turned on keeps that laye
|
||||
assert.deepEqual(on(manager), ['flights', 'military']);
|
||||
});
|
||||
|
||||
test('a bridge ride keeps Live AIS Vessels when Contacts had turned it on', async (t) => {
|
||||
const live = await liveFixture(t, {
|
||||
tracked: { layerId: 'flights', info: CIVIL },
|
||||
});
|
||||
const { manager, controls, coordinator, settle } = live;
|
||||
assert.equal(await controls._selectContextMode('flights'), true);
|
||||
await settle();
|
||||
assert.equal(manager.isEnabled('ais-live-vessels'), true);
|
||||
// The bridge reports its layer on entry (cockpitBridge.test.mjs).
|
||||
coordinator._adoptRiddenLayer('ais-live-vessels');
|
||||
await controls._selectContextMode(null);
|
||||
await settle();
|
||||
assert.equal(controls.getContextModeState().mode, null);
|
||||
assert.deepEqual(on(manager), ['ais-live-vessels']);
|
||||
});
|
||||
|
||||
test('the ridden layer still ends the Cockpit while Contacts is on', async (t) => {
|
||||
const live = await liveFixture(t, {
|
||||
tracked: { layerId: 'flights', info: CIVIL },
|
||||
@@ -465,3 +483,19 @@ test('without a Cockpit, ending Contacts restores the layers it found', async (t
|
||||
assert.equal(controls.getContextModeState().mode, null);
|
||||
assert.deepEqual(on(manager), [], 'Live Flights goes back off');
|
||||
});
|
||||
|
||||
test('the readout entry reads BRIDGE for a selected vessel', async (t) => {
|
||||
const { $, store } = fixture(t);
|
||||
store.publishPresence({
|
||||
active: false,
|
||||
entryAvailable: true,
|
||||
entryKind: 'vessel',
|
||||
subjectKind: null,
|
||||
tr3b: null,
|
||||
});
|
||||
await nextTick();
|
||||
const readoutEntry = $('#cockpit-entry-readout');
|
||||
assert.equal(readoutEntry.hidden, false);
|
||||
assert.match(readoutEntry.textContent, /directions_boat/);
|
||||
assert.match(readoutEntry.textContent, /BRIDGE/);
|
||||
});
|
||||
+108
-14
@@ -1,5 +1,6 @@
|
||||
/** Route Cockpit keys while preserving the active disclosure and form-control owner. */
|
||||
import * as Cesium from 'cesium';
|
||||
import { lookKeyStep } from '../cockpitLook.js';
|
||||
import { isPointerFree } from '../data/inputOwnership.js';
|
||||
|
||||
/** How far from the followed track a double-click may land, CSS pixels. */
|
||||
@@ -22,14 +23,33 @@ export function doubleClickHitsSubject(
|
||||
return Number.isFinite(distance) && distance <= radiusPx;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long the first press of a double-click keeps its picture of the track,
|
||||
* ms: a click on a selected ship re-centres the camera, so the ship can move
|
||||
* on screen before the second click lands.
|
||||
*/
|
||||
export const DOUBLE_CLICK_MEMORY_MS = 700;
|
||||
|
||||
/** Where the track `kind` would ride is drawn now, as a world position. */
|
||||
function subjectWorldPosition(kind) {
|
||||
if (kind !== 'aircraft') return null;
|
||||
return (
|
||||
this.viewer.trackedEntity?.position?.getValue?.(
|
||||
this.viewer.clock?.currentTime,
|
||||
) ?? null
|
||||
);
|
||||
if (kind === 'aircraft') {
|
||||
return (
|
||||
this.viewer.trackedEntity?.position?.getValue?.(
|
||||
this.viewer.clock?.currentTime,
|
||||
) ?? null
|
||||
);
|
||||
}
|
||||
const info = this.readVesselInfo();
|
||||
if (!Number.isFinite(info?.latitude) || !Number.isFinite(info?.longitude))
|
||||
return null;
|
||||
// The sprite floats on the geoid, not on the ellipsoid (tens of metres
|
||||
// apart): project the height it is drawn at.
|
||||
const heightM = Number.isFinite(info.markHeightM)
|
||||
? info.markHeightM
|
||||
: Number.isFinite(info.seaSurfaceHeightM)
|
||||
? info.seaSurfaceHeightM
|
||||
: 0;
|
||||
return Cesium.Cartesian3.fromDegrees(info.longitude, info.latitude, heightM);
|
||||
}
|
||||
|
||||
/** The followed track's canvas position now, or null off screen. */
|
||||
@@ -44,21 +64,43 @@ function subjectCanvasPosition() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note where the followed track is drawn as a press begins, for a
|
||||
* double-click whose first click moves it. The second press of the gesture
|
||||
* keeps the first one's picture: by then the first click may have moved it.
|
||||
* @param {number} [nowMs]
|
||||
*/
|
||||
export function onScenePointerDown(nowMs = performance.now()) {
|
||||
if (this.active || this.destroyed) return;
|
||||
const start = this.doubleClickStart;
|
||||
if (start && nowMs - start.atMs <= DOUBLE_CLICK_MEMORY_MS) return;
|
||||
const at = subjectCanvasPosition.call(this);
|
||||
this.doubleClickStart = at ? { x: at.x, y: at.y, atMs: nowMs } : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter first person when the followed track itself is double-clicked: the
|
||||
* same entry, and the same gates, as C and the entry buttons. A
|
||||
* same entry, and the same gates, as C and the entry buttons. The click may
|
||||
* land where the track is drawn now or where it was as the gesture began. A
|
||||
* double-click anywhere else, or one a tool owns (drawing ends a shape with
|
||||
* one), is left alone.
|
||||
* @param {{x: number, y: number}|null|undefined} position Canvas position.
|
||||
* @param {number} [nowMs]
|
||||
* @returns {boolean} True when it landed on the followed track, entered or
|
||||
* refused by the gate: the caller does nothing else with it.
|
||||
*/
|
||||
export function onSceneDoubleClick(position) {
|
||||
export function onSceneDoubleClick(position, nowMs = performance.now()) {
|
||||
const start = this.doubleClickStart;
|
||||
this.doubleClickStart = null;
|
||||
if (this.active || this.destroyed || !isPointerFree()) return false;
|
||||
if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y))
|
||||
return false;
|
||||
if (!doubleClickHitsSubject(position, subjectCanvasPosition.call(this)))
|
||||
return false;
|
||||
const hit =
|
||||
doubleClickHitsSubject(position, subjectCanvasPosition.call(this)) ||
|
||||
(Boolean(start) &&
|
||||
nowMs - start.atMs <= DOUBLE_CLICK_MEMORY_MS &&
|
||||
doubleClickHitsSubject(position, start));
|
||||
if (!hit) return false;
|
||||
this.enter();
|
||||
return true;
|
||||
}
|
||||
@@ -91,12 +133,55 @@ export function routeSceneDoubleClick() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit's capture-phase keydown: Escape and C.
|
||||
* Focus inside one of these keeps its arrows (and Home): text entry, sliders,
|
||||
* tabs, radio groups, lists and menus all move with them.
|
||||
*/
|
||||
const LOOK_KEY_OWNERS = [
|
||||
'input',
|
||||
'textarea',
|
||||
'select',
|
||||
'[contenteditable]',
|
||||
'[role=slider]',
|
||||
'[role=tab]',
|
||||
'[role=tablist]',
|
||||
'[role=radio]',
|
||||
'[role=radiogroup]',
|
||||
'[role=listbox]',
|
||||
'[role=menu]',
|
||||
'[role=menuitem]',
|
||||
'[role=option]',
|
||||
].join(', ');
|
||||
|
||||
/**
|
||||
* Turn the bridge view with the arrow keys (Shift for 45° steps) and bring
|
||||
* it back over the bow with Home or 0. Only a bridge looks around, and only
|
||||
* while focus is on the scene or a plain HUD button.
|
||||
* @returns {boolean} True when the key was taken.
|
||||
*/
|
||||
function handleLookKey(event) {
|
||||
if (!this.active || this.subjectKind !== 'vessel') return false;
|
||||
if (event.metaKey || event.ctrlKey || event.altKey) return false;
|
||||
const step = lookKeyStep(event.key, event.shiftKey);
|
||||
const reset = !event.repeat && (event.key === 'Home' || event.key === '0');
|
||||
if (!step && !reset) return false;
|
||||
if (event.target?.closest?.(LOOK_KEY_OWNERS)) return false;
|
||||
if (this.isUtilityDisclosureOpen?.()) return false;
|
||||
event.preventDefault();
|
||||
if (step) this.turnLook(step);
|
||||
else this.lookAhead();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit's capture-phase keydown: Escape and C, and on a bridge the
|
||||
* look-around keys.
|
||||
* @param {KeyboardEvent} event
|
||||
*/
|
||||
export function onKeyDown(event) {
|
||||
if (this.destroyed) return false;
|
||||
if (event.repeat || event.isComposing) return;
|
||||
if (event.isComposing) return;
|
||||
// Held arrows turn a bridge view smoothly; every other key acts once.
|
||||
if (event.repeat && !lookKeyStep(event.key)) return;
|
||||
if (event.key === 'Escape' && this.active) {
|
||||
// The credit lightbox owns Escape while its Close control or links hold
|
||||
// focus. Its target handler closes the overlay and restores attribution
|
||||
@@ -139,19 +224,28 @@ export function onKeyDown(event) {
|
||||
}
|
||||
if (event.target?.closest?.('input, textarea, select, [contenteditable]'))
|
||||
return;
|
||||
if (handleLookKey.call(this, event)) return;
|
||||
const key = event.key?.toLowerCase();
|
||||
if (key === 'c' && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
||||
if (!this.active) {
|
||||
const cockpitAttempt = !!(
|
||||
this.readAircraftInfo() && this.viewer.trackedEntity?.position
|
||||
);
|
||||
if (!cockpitAttempt) return;
|
||||
// With no tracked aircraft, C takes the selected vessel's bridge.
|
||||
const bridgeAttempt = !cockpitAttempt && !!this.readVesselInfo();
|
||||
if (!cockpitAttempt && !bridgeAttempt) return;
|
||||
if (bridgeAttempt) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (this.isBridgeEntryAllowed()) this.enter({ kind: 'vessel' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (!this.active && !this.isEntryAllowed()) return;
|
||||
if (this.active) this.exit();
|
||||
else this.enter();
|
||||
else this.enter({ kind: 'aircraft' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -52,15 +52,28 @@ function createRimState(value) {
|
||||
*/
|
||||
export function createInstrumentState() {
|
||||
return {
|
||||
// 'aircraft' or 'vessel': which readouts the HUD labels and shows.
|
||||
kind: 'aircraft',
|
||||
layer: null,
|
||||
callsign: t('AIRCRAFT'),
|
||||
meta: { text: t('LIVE TRACK · COURSE ALIGNED'), emergency: false },
|
||||
speed: null,
|
||||
altitude: null,
|
||||
// A vessel's course over ground, shown where an aircraft shows altitude.
|
||||
course: null,
|
||||
heading: null,
|
||||
// A vessel's `heading` readout is its true heading, or its course over
|
||||
// ground when it reports none: 'heading' | 'course' | null.
|
||||
trackSource: null,
|
||||
speedRim: createRimState('---'),
|
||||
altitudeRim: createRimState('-----'),
|
||||
compass: [],
|
||||
// A bridge tape's bow (prograde) and stern (retrograde) marks, in
|
||||
// division slots off its centre; null when off the tape or not a bridge.
|
||||
compassMarkers: { prograde: null, retrograde: null },
|
||||
// A bridge view turned off the bow: whether it is, the target yaw off
|
||||
// the bow (degrees, -180..180, starboard positive) and its worded readout.
|
||||
look: { offset: false, yawDeg: 0, readout: '' },
|
||||
clock: '--:--:--Z',
|
||||
position: '--° · --°',
|
||||
};
|
||||
@@ -73,6 +86,8 @@ export function createInstrumentState() {
|
||||
*/
|
||||
export function createRouteState() {
|
||||
return {
|
||||
// A vessel's card shows only the free-text AIS destination.
|
||||
kind: 'aircraft',
|
||||
visible: false,
|
||||
from: t('UNKNOWN'),
|
||||
to: t('UNKNOWN'),
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
cockpitAltitudeDisplayFt,
|
||||
cockpitUiUpdateDue,
|
||||
compassDivisions,
|
||||
compassMarkerSlot,
|
||||
scrollingCompassDivisions,
|
||||
formatAltitudeRulerTick,
|
||||
formatCompassDivision,
|
||||
formatCockpitEmergency,
|
||||
@@ -22,10 +24,23 @@ import {
|
||||
} from '../cockpitMath.js';
|
||||
import {
|
||||
COCKPIT_CONTEXT_UPDATE_MS,
|
||||
cockpitUnitCase,
|
||||
compassPointLabel,
|
||||
formatCockpitCoordinate,
|
||||
} from './cockpitPresentation.js';
|
||||
import { createVisionState } from './cockpitInstrumentState.js';
|
||||
import { unitLabel } from './unitLabels.js';
|
||||
import {
|
||||
VESSEL_BRIDGE_PITCH_DEG,
|
||||
vesselCameraProfile,
|
||||
} from '../cockpitSubjects.js';
|
||||
import { lookIsOffset, lookReadoutParts, wrapLookYaw } from '../cockpitLook.js';
|
||||
import {
|
||||
RADAR_MAX_CONTACTS,
|
||||
radarPicture,
|
||||
radarRangeM,
|
||||
radarRangeNm,
|
||||
} from '../cockpitRadar.js';
|
||||
|
||||
/** A transponder status name (src/data/aircraftEmergency.js) for the HUD. */
|
||||
const emergencyLabel = ({ name }) => t(name).toUpperCase();
|
||||
@@ -68,20 +83,68 @@ export function publishInstrumentsView() {
|
||||
meta: { ...view.meta },
|
||||
speed: view.speed && { ...view.speed },
|
||||
altitude: view.altitude && { ...view.altitude },
|
||||
course: view.course && { ...view.course },
|
||||
heading: view.heading && { ...view.heading },
|
||||
speedRim: rim(view.speedRim),
|
||||
altitudeRim: rim(view.altitudeRim),
|
||||
compass: view.compass.map((division) => ({ ...division })),
|
||||
compassMarkers: { ...view.compassMarkers },
|
||||
look: { ...view.look },
|
||||
});
|
||||
}
|
||||
|
||||
/** Word a bridge look's readout parts (see `lookReadoutParts`). */
|
||||
function wordLook({ side, bearingDeg, elevation, angleDeg }) {
|
||||
const bearing = formatHeadingReadout(bearingDeg);
|
||||
const angle = formatNumber(angleDeg);
|
||||
let direction = '';
|
||||
if (side === 'starboard') direction = t('LOOK STBD {bearing}°', { bearing });
|
||||
else if (side === 'port') direction = t('LOOK PORT {bearing}°', { bearing });
|
||||
else if (side === 'astern') direction = t('LOOK ASTERN');
|
||||
let tilt = '';
|
||||
if (elevation === 'up') tilt = t('UP {angle}°', { angle });
|
||||
else if (elevation === 'down') tilt = t('DOWN {angle}°', { angle });
|
||||
else if (elevation === 'level') tilt = t('LEVEL');
|
||||
if (direction && tilt)
|
||||
return t('{direction} · {elevation}', { direction, elevation: tilt });
|
||||
if (tilt) return t('LOOK {elevation}', { elevation: tilt });
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the bridge look target: whether the view is turned off the bow,
|
||||
* its yaw for the radar and its worded readout. Outside a bridge the look
|
||||
* always rests. The caller publishes.
|
||||
*/
|
||||
export function presentLook() {
|
||||
const target = this.lookTarget;
|
||||
const offset =
|
||||
this.active &&
|
||||
this.subjectKind === 'vessel' &&
|
||||
lookIsOffset(target, VESSEL_BRIDGE_PITCH_DEG);
|
||||
this.instruments.look = offset
|
||||
? {
|
||||
offset: true,
|
||||
yawDeg: wrapLookYaw(target.yawDeg),
|
||||
readout: wordLook(lookReadoutParts(target, VESSEL_BRIDGE_PITCH_DEG)),
|
||||
}
|
||||
: { offset: false, yawDeg: 0, readout: '' };
|
||||
}
|
||||
|
||||
export function updateHud(
|
||||
info,
|
||||
nowMs = performance.now(),
|
||||
forceContext = false,
|
||||
) {
|
||||
if (info?.kind === 'vessel') {
|
||||
updateVesselHud.call(this, info, nowMs, forceContext);
|
||||
return;
|
||||
}
|
||||
this.lastAircraftInfo = info;
|
||||
const view = this.instruments;
|
||||
view.kind = 'aircraft';
|
||||
view.trackSource = null;
|
||||
view.course = null;
|
||||
const heading = normalizeHeading(this.heading ?? info.track ?? 0);
|
||||
view.callsign =
|
||||
info.callsign || info.registration || info.icao24 || t('AIRCRAFT');
|
||||
@@ -128,6 +191,7 @@ export function updateHud(
|
||||
slot: index - 3,
|
||||
label: compassPointLabel(formatCompassDivision(division)),
|
||||
}));
|
||||
view.compassMarkers = { prograde: null, retrograde: null };
|
||||
view.clock = new Date().toISOString().slice(11, 19) + 'Z';
|
||||
const lat = Number.isFinite(info.latitude)
|
||||
? formatCockpitCoordinate(info.latitude, 'N', 'S')
|
||||
@@ -175,6 +239,153 @@ export function updateHud(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the bridge readouts: speed and course over ground, true heading,
|
||||
* the vessel type and its assumed eye height. Contact navigation and Live
|
||||
* Signals stay aircraft-only, so the Contact card is withdrawn.
|
||||
*/
|
||||
function updateVesselHud(info, nowMs, forceContext) {
|
||||
this.lastAircraftInfo = info;
|
||||
const view = this.instruments;
|
||||
view.kind = 'vessel';
|
||||
view.trackSource = info.trackSource ?? null;
|
||||
// A ship reporting neither heading nor course has no heading to read out
|
||||
// and no bow to mark; the tape still follows the camera.
|
||||
const headingKnown = Number.isFinite(info.track);
|
||||
const cameraHeading = normalizeHeading(this.heading ?? info.track ?? 0);
|
||||
const heading = headingKnown ? cameraHeading : null;
|
||||
view.callsign = info.name;
|
||||
const speedKt = Number.isFinite(info.speedKt)
|
||||
? Math.max(0, info.speedKt)
|
||||
: null;
|
||||
view.speed = {
|
||||
text: formatSpeedRulerTick(speedKt),
|
||||
value: speedKt,
|
||||
immediate: forceContext,
|
||||
};
|
||||
view.speedRim.unavailable = speedKt === null;
|
||||
view.speedRim.value = formatSpeedRulerTick(speedKt);
|
||||
placeRimTicks(
|
||||
view.speedRim.ticks,
|
||||
speedRulerTicks(speedKt, view.speedRim.ticks.length),
|
||||
(tick) => formatSpeedRulerTick(tick.valueKt),
|
||||
);
|
||||
view.altitude = null;
|
||||
view.altitudeRim.unavailable = true;
|
||||
const course = Number.isFinite(info.course)
|
||||
? normalizeHeading(info.course)
|
||||
: null;
|
||||
view.course = {
|
||||
text: formatHeadingReadout(course),
|
||||
value: course,
|
||||
immediate: forceContext,
|
||||
};
|
||||
view.heading = {
|
||||
text: formatHeadingReadout(heading),
|
||||
value: heading,
|
||||
immediate: forceContext,
|
||||
};
|
||||
// Looking around turns the tape with the camera; the readout above it
|
||||
// keeps the ship's heading, and the bow and stern marks stay on the ship.
|
||||
const viewHeading = normalizeHeading(
|
||||
cameraHeading + (this.lookView?.yawDeg ?? 0),
|
||||
);
|
||||
// The tape scrolls continuously, so the caret reads the view's exact
|
||||
// heading and the marks sit at their true bearings from it.
|
||||
view.compass = scrollingCompassDivisions(viewHeading).map((division) => ({
|
||||
slot: division.slot,
|
||||
heading: division.heading,
|
||||
active: division.nearest,
|
||||
label: compassPointLabel(formatCompassDivision(division.heading)),
|
||||
}));
|
||||
view.compassMarkers = headingKnown
|
||||
? {
|
||||
prograde: compassMarkerSlot(heading, viewHeading),
|
||||
retrograde: compassMarkerSlot(heading + 180, viewHeading),
|
||||
}
|
||||
: { prograde: null, retrograde: null };
|
||||
view.clock = new Date().toISOString().slice(11, 19) + 'Z';
|
||||
view.position = `${formatCockpitCoordinate(info.latitude, 'N', 'S')} · ${formatCockpitCoordinate(info.longitude, 'E', 'W')}`;
|
||||
const eyeHeightM = vesselCameraProfile(info).upM;
|
||||
view.meta.text = t('{vesselType} · {feedState} · EYE {height}', {
|
||||
vesselType: info.typeLabel || t('VESSEL'),
|
||||
feedState: info.stale ? t('STALE FEED') : t('LIVE AIS'),
|
||||
height: `${formatNumber(Math.round(eyeHeightM))} ${cockpitUnitCase(unitLabel('m'))}`,
|
||||
});
|
||||
view.meta.emergency = false;
|
||||
view.layer = info.layerId;
|
||||
// Reworded here too, so a language switch reaches the look readout.
|
||||
this.presentLook();
|
||||
this.publishInstrumentsView();
|
||||
updateVesselRoute.call(this, info);
|
||||
if (
|
||||
forceContext ||
|
||||
cockpitUiUpdateDue(
|
||||
nowMs,
|
||||
this.lastContextUpdateMs,
|
||||
COCKPIT_CONTEXT_UPDATE_MS,
|
||||
)
|
||||
) {
|
||||
this.lastContextUpdateMs = nowMs;
|
||||
this.updateLocalPosition(info);
|
||||
this.maybeRefreshRegionalBrief(info);
|
||||
this.updateRadar(info);
|
||||
this.showContextCard(false);
|
||||
this.pushCockpitSignal(
|
||||
'context-status',
|
||||
'info',
|
||||
t('CONTACT NAVIGATION OFF'),
|
||||
t('THE BRIDGE STAYS WITH THE SELECTED VESSEL'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the bridge radar: nearby AIS vessels drawn heading-up from the
|
||||
* camera's current heading, within the chosen range.
|
||||
* @param {object} info The vessel subject (`readVesselInfo`).
|
||||
*/
|
||||
export function updateRadar(info) {
|
||||
const layer = this.services.aisLiveVesselsLayer;
|
||||
if (!info || typeof layer?.getRadarContacts !== 'function') {
|
||||
this.publishRadar(null);
|
||||
return;
|
||||
}
|
||||
const rangeNm = radarRangeNm(this.radarRangeNm);
|
||||
const contacts = layer.getRadarContacts(
|
||||
info.latitude,
|
||||
info.longitude,
|
||||
radarRangeM(rangeNm),
|
||||
RADAR_MAX_CONTACTS,
|
||||
);
|
||||
const picture = radarPicture(
|
||||
{
|
||||
latitude: info.latitude,
|
||||
longitude: info.longitude,
|
||||
headingDeg: normalizeHeading(this.heading ?? info.track ?? 0),
|
||||
courseDeg: info.course,
|
||||
},
|
||||
contacts,
|
||||
rangeNm,
|
||||
);
|
||||
this.publishRadar({
|
||||
...picture,
|
||||
rangeLabel: t('{range} NM', { range: formatNumber(rangeNm) }),
|
||||
});
|
||||
}
|
||||
|
||||
/** Show the AIS voyage destination; it is crew-entered text, not a place. */
|
||||
function updateVesselRoute(info) {
|
||||
const route = this.routeView;
|
||||
route.kind = 'vessel';
|
||||
route.from = '';
|
||||
route.to = info.destination || t('UNKNOWN');
|
||||
route.status = t('AIS DESTINATION · CREW REPORTED');
|
||||
route.visible = Boolean(info.destination);
|
||||
// No coordinates, so no arrow; clearing also publishes the card.
|
||||
this.clearPredictiveRoute();
|
||||
}
|
||||
|
||||
/** Publish the route card and destination arrow when either changed. */
|
||||
export function publishRouteView() {
|
||||
const signature = JSON.stringify(this.routeView);
|
||||
@@ -188,6 +399,7 @@ export function publishRouteView() {
|
||||
|
||||
export function updateRoute(info) {
|
||||
const route = this.routeView;
|
||||
route.kind = 'aircraft';
|
||||
const origin = info?.route?.origin;
|
||||
const destination = info?.route?.destination;
|
||||
const validDestination =
|
||||
|
||||
@@ -146,16 +146,18 @@ export function formatCockpitWindDirection(value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit entry for each subject it can ride: an aircraft's cockpit.
|
||||
* Both entry buttons (Contacts and the Intel HUD readout) show it.
|
||||
* The Cockpit entry for each subject it can ride: an aircraft's cockpit or a
|
||||
* vessel's bridge. Both entry buttons (Contacts and
|
||||
* the Intel HUD readout) show it.
|
||||
*/
|
||||
const COCKPIT_ENTRY_FACES = Object.freeze({
|
||||
aircraft: Object.freeze({ icon: 'flight', label: msg('COCKPIT') }),
|
||||
vessel: Object.freeze({ icon: 'directions_boat', label: msg('BRIDGE') }),
|
||||
});
|
||||
|
||||
/**
|
||||
* The entry's glyph and localized label for the subject it would ride.
|
||||
* @param {'aircraft'|null|undefined} kind
|
||||
* @param {'aircraft'|'vessel'|null|undefined} kind
|
||||
* @returns {{icon: string, label: string}}
|
||||
*/
|
||||
export function cockpitEntryFace(kind) {
|
||||
|
||||
@@ -6,6 +6,12 @@ import {
|
||||
resolveTrackedAircraftInfo,
|
||||
} from '../cockpitMath.js';
|
||||
|
||||
/** The camera's own heading in degrees, or 0 when it has none. */
|
||||
function cameraHeadingDeg(camera) {
|
||||
const heading = camera?.heading;
|
||||
return Number.isFinite(heading) ? (heading * 180) / Math.PI : 0;
|
||||
}
|
||||
|
||||
export function readAircraftInfo() {
|
||||
// In cockpit mode the controller takes the entity off `viewer.trackedEntity`
|
||||
// (see update()), so the cockpit's own handle is the tracked identity there.
|
||||
@@ -17,14 +23,20 @@ export function readAircraftInfo() {
|
||||
});
|
||||
}
|
||||
|
||||
/** The selected vessel the bridge view would ride, or rides; null without one. */
|
||||
export function readVesselInfo() {
|
||||
return this.services.aisLiveVesselsLayer?.getCockpitSubject?.() || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The layer the active view rides: the aircraft's own layer. It is read from
|
||||
* the tracked entity's id once the layer has dropped its tracking, so a layer
|
||||
* turned off still names itself.
|
||||
* @returns {'flights'|'military'|null}
|
||||
* The layer the active view rides: Live AIS Vessels on a bridge, else the
|
||||
* aircraft's own layer. It is read from the tracked entity's id once the
|
||||
* layer has dropped its tracking, so a layer turned off still names itself.
|
||||
* @returns {'flights'|'military'|'ais-live-vessels'|null}
|
||||
*/
|
||||
export function readSubjectLayerId() {
|
||||
if (!this.active) return null;
|
||||
if (this.subjectKind === 'vessel') return 'ais-live-vessels';
|
||||
const layerId = this.readAircraftInfo()?.layerId;
|
||||
if (layerId) return layerId;
|
||||
const [prefix] = String(this.trackedEntity?.gevTrackedId || '').split(':');
|
||||
@@ -32,23 +44,26 @@ export function readSubjectLayerId() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The subject entry would take: a Cesium-tracked aircraft.
|
||||
* @returns {'aircraft'|null}
|
||||
* The subject entry would take: a Cesium-tracked aircraft first, else the
|
||||
* selected vessel. Vessels never take Cesium tracking, so an aircraft and a
|
||||
* vessel cannot be live through the same owner.
|
||||
* @returns {'aircraft'|'vessel'|null}
|
||||
*/
|
||||
export function resolveEntryKind() {
|
||||
return this.readAircraftInfo() && this.viewer.trackedEntity?.position
|
||||
? 'aircraft'
|
||||
: null;
|
||||
if (this.readAircraftInfo() && this.viewer.trackedEntity?.position)
|
||||
return 'aircraft';
|
||||
return this.readVesselInfo() ? 'vessel' : null;
|
||||
}
|
||||
|
||||
export function dispatchCockpitModeChanged(active, info = null) {
|
||||
const subjectId = active
|
||||
? String(info?.icao24 || '')
|
||||
? String(info?.icao24 || info?.mmsi || '')
|
||||
.trim()
|
||||
.toLowerCase() || null
|
||||
: null;
|
||||
const layerId =
|
||||
active && ['flights', 'military'].includes(info?.layerId)
|
||||
active &&
|
||||
['flights', 'military', 'ais-live-vessels'].includes(info?.layerId)
|
||||
? info.layerId
|
||||
: null;
|
||||
window.dispatchEvent(
|
||||
@@ -103,17 +118,29 @@ export function syncEntry() {
|
||||
const info = this.readAircraftInfo();
|
||||
const trackedContact = !!(info && this.viewer.trackedEntity?.position);
|
||||
this.syncTr3bToggle(trackedContact ? info : null);
|
||||
const available = !!(this.isEntryAllowed() && trackedContact);
|
||||
const bridgeContact = !trackedContact && !!this.readVesselInfo();
|
||||
let entryKind = null;
|
||||
if (trackedContact) entryKind = this.isEntryAllowed() ? 'aircraft' : null;
|
||||
else if (bridgeContact)
|
||||
entryKind = this.isBridgeEntryAllowed() ? 'vessel' : null;
|
||||
const available = entryKind !== null;
|
||||
// Change-only publishes: this runs on a preUpdate cadence, and a fresh
|
||||
// presence every frame would re-render the views even when nothing
|
||||
// changed. (perf item 9)
|
||||
if (this.presence.entryAvailable === available) return;
|
||||
if (
|
||||
this.presence.entryAvailable === available &&
|
||||
this.presence.entryKind === entryKind
|
||||
)
|
||||
return;
|
||||
this.presence.entryAvailable = available;
|
||||
this.presence.entryKind = entryKind;
|
||||
this.publishPresenceView();
|
||||
}
|
||||
|
||||
export function navigateContext(direction, options = {}) {
|
||||
if (this.destroyed) return false;
|
||||
// Contact navigation moves between aircraft; a bridge does not jump ship.
|
||||
if (this.subjectKind === 'vessel') return false;
|
||||
const method = direction < 0 ? 'navigatePrevious' : 'navigateNext';
|
||||
const wasActive = this.active;
|
||||
if (wasActive) this.contextNavigationDeadlineMs = performance.now() + 1500;
|
||||
@@ -132,6 +159,9 @@ export function navigateContext(direction, options = {}) {
|
||||
}
|
||||
|
||||
export function _adoptTrackedEntity(nowMs, suppliedInfo = null) {
|
||||
// An aircraft tracked from the bridge ends it (see the vessel camera
|
||||
// update); it is never adopted as the bridge's subject.
|
||||
if (this.subjectKind === 'vessel') return false;
|
||||
const nextEntity = this.viewer.trackedEntity;
|
||||
if (
|
||||
!this.active ||
|
||||
@@ -160,13 +190,24 @@ export function _adoptTrackedEntity(nowMs, suppliedInfo = null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export function enter() {
|
||||
/**
|
||||
* Enter first person on a tracked aircraft or, with none tracked, the
|
||||
* selected vessel's bridge.
|
||||
* @param {{kind?: 'aircraft'|'vessel'|null}} [options] Restrict
|
||||
* entry to one subject kind; voice entry is aircraft-only.
|
||||
* @returns {boolean} True when the view was entered.
|
||||
*/
|
||||
export function enter({ kind = null } = {}) {
|
||||
if (this.destroyed) return false;
|
||||
if (this.active) return false;
|
||||
if (!this.isEntryAllowed()) return false;
|
||||
const info = this.readAircraftInfo();
|
||||
const entity = this.viewer.trackedEntity;
|
||||
if (!info || !entity?.position) return false;
|
||||
const subjectKind = kind ?? this.resolveEntryKind() ?? 'aircraft';
|
||||
const vessel = subjectKind === 'vessel';
|
||||
const allowed = vessel ? this.isBridgeEntryAllowed() : this.isEntryAllowed();
|
||||
if (!allowed) return false;
|
||||
const info = vessel ? this.readVesselInfo() : this.readAircraftInfo();
|
||||
// Only an aircraft is ridden through its Cesium entity.
|
||||
const entity = vessel ? null : this.viewer.trackedEntity;
|
||||
if (!info || (!vessel && !entity?.position)) return false;
|
||||
this.entryFocusOrigin =
|
||||
document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
@@ -174,10 +215,26 @@ export function enter() {
|
||||
// Retire deferred navigation before cancelFlight can run its callbacks.
|
||||
this.onCameraTakeover?.();
|
||||
this.viewer.camera.cancelFlight();
|
||||
this.subjectKind = subjectKind;
|
||||
// Each session reads its own water: never a height left from the last.
|
||||
this.vesselWaterline = null;
|
||||
this.subjectId = vessel ? info.mmsi : null;
|
||||
this.trackedEntity = entity;
|
||||
this.trackedEntityWasShown = entity.show;
|
||||
entity.show = false;
|
||||
this.heading = normalizeHeading(info.track ?? 0);
|
||||
if (entity) {
|
||||
this.trackedEntityWasShown = entity.show;
|
||||
entity.show = false;
|
||||
} else {
|
||||
this.services.aisLiveVesselsLayer?.setCockpitSubject?.(info.mmsi);
|
||||
}
|
||||
// A ship reporting neither heading nor course keeps the camera's own
|
||||
// heading: no direction is made up for it.
|
||||
this.heading = normalizeHeading(
|
||||
Number.isFinite(info.track)
|
||||
? info.track
|
||||
: vessel
|
||||
? cameraHeadingDeg(this.viewer.camera)
|
||||
: 0,
|
||||
);
|
||||
this.lastFrameMs = performance.now();
|
||||
this.lastCameraUpdateMs = 0;
|
||||
this.lastHudUpdateMs = 0;
|
||||
@@ -189,6 +246,8 @@ export function enter() {
|
||||
this.surfaceFallback = false;
|
||||
this.cockpitAnchorValid = false;
|
||||
this.lastCameraUpdateMs = 0;
|
||||
// Every bridge opens looking over the bow.
|
||||
this.resetLook({ immediate: true });
|
||||
this.active = true;
|
||||
// Cockpit animates the camera from preUpdate every frame — preUpdate only
|
||||
// runs on rendered frames, so idle mode would freeze the cockpit solid.
|
||||
@@ -197,31 +256,58 @@ export function enter() {
|
||||
this.viewer.trackedEntity = undefined;
|
||||
this.viewer.scene.screenSpaceCameraController.enableInputs = false;
|
||||
document.body.classList.add('cockpit-mode');
|
||||
// Bridge styling reaches surfaces outside the HUD (exit row, side panels).
|
||||
if (vessel) document.body.classList.add('cockpit-bridge');
|
||||
// Activation hides the entry and TR-3B chip; clearing the chip's signature
|
||||
// lets the exit-path syncEntry publish it again.
|
||||
this._tr3bSignature = null;
|
||||
Object.assign(this.presence, {
|
||||
active: true,
|
||||
entryAvailable: false,
|
||||
entryKind: null,
|
||||
subjectKind,
|
||||
tr3b: null,
|
||||
});
|
||||
this.publishPresenceView();
|
||||
// Only a bridge has a radar.
|
||||
if (!vessel) this.publishRadar(null);
|
||||
this.signalItems = [];
|
||||
this.signalSignatures.clear();
|
||||
this.showBriefPage(0);
|
||||
this.startBriefRotation();
|
||||
const trackLabel =
|
||||
info.callsign || info.registration || info.icao24 || t('AIRCRAFT');
|
||||
const trackHeading = formatHeadingReadout(info.track ?? 0);
|
||||
this.pushCockpitSignal(
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · COURSE {heading}°', {
|
||||
label: trackLabel,
|
||||
heading: trackHeading,
|
||||
}),
|
||||
);
|
||||
if (vessel) {
|
||||
this.pushCockpitSignal(
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
// A ship with no true heading is held on its course over ground; one
|
||||
// with neither is named without a direction.
|
||||
info.trackSource === 'course'
|
||||
? t('{label} · COURSE {heading}°', {
|
||||
label: info.name,
|
||||
heading: trackHeading,
|
||||
})
|
||||
: info.trackSource === 'heading'
|
||||
? t('{label} · HEADING {heading}°', {
|
||||
label: info.name,
|
||||
heading: trackHeading,
|
||||
})
|
||||
: t('{label} · NO HEADING', { label: info.name }),
|
||||
);
|
||||
} else {
|
||||
const trackLabel =
|
||||
info.callsign || info.registration || info.icao24 || t('AIRCRAFT');
|
||||
this.pushCockpitSignal(
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · COURSE {heading}°', {
|
||||
label: trackLabel,
|
||||
heading: trackHeading,
|
||||
}),
|
||||
);
|
||||
}
|
||||
this.updateHud(info, performance.now(), true);
|
||||
this.setVisionMode(this.getInitialVisionMode());
|
||||
this.scheduleContextLayout();
|
||||
@@ -239,10 +325,15 @@ export function enter() {
|
||||
export function exit({ restoreTracking = true } = {}) {
|
||||
if (!this.active) return false;
|
||||
const entity = this.trackedEntity;
|
||||
const vesselSubject = this.subjectKind === 'vessel' ? this.subjectId : null;
|
||||
this.active = false;
|
||||
this.subjectKind = null;
|
||||
this.vesselWaterline = null;
|
||||
this.subjectId = null;
|
||||
this.services.releaseContinuousRender('cockpit');
|
||||
this.trackedEntity = null;
|
||||
this.heading = null;
|
||||
this.resetLook({ immediate: true });
|
||||
this.cockpitAnchorValid = false;
|
||||
this.surfaceWaitStartedMs = 0;
|
||||
this.surfaceAcquiring = false;
|
||||
@@ -255,22 +346,29 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
this.regionalBriefAbort = null;
|
||||
this.regionalBriefRequestToken += 1;
|
||||
this.regionalBriefSubjectId = null;
|
||||
document.body.classList.remove('cockpit-mode');
|
||||
document.body.classList.remove('cockpit-mode', 'cockpit-bridge');
|
||||
this.onExited?.();
|
||||
this.publishUtilityLayout(null);
|
||||
this.presence.active = false;
|
||||
this.presence.subjectKind = null;
|
||||
this.publishPresenceView();
|
||||
this.routeView.visible = false;
|
||||
this.clearPredictiveRoute();
|
||||
this.publishRadar(null);
|
||||
this.setVisionMode('optical');
|
||||
this.viewer.scene.screenSpaceCameraController.enableInputs = true;
|
||||
if (entity && this.viewer.entities.contains(entity))
|
||||
entity.show = this.trackedEntityWasShown;
|
||||
this.trackedEntityWasShown = true;
|
||||
if (vesselSubject)
|
||||
this.services.aisLiveVesselsLayer?.setCockpitSubject?.(null);
|
||||
this.dispatchCockpitModeChanged(false);
|
||||
if (restoreTracking && entity && this.viewer.entities.contains(entity)) {
|
||||
this.viewer.trackedEntity = entity;
|
||||
this.restoreTrackingFrame(entity);
|
||||
} else if (restoreTracking && vesselSubject) {
|
||||
// Back to the selected vessel's map view, through the layer's own focus.
|
||||
this.services.aisLiveVesselsLayer?.focusSelectedVessel?.();
|
||||
}
|
||||
this.syncEntry();
|
||||
// Back to whichever entry was used: the Contacts button or the readout's.
|
||||
|
||||
@@ -34,7 +34,13 @@ export const useCockpitStore = defineStore('gev-cockpit', () => {
|
||||
context.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/** The presented instruments; null until the first HUD update. */
|
||||
/**
|
||||
* The presented instruments; null until the first HUD update. Besides the
|
||||
* readouts, `look: { offset, yawDeg, readout }` says whether a bridge view
|
||||
* is turned off the bow, the yaw it is turned to (degrees in -180..180,
|
||||
* starboard positive; the radar draws its look line there) and the worded
|
||||
* readout. An aircraft's look always rests (`offset: false`).
|
||||
*/
|
||||
const instruments = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation of the instruments. */
|
||||
@@ -66,6 +72,21 @@ export const useCockpitStore = defineStore('gev-cockpit', () => {
|
||||
signals.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/**
|
||||
* The bridge radar: null outside a vessel bridge. Shape:
|
||||
* `{ rangeNm, rangeLabel, ringsNm: number[], headingDeg,
|
||||
* ownRelativeCourseDeg|null,
|
||||
* contacts: [{ id, name, x, y, distanceNm, relativeBearingDeg,
|
||||
* relativeCourseDeg|null, color, stale }] }` where x/y are heading-up
|
||||
* screen fractions in [-1, 1] (x right, y up) of the range circle.
|
||||
*/
|
||||
const radar = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation of the bridge radar. */
|
||||
function publishRadar(next) {
|
||||
radar.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/**
|
||||
* The utility strip's measured layout: its top and height limits as CSS
|
||||
* lengths (null leaves the stylesheet's), whether only the expanded control
|
||||
@@ -101,6 +122,8 @@ export const useCockpitStore = defineStore('gev-cockpit', () => {
|
||||
publishVision,
|
||||
signals,
|
||||
publishSignals,
|
||||
radar,
|
||||
publishRadar,
|
||||
utilityLayout,
|
||||
publishUtilityLayout,
|
||||
};
|
||||
|
||||
@@ -283,6 +283,10 @@ body.cockpit-mode:has(#left-panel-stack > .panel-collapsible:not(.collapsed))
|
||||
color: var(--cockpit-accent);
|
||||
opacity: 0.9;
|
||||
}
|
||||
/* A bridge has no altitude tape; course over ground replaces the readout. */
|
||||
#cockpit-altitude-rim[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.cockpit-altitude-rim-label {
|
||||
position: absolute;
|
||||
top: 20%;
|
||||
@@ -2249,3 +2253,453 @@ body.cockpit-mode #intel-hud .hud-right-edge {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Ship bridge
|
||||
A vessel's bridge reads as a wheelhouse window rather than an aircraft
|
||||
visor: straight mullions, a straight speed tape and heading tape, square
|
||||
panels, and a radar console in the bottom-right corner. Every rule is
|
||||
scoped to the bridge, so the aircraft cockpit keeps its keyhole. */
|
||||
#cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-size: 240px;
|
||||
--cockpit-radar-label-height: 28px;
|
||||
--cockpit-radar-right: clamp(24px, 4vw, 58px);
|
||||
/* Above the position readout, which sits above the language picker. */
|
||||
--cockpit-radar-bottom: calc(max(clamp(22px, 4vh, 42px), 3.5rem) + 40px);
|
||||
/* From the viewport bottom to clear above the console (border + gap). */
|
||||
--cockpit-radar-clearance: calc(
|
||||
var(--cockpit-radar-bottom) + var(--cockpit-radar-size) +
|
||||
var(--cockpit-radar-label-height) + 14px
|
||||
);
|
||||
}
|
||||
:root[data-ui-theme='cyber'] #cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-right: 30px;
|
||||
}
|
||||
:root[data-ui-theme='cyber'] #cockpit-hud[data-subject='vessel']::before {
|
||||
clip-path: none;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber']) body.cockpit-bridge {
|
||||
--panel-radius: 2px;
|
||||
--btn-radius: 2px;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-bridge-frame {
|
||||
display: block;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
color: color-mix(in srgb, var(--cockpit-accent) 32%, transparent);
|
||||
stroke-width: 1;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-bridge-frame path {
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-reticle {
|
||||
width: 36px;
|
||||
height: 14px;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
color: transparent;
|
||||
background:
|
||||
linear-gradient(var(--cockpit-accent), var(--cockpit-accent)) 50% 0 / 1px
|
||||
100% no-repeat,
|
||||
linear-gradient(90deg, var(--cockpit-accent), var(--cockpit-accent)) 0 50% /
|
||||
100% 1px no-repeat;
|
||||
font-size: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-reticle::before,
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-reticle::after {
|
||||
display: none;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-horizon-guide {
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-horizon-guide span,
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-visor-status {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Speed over ground: a straight vertical tape beside the left pane post. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-speed-rim {
|
||||
top: 22vh;
|
||||
right: auto;
|
||||
left: calc(27vw + 14px);
|
||||
width: 150px;
|
||||
height: 46vh;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-label {
|
||||
top: 0;
|
||||
right: auto;
|
||||
left: 0;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
:is(.cockpit-altitude-rim-rail, .cockpit-altitude-rim-scale) {
|
||||
inset: 18px 0 0;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-rail {
|
||||
background: linear-gradient(90deg, rgba(0, 7, 12, 0.3), transparent 70%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-rail::before {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 0;
|
||||
height: auto;
|
||||
border: 0;
|
||||
border-left: 2px solid
|
||||
color-mix(in srgb, var(--cockpit-accent) 72%, transparent);
|
||||
border-radius: 0;
|
||||
box-shadow: -3px 0 12px
|
||||
color-mix(in srgb, var(--cockpit-accent) 18%, transparent);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-scale
|
||||
> span {
|
||||
left: 2px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-pointer {
|
||||
z-index: 1;
|
||||
top: calc(50% + 9px);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-speed-rim
|
||||
.cockpit-altitude-rim-pointer
|
||||
strong {
|
||||
min-width: 0;
|
||||
padding: 2px 5px;
|
||||
border: 1px solid var(--cockpit-accent);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.78);
|
||||
}
|
||||
|
||||
/* Heading: a straight horizontal tape under flat readouts. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] :is(.cockpit-speed, .cockpit-altitude) {
|
||||
transform: none;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-tape {
|
||||
height: 44px;
|
||||
margin-top: 0;
|
||||
overflow: hidden;
|
||||
/* The minor ticks below scroll by a fraction of the tape's width. */
|
||||
container-type: inline-size;
|
||||
transform-style: flat;
|
||||
-webkit-mask-image: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
#000 12% 88%,
|
||||
transparent
|
||||
);
|
||||
mask-image: linear-gradient(90deg, transparent, #000 12% 88%, transparent);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-tape::before {
|
||||
inset: 0 0 auto;
|
||||
height: 26px;
|
||||
border-top: 1px solid
|
||||
color-mix(in srgb, var(--cockpit-accent) 78%, transparent);
|
||||
border-bottom: 1px solid
|
||||
color-mix(in srgb, var(--cockpit-accent) 22%, transparent);
|
||||
border-radius: 0;
|
||||
/* Minor ticks every 10 degrees, centred on the 30-degree divisions. */
|
||||
background:
|
||||
linear-gradient(
|
||||
90deg,
|
||||
transparent calc(50% - 0.5px),
|
||||
color-mix(in srgb, var(--cockpit-accent) 46%, transparent)
|
||||
calc(50% - 0.5px) calc(50% + 0.5px),
|
||||
transparent calc(50% + 0.5px)
|
||||
)
|
||||
50% 0 / calc(14% / 3) 6px repeat-x,
|
||||
rgba(0, 7, 12, 0.34);
|
||||
/* Scrolled with the divisions (--tape-shift slots of 14% each). */
|
||||
background-position:
|
||||
calc(50% + var(--tape-shift, 0) * 14cqw) 0,
|
||||
0 0;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-tape span {
|
||||
top: 0;
|
||||
left: calc(50% + (var(--slot) * 14%));
|
||||
font-size: 11px;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-tape span::before {
|
||||
height: 10px;
|
||||
margin: 0 auto 5px;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-tape span.active {
|
||||
font-size: 15px;
|
||||
}
|
||||
/* The tape follows the look; the bow (prograde: a ring and centre dot) and
|
||||
stern (retrograde: a ring and cross) marks sit under it at the ship's
|
||||
heading and its reciprocal. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-marker {
|
||||
position: absolute;
|
||||
top: 30px;
|
||||
left: calc(50% + (var(--slot) * 14%));
|
||||
box-sizing: border-box;
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border: 1.5px solid var(--cockpit-accent);
|
||||
border-radius: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-marker::before,
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-retrograde::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
background: var(--cockpit-accent);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-prograde::before {
|
||||
width: 3px;
|
||||
height: 3px;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-retrograde::before,
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-retrograde::after {
|
||||
width: 1.5px;
|
||||
height: 9px;
|
||||
transform: translate(-50%, -50%) rotate(45deg);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass-retrograde::after {
|
||||
transform: translate(-50%, -50%) rotate(-45deg);
|
||||
}
|
||||
|
||||
/* Square panels and buttons. */
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
:is(
|
||||
.cockpit-vision-controls,
|
||||
.cockpit-vision-controls button,
|
||||
.cockpit-card-actions button,
|
||||
.cockpit-utility-glyph,
|
||||
.cockpit-radio-transport button,
|
||||
.cockpit-route-direction small,
|
||||
#cockpit-brief-auto
|
||||
) {
|
||||
border-radius: 2px;
|
||||
}
|
||||
body.cockpit-bridge #view-switcher button {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* The briefing card sits flat and shorter, above the radar console. Its top
|
||||
leaves the utility strip room below the REC readout. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-signal-window {
|
||||
bottom: var(--cockpit-radar-clearance);
|
||||
max-height: max(
|
||||
44px,
|
||||
min(30vh, 280px, calc(100vh - var(--cockpit-radar-clearance) - 290px))
|
||||
);
|
||||
border-radius: 2px;
|
||||
transform: none;
|
||||
}
|
||||
/* Cyber anchors the card's top from the layout pass; bound its height. */
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-signal-window {
|
||||
bottom: auto;
|
||||
max-height: max(
|
||||
44px,
|
||||
min(
|
||||
30vh,
|
||||
280px,
|
||||
calc(
|
||||
100vh - var(--cockpit-signal-top, clamp(255px, 28vh, 300px)) -
|
||||
var(--cockpit-radar-clearance)
|
||||
)
|
||||
)
|
||||
);
|
||||
clip-path: none;
|
||||
}
|
||||
|
||||
/* The radar console: CockpitRadar fills it, label row included. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-console {
|
||||
position: absolute;
|
||||
z-index: 4;
|
||||
right: var(--cockpit-radar-right);
|
||||
bottom: var(--cockpit-radar-bottom);
|
||||
display: grid;
|
||||
width: var(--cockpit-radar-size);
|
||||
height: calc(var(--cockpit-radar-size) + var(--cockpit-radar-label-height));
|
||||
overflow: hidden;
|
||||
border: 1px solid color-mix(in srgb, var(--cockpit-accent) 30%, transparent);
|
||||
border-top-color: color-mix(in srgb, var(--cockpit-accent) 64%, transparent);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.68);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.04),
|
||||
0 0 28px rgba(0, 0, 0, 0.26);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
pointer-events: auto;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-radar-console:has(> .cockpit-radar[hidden]) {
|
||||
display: none;
|
||||
}
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-radar-console {
|
||||
border-color: rgba(105, 203, 209, 0.34);
|
||||
border-top-color: rgba(196, 84, 84, 0.82);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(105, 203, 209, 0.07), transparent 38%),
|
||||
rgba(8, 23, 27, 0.78);
|
||||
}
|
||||
|
||||
@media (min-width: 761px) {
|
||||
/* The heading tape narrows to stay clear of the console. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-compass {
|
||||
width: min(
|
||||
760px,
|
||||
72vw,
|
||||
calc(
|
||||
100vw - 2 *
|
||||
(var(--cockpit-radar-right) + var(--cockpit-radar-size) + 24px)
|
||||
)
|
||||
);
|
||||
}
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-compass {
|
||||
width: min(
|
||||
650px,
|
||||
56vw,
|
||||
calc(
|
||||
100vw - 2 *
|
||||
(var(--cockpit-radar-right) + var(--cockpit-radar-size) + 24px)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@media (min-width: 761px) and (min-height: 601px) {
|
||||
/* The console takes the intel HUD's bottom-right corner. */
|
||||
body.cockpit-bridge #intel-hud .hud-bottom-right {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1280px), (max-height: 820px) {
|
||||
#cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-size: 192px;
|
||||
--cockpit-radar-label-height: 24px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 960px) {
|
||||
#cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-size: 152px;
|
||||
--cockpit-radar-label-height: 22px;
|
||||
}
|
||||
}
|
||||
/* Too small for a console: the briefing card returns to its usual place. */
|
||||
@media (max-width: 760px), (max-height: 600px) {
|
||||
#cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-clearance: var(--cockpit-bottom-rail-safe);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-console {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Look around: the readout and LOOK AHEAD control sit beside the radar
|
||||
console, out of the forward view, while the view is turned off the bow;
|
||||
the radar scope draws the matching look line. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look {
|
||||
position: absolute;
|
||||
right: calc(var(--cockpit-radar-right) + var(--cockpit-radar-size) + 14px);
|
||||
bottom: var(--cockpit-radar-bottom);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 6px;
|
||||
opacity: 0.78;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look:focus-within,
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
/* Without the console, the controls take its corner. */
|
||||
@media (max-width: 760px), (max-height: 600px) {
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look {
|
||||
right: var(--cockpit-radar-right);
|
||||
}
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look[hidden] {
|
||||
display: none;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look-readout {
|
||||
padding: 2px 6px;
|
||||
border: 1px solid color-mix(in srgb, var(--cockpit-accent) 46%, transparent);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.62);
|
||||
color: var(--cockpit-accent);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.12em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look-ahead {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 3px 8px;
|
||||
border: 1px solid color-mix(in srgb, var(--cockpit-accent) 64%, transparent);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.78);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.14em;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look-ahead:hover {
|
||||
border-color: var(--cockpit-accent);
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-look-ahead:focus-visible {
|
||||
outline: 2px solid var(--cockpit-accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
/* A narrow wedge from own ship with a line along its centre, eased with the
|
||||
camera's turn. Both point up (ahead) before rotation. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-look {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 50%;
|
||||
background: conic-gradient(
|
||||
from -6deg,
|
||||
color-mix(in srgb, var(--cockpit-accent) 18%, transparent) 0deg 12deg,
|
||||
transparent 12deg
|
||||
);
|
||||
pointer-events: none;
|
||||
transition: transform 180ms ease-out;
|
||||
}
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-look::before {
|
||||
position: absolute;
|
||||
bottom: 50%;
|
||||
left: 50%;
|
||||
width: 0;
|
||||
height: 50%;
|
||||
border-left: 1px dashed
|
||||
color-mix(in srgb, var(--cockpit-accent) 80%, transparent);
|
||||
content: '';
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-look {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
/* Bridge radar internals (src/ui/views/panels/CockpitRadar.vue). The
|
||||
Cockpit view places and sizes the console; the radar fills it, with a
|
||||
square scope as large as the smaller side allows. */
|
||||
.cockpit-radar {
|
||||
--radar-line: color-mix(
|
||||
in srgb,
|
||||
var(--cockpit-accent, #00dcff) 34%,
|
||||
transparent
|
||||
);
|
||||
--radar-faint: color-mix(
|
||||
in srgb,
|
||||
var(--cockpit-accent, #00dcff) 16%,
|
||||
transparent
|
||||
);
|
||||
--radar-readout-height: 22px;
|
||||
container-type: size;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 4px;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
color: rgba(244, 251, 255, 0.82);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.cockpit-radar[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.cockpit-radar-scope {
|
||||
position: relative;
|
||||
flex: none;
|
||||
width: min(100cqw, calc(100cqh - var(--radar-readout-height) - 4px));
|
||||
aspect-ratio: 1;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--radar-line);
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(
|
||||
circle,
|
||||
rgba(0, 24, 32, 0.72) 0%,
|
||||
rgba(0, 9, 14, 0.82) 100%
|
||||
);
|
||||
box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
.cockpit-radar-ring,
|
||||
.cockpit-radar-sweep,
|
||||
.cockpit-radar-own,
|
||||
.cockpit-radar-contact {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
}
|
||||
.cockpit-radar-ring {
|
||||
border: 1px solid var(--radar-faint);
|
||||
border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.cockpit-radar-tick {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
}
|
||||
.cockpit-radar-tick::before {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
width: 1px;
|
||||
height: 5px;
|
||||
background: var(--radar-line);
|
||||
content: '';
|
||||
}
|
||||
.cockpit-radar-tick-major::before {
|
||||
height: 8px;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--cockpit-accent, #00dcff) 62%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
.cockpit-radar-sweep {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: -50% 0 0 -50%;
|
||||
border-radius: 50%;
|
||||
/* The bright edge leads clockwise; the trail fades behind it. */
|
||||
background: conic-gradient(
|
||||
transparent 0deg 270deg,
|
||||
color-mix(in srgb, var(--cockpit-accent, #00dcff) 4%, transparent) 300deg,
|
||||
color-mix(in srgb, var(--cockpit-accent, #00dcff) 26%, transparent) 357deg,
|
||||
color-mix(in srgb, var(--cockpit-accent, #00dcff) 70%, transparent) 360deg
|
||||
);
|
||||
will-change: transform;
|
||||
}
|
||||
.cockpit-radar-heading-line {
|
||||
position: absolute;
|
||||
bottom: 50%;
|
||||
left: 50%;
|
||||
width: 1px;
|
||||
height: 50%;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--cockpit-accent, #00dcff) 72%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
.cockpit-radar-own {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
margin: -3.5px 0 0 -3.5px;
|
||||
border: 1px solid var(--cockpit-accent, #00dcff);
|
||||
border-radius: 1px;
|
||||
background: rgba(0, 9, 14, 0.9);
|
||||
}
|
||||
.cockpit-radar-contact {
|
||||
--radar-contact-color: #9fb3c8;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin: -2.5px 0 0 -2.5px;
|
||||
border-radius: 50%;
|
||||
background: var(--radar-contact-color);
|
||||
box-shadow: 0 0 4px var(--radar-contact-color);
|
||||
will-change: opacity;
|
||||
}
|
||||
.cockpit-radar-contact-stale {
|
||||
border: 1px solid var(--radar-contact-color);
|
||||
background: transparent;
|
||||
box-shadow: none;
|
||||
}
|
||||
/* A course vector starts at the mark's centre and points along the course. */
|
||||
.cockpit-radar-vector {
|
||||
position: absolute;
|
||||
bottom: 50%;
|
||||
left: 50%;
|
||||
width: 1px;
|
||||
height: 9px;
|
||||
margin-left: -0.5px;
|
||||
background: var(--radar-contact-color);
|
||||
transform-origin: 50% 100%;
|
||||
}
|
||||
.cockpit-radar-own-vector {
|
||||
height: 14px;
|
||||
background: #f4fbff;
|
||||
}
|
||||
.cockpit-radar-readout {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: var(--radar-readout-height);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cockpit-radar-range {
|
||||
flex: none;
|
||||
min-width: 44px;
|
||||
height: 20px;
|
||||
padding: 0 6px;
|
||||
border: 1px solid var(--radar-line);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.6);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.1em;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.cockpit-radar-range:hover,
|
||||
.cockpit-radar-range:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
.cockpit-radar-rings,
|
||||
.cockpit-radar-count {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.cockpit-radar-count {
|
||||
color: var(--cockpit-accent, #00dcff);
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cockpit-radar-sweep {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { useCockpitStore } from '../stores/cockpit.js';
|
||||
import { useGlobeActionsStore } from '../stores/globeActions.js';
|
||||
import CockpitBriefing from './panels/CockpitBriefing.vue';
|
||||
import CockpitContext from './panels/CockpitContext.vue';
|
||||
import CockpitRadar from './panels/CockpitRadar.vue';
|
||||
import CockpitRollingValue from './panels/CockpitRollingValue.vue';
|
||||
import CockpitUtilityControls from './panels/CockpitUtilityControls.vue';
|
||||
|
||||
@@ -23,13 +24,32 @@ import CockpitUtilityControls from './panels/CockpitUtilityControls.vue';
|
||||
const { presence, instruments, route, vision, utilityLayout } =
|
||||
storeToRefs(useCockpitStore());
|
||||
const active = computed(() => Boolean(presence.value?.active));
|
||||
// A vessel subject swaps the aviation readouts for bridge ones.
|
||||
const bridge = computed(() => presence.value?.subjectKind === 'vessel');
|
||||
const subject = computed(() => (bridge.value ? 'vessel' : 'aircraft'));
|
||||
const hudLabel = computed(() =>
|
||||
bridge.value ? t('Ship bridge view') : t('Aircraft cockpit view'),
|
||||
);
|
||||
const exitLabel = computed(() =>
|
||||
bridge.value ? t('Exit bridge view') : t('Exit cockpit view'),
|
||||
);
|
||||
const exitText = computed(() =>
|
||||
bridge.value ? t('EXIT BRIDGE') : t('EXIT COCKPIT'),
|
||||
);
|
||||
const globe = useGlobeActionsStore();
|
||||
const { resetBusy } = storeToRefs(globe);
|
||||
const initialInstruments = createInstrumentState();
|
||||
const initialRoute = createRouteState();
|
||||
const initialVision = createVisionState();
|
||||
const hud = computed(() => instruments.value ?? initialInstruments);
|
||||
// The bridge tape scrolls continuously: its minor ticks shift with the
|
||||
// division nearest the caret.
|
||||
const tapeShift = computed(
|
||||
() => hud.value.compass?.find((division) => division.active)?.slot ?? 0,
|
||||
);
|
||||
const direction = computed(() => (route.value ?? initialRoute).direction);
|
||||
// Where a bridge view is turned; an aircraft's always rests.
|
||||
const look = computed(() => hud.value.look ?? initialInstruments.look);
|
||||
const v = computed(() => vision.value ?? initialVision);
|
||||
const visionLabel = computed(() =>
|
||||
t('Current cockpit vision style: {style}. Activate for next style.', {
|
||||
@@ -54,11 +74,20 @@ const tickStyle = (tick) =>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Aircraft first-person view. It can be entered from the visible view switcher. -->
|
||||
<section id="cockpit-hud" :aria-label="t('Aircraft cockpit view')" :hidden="!active" :style="utilityStyle" v-class-toggle="{ 'signals-active': active, 'context-active': Boolean(presence?.context) }" :data-layer="hud.layer ?? undefined">
|
||||
<!-- Aircraft first-person view or a vessel's bridge. It can be entered from the visible view switcher. -->
|
||||
<section id="cockpit-hud" :aria-label="hudLabel" :hidden="!active" :data-subject="subject" :style="utilityStyle" v-class-toggle="{ 'signals-active': active, 'context-active': Boolean(presence?.context) }" :data-layer="hud.layer ?? undefined">
|
||||
<!-- One optical coordinate system: every targeting mark shares this center.
|
||||
Decorative only; telemetry and interactive panels remain separate. -->
|
||||
<svg class="cockpit-frame-lines" viewBox="0 0 1200 720" preserveAspectRatio="none" aria-hidden="true" focusable="false">
|
||||
Decorative only; telemetry and interactive panels remain separate.
|
||||
A bridge looks out through straight window mullions instead: a header
|
||||
beam, two pane posts and the sill either side of the console. -->
|
||||
<svg v-if="bridge" class="cockpit-frame-lines cockpit-bridge-frame" viewBox="0 0 1200 720" preserveAspectRatio="none" aria-hidden="true" focusable="false">
|
||||
<g fill="none" stroke="currentColor">
|
||||
<path d="M0 96H1200 M0 101H1200"/>
|
||||
<path d="M324 101V600 M876 101V600"/>
|
||||
<path d="M0 600H324 M876 600H1200"/>
|
||||
</g>
|
||||
</svg>
|
||||
<svg v-else class="cockpit-frame-lines" viewBox="0 0 1200 720" preserveAspectRatio="none" aria-hidden="true" focusable="false">
|
||||
<g fill="none" stroke="currentColor">
|
||||
<path d="M42 106H234L266 126H334 M866 126H934L966 106H1158 M42 114H226L258 136H318 M882 136H942L974 114H1158"/>
|
||||
<path d="M42 616H226L254 598H320 M880 598H946L974 616H1158 M42 624H238L266 606H330 M870 606H934L962 624H1158"/>
|
||||
@@ -68,7 +97,7 @@ const tickStyle = (tick) =>
|
||||
<path class="cockpit-frame-warning" d="M338 645H476L490 654H710L724 645H862" fill="none"/>
|
||||
<path class="cockpit-frame-meter" d="M372 642H418 M782 642H828"/>
|
||||
</svg>
|
||||
<div class="cockpit-scan-array" aria-hidden="true">
|
||||
<div v-if="!bridge" class="cockpit-scan-array" aria-hidden="true">
|
||||
<svg class="cockpit-target-geometry" viewBox="0 0 600 600" fill="none" focusable="false">
|
||||
<g class="cockpit-target-hairline">
|
||||
<circle cx="300" cy="300" r="276"/>
|
||||
@@ -101,7 +130,8 @@ const tickStyle = (tick) =>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="cockpit-visor-shell" aria-hidden="true">
|
||||
<div class="cockpit-roll-arc">
|
||||
<!-- A ship's bridge keeps no roll arc or pitch ladder. -->
|
||||
<div v-if="!bridge" class="cockpit-roll-arc">
|
||||
<span style="--slot:-3;--depth:3">−30</span>
|
||||
<span style="--slot:-2;--depth:2">−20</span>
|
||||
<span style="--slot:-1;--depth:1">−10</span>
|
||||
@@ -110,10 +140,10 @@ const tickStyle = (tick) =>
|
||||
<span style="--slot:2;--depth:2">+20</span>
|
||||
<span style="--slot:3;--depth:3">+30</span>
|
||||
</div>
|
||||
<div class="cockpit-pitch-rail cockpit-pitch-rail-left">
|
||||
<div v-if="!bridge" class="cockpit-pitch-rail cockpit-pitch-rail-left">
|
||||
<span>+20</span><span>+10</span><span class="active">00</span><span>−10</span><span>−20</span>
|
||||
</div>
|
||||
<div class="cockpit-pitch-rail cockpit-pitch-rail-right">
|
||||
<div v-if="!bridge" class="cockpit-pitch-rail cockpit-pitch-rail-right">
|
||||
<span>+20</span><span>+10</span><span class="active">00</span><span>−10</span><span>−20</span>
|
||||
</div>
|
||||
<div class="cockpit-horizon-guide">
|
||||
@@ -125,11 +155,11 @@ const tickStyle = (tick) =>
|
||||
</svg>
|
||||
<small id="cockpit-route-direction-label">{{ direction.label }}</small>
|
||||
</div>
|
||||
<div class="cockpit-visor-status cockpit-visor-status-left">{{ t('OPTICAL PLANE · 01') }}</div>
|
||||
<div class="cockpit-visor-status cockpit-visor-status-right">{{ t('VISOR LOCK · ACTIVE') }}</div>
|
||||
<div class="cockpit-visor-status cockpit-visor-status-left">{{ bridge ? t('BRIDGE WINDOW · FWD') : t('OPTICAL PLANE · 01') }}</div>
|
||||
<div class="cockpit-visor-status cockpit-visor-status-right">{{ bridge ? (hud.trackSource === 'course' ? t('COURSE HOLD · AIS') : hud.trackSource === 'heading' ? t('HEADING HOLD · AIS') : t('NO HEADING · AIS')) : t('VISOR LOCK · ACTIVE') }}</div>
|
||||
</div>
|
||||
<div id="cockpit-speed-rim" class="cockpit-altitude-rim cockpit-speed-rim" v-class-toggle="{ unavailable: hud.speedRim.unavailable }">
|
||||
<span class="cockpit-altitude-rim-label">{{ t('GROUND SPEED · KTS') }}</span>
|
||||
<span class="cockpit-altitude-rim-label">{{ bridge ? t('SPEED OVER GROUND · KTS') : t('GROUND SPEED · KTS') }}</span>
|
||||
<div class="cockpit-altitude-rim-rail"></div>
|
||||
<div class="cockpit-altitude-rim-scale">
|
||||
<span v-for="(tick, index) in hud.speedRim.ticks" :key="index" data-speed-rim-tick :hidden="tick.hidden" :class="{ major: tick.major }" :style="tickStyle(tick)"><b>{{ tick.label }}</b><i></i></span>
|
||||
@@ -139,7 +169,7 @@ const tickStyle = (tick) =>
|
||||
<strong id="cockpit-speed-rim-value">{{ hud.speedRim.value }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cockpit-altitude-rim" class="cockpit-altitude-rim" v-class-toggle="{ unavailable: hud.altitudeRim.unavailable }">
|
||||
<div id="cockpit-altitude-rim" class="cockpit-altitude-rim" :hidden="bridge" v-class-toggle="{ unavailable: hud.altitudeRim.unavailable }">
|
||||
<span class="cockpit-altitude-rim-label">{{ t('ALTITUDE · FT') }}</span>
|
||||
<div class="cockpit-altitude-rim-rail"></div>
|
||||
<div class="cockpit-altitude-rim-scale">
|
||||
@@ -152,7 +182,7 @@ const tickStyle = (tick) =>
|
||||
</div>
|
||||
<div class="cockpit-topline">
|
||||
<div>
|
||||
<span class="cockpit-kicker">{{ t('FIRST PERSON') }}</span>
|
||||
<span class="cockpit-kicker">{{ bridge ? t('BRIDGE VIEW') : t('FIRST PERSON') }}</span>
|
||||
<strong id="cockpit-callsign">{{ hud.callsign }}</strong>
|
||||
<span id="cockpit-aircraft-meta" v-class-toggle="{ emergency: hud.meta.emergency }" class="cockpit-aircraft-meta">{{ hud.meta.text }}</span>
|
||||
</div>
|
||||
@@ -172,22 +202,34 @@ const tickStyle = (tick) =>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cockpit-reticle material-symbols-outlined" aria-hidden="true">my_location</div>
|
||||
<div class="cockpit-compass" :aria-label="t('Current aircraft heading')">
|
||||
<!-- A bridge view turned off the bow says where it looks and offers the way back. -->
|
||||
<div v-if="bridge" class="cockpit-look" :hidden="!look.offset">
|
||||
<span id="cockpit-look-readout" class="cockpit-look-readout" aria-live="polite">{{ look.readout }}</span>
|
||||
<button id="cockpit-look-ahead" type="button" class="cockpit-look-ahead" :aria-label="t('Look ahead: turn the bridge view back to the bow')" :title="t('Look ahead (Home or 0)')" aria-keyshortcuts="Home 0">
|
||||
<span>{{ t('LOOK AHEAD') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="cockpit-compass" :aria-label="bridge ? t('Current vessel heading') : t('Current aircraft heading')">
|
||||
<div class="cockpit-instrument-row">
|
||||
<div class="cockpit-readout cockpit-speed">
|
||||
<span class="cockpit-readout-label">{{ t('GROUND SPEED') }}</span>
|
||||
<span class="cockpit-readout-label">{{ bridge ? t('SPEED OVER GROUND') : t('GROUND SPEED') }}</span>
|
||||
<CockpitRollingValue id="cockpit-speed-value" tag="strong" :reading="hud.speed" placeholder="---" />
|
||||
<span class="cockpit-readout-unit">{{ t('KTS') }}</span>
|
||||
</div>
|
||||
<div class="cockpit-heading-value"><CockpitRollingValue id="cockpit-heading-value" :reading="hud.heading" placeholder="---" :circular-range="360" /><small>°</small></div>
|
||||
<div class="cockpit-readout cockpit-altitude">
|
||||
<div v-if="bridge" class="cockpit-readout cockpit-altitude cockpit-course">
|
||||
<span class="cockpit-readout-label">{{ t('COURSE OVER GROUND') }}</span>
|
||||
<CockpitRollingValue id="cockpit-course-value" tag="strong" :reading="hud.course" placeholder="---" :circular-range="360" />
|
||||
<span class="cockpit-readout-unit">°</span>
|
||||
</div>
|
||||
<div v-else class="cockpit-readout cockpit-altitude">
|
||||
<span class="cockpit-readout-label">{{ t('ALTITUDE') }}</span>
|
||||
<CockpitRollingValue id="cockpit-altitude-value" tag="strong" :reading="hud.altitude" placeholder="-----" />
|
||||
<span class="cockpit-readout-unit">{{ t('FT') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="cockpit-heading-caret material-symbols-outlined" aria-hidden="true">arrow_drop_down</span>
|
||||
<div class="cockpit-compass-tape" id="cockpit-compass-tape" aria-hidden="true"><span v-for="division in hud.compass" :key="division.slot" :class="division.slot === 0 ? 'active' : ''" :style="{ '--slot': division.slot, '--depth': Math.abs(division.slot) }">{{ division.label }}</span></div>
|
||||
<div class="cockpit-compass-tape" id="cockpit-compass-tape" aria-hidden="true" :style="bridge ? { '--tape-shift': tapeShift } : undefined"><span v-for="division in hud.compass" :key="division.heading ?? division.slot" :class="(division.active ?? division.slot === 0) ? 'active' : ''" :style="{ '--slot': division.slot, '--depth': Math.abs(division.slot) }">{{ division.label }}</span><template v-if="bridge"><i v-if="hud.compassMarkers?.prograde != null" class="cockpit-compass-marker cockpit-compass-prograde" aria-hidden="true" :style="{ '--slot': hud.compassMarkers.prograde }"></i><i v-if="hud.compassMarkers?.retrograde != null" class="cockpit-compass-marker cockpit-compass-retrograde" aria-hidden="true" :style="{ '--slot': hud.compassMarkers.retrograde }"></i></template></div>
|
||||
</div>
|
||||
<div class="cockpit-position-readout">
|
||||
<span id="cockpit-clock">{{ hud.clock }}</span>
|
||||
@@ -195,8 +237,12 @@ const tickStyle = (tick) =>
|
||||
</div>
|
||||
<CockpitContext />
|
||||
<CockpitBriefing />
|
||||
<!-- The bridge radar's console: bottom right, below the briefing card. -->
|
||||
<div v-if="bridge" class="cockpit-radar-console">
|
||||
<CockpitRadar />
|
||||
</div>
|
||||
<CockpitUtilityControls />
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi> <span>·</span> <bdi>{{ t('C TOGGLE') }}</bdi></div>
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi> <span>·</span> <bdi>{{ t('C TOGGLE') }}</bdi><template v-if="bridge"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template></div>
|
||||
</section>
|
||||
|
||||
<nav id="view-switcher" :aria-label="t('View switcher')">
|
||||
@@ -204,9 +250,9 @@ const tickStyle = (tick) =>
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
<span>{{ t('RESET') }}</span>
|
||||
</button>
|
||||
<button id="map-view-switch" type="button" :aria-label="t('Exit cockpit view')" aria-keyshortcuts="Escape C" :title="t('Exit cockpit view')" :hidden="!active">
|
||||
<button id="map-view-switch" type="button" :aria-label="exitLabel" aria-keyshortcuts="Escape C" :title="exitLabel" :hidden="!active">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">close_fullscreen</span>
|
||||
<span>{{ t('EXIT COCKPIT') }}</span>
|
||||
<span>{{ exitText }}</span>
|
||||
</button>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -20,8 +20,8 @@ import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
// publishes them; until it does, the panel shows its initial markup.
|
||||
const { view: ctx } = storeToRefs(useContextStore());
|
||||
const { presence: cockpit } = storeToRefs(useCockpitStore());
|
||||
// The entry rides the tracked aircraft (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace('aircraft'));
|
||||
// The entry names the subject it would ride (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace(cockpit.value?.entryKind));
|
||||
// While the Bhote Koshi event is on, its panel is the rail's only content.
|
||||
const { panel: bhotePanel } = storeToRefs(useBhoteKoshiPanelStore());
|
||||
// The Scene runtime chip SceneControls presents while a scene plays.
|
||||
|
||||
@@ -16,8 +16,8 @@ const view = computed(() => hud.value ?? EMPTY);
|
||||
// button, so first person needs no Contacts panel. The Cockpit controller
|
||||
// answers its clicks.
|
||||
const { presence: cockpit } = storeToRefs(useCockpitStore());
|
||||
// The entry rides the tracked aircraft (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace('aircraft'));
|
||||
// The entry names the subject it would ride (cockpitEntryFace).
|
||||
const entry = computed(() => cockpitEntryFace(cockpit.value?.entryKind));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { formatNumber, t, tn } from '../../../i18n/index.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
|
||||
// The bridge radar: a heading-up scope of nearby AIS vessels, with a line
|
||||
// where the bridge view looks when it is turned off the bow. The Cockpit
|
||||
// controller presents them as positions on the range circle and keeps the
|
||||
// range button's listener; this view draws them. The sweep and each
|
||||
// contact's afterglow are compositor animations sharing one clock, so a
|
||||
// contact brightens as the sweep crosses its bearing without a frame loop.
|
||||
|
||||
/** One sweep turn, in milliseconds. */
|
||||
const SWEEP_MS = 4000;
|
||||
/** Relative bearings of the rim ticks. */
|
||||
const RIM_TICKS = Array.from({ length: 12 }, (_, index) => index * 30);
|
||||
const SWEEP_FRAMES = [
|
||||
{ transform: 'rotate(0turn)' },
|
||||
{ transform: 'rotate(1turn)' },
|
||||
];
|
||||
const GLOW_FRAMES = [
|
||||
{ opacity: 1, offset: 0 },
|
||||
{ opacity: 0.6, offset: 0.2 },
|
||||
{ opacity: 0.25, offset: 1 },
|
||||
];
|
||||
|
||||
const { radar, instruments } = storeToRefs(useCockpitStore());
|
||||
|
||||
// The bridge view's look line: the yaw the view is turned to off the bow,
|
||||
// kept unwrapped so its turn eases the short way across astern. Unwrapping
|
||||
// needs the last angle shown, so it is state a watch keeps, not a computed.
|
||||
const lookDeg = ref(null);
|
||||
watch(
|
||||
() => {
|
||||
const look = instruments.value?.look;
|
||||
return look?.offset && look.yawDeg !== 0 ? look.yawDeg : null;
|
||||
},
|
||||
(yawDeg) => {
|
||||
if (yawDeg === null) {
|
||||
lookDeg.value = null;
|
||||
return;
|
||||
}
|
||||
const from = lookDeg.value ?? 0;
|
||||
lookDeg.value = from + ((((yawDeg - from) % 360) + 540) % 360) - 180;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const motionQuery =
|
||||
typeof window.matchMedia === 'function'
|
||||
? window.matchMedia('(prefers-reduced-motion: reduce)')
|
||||
: null;
|
||||
const reducedMotion = ref(Boolean(motionQuery?.matches));
|
||||
const onMotionChange = (event) => {
|
||||
reducedMotion.value = event.matches;
|
||||
};
|
||||
motionQuery?.addEventListener?.('change', onMotionChange);
|
||||
onBeforeUnmount(() =>
|
||||
motionQuery?.removeEventListener?.('change', onMotionChange),
|
||||
);
|
||||
|
||||
/**
|
||||
* Run an element's sweep-phased animation, or stop it (`phaseMs` null).
|
||||
* Each animation starts on the document timeline at its phase, so every
|
||||
* one keeps time with the sweep however late it was created.
|
||||
*/
|
||||
function phase(el, frames, phaseMs) {
|
||||
if (phaseMs === null || typeof el.animate !== 'function') {
|
||||
el._radarAnimation?.cancel();
|
||||
el._radarAnimation = null;
|
||||
return;
|
||||
}
|
||||
if (!el._radarAnimation) {
|
||||
el._radarAnimation = el.animate(frames, {
|
||||
duration: SWEEP_MS,
|
||||
iterations: Infinity,
|
||||
easing: 'linear',
|
||||
});
|
||||
// Cancelling on unmount rejects `finished`; nothing waits on it.
|
||||
el._radarAnimation.finished?.catch(() => {});
|
||||
}
|
||||
// Before zero, so the animation is already running at page start.
|
||||
const startTime = phaseMs - SWEEP_MS;
|
||||
if (el._radarAnimation.startTime !== startTime)
|
||||
el._radarAnimation.startTime = startTime;
|
||||
}
|
||||
|
||||
const vSweep = {
|
||||
mounted: (el) => phase(el, SWEEP_FRAMES, 0),
|
||||
unmounted: (el) => phase(el, SWEEP_FRAMES, null),
|
||||
};
|
||||
|
||||
const vAfterglow = {
|
||||
mounted: (el, { value }) => phase(el, GLOW_FRAMES, value),
|
||||
updated: (el, { value }) => phase(el, GLOW_FRAMES, value),
|
||||
unmounted: (el) => phase(el, GLOW_FRAMES, null),
|
||||
};
|
||||
|
||||
/** When in the sweep's turn a bearing is crossed, or null when steady. */
|
||||
function glowPhase(relativeBearingDeg) {
|
||||
if (reducedMotion.value) return null;
|
||||
const clockwise = (((relativeBearingDeg % 360) + 360) % 360) / 360;
|
||||
return Math.round(clockwise * SWEEP_MS);
|
||||
}
|
||||
|
||||
const percent = (fraction) => `${(fraction * 100).toFixed(2)}%`;
|
||||
const contactStyle = (contact) => ({
|
||||
left: percent(0.5 + contact.x / 2),
|
||||
top: percent(0.5 - contact.y / 2),
|
||||
'--radar-contact-color': contact.color || undefined,
|
||||
});
|
||||
const rotate = (deg) => ({ transform: `rotate(${deg}deg)` });
|
||||
|
||||
const rangeLabel = computed(() => radar.value?.rangeLabel ?? '');
|
||||
const ringFractions = computed(() =>
|
||||
radar.value
|
||||
? radar.value.ringsNm.map((ring) => ring / radar.value.rangeNm)
|
||||
: [],
|
||||
);
|
||||
const ringLabel = computed(() =>
|
||||
radar.value?.ringsNm.length
|
||||
? t('RINGS {spacing} NM', {
|
||||
spacing: formatNumber(radar.value.ringsNm[0]),
|
||||
})
|
||||
: '',
|
||||
);
|
||||
const countLabel = computed(() => {
|
||||
const count = radar.value?.contacts.length ?? 0;
|
||||
return tn(count, '{count} CONTACT', '{count} CONTACTS', {
|
||||
count: formatNumber(count),
|
||||
});
|
||||
});
|
||||
const rangeAction = computed(() =>
|
||||
t('Radar range {range}. Select for the next range.', {
|
||||
range: rangeLabel.value,
|
||||
}),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="cockpit-radar" class="cockpit-radar" :aria-label="t('Bridge radar')" :hidden="!radar">
|
||||
<div class="cockpit-radar-scope" aria-hidden="true">
|
||||
<template v-if="radar">
|
||||
<span v-for="fraction in ringFractions" :key="fraction" class="cockpit-radar-ring" :style="{ width: percent(fraction), height: percent(fraction) }"></span>
|
||||
<span v-for="tick in RIM_TICKS" :key="tick" class="cockpit-radar-tick" :class="{ 'cockpit-radar-tick-major': tick % 90 === 0 }" :style="rotate(tick)"></span>
|
||||
<span v-if="!reducedMotion" v-sweep class="cockpit-radar-sweep"></span>
|
||||
<span class="cockpit-radar-heading-line"></span>
|
||||
<span v-if="lookDeg !== null" class="cockpit-radar-look" :style="rotate(lookDeg)"></span>
|
||||
<span v-for="contact in radar.contacts" :key="contact.id" v-afterglow="glowPhase(contact.relativeBearingDeg)" class="cockpit-radar-contact" :class="{ 'cockpit-radar-contact-stale': contact.stale }" :style="contactStyle(contact)">
|
||||
<span v-if="contact.relativeCourseDeg !== null" class="cockpit-radar-vector" :style="rotate(contact.relativeCourseDeg)"></span>
|
||||
</span>
|
||||
<span class="cockpit-radar-own">
|
||||
<span v-if="radar.ownRelativeCourseDeg !== null && radar.ownRelativeCourseDeg !== undefined" class="cockpit-radar-vector cockpit-radar-own-vector" :style="rotate(radar.ownRelativeCourseDeg)"></span>
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
<div class="cockpit-radar-readout">
|
||||
<button id="cockpit-radar-range" type="button" class="cockpit-radar-range" :aria-label="rangeAction" :title="rangeAction">{{ rangeLabel }}</button>
|
||||
<span class="cockpit-radar-rings">{{ ringLabel }}</span>
|
||||
<span class="cockpit-radar-count">{{ countLabel }}</span>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -14,17 +14,17 @@ const r = computed(() => route.value ?? initial);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section id="cockpit-route" class="cockpit-route-card" :aria-label="t('Estimated flight plan')" :hidden="!r.visible">
|
||||
<section id="cockpit-route" class="cockpit-route-card" :aria-label="r.kind === 'vessel' ? t('Reported voyage') : t('Estimated flight plan')" :hidden="!r.visible">
|
||||
<div class="cockpit-route-heading">
|
||||
<span class="cockpit-route-kicker">{{ t('ESTIMATED FLIGHT PLAN') }}</span>
|
||||
<span class="cockpit-route-kicker">{{ r.kind === 'vessel' ? t('REPORTED VOYAGE') : t('ESTIMATED FLIGHT PLAN') }}</span>
|
||||
<small id="cockpit-route-status">{{ r.status }}</small>
|
||||
</div>
|
||||
<div class="cockpit-route-endpoints">
|
||||
<div class="cockpit-route-airport">
|
||||
<div v-if="r.kind !== 'vessel'" class="cockpit-route-airport">
|
||||
<span>{{ t('FROM') }}</span>
|
||||
<strong id="cockpit-route-from">{{ r.from }}</strong>
|
||||
</div>
|
||||
<span class="cockpit-route-arrow material-symbols-outlined" aria-hidden="true">east</span>
|
||||
<span v-if="r.kind !== 'vessel'" class="cockpit-route-arrow material-symbols-outlined" aria-hidden="true">east</span>
|
||||
<div class="cockpit-route-airport">
|
||||
<span>{{ t('TO') }}</span>
|
||||
<strong id="cockpit-route-to">{{ r.to }}</strong>
|
||||
|
||||
Reference in new issue
Block a user