mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
Merge main into german/i18n-plurals-context
The catalogs conflicted only on neighbouring lines: no key changed on both sides, so they are merged key by key in main's order. Main removed the rail timeline, the other user of plain "Latest", so that entry is pruned and the News test no longer checks the timeline's wording.
This commit is contained in:
commit
49409ba8f1
1502 files changed
+180715
-47887
No files matched your search
@@ -12,6 +12,12 @@ import { useCockpitStore } from './stores/cockpit.js';
|
||||
import CockpitView from './views/CockpitView.vue';
|
||||
import ContextView from './views/ContextView.vue';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
bindFakeCesiumCamera,
|
||||
followEntity,
|
||||
followedEntity,
|
||||
} from '../testSupport/fakeCameraPort.mjs';
|
||||
import { fakeScenePorts } from '../testSupport/fakeCesiumScene.mjs';
|
||||
import { vesselCockpitInfo } from '../layers/vessels/cockpitSubject.js';
|
||||
import { VesselRecords } from '../layers/vessels/records.js';
|
||||
|
||||
@@ -90,6 +96,54 @@ function vesselLayer(record) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The query port over the test's fake scene, as the Cesium adapter answers
|
||||
* it: a position is drawn where `scene.cartesianToCanvasCoordinates` says;
|
||||
* heights come from `scene.sampleHeight` (loaded tiles, at once) and
|
||||
* `scene.sampleHeightMostDetailed` (the full-detail read), per probe.
|
||||
*/
|
||||
/** The surfaces the bridge's height reads asked for, in order. */
|
||||
const surfacesAsked = [];
|
||||
|
||||
function sceneQuery(viewer, ports) {
|
||||
const scene = () => viewer.scene;
|
||||
const cartographic = ({ lon, lat }) =>
|
||||
Cesium.Cartographic.fromDegrees(lon, lat);
|
||||
return {
|
||||
...ports.query,
|
||||
project: (position) =>
|
||||
scene().cartesianToCanvasCoordinates?.(position, {}) ?? null,
|
||||
sampleHeightNow(point, options = {}) {
|
||||
surfacesAsked.push(options.against ?? 'surface');
|
||||
const height = scene().sampleHeight?.(cartographic(point));
|
||||
return Number.isFinite(height) ? height : null;
|
||||
},
|
||||
sampleHeight(points, { mostDetailed = false, against = 'surface' } = {}) {
|
||||
surfacesAsked.push(against);
|
||||
if (
|
||||
!mostDetailed ||
|
||||
typeof scene().sampleHeightMostDetailed !== 'function'
|
||||
)
|
||||
return Promise.resolve(points.map(() => null));
|
||||
// Answered as soon as the scene's read lands, as the adapter does.
|
||||
return scene()
|
||||
.sampleHeightMostDetailed(points.map(cartographic))
|
||||
.then((sampled) =>
|
||||
(sampled || []).map((position) =>
|
||||
Number.isFinite(position?.height)
|
||||
? {
|
||||
height: position.height,
|
||||
confidence: 1,
|
||||
source: 'tiles',
|
||||
lod: 'finest',
|
||||
}
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function fixture(
|
||||
t,
|
||||
{ bridgeAllowed = true, record = RECORD, aircraftInfo = null } = {},
|
||||
@@ -116,7 +170,6 @@ function fixture(
|
||||
// Each placed camera: where it is and where it looks.
|
||||
const shots = [];
|
||||
const viewer = {
|
||||
trackedEntity: undefined,
|
||||
clock: { currentTime: null },
|
||||
camera: {
|
||||
cancelFlight() {},
|
||||
@@ -143,6 +196,11 @@ function fixture(
|
||||
const disableFlights = () => {
|
||||
flightsEnabled = false;
|
||||
};
|
||||
// The Cockpit drives the camera, reads frames and queries the scene
|
||||
// through ports: the Cesium camera port over the fake camera, and a query
|
||||
// that answers from the test's scene (`sceneQuery`).
|
||||
const ports = fakeScenePorts(viewer);
|
||||
bindFakeCesiumCamera(viewer, { ...ports, query: sceneQuery(viewer, ports) });
|
||||
const cockpit = new CockpitViewController(viewer, {
|
||||
services: {
|
||||
flightsLayer: {
|
||||
@@ -397,10 +455,10 @@ test('tracking an aircraft from the bridge ends it without refocusing the vessel
|
||||
const { cockpit, viewer, vessels, aircraft } = fixture(t);
|
||||
cockpit.enter();
|
||||
await settle();
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
cockpit.update();
|
||||
assert.equal(cockpit.active, false);
|
||||
assert.equal(viewer.trackedEntity, aircraft, 'the aircraft keeps tracking');
|
||||
assert.equal(followedEntity(viewer), aircraft, 'the aircraft keeps tracking');
|
||||
assert.equal(aircraft.show, true, 'the aircraft was never adopted');
|
||||
assert.deepEqual(vessels.calls, [
|
||||
['subject', RECORD.id],
|
||||
@@ -408,6 +466,18 @@ test('tracking an aircraft from the bridge ends it without refocusing the vessel
|
||||
]);
|
||||
});
|
||||
|
||||
test('following a satellite or a site from the bridge ends it too', async (t) => {
|
||||
const { cockpit, viewer, vessels } = fixture(t);
|
||||
cockpit.enter();
|
||||
await settle();
|
||||
// A satellite's or an installation's follow carrier has no position of
|
||||
// its own (the camera reads the follow target's).
|
||||
followEntity(viewer, { id: 'satellites:25544', noradId: 25544 });
|
||||
cockpit.update();
|
||||
assert.equal(cockpit.active, false);
|
||||
assert.deepEqual(vessels.calls.at(-1), ['subject', null]);
|
||||
});
|
||||
|
||||
test('a vessel that leaves the selection ends the bridge', async (t) => {
|
||||
const { cockpit, vessels } = fixture(t);
|
||||
cockpit.enter();
|
||||
@@ -443,7 +513,7 @@ test("turning off the ridden aircraft's layer ends the cockpit", async (t) => {
|
||||
const { cockpit, viewer, aircraft, disableFlights } = fixture(t, {
|
||||
aircraftInfo,
|
||||
});
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
assert.equal(cockpit.enter({ kind: 'aircraft' }), true);
|
||||
await settle();
|
||||
cockpit.update();
|
||||
@@ -846,7 +916,7 @@ test('arrows do nothing new in an aircraft cockpit', async (t) => {
|
||||
const { cockpit, viewer, aircraft, shots, store } = fixture(t, {
|
||||
aircraftInfo,
|
||||
});
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
assert.equal(cockpit.enter({ kind: 'aircraft' }), true);
|
||||
await settle();
|
||||
assert.equal(cockpit.subjectKind, 'aircraft');
|
||||
@@ -867,7 +937,7 @@ test('arrows do nothing new in an aircraft cockpit', async (t) => {
|
||||
near(after.pitchDeg, before.pitchDeg, 'the aircraft pitch', 1e-6);
|
||||
assert.deepEqual(cockpit.lookTarget, { yawDeg: 0, pitchDeg: -2 });
|
||||
assert.equal(store.instruments.look.offset, false);
|
||||
assert.equal(document.querySelector('.cockpit-look'), null);
|
||||
assert.equal(document.querySelector('.cockpit-look') === null, true);
|
||||
// The tape stays on the aircraft's heading, with no bow or stern marks.
|
||||
const centre = store.instruments.compass.find(
|
||||
(division) => division.slot === 0,
|
||||
@@ -877,7 +947,7 @@ test('arrows do nothing new in an aircraft cockpit', async (t) => {
|
||||
prograde: null,
|
||||
retrograde: null,
|
||||
});
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker'), null);
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker') === null, true);
|
||||
assert.doesNotMatch(
|
||||
document.querySelector('.cockpit-help').textContent,
|
||||
/ARROWS LOOK/,
|
||||
@@ -896,7 +966,7 @@ test('C neither enters nor leaves an aircraft cockpit', async (t) => {
|
||||
onGround: false,
|
||||
};
|
||||
const { cockpit, viewer, aircraft } = fixture(t, { aircraftInfo });
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
const outside = press(cockpit, 'c');
|
||||
await settle();
|
||||
assert.equal(cockpit.active, false, 'C does not enter');
|
||||
@@ -934,6 +1004,7 @@ test('a bridge on a river above sea level rides the water, not the geoid', async
|
||||
clock.set(START_MS);
|
||||
const record = { ...RECORD, lastPositionEpoch: START_MS / 1000 };
|
||||
const river = fixture(t, { record });
|
||||
surfacesAsked.length = 0;
|
||||
const probed = [];
|
||||
// The ship's own model reads 40 m; the ring finds the river at 27 m and
|
||||
// a quay at 33 m.
|
||||
@@ -957,6 +1028,10 @@ test('a bridge on a river above sea level rides the water, not the geoid', async
|
||||
0.5,
|
||||
);
|
||||
assert.equal(probed[0], 9, 'the ship and eight probes around it');
|
||||
// The drawn surface, the globe's terrain included, as the scene's own
|
||||
// sample read it.
|
||||
assert.ok(surfacesAsked.length > 0);
|
||||
assert.deepEqual([...new Set(surfacesAsked)], ['surface']);
|
||||
const reads = probed.length;
|
||||
frames(river.cockpit, clock, river.shots, 20);
|
||||
await settle();
|
||||
@@ -1288,7 +1363,7 @@ test('a ship with neither heading nor course makes up no direction', async (t) =
|
||||
prograde: null,
|
||||
retrograde: null,
|
||||
});
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker'), null);
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker') === null, true);
|
||||
assert.match(
|
||||
$('.cockpit-visor-status-right').textContent,
|
||||
/NO HEADING · AIS/,
|
||||
@@ -1544,7 +1619,7 @@ test('a followed aircraft keeps its own double-click hit area', async (t) => {
|
||||
onGround: false,
|
||||
};
|
||||
const { cockpit, viewer, aircraft } = fixture(t, { aircraftInfo });
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
heightSensitiveProjection(viewer);
|
||||
// Drawn at (400, -2700) as the press begins, at (600, -2700) by the
|
||||
// double-click: a click there is not on the aircraft.
|
||||
@@ -1570,7 +1645,7 @@ test("a ship's double-click memory does not carry over to an aircraft followed s
|
||||
// The press finds the ship at (400, 300).
|
||||
cockpit.onScenePointerDown(1000);
|
||||
// Within the memory, an aircraft is followed, drawn elsewhere.
|
||||
viewer.trackedEntity = aircraft;
|
||||
followEntity(viewer, aircraft);
|
||||
heightSensitiveProjection(viewer, { x: 900 });
|
||||
assert.equal(cockpit.onSceneDoubleClick({ x: 400, y: 300 }, 1250), false);
|
||||
assert.equal(cockpit.active, false);
|
||||
|
||||
Reference in new issue
Block a user