mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Merge upstream main into pr/street-level-show-action
Locale conflicts: main's catalogs plus the PR's 10 street-level strings.
This commit is contained in:
commit
b7531e655d
84 files changed
+7506
-244
No files matched your search
@@ -365,6 +365,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,
|
||||
@@ -404,6 +405,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
@@ -85,12 +85,9 @@ export function relocalizeBrief() {
|
||||
Object.assign(this.brief, cycleWords(this.briefAutoRotateEnabled));
|
||||
this.showBriefPage(this.briefPageIndex);
|
||||
if (this.regionalBrief)
|
||||
this.renderRegionalBrief(this.regionalBrief, this.lastAircraftInfo);
|
||||
this.renderRegionalBrief(this.regionalBrief, this.lastSubjectInfo);
|
||||
else if (this.brief.news.state)
|
||||
this.renderRegionalBriefStatus(
|
||||
this.brief.news.state,
|
||||
this.lastAircraftInfo,
|
||||
);
|
||||
this.renderRegionalBriefStatus(this.brief.news.state, this.lastSubjectInfo);
|
||||
}
|
||||
|
||||
export function setBriefAutoRotate(enabled) {
|
||||
@@ -156,7 +153,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;
|
||||
|
||||
+240
-11
@@ -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,216 @@ 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. Once a full-detail read has answered, only full-detail reads
|
||||
* change the height; before then a loaded-tile read may find raised water
|
||||
* but never takes a raised height back to the sea. One coarse probe cannot
|
||||
* drop a river bridge to the sea, and a read that sampled nothing keeps
|
||||
* the height it had.
|
||||
* @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,
|
||||
// Whether a full-detail read has answered for this ship.
|
||||
landed: false,
|
||||
inFlight: false,
|
||||
};
|
||||
this.vesselWaterline = read;
|
||||
} else {
|
||||
read.sampledMs = nowMs;
|
||||
if (read.inFlight && !read.landed) {
|
||||
const loadedM = loadedWaterlineM(scene, probes, seaM);
|
||||
// Taking a river back to the sea is the full-detail read's to say.
|
||||
const lowers =
|
||||
Number.isFinite(read.heightM) &&
|
||||
read.heightM > seaM &&
|
||||
!(loadedM > seaM);
|
||||
if (Number.isFinite(loadedM) && !lowers) 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) {
|
||||
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; one that sampled nothing (tiles
|
||||
// not loaded yet) is no answer and keeps the height already read.
|
||||
const heights = (samples || []).map((sample) => sample?.height);
|
||||
if (!heights.some(Number.isFinite)) return;
|
||||
read.landed = true;
|
||||
read.heightM = vesselWaterlineM(seaM, heights);
|
||||
},
|
||||
() => {
|
||||
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(),
|
||||
);
|
||||
// The radar centres here too, so it agrees with the view out the window.
|
||||
this.vesselFix = fix;
|
||||
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 +322,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 +346,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,
|
||||
@@ -187,9 +407,18 @@ function placeCamera(target, info, nowMs, dtSec, profile) {
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
this.scratchTargetCartographic,
|
||||
);
|
||||
// A bridge's target is its fix dead-reckoned up to minutes ahead: read
|
||||
// the floor where the ship is now, as its water is.
|
||||
const floorAt =
|
||||
info.kind === 'vessel'
|
||||
? {
|
||||
latitude: Cesium.Math.toDegrees(targetCartographic.latitude),
|
||||
longitude: Cesium.Math.toDegrees(targetCartographic.longitude),
|
||||
}
|
||||
: info;
|
||||
let cockpitFloorM = this.services.cachedGroundFloor(
|
||||
info.latitude,
|
||||
info.longitude,
|
||||
floorAt.latitude,
|
||||
floorAt.longitude,
|
||||
);
|
||||
if (info.onGround === true) {
|
||||
const groundPoint = [{ lat: info.latitude, lon: info.longitude }];
|
||||
@@ -296,8 +525,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 +535,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,
|
||||
|
||||
+120
-8
@@ -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.
|
||||
@@ -179,7 +217,8 @@ export class CockpitViewController {
|
||||
this.contextView = createContextState();
|
||||
this.brief = createBriefState();
|
||||
this.briefTimer = null;
|
||||
this.lastAircraftInfo = null;
|
||||
// The last aircraft or vessel the HUD drew.
|
||||
this.lastSubjectInfo = null;
|
||||
this.regionalBrief = null;
|
||||
this.regionalBriefAnchor = null;
|
||||
this.regionalBriefFetchedAt = 0;
|
||||
@@ -216,9 +255,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 +293,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 +343,9 @@ export class CockpitViewController {
|
||||
readAircraftInfo() {
|
||||
return readAircraftInfo.call(this);
|
||||
}
|
||||
readVesselInfo() {
|
||||
return readVesselInfo.call(this);
|
||||
}
|
||||
readSubjectLayerId() {
|
||||
return readSubjectLayerId.call(this);
|
||||
}
|
||||
@@ -316,8 +373,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 +394,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.lastSubjectInfo)
|
||||
this.updateRadar(this.lastSubjectInfo);
|
||||
}
|
||||
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 +535,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) {
|
||||
@@ -444,10 +556,10 @@ export class CockpitViewController {
|
||||
this.relocalizeBrief();
|
||||
this.publishVision(createVisionState(this.visionMode));
|
||||
this.routeSignature = null;
|
||||
if (this.active && this.lastAircraftInfo) {
|
||||
if (this.active && this.lastSubjectInfo) {
|
||||
this.rewordingSignals = true;
|
||||
try {
|
||||
this.updateHud(this.lastAircraftInfo, performance.now(), true);
|
||||
this.updateHud(this.lastSubjectInfo, performance.now(), true);
|
||||
} finally {
|
||||
this.rewordingSignals = false;
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
@@ -158,6 +172,10 @@ export class CockpitCoordinator {
|
||||
_cockpitEntryRefusal() {
|
||||
if (this._contextModeChanging)
|
||||
return 'Context is still changing — try Cockpit again in a moment';
|
||||
// Tracking an aircraft from the bridge ends the bridge and clears the
|
||||
// vessel selection before the entry can run, leaving neither.
|
||||
if (this.cockpitView?.active && this.cockpitView.subjectKind === 'vessel')
|
||||
return 'Cockpit is on a vessel bridge — exit the bridge first, then track an aircraft to enter Cockpit';
|
||||
if (!this._aircraftLayerEnabled)
|
||||
return 'No aircraft layer is on — turn on Flights or Military Flights and track an aircraft to enter Cockpit';
|
||||
return null;
|
||||
@@ -167,6 +185,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 +218,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) => {
|
||||
@@ -197,6 +199,27 @@ test('with no aircraft layer on, entry is refused for that reason, never for Con
|
||||
assert.equal(cockpit.active, false);
|
||||
});
|
||||
|
||||
test('voice entry on a vessel bridge refuses before it touches tracking', (t) => {
|
||||
const { coordinator, cockpit } = fixture(t, { enabled: ['flights'] });
|
||||
let navigated = false;
|
||||
coordinator.services.militaryAwarenessLayer.navigateNext = () => {
|
||||
navigated = true;
|
||||
return true;
|
||||
};
|
||||
// Stand in for a bridge ride: the refusal reads only these two.
|
||||
cockpit.active = true;
|
||||
cockpit.subjectKind = 'vessel';
|
||||
t.after(() => {
|
||||
cockpit.active = false;
|
||||
cockpit.subjectKind = null;
|
||||
});
|
||||
const voice = coordinator.controlCockpit('enter', { targetLayer: 'flights' });
|
||||
assert.equal(voice.ok, false);
|
||||
assert.match(voice.error, /vessel bridge/);
|
||||
assert.equal(navigated, false, 'no aircraft was tracked');
|
||||
assert.equal(cockpit.subjectKind, 'vessel');
|
||||
});
|
||||
|
||||
test('with an aircraft layer on but nothing tracked, the reason is the missing aircraft', (t) => {
|
||||
const { coordinator } = fixture(t, { enabled: ['military'] });
|
||||
assert.equal(
|
||||
@@ -439,6 +462,22 @@ test('a ride handed to an aircraft on a layer Contacts turned on keeps that laye
|
||||
assert.deepEqual(on(manager), ['flights', 'military']);
|
||||
});
|
||||
|
||||
test('Live AIS Vessels, once adopted as the ridden layer, outlives Contacts', 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 +504,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/);
|
||||
});
|
||||
+135
-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,54 @@ function subjectCanvasPosition() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note where the selected ship 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;
|
||||
// Only a ship moves under its own click (selecting it re-centres the
|
||||
// camera); a followed aircraft stays put, so its hit area stays its own.
|
||||
if (this.resolveEntryKind() !== 'vessel') {
|
||||
this.doubleClickStart = null;
|
||||
return;
|
||||
}
|
||||
const at = subjectCanvasPosition.call(this);
|
||||
const mmsi = this.readVesselInfo()?.mmsi ?? null;
|
||||
this.doubleClickStart = at ? { x: at.x, y: at.y, atMs: nowMs, mmsi } : 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 &&
|
||||
// The memory is the ship's it was taken for: one followed since (an
|
||||
// aircraft, another ship) is hit only where it is drawn.
|
||||
this.resolveEntryKind() === 'vessel' &&
|
||||
start.mmsi === (this.readVesselInfo()?.mmsi ?? null) &&
|
||||
doubleClickHitsSubject(position, start));
|
||||
if (!hit) return false;
|
||||
this.enter();
|
||||
return true;
|
||||
}
|
||||
@@ -91,12 +144,66 @@ 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=combobox]',
|
||||
'[role=grid]',
|
||||
'[role=menubar]',
|
||||
'[role=menuitemcheckbox]',
|
||||
'[role=menuitemradio]',
|
||||
'[role=scrollbar]',
|
||||
'[role=searchbox]',
|
||||
'[role=slider]',
|
||||
'[role=spinbutton]',
|
||||
'[role=textbox]',
|
||||
'[role=tree]',
|
||||
'[role=treeitem]',
|
||||
'[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 +246,33 @@ 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, but
|
||||
// only when the bridge can be entered: otherwise C stays the CCTV
|
||||
// shortcut, as it is with nothing selected.
|
||||
const bridgeAttempt =
|
||||
!cockpitAttempt &&
|
||||
!!this.readVesselInfo() &&
|
||||
this.isBridgeEntryAllowed();
|
||||
if (!cockpitAttempt && !bridgeAttempt) return;
|
||||
if (bridgeAttempt) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
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,
|
||||
) {
|
||||
this.lastAircraftInfo = info;
|
||||
if (info?.kind === 'vessel') {
|
||||
updateVesselHud.call(this, info, nowMs, forceContext);
|
||||
return;
|
||||
}
|
||||
this.lastSubjectInfo = 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,157 @@ 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.lastSubjectInfo = 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. Own ship sits where
|
||||
* the camera rides (its fix dead-reckoned); contacts sit at their last
|
||||
* fixes, where the vessel layer draws them, so the scope matches the
|
||||
* window.
|
||||
* @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 own = this.vesselFix ?? info;
|
||||
const contacts = layer.getRadarContacts(
|
||||
own.latitude,
|
||||
own.longitude,
|
||||
radarRangeM(rangeNm),
|
||||
RADAR_MAX_CONTACTS,
|
||||
);
|
||||
const picture = radarPicture(
|
||||
{
|
||||
latitude: own.latitude,
|
||||
longitude: own.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 +403,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,27 @@ 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.vesselFix = 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 +247,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 +257,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 +326,16 @@ 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.vesselFix = 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 +348,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,
|
||||
};
|
||||
|
||||
+95
-12
@@ -8,10 +8,18 @@ const LIVE_TICK_MS = 1000;
|
||||
const LIVE_EDGE = 0.005;
|
||||
/** The least that counts as at now, past the readout's own second. */
|
||||
const LIVE_EDGE_MS = 5000;
|
||||
/** The speeds play offers, in world ms per real ms. */
|
||||
export const WORLD_TIME_SPEEDS = Object.freeze({
|
||||
real: 1,
|
||||
minute: 60,
|
||||
hour: 3_600,
|
||||
day: 86_400,
|
||||
week: 604_800,
|
||||
});
|
||||
|
||||
/**
|
||||
* The world clock as the timeline shows it: `{live, playing, timeMs,
|
||||
* supported, span}`, where `supported` says a layer that moves with the clock
|
||||
* The world clock as the timeline shows it: `{live, playing, stepping,
|
||||
* buffering, timeMs, supported, span}`, where `supported` says a layer that moves with the clock
|
||||
* has time to show and `span` is the stretch the timeline runs over: the
|
||||
* time those layers cover, reaching to now and to the world time, with their
|
||||
* marks. It follows the page's world clock, which tells it of every move, and
|
||||
@@ -20,26 +28,68 @@ const LIVE_EDGE_MS = 5000;
|
||||
* track's end keep up with now.
|
||||
*/
|
||||
export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
const spanOf = (state) => {
|
||||
if (!state.supported) return null;
|
||||
// The time the layers cover, reaching to now.
|
||||
const reach = () => {
|
||||
const coverage = worldClock.coverage();
|
||||
if (!coverage) return null;
|
||||
const now = worldClock.wallNow();
|
||||
return Object.freeze({
|
||||
start: Math.min(coverage.start, now, state.timeMs),
|
||||
end: Math.max(coverage.end, now, state.timeMs),
|
||||
return {
|
||||
start: Math.min(coverage.start, now),
|
||||
end: Math.max(coverage.end, now),
|
||||
marks: coverage.marks,
|
||||
};
|
||||
};
|
||||
const spanOf = (state) => {
|
||||
if (!state.supported) return null;
|
||||
const covered = reach();
|
||||
if (!covered) return null;
|
||||
return Object.freeze({
|
||||
start: Math.min(covered.start, state.timeMs),
|
||||
end: Math.max(covered.end, state.timeMs),
|
||||
marks: covered.marks,
|
||||
});
|
||||
};
|
||||
const nearNow = (ms, length) =>
|
||||
Math.abs(ms - worldClock.wallNow()) <=
|
||||
Math.max(LIVE_EDGE_MS, length * LIVE_EDGE);
|
||||
// Whether the track ends at now (and moves on with it), not past it.
|
||||
const endsAtNow = (covered) =>
|
||||
covered.end - worldClock.wallNow() <= LIVE_EDGE_MS;
|
||||
// Play stops at the end of the track: at now it goes live, past now (a
|
||||
// satellite's future) it holds there.
|
||||
let stopping = false;
|
||||
const stopAtEnd = (state) => {
|
||||
if (stopping || !state.playing || state.live || !state.supported)
|
||||
return false;
|
||||
const covered = reach();
|
||||
if (!covered || state.timeMs < covered.end) return false;
|
||||
stopping = true;
|
||||
try {
|
||||
if (endsAtNow(covered)) worldClock.goLive();
|
||||
else {
|
||||
// Back to the end first, so nothing hears the overshoot as paused.
|
||||
worldClock.seek(covered.end);
|
||||
worldClock.pause();
|
||||
worldClock.seek(covered.end);
|
||||
}
|
||||
} finally {
|
||||
stopping = false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const read = (state = worldClock.getState()) =>
|
||||
Object.freeze({
|
||||
live: state.live,
|
||||
playing: state.playing,
|
||||
stepping: state.stepping,
|
||||
buffering: state.buffering,
|
||||
timeMs: state.timeMs,
|
||||
supported: state.supported,
|
||||
span: spanOf(state),
|
||||
});
|
||||
const time = shallowRef(read());
|
||||
const speed = shallowRef('real');
|
||||
const rate = () => WORLD_TIME_SPEEDS[speed.value];
|
||||
let ticker = null;
|
||||
const syncTicker = () => {
|
||||
// Playing, the clock tells of the time itself.
|
||||
@@ -54,6 +104,7 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
}
|
||||
};
|
||||
const unsubscribe = worldClock.subscribe((state) => {
|
||||
if (stopAtEnd(state)) return;
|
||||
time.value = read(state);
|
||||
syncTicker();
|
||||
});
|
||||
@@ -66,13 +117,45 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
|
||||
return {
|
||||
time,
|
||||
togglePlay: () => worldClock.togglePlay(),
|
||||
/**
|
||||
* Play runs the track at the speed chosen, from the start when it is at
|
||||
* its end (at live, say), as a video plays again from the top. It runs
|
||||
* the clock itself, past weather's own replay: weather follows the time
|
||||
* frame by frame like every other layer the track covers.
|
||||
*/
|
||||
togglePlay() {
|
||||
const { playing, live, timeMs, span } = time.value;
|
||||
if (playing) return worldClock.pause();
|
||||
const covered = reach();
|
||||
if (span && covered && (live || timeMs >= covered.end))
|
||||
worldClock.seek(span.start);
|
||||
worldClock.play({ rate: rate(), continuous: true });
|
||||
},
|
||||
speed,
|
||||
/**
|
||||
* Choose how fast play runs; playing, it changes at once. Weather's own
|
||||
* replay steps at its own pace, so a speed chosen while it plays takes
|
||||
* playback over from where it is.
|
||||
*/
|
||||
setSpeed(next) {
|
||||
if (!Object.hasOwn(WORLD_TIME_SPEEDS, next)) return;
|
||||
speed.value = next;
|
||||
const { playing, stepping } = worldClock.getState();
|
||||
if (!playing) return;
|
||||
if (!stepping) return worldClock.setRate(rate());
|
||||
worldClock.pause();
|
||||
worldClock.play({ rate: rate(), continuous: true });
|
||||
},
|
||||
goLive: () => worldClock.goLive(),
|
||||
/** Scrub to `ms`: playback stops where the hand puts it; at now, live. */
|
||||
scrub(ms) {
|
||||
/**
|
||||
* Scrub to `ms`: playback stops where the hand puts it; at now, live.
|
||||
* How near now counts as now goes by `length`, the stretch the track
|
||||
* shows, all of the span unless it is zoomed.
|
||||
*/
|
||||
scrub(ms, length) {
|
||||
const span = time.value.span;
|
||||
const edge = span ? (span.end - span.start) * LIVE_EDGE : 0;
|
||||
if (Math.abs(ms - worldClock.wallNow()) <= Math.max(LIVE_EDGE_MS, edge)) {
|
||||
length ??= span ? span.end - span.start : 0;
|
||||
if (nearNow(ms, length)) {
|
||||
worldClock.goLive();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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%;
|
||||
|
||||
@@ -0,0 +1,449 @@
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,9 @@
|
||||
--world-timeline-lift: 0px;
|
||||
}
|
||||
|
||||
/* The bar and the time's bubble over its handle. */
|
||||
body:has(#world-timeline) {
|
||||
--world-timeline-lift: 50px;
|
||||
--world-timeline-lift: 66px;
|
||||
}
|
||||
|
||||
/* Clean view, recording and the cockpit put the dock away; the bar goes too. */
|
||||
@@ -22,7 +23,10 @@ body.cockpit-mode #world-timeline {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Time runs left to right in every language, so the handle, the fill, the
|
||||
ticks and the bubble agree under a right-to-left page too. */
|
||||
#world-timeline {
|
||||
direction: ltr;
|
||||
position: fixed;
|
||||
bottom: 2vh;
|
||||
left: 50%;
|
||||
@@ -77,32 +81,83 @@ body.cockpit-mode #world-timeline {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-time {
|
||||
overflow: hidden;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 13px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
#world-timeline .world-timeline-speed {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-edge {
|
||||
flex: none;
|
||||
color: var(--text-secondary);
|
||||
/* The time rides over the handle. It slides across itself as the handle
|
||||
crosses the track (its start at the handle at the track's start, its end at
|
||||
the end), so however wide its date it stays within the track. */
|
||||
#world-timeline .world-timeline-time {
|
||||
--inset: 0px;
|
||||
position: absolute;
|
||||
bottom: calc(100% + 6px);
|
||||
left: calc(var(--inset) + (100% - var(--inset)) * var(--at));
|
||||
padding: 2px 8px;
|
||||
border: 1px solid rgba(0, 212, 255, 0.4);
|
||||
border-radius: 6px;
|
||||
background: var(--glass-bg);
|
||||
color: var(--text-primary);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
transform: translateX(calc(var(--at) * -100%));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Playing, held while a layer loads the time's data: a spinner by the time. */
|
||||
#world-timeline .world-timeline-time.is-waiting {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-spinner {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 2px solid rgba(255, 255, 255, 0.2);
|
||||
border-top-color: var(--accent);
|
||||
border-radius: 50%;
|
||||
animation: world-timeline-spin 0.9s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes world-timeline-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
#world-timeline .world-timeline-spinner {
|
||||
animation: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
}
|
||||
|
||||
/* The track: ticks for each launch or frame, the elapsed fill, and a native
|
||||
range input on top for dragging and the keyboard. */
|
||||
#world-timeline .world-timeline-track {
|
||||
position: relative;
|
||||
/* Two fingers pinch the track, not the page. */
|
||||
touch-action: none;
|
||||
flex: 1 1 auto;
|
||||
cursor: pointer;
|
||||
min-width: 80px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
/* Zoomed, the track's ends fade, as it goes on past them. */
|
||||
#world-timeline .world-timeline-track.is-zoomed::before {
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(123, 189, 211, 0.22) 12px,
|
||||
rgba(123, 189, 211, 0.22) calc(100% - 12px),
|
||||
transparent
|
||||
);
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-track::before {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
@@ -139,6 +194,17 @@ body.cockpit-mode #world-timeline {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Zoomed, the track drags along. */
|
||||
#world-timeline .world-timeline-track.is-zoomed {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-track.is-zoomed:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
/* Only the handle takes the pointer as a slider; the track around it takes
|
||||
taps, drags and pinches itself. */
|
||||
#world-timeline .world-timeline-scrub {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
@@ -146,8 +212,29 @@ body.cockpit-mode #world-timeline {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
appearance: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub::-webkit-slider-thumb {
|
||||
cursor: ew-resize;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub::-moz-range-thumb {
|
||||
cursor: ew-resize;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
/* The time dragged off the track: the handle waits at its edge, unseen. */
|
||||
#world-timeline .world-timeline-scrub.is-off-view::-webkit-slider-thumb {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub.is-off-view::-moz-range-thumb {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub::-webkit-slider-runnable-track {
|
||||
@@ -178,6 +265,20 @@ body.cockpit-mode #world-timeline {
|
||||
background: #031018;
|
||||
}
|
||||
|
||||
/* A finger needs a bigger handle. */
|
||||
@media (pointer: coarse) {
|
||||
#world-timeline .world-timeline-scrub::-webkit-slider-thumb {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub::-moz-range-thumb {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-scrub:focus-visible {
|
||||
outline: 1px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
@@ -190,7 +291,7 @@ body.cockpit-mode #world-timeline {
|
||||
}
|
||||
|
||||
/* On phones the bar sits just above the tab bar, under the voice dock, with
|
||||
the track on a row of its own beneath play, the time and live. */
|
||||
the track and the speed on a row of their own beneath play and live. */
|
||||
body.mobile-shell:has(#world-timeline) {
|
||||
--world-timeline-lift: 80px;
|
||||
}
|
||||
@@ -202,21 +303,23 @@ body.mobile-shell #world-timeline {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* The bubble rises into the first row, clear of play on its left. */
|
||||
body.mobile-shell #world-timeline .world-timeline-time {
|
||||
flex: 1 1 0;
|
||||
--inset: 48px;
|
||||
}
|
||||
|
||||
/* The speed sits on the track's row, a full-size target beside it. */
|
||||
body.mobile-shell #world-timeline .world-timeline-track {
|
||||
order: 1;
|
||||
flex-basis: 100%;
|
||||
flex: 1 1 calc(100% - 96px);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
#world-timeline .world-timeline-edge {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#world-timeline .world-timeline-time {
|
||||
font-size: 11px;
|
||||
}
|
||||
body.mobile-shell #world-timeline .world-timeline-live {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
body.mobile-shell #world-timeline .world-timeline-speed {
|
||||
order: 2;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -148,3 +148,401 @@ test('the track runs over the time the layers show, to now, and scrubs', async (
|
||||
assert.equal(worldClock.isLive(), false, 'a scrub past now stays there');
|
||||
assert.equal(worldClock.now(), ahead);
|
||||
});
|
||||
|
||||
test('play runs in real time, from the start of the track when at live', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start, end: now - 86_400_000 }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
// Weather's replay stepping its own frames does not take the track's play.
|
||||
const stepped = [];
|
||||
const driver = worldClock.attachDriver({
|
||||
play: () => stepped.push('play'),
|
||||
pause: () => stepped.push('pause'),
|
||||
});
|
||||
t.after(() => driver.detach());
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
worldClock.pause();
|
||||
await nextTick();
|
||||
assert.deepEqual(stepped, []);
|
||||
const rate = worldClock.getRate();
|
||||
assert.ok(worldClock.now() - start < rate * 1_000, 'from the start of the track');
|
||||
assert.equal(rate, 1, 'real time to start with');
|
||||
worldClock.play({ continuous: true });
|
||||
|
||||
// Playing on to now goes live.
|
||||
worldClock.seek(Date.now() + 1_000);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.getRate(), 1, 'live plays at the rate of the world');
|
||||
});
|
||||
|
||||
test('play holds at the end of a track that reaches past now', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
// An hour ahead is within the track's share of now, but still ahead of it.
|
||||
const end = now + 3_600_000;
|
||||
const release = worldClock.hold('test-ahead');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-ahead',
|
||||
coverage: () => ({ start: now - 10 * 86_400_000, end }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
// Paused just past now, play plays on rather than from the top.
|
||||
worldClock.seek(Date.now() + 1_000);
|
||||
await nextTick();
|
||||
const from = worldClock.now();
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
worldClock.pause();
|
||||
assert.ok(worldClock.now() >= from, 'plays on from where it was');
|
||||
worldClock.play();
|
||||
worldClock.seek(end + 60_000);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
assert.equal(worldClock.now(), end);
|
||||
});
|
||||
|
||||
test('the speed chosen sets how fast play runs, at once while playing', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start: now - 10 * 86_400_000, end: now - 86_400_000 }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const select = bar().querySelector('select.world-timeline-speed');
|
||||
assert.equal(select.value, 'real');
|
||||
assert.deepEqual(
|
||||
[...select.options].map((option) => option.value),
|
||||
['real', 'minute', 'hour', 'day', 'week'],
|
||||
);
|
||||
select.value = 'week';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
assert.equal(worldClock.getRate(), 604_800, 'a week a second');
|
||||
select.value = 'hour';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getRate(), 3_600, 'changed while playing');
|
||||
select.value = 'minute';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.getRate(), 60, 'a minute a second');
|
||||
select.value = 'real';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.getRate(), 1, 'the world as it goes');
|
||||
});
|
||||
|
||||
test('a speed chosen while weather replay steps takes playback over', async (t) => {
|
||||
const bar = mount(t);
|
||||
const at = Date.now() - 3_600_000;
|
||||
supportingLayer(t, at);
|
||||
const calls = [];
|
||||
const driver = worldClock.attachDriver({
|
||||
play() {
|
||||
calls.push('play');
|
||||
driver.driven(true, at - 600_000);
|
||||
},
|
||||
pause() {
|
||||
calls.push('pause');
|
||||
driver.driven(false);
|
||||
},
|
||||
});
|
||||
t.after(() => driver.detach());
|
||||
worldClock.play();
|
||||
await nextTick();
|
||||
assert.equal(worldClock.getState().stepping, true);
|
||||
const select = bar().querySelector('select.world-timeline-speed');
|
||||
select.value = 'hour';
|
||||
select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.deepEqual(calls, ['play', 'pause']);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getRate(), 3_600);
|
||||
assert.ok(worldClock.now() - (at - 600_000) < 3_600 * 1_000, 'on from where it was');
|
||||
worldClock.pause();
|
||||
});
|
||||
|
||||
test('paused just before the end, play carries on rather than restarting', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const end = now + 86_400_000;
|
||||
const release = worldClock.hold('test-ahead');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-ahead',
|
||||
coverage: () => ({ start: now - 86_400_000, end }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
worldClock.seek(end - 4_000);
|
||||
await nextTick();
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
worldClock.pause();
|
||||
assert.ok(worldClock.now() >= end - 4_000, 'not back to the start');
|
||||
});
|
||||
|
||||
test('the track zooms around the handle, follows it, and shows it all again', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 26 * 86_400_000;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
// A month of launches and three hours of lightning, sharing one track.
|
||||
coverage: () => ({
|
||||
start,
|
||||
end: now,
|
||||
marks: [start, now - 3 * 3_600_000, now - 2 * 3_600_000, now - 3_600_000],
|
||||
}),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
const length = () => Number(input.max) - Number(input.min);
|
||||
const full = length();
|
||||
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 4);
|
||||
|
||||
// Live, the handle is at the end: zooming in keeps the view on now.
|
||||
for (let i = 0; i < 10; i++) {
|
||||
track.dispatchEvent(new WheelEvent('wheel', { deltaY: -200, cancelable: true }));
|
||||
await nextTick();
|
||||
}
|
||||
assert.ok(length() < full / 100, 'zoomed in');
|
||||
assert.ok(Number(input.max) >= now, 'still ending at now');
|
||||
assert.equal(track.classList.contains('is-zoomed'), true);
|
||||
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 3, 'only the ticks in view');
|
||||
|
||||
// A seek off the view takes the view along.
|
||||
worldClock.seek(start + 86_400_000);
|
||||
await nextTick();
|
||||
assert.ok(Number(input.min) <= start + 86_400_000 && Number(input.max) >= start + 86_400_000);
|
||||
assert.ok(length() < full / 100, 'at the same zoom');
|
||||
|
||||
// Minus widens, zero and a double-click show it all.
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: '-' }));
|
||||
await nextTick();
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: '0' }));
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(length() - full) < 1_000, 'all of it');
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: '+' }));
|
||||
await nextTick();
|
||||
assert.ok(length() < full);
|
||||
track.dispatchEvent(new MouseEvent('dblclick'));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), false);
|
||||
});
|
||||
|
||||
test('zoomed, a scrub near now stays off live, and the view keeps a still handle', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 26 * 86_400_000;
|
||||
let end = now;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start, end, marks: [start, now - 3_600_000] }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
// Ten notches of a line-mode wheel, as Firefox sends them.
|
||||
for (let i = 0; i < 10; i++) {
|
||||
track.dispatchEvent(new WheelEvent('wheel', { deltaY: -12, deltaMode: 1, cancelable: true }));
|
||||
await nextTick();
|
||||
}
|
||||
assert.ok(Number(input.max) - Number(input.min) < 6 * 3_600_000, 'lines zoom like pixels');
|
||||
|
||||
// Twenty minutes back is near now on a month, not on a few hours.
|
||||
input.value = String(now - 20 * 60_000);
|
||||
input.dispatchEvent(new Event('input'));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
assert.ok(Math.abs(worldClock.now() - (now - 20 * 60_000)) < 1_000);
|
||||
|
||||
// The span running on past the paused handle takes the view back to it.
|
||||
end = now + 86_400_000;
|
||||
worldClock.coverageChanged();
|
||||
await nextTick();
|
||||
const at = worldClock.now();
|
||||
assert.ok(Number(input.min) <= at && Number(input.max) >= at, 'handle in view');
|
||||
|
||||
// With a modifier, plus is the browser's zoom.
|
||||
const browserZoom = new KeyboardEvent('keydown', { key: '+', ctrlKey: true, cancelable: true });
|
||||
input.dispatchEvent(browserZoom);
|
||||
assert.equal(browserZoom.defaultPrevented, false);
|
||||
|
||||
// A double-click puts back the time its first press moved.
|
||||
track.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, pointerId: 1 }));
|
||||
track.dispatchEvent(new PointerEvent('pointerup', { bubbles: true, pointerId: 1 }));
|
||||
input.value = String(at - 3_600_000);
|
||||
input.dispatchEvent(new Event('input'));
|
||||
track.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), false);
|
||||
assert.ok(Math.abs(worldClock.now() - at) < 1_000, 'time as it was');
|
||||
});
|
||||
|
||||
test('play held for a layer to load shows a spinner once the hold lasts', async (t) => {
|
||||
const bar = mount(t);
|
||||
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
|
||||
supportingLayer(t, at);
|
||||
worldClock.seek(at - 1_800_000);
|
||||
worldClock.play({ continuous: true });
|
||||
await nextTick();
|
||||
const bubble = () => bar().querySelector('.world-timeline-time');
|
||||
const release = worldClock.wait('test-radar');
|
||||
t.after(release);
|
||||
// A clock tick (a quarter second) tells of the hold; the spinner waits on.
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
await nextTick();
|
||||
assert.equal(bubble().querySelector('.world-timeline-spinner'), null, 'not for a quick frame');
|
||||
// The clock tells of the hold on its next tick, and the bar shows it after.
|
||||
const until = async (shown) => {
|
||||
for (let waited = 0; waited < 3_000; waited += 50) {
|
||||
if (Boolean(bubble().querySelector('.world-timeline-spinner')) === shown) return true;
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
await nextTick();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
assert.ok(await until(true), 'spinner once the hold lasts');
|
||||
assert.match(bubble().textContent, /UTC$/, 'the time stays');
|
||||
release();
|
||||
assert.ok(await until(false), 'gone once play goes on');
|
||||
});
|
||||
|
||||
test('the track drags along, a tap goes to its time, and the handle waits off it', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 26 * 86_400_000;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start, end: now, marks: [start] }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
// A 1000 px track from x = 0.
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const press = (type, clientX, pointerId = 1) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
|
||||
const view = () => ({ min: Number(input.min), max: Number(input.max) });
|
||||
|
||||
// All of it shown, a tap goes to the time under it.
|
||||
press('pointerdown', 500);
|
||||
press('pointerup', 500);
|
||||
await nextTick();
|
||||
const middle = start + (now - start) / 2;
|
||||
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'went to the middle');
|
||||
|
||||
// Zoomed to a day around it, dragging right by half the track goes back half a day.
|
||||
for (let i = 0; i < 6; i++) {
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: '+' }));
|
||||
await nextTick();
|
||||
}
|
||||
const before = view();
|
||||
const day = before.max - before.min;
|
||||
press('pointerdown', 600, 2);
|
||||
press('pointermove', 700, 2);
|
||||
press('pointermove', 1_100, 2);
|
||||
press('pointerup', 1_100, 2);
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(view().max - (before.max - day / 2)) < 1_000, 'dragged half a view');
|
||||
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'a drag leaves the time');
|
||||
|
||||
// Dragged off the handle, it waits unseen at the edge; a sideways swipe drags too.
|
||||
track.dispatchEvent(new WheelEvent('wheel', { deltaX: -2_000, deltaY: 0, cancelable: true }));
|
||||
await nextTick();
|
||||
assert.ok(view().max < worldClock.now(), 'the handle is past the view');
|
||||
assert.equal(input.classList.contains('is-off-view'), true);
|
||||
// Moving the time takes the view back to it.
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'PageUp' }));
|
||||
await nextTick();
|
||||
assert.equal(input.classList.contains('is-off-view'), false);
|
||||
});
|
||||
|
||||
test('a pinch measures from where the fingers are, and a lifted finger ends it', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 26 * 86_400_000;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start, end: now, marks: [start] }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const on = (target, type, clientX, pointerId) =>
|
||||
target.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
|
||||
const length = () => Number(input.max) - Number(input.min);
|
||||
for (let i = 0; i < 4; i++) {
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: '+' }));
|
||||
await nextTick();
|
||||
}
|
||||
const before = length();
|
||||
// A finger on the handle moves before the second comes down.
|
||||
on(input, 'pointerdown', 300, 1);
|
||||
on(input, 'pointermove', 500, 1);
|
||||
on(track, 'pointerdown', 700, 2);
|
||||
on(input, 'pointermove', 500, 1);
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(length() - before) < 1_000, 'no zoom from a stale finger');
|
||||
on(track, 'pointermove', 900, 2);
|
||||
await nextTick();
|
||||
assert.ok(length() < before, 'spread apart, it zooms in');
|
||||
// One finger up: the other moving does nothing, and throws nothing.
|
||||
const zoomedTo = length();
|
||||
on(track, 'pointerup', 900, 2);
|
||||
on(input, 'pointermove', 100, 1);
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(length() - zoomedTo) < 1_000);
|
||||
on(input, 'pointercancel', 100, 1);
|
||||
});
|
||||
@@ -1,58 +1,316 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { formatDate, t } from '../../../i18n/index.js';
|
||||
import { useWorldTimeStore } from '../../stores/worldTime.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
|
||||
// The world timeline: play and pause on the left, the time, a track across
|
||||
// the stretch the layers on can show (each launch or frame a tick) with a
|
||||
// handle to scrub, and the way back to live on the right, lit while live. It
|
||||
// shows while a layer with a time of its own (weather, satellites, launches,
|
||||
// The world timeline: play and pause and the speed on the left, a track
|
||||
// across the stretch the layers on can show (each launch or frame a tick)
|
||||
// with a handle to scrub and the time in a bubble over it, and the way back
|
||||
// to live on the right, lit while live. Scrolling or pinching the track
|
||||
// zooms it around the handle, dragging it moves along it, and a double-click
|
||||
// shows it all again. It shows
|
||||
// while a layer with a time of its own (weather, satellites, launches,
|
||||
// or one a host follows) is on with time to show; with only live feeds such
|
||||
// as flights on, the bar stays hidden.
|
||||
const store = useWorldTimeStore();
|
||||
const { time } = storeToRefs(store);
|
||||
const { time, speed } = storeToRefs(store);
|
||||
const speeds = computed(() => [
|
||||
{ value: 'real', label: '1×' },
|
||||
{ value: 'minute', label: t('1 min/s') },
|
||||
{ value: 'hour', label: t('1 h/s') },
|
||||
{ value: 'day', label: t('1 d/s') },
|
||||
{ value: 'week', label: t('1 wk/s') },
|
||||
]);
|
||||
|
||||
const DATE_TIME = Object.freeze({
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'medium',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
const EDGE_DATE = Object.freeze({
|
||||
// The bubble over the handle: the date and the minute, kept short.
|
||||
const BUBBLE_DATE = Object.freeze({
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
const BUBBLE_TIME = Object.freeze({
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
timeZone: 'UTC',
|
||||
});
|
||||
// The keyboard's fallback step, as a share of the track, with no mark to go to.
|
||||
const KEY_STEP = 0.01;
|
||||
const PAGE_STEP = 0.1;
|
||||
// Zooming: the shortest stretch the track narrows to, the step a key or a
|
||||
// notch of the wheel takes, and how far a wheel's pixel of scroll zooms.
|
||||
const MIN_VIEW_MS = 5 * 60_000;
|
||||
const ZOOM_STEP = 1.5;
|
||||
const WHEEL_ZOOM = 0.0025;
|
||||
// Two presses this close are a double-click.
|
||||
const DOUBLE_PRESS_MS = 500;
|
||||
|
||||
const readout = computed(() =>
|
||||
Number.isFinite(time.value.timeMs)
|
||||
? `${formatDate(time.value.timeMs, DATE_TIME)} UTC`
|
||||
: '',
|
||||
);
|
||||
const bubble = computed(() =>
|
||||
Number.isFinite(time.value.timeMs)
|
||||
? `${formatDate(time.value.timeMs, BUBBLE_DATE)} · ${formatDate(time.value.timeMs, BUBBLE_TIME)} UTC`
|
||||
: '',
|
||||
);
|
||||
// Play held while a layer loads the time's data shows a spinner by the time,
|
||||
// once the hold lasts long enough to notice, so a quick frame does not flash
|
||||
// it, and until play has run a while, so a run of slow frames keeps it still.
|
||||
const WAIT_SHOWN_MS = 300;
|
||||
const WAIT_HIDDEN_MS = 500;
|
||||
const waiting = shallowRef(false);
|
||||
let waitTimer = null;
|
||||
watch(
|
||||
() => time.value.buffering,
|
||||
(buffering) => {
|
||||
clearTimeout(waitTimer);
|
||||
waitTimer = null;
|
||||
if (buffering === waiting.value) return;
|
||||
waitTimer = setTimeout(
|
||||
() => {
|
||||
waitTimer = null;
|
||||
waiting.value = buffering;
|
||||
},
|
||||
buffering ? WAIT_SHOWN_MS : WAIT_HIDDEN_MS,
|
||||
);
|
||||
},
|
||||
);
|
||||
onBeforeUnmount(() => clearTimeout(waitTimer));
|
||||
const span = computed(() => time.value.span);
|
||||
// Where the handle is, or null with no track.
|
||||
const at = computed(() => {
|
||||
if (!span.value) return null;
|
||||
const { start, end } = span.value;
|
||||
return Math.min(end, Math.max(start, time.value.timeMs));
|
||||
});
|
||||
const place = (ms) => {
|
||||
|
||||
// The track shows the whole span, or zoomed, a stretch of it: `length` long,
|
||||
// ending at `end`, or at the span's end (and so at now) while `end` is null.
|
||||
// Everything still plays together; zooming only changes what the track shows.
|
||||
const zoom = shallowRef(null);
|
||||
const view = computed(() => {
|
||||
if (!span.value) return null;
|
||||
const { start, end } = span.value;
|
||||
const length = zoom.value?.length;
|
||||
if (!length || length >= end - start) return { start, end };
|
||||
const viewEnd = Math.min(end, Math.max(start + length, zoom.value.end ?? end));
|
||||
return { start: viewEnd - length, end: viewEnd };
|
||||
});
|
||||
const zoomed = computed(() => zoom.value !== null);
|
||||
const viewLength = () => view.value.end - view.value.start;
|
||||
// Show `length` of the span ending at `viewEnd`, held to the span.
|
||||
function showView(length, viewEnd) {
|
||||
const { start, end } = span.value;
|
||||
if (length >= end - start) {
|
||||
showWhole();
|
||||
return;
|
||||
}
|
||||
const clamped = Math.min(end, Math.max(start + length, viewEnd));
|
||||
zoom.value = { length, end: clamped >= end ? null : clamped };
|
||||
}
|
||||
// Narrow or widen the view to `length`, keeping the handle where it is on it,
|
||||
// or with the handle off it, the middle.
|
||||
function zoomTo(length) {
|
||||
const { start: from, end: to } = view.value;
|
||||
const pivot = offView(at.value) ? (from + to) / 2 : at.value;
|
||||
const share = (pivot - from) / (to - from);
|
||||
const next = Math.max(MIN_VIEW_MS, length);
|
||||
showView(next, pivot + (1 - share) * next);
|
||||
}
|
||||
const zoomBy = (factor) => zoomTo(viewLength() * factor);
|
||||
// A view dragged off the handle stays where it was put while the handle only
|
||||
// creeps on with now; playing or a move of the handle takes it back.
|
||||
let panned = false;
|
||||
const follow = (ms) => {
|
||||
panned = false;
|
||||
showView(zoom.value.length, ms + zoom.value.length / 2);
|
||||
};
|
||||
const offView = (ms) => ms < view.value.start || ms > view.value.end;
|
||||
const showWhole = () => {
|
||||
zoom.value = null;
|
||||
panned = false;
|
||||
};
|
||||
// The span narrowing to the zoom or less, or going, lets go of the zoom.
|
||||
watch(span, (next) => {
|
||||
if (zoom.value && (!next || zoom.value.length >= next.end - next.start))
|
||||
showWhole();
|
||||
});
|
||||
watch(at, (ms) => {
|
||||
if (!zoom.value || ms === null || !offView(ms)) return;
|
||||
if (panned && time.value.live && !time.value.playing) return;
|
||||
follow(ms);
|
||||
});
|
||||
// Left behind as now moves the view on, the handle takes the view back.
|
||||
watch(view, () => {
|
||||
if (zoom.value && !panned && at.value !== null && offView(at.value))
|
||||
follow(at.value);
|
||||
});
|
||||
const pan = (ms) => {
|
||||
panned = true;
|
||||
showView(zoom.value.length, view.value.end + ms);
|
||||
};
|
||||
// A wheel's lines and pages, in pixels.
|
||||
const WHEEL_UNITS = [1, 16, 400];
|
||||
const onWheel = (event) => {
|
||||
const unit = WHEEL_UNITS[event.deltaMode] ?? 1;
|
||||
const sideways = Math.abs(event.deltaX) > Math.abs(event.deltaY);
|
||||
// A sideways swipe, or a wheel with shift, drags; a wheel zooms.
|
||||
if (sideways || event.shiftKey) {
|
||||
if (!zoom.value) return;
|
||||
event.preventDefault();
|
||||
const width = event.currentTarget.clientWidth;
|
||||
const pixels = (sideways ? event.deltaX : event.deltaY) * unit;
|
||||
if (width > 0) pan((pixels / width) * viewLength());
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
zoomBy(Math.exp(event.deltaY * unit * WHEEL_ZOOM));
|
||||
};
|
||||
// A double-click starts with presses that move the time, so it puts back the
|
||||
// time from before its first; so does a pinch, which may start on the handle.
|
||||
let before = null;
|
||||
let pressedAt = -Infinity;
|
||||
const onPress = (event) => {
|
||||
if (event.timeStamp - pressedAt > DOUBLE_PRESS_MS)
|
||||
before = { live: time.value.live, timeMs: time.value.timeMs };
|
||||
pressedAt = event.timeStamp;
|
||||
};
|
||||
const restore = () => {
|
||||
if (!before) return;
|
||||
if (before.live) store.goLive();
|
||||
else store.scrub(before.timeMs, 0);
|
||||
};
|
||||
const showAll = () => {
|
||||
restore();
|
||||
showWhole();
|
||||
};
|
||||
|
||||
// The handle drags the time. The rest of the track takes the pointer: a tap
|
||||
// goes to the time under it, a drag drags a zoomed track along (or the time,
|
||||
// with all of it shown), and two fingers pinch it.
|
||||
const DRAG_PX = 4;
|
||||
const pointers = new Map();
|
||||
let gesture = null;
|
||||
const timeAt = (clientX, track) => {
|
||||
const { left, width } = track.getBoundingClientRect();
|
||||
const share = width > 0 ? Math.min(1, Math.max(0, (clientX - left) / width)) : 1;
|
||||
return view.value.start + share * viewLength();
|
||||
};
|
||||
// Whether the first finger has moved the time, for a pinch to put it back.
|
||||
let movedTime = false;
|
||||
const onPointerDown = (event) => {
|
||||
// Only the main button: a right-click is for the menu.
|
||||
if (event.button > 0) return;
|
||||
const onHandle = event.target instanceof HTMLInputElement;
|
||||
pointers.set(event.pointerId, { x: event.clientX, onHandle });
|
||||
if (pointers.size === 1) {
|
||||
onPress(event);
|
||||
movedTime = onHandle;
|
||||
// The keys zoom and step the track as soon as it is touched.
|
||||
if (!onHandle)
|
||||
event.currentTarget.querySelector('input')?.focus({ preventScroll: true });
|
||||
}
|
||||
if (pointers.size === 2) {
|
||||
const [a, b] = [...pointers.values()];
|
||||
if (movedTime) restore();
|
||||
gesture = {
|
||||
kind: 'pinch',
|
||||
spread: Math.abs(a.x - b.x),
|
||||
length: viewLength(),
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (onHandle || pointers.size !== 1) return;
|
||||
// The drag goes on past the track's ends; without the capture, to them.
|
||||
try {
|
||||
event.currentTarget.setPointerCapture?.(event.pointerId);
|
||||
} catch {
|
||||
// A pointer the page no longer knows of drags no further than the track.
|
||||
}
|
||||
gesture = { kind: 'press', x: event.clientX, end: view.value.end };
|
||||
};
|
||||
const onPointerMove = (event) => {
|
||||
const pointer = pointers.get(event.pointerId);
|
||||
if (!pointer) return;
|
||||
pointer.x = event.clientX;
|
||||
if (!gesture) return;
|
||||
const track = event.currentTarget;
|
||||
if (gesture.kind === 'pinch') {
|
||||
const [a, b] = [...pointers.values()];
|
||||
const spreadNow = Math.abs(a.x - b.x);
|
||||
if (spreadNow > 0) zoomTo((gesture.length * gesture.spread) / spreadNow);
|
||||
return;
|
||||
}
|
||||
if (gesture.kind === 'press') {
|
||||
if (Math.abs(event.clientX - gesture.x) < DRAG_PX) return;
|
||||
gesture.kind = zoom.value ? 'pan' : 'scrub';
|
||||
movedTime = gesture.kind === 'scrub';
|
||||
}
|
||||
if (gesture.kind === 'pan') {
|
||||
if (!track.clientWidth) return;
|
||||
panned = true;
|
||||
const moved = ((gesture.x - event.clientX) / track.clientWidth) * viewLength();
|
||||
showView(zoom.value.length, gesture.end + moved);
|
||||
} else store.scrub(timeAt(event.clientX, track), viewLength());
|
||||
};
|
||||
const onPointerUp = (event) => {
|
||||
if (!pointers.delete(event.pointerId)) return;
|
||||
if (gesture?.kind === 'press' && event.type === 'pointerup')
|
||||
store.scrub(timeAt(event.clientX, event.currentTarget), viewLength());
|
||||
// A finger lifted from a pinch ends it; the other one moves nothing.
|
||||
gesture = null;
|
||||
};
|
||||
|
||||
const place = (ms) => {
|
||||
const { start, end } = view.value;
|
||||
return end > start ? ((ms - start) / (end - start)) * 100 : 100;
|
||||
};
|
||||
const ticks = computed(() =>
|
||||
span.value.marks.map((mark) => `${place(mark)}%`),
|
||||
const ticks = computed(() => {
|
||||
const { start, end } = view.value;
|
||||
return span.value.marks
|
||||
.filter((mark) => mark >= start && mark <= end)
|
||||
.map((mark) => `${place(mark)}%`);
|
||||
});
|
||||
const shown = computed(() =>
|
||||
Math.min(view.value.end, Math.max(view.value.start, at.value)),
|
||||
);
|
||||
const scrub = (event) => store.scrub(Number(event.target.value));
|
||||
const handleOff = computed(() => at.value !== shown.value);
|
||||
const scrub = (event) => {
|
||||
// A pinch only zooms; the input goes back to the handle.
|
||||
if (gesture?.kind === 'pinch') {
|
||||
event.target.value = shown.value;
|
||||
return;
|
||||
}
|
||||
store.scrub(Number(event.target.value), viewLength());
|
||||
};
|
||||
// Arrows go to the previous or next mark (a launch, a frame), or a step along
|
||||
// the track; Page keys take a tenth of it; Home and End go to its ends.
|
||||
// the track as shown; Page keys take a tenth of it; Home and End go to the
|
||||
// ends of all of it. Plus and minus zoom, and zero shows it all; with a
|
||||
// modifier they are the browser's own zoom.
|
||||
const ZOOM_KEYS = ['+', '=', '-', '0'];
|
||||
const onKey = (event) => {
|
||||
if (ZOOM_KEYS.includes(event.key)) {
|
||||
if (event.ctrlKey || event.metaKey || event.altKey) return;
|
||||
event.preventDefault();
|
||||
if (event.key === '-') zoomBy(ZOOM_STEP);
|
||||
else if (event.key === '0') showWhole();
|
||||
else zoomBy(1 / ZOOM_STEP);
|
||||
return;
|
||||
}
|
||||
const { start, end, marks } = span.value;
|
||||
const now = at.value;
|
||||
const length = end - start;
|
||||
const length = viewLength();
|
||||
let to = null;
|
||||
if (event.key === 'ArrowLeft' || event.key === 'ArrowDown')
|
||||
to = marks.findLast((mark) => mark < now) ?? now - length * KEY_STEP;
|
||||
@@ -64,7 +322,7 @@ const onKey = (event) => {
|
||||
else if (event.key === 'End') to = end;
|
||||
if (to === null) return;
|
||||
event.preventDefault();
|
||||
store.scrub(Math.min(end, Math.max(start, to)));
|
||||
store.scrub(Math.min(end, Math.max(start, to)), length);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -72,24 +330,26 @@ const onKey = (event) => {
|
||||
<div v-if="time.supported && time.span" id="world-timeline" role="group" :aria-label="t('World time')"
|
||||
><UiButton class="world-timeline-play" :label="time.playing ? t('Pause') : t('Play')" @click="store.togglePlay()"
|
||||
><UiIcon :name="time.playing ? 'pause' : 'play_arrow'" :size="20" /></UiButton
|
||||
><time class="world-timeline-time" :datetime="new Date(time.timeMs).toISOString()" aria-live="off">{{ readout }}</time
|
||||
><span class="world-timeline-edge">{{ formatDate(span.start, EDGE_DATE) }}</span
|
||||
><div class="world-timeline-track"
|
||||
><UiSelect class="gev-field gev-field--compact world-timeline-speed" :aria-label="t('Play speed')" :title="t('Play speed')" :options="speeds" :model-value="speed" @update:model-value="store.setSpeed($event)"
|
||||
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp"
|
||||
><time class="world-timeline-time" :class="{ 'is-waiting': waiting }" :style="{ '--at': place(shown) / 100 }" :datetime="new Date(time.timeMs).toISOString()" aria-live="off"
|
||||
><span v-if="waiting" class="world-timeline-spinner" aria-hidden="true"></span>{{ bubble }}</time
|
||||
><span v-for="(left, index) in ticks" :key="index" class="world-timeline-tick" :style="{ left }" aria-hidden="true"></span
|
||||
><span class="world-timeline-fill" :style="{ width: `${place(at)}%` }" aria-hidden="true"></span
|
||||
><span class="world-timeline-fill" :style="{ width: `${place(shown)}%` }" aria-hidden="true"></span
|
||||
><input
|
||||
class="world-timeline-scrub"
|
||||
:class="{ 'is-off-view': handleOff }"
|
||||
type="range"
|
||||
:aria-label="t('World time')"
|
||||
:aria-valuetext="readout"
|
||||
:min="span.start"
|
||||
:max="span.end"
|
||||
:min="view.start"
|
||||
:max="view.end"
|
||||
step="any"
|
||||
:value="at"
|
||||
:value="shown"
|
||||
@input="scrub"
|
||||
aria-keyshortcuts="+ - 0"
|
||||
@keydown="onKey"
|
||||
/></div
|
||||
><span class="world-timeline-edge">{{ formatDate(span.end, EDGE_DATE) }}</span
|
||||
><UiButton class="world-timeline-live" :label="time.live ? t('Live') : t('Back to live')" :pressed="time.live" pressed-class="is-live" :disabled="time.live" @click="store.goLive()">{{ t('Live') }}</UiButton
|
||||
></div>
|
||||
</template>
|
||||
Reference in new issue
Block a user