mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Merge main into denis/iss-live-telemetry
Conflicts: the locale catalogs, package boundaries and format scope are three-way merges (entries main removed, such as displayPanelScroll.js, stay removed); applicationShell.js and ContextView.vue keep main's Space Missions panel and the STATION and LIVE wiring, moved back into _initGlobalContextPanel; installations take main's feedback module, and their label box joins main's card-on-top click rule; ports.test.mjs lists modelParts and modelNodes; CURRENT-STATE.md keeps both edits. zh-Hant is regenerated from zh-CN, as main now requires. "Below" keeps main's translations.
This commit is contained in:
commit
0620d01140
1526 files changed
+52168
-11320
No files matched your search
@@ -8,7 +8,8 @@ export function createInteraction({
|
||||
parts,
|
||||
source,
|
||||
}) {
|
||||
const { resolvePickId, isOwnedByOtherLayer } = services.picking;
|
||||
const { resolvePickId, isOwnedByOtherLayer, isUnderOtherCard } =
|
||||
services.picking;
|
||||
|
||||
function _onKeyDown(e) {
|
||||
// The Cockpit owns Escape while it rides the tracked satellite.
|
||||
@@ -51,6 +52,9 @@ export function createInteraction({
|
||||
// The Cockpit camera rides the tracked satellite: a click on the
|
||||
// picture below must not untrack it or switch satellites.
|
||||
if (parts.cockpit?._cockpitHeld()) return;
|
||||
// Another layer's card or label painted on top takes the click: the item
|
||||
// under it does not act, and the click is not empty space either.
|
||||
if (isUnderOtherCard?.(event)) return;
|
||||
const picked = event.topHit;
|
||||
const hit = event.drawHit;
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createInteraction } from './interaction.js';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
|
||||
// The card or label painted on top takes the click: a satellite under another
|
||||
// layer's card is neither tracked nor let go.
|
||||
test("another layer's card over a satellite keeps the click", (t) => {
|
||||
const previousDocument = globalThis.document;
|
||||
globalThis.document = new EventTarget();
|
||||
let picked = null;
|
||||
const viewer = { scene: { canvas: new EventTarget(), pick: () => picked } };
|
||||
const input = fakeInput(viewer);
|
||||
const calls = [];
|
||||
const state = {
|
||||
_enabled: true,
|
||||
_trackedNorad: null,
|
||||
_clickSubscription: null,
|
||||
_trackedEntityChangedRemove: () => {},
|
||||
_catalog: new Map([[25544, {}]]),
|
||||
};
|
||||
const interaction = createInteraction({
|
||||
state,
|
||||
services: { picking },
|
||||
parts: {
|
||||
rendering: {
|
||||
_hitIsTracked: () => false,
|
||||
_hitPointId: (hit) =>
|
||||
hit?.set === 'satellites:dots' ? Number(hit.id) : null,
|
||||
},
|
||||
tracking: {
|
||||
_cancelPendingTrackingRestore() {},
|
||||
_trackSatellite: (id) => calls.push(['track', id]),
|
||||
_clearTracking: () => calls.push(['clear']),
|
||||
},
|
||||
},
|
||||
});
|
||||
interaction._installClickHandler(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
picking.setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
picking.setClickCardHitTest(null);
|
||||
state._clickSubscription?.();
|
||||
input.destroy();
|
||||
if (previousDocument === undefined) delete globalThis.document;
|
||||
else globalThis.document = previousDocument;
|
||||
});
|
||||
const click = (hit) => {
|
||||
picked = hit ? { id: hit } : null;
|
||||
input.tap({ x: 10, y: 10 });
|
||||
};
|
||||
const dot = { set: 'satellites:dots', id: '25544' };
|
||||
click(dot);
|
||||
assert.deepEqual(calls, [], 'covered: not tracked');
|
||||
state._trackedNorad = 1;
|
||||
click(null);
|
||||
assert.deepEqual(calls, [], 'covered: tracking kept');
|
||||
top = null;
|
||||
click(null);
|
||||
assert.deepEqual(calls, [['clear']], 'open map lets it go');
|
||||
state._trackedNorad = null;
|
||||
click(dot);
|
||||
assert.deepEqual(calls.at(-1), ['track', 25544]);
|
||||
});
|
||||
@@ -271,13 +271,22 @@ test('the rendering part draws the dots, the tracked dot and the rings through t
|
||||
state._enabled = true;
|
||||
state._params = { showPoints: false, showOrbits: false };
|
||||
let at = { x: 10, y: 20, z: 30 };
|
||||
const carrier = rendering._addTrackedEntity({ position: () => at });
|
||||
const issRed = [1, 0.27, 0.27, 1];
|
||||
const carrier = rendering._addTrackedEntity({
|
||||
position: () => at,
|
||||
color: issRed,
|
||||
});
|
||||
assert.deepEqual(carrier, { noradId: 25544 });
|
||||
const tracked = draw.set(points.replace(':points', ':tracked'));
|
||||
assert.equal(tracked.items.size, 0);
|
||||
rendering._preRenderTick({ frame: 3 });
|
||||
assert.deepEqual(tracked.items.get('25544').pos, at);
|
||||
assert.equal(tracked.items.get('25544').pixelSize, 14);
|
||||
assert.deepEqual(
|
||||
tracked.items.get('25544').color,
|
||||
issRed,
|
||||
'the satellite keeps its own colour',
|
||||
);
|
||||
assert.equal(tracked.items.get('25544').disableDepthTest, Infinity);
|
||||
at = { x: 11, y: 21, z: 31 };
|
||||
rendering._preRenderTick({ frame: 4 });
|
||||
|
||||
@@ -34,12 +34,11 @@ const POINT_SCALE_BY_DISTANCE = Object.freeze({
|
||||
});
|
||||
|
||||
/**
|
||||
* The tracked satellite's dot: 14 px yellow with a white outline, drawn
|
||||
* over everything.
|
||||
* The tracked satellite's dot: 14 px in the satellite's own colour with a
|
||||
* white outline, drawn over everything. Tracking never recolours it.
|
||||
*/
|
||||
const TRACKED_DOT = Object.freeze({
|
||||
pixelSize: 14,
|
||||
color: Object.freeze([1, 1, 0, 1]),
|
||||
outlineColor: Object.freeze([1, 1, 1, 1]),
|
||||
outlineWidth: 2,
|
||||
disableDepthTest: Number.POSITIVE_INFINITY,
|
||||
@@ -433,12 +432,13 @@ export function createRendering({
|
||||
/**
|
||||
* Draw the tracked satellite's dot and make the carrier the follow target
|
||||
* and the tracked card read (its entity record holds the card).
|
||||
* @param {{position: () => object, viewFrom: {x: number, y: number,
|
||||
* z: number}}} options `position` is read as the follow camera reads
|
||||
* it, once each frame before the tick moves the sample on.
|
||||
* @param {{position: () => object, color: number[], viewFrom: {x: number,
|
||||
* y: number, z: number}}} options `position` is read as the follow
|
||||
* camera reads it, once each frame before the tick moves the sample on;
|
||||
* `color` is the satellite's own dot colour.
|
||||
* @returns {object} The carrier.
|
||||
*/
|
||||
function _addTrackedEntity({ position }) {
|
||||
function _addTrackedEntity({ position, color }) {
|
||||
const noradId = layerState._trackedNorad;
|
||||
const carrier = { noradId };
|
||||
trackedDot = {
|
||||
@@ -447,6 +447,7 @@ export function createRendering({
|
||||
id: String(noradId),
|
||||
pos: { x: 0, y: 0, z: 0 },
|
||||
...TRACKED_DOT,
|
||||
color,
|
||||
meta: { noradId },
|
||||
},
|
||||
drawn: false,
|
||||
|
||||
@@ -502,6 +502,8 @@ export function createTracking({ state: layerState, services, parts, source }) {
|
||||
|
||||
layerState._trackedEntity = parts.rendering._addTrackedEntity({
|
||||
position: trackedPosition,
|
||||
// Its own dot's colour: tracking never recolours a satellite.
|
||||
color: parts.controls._pointStyleFor(noradId, sat.group).color,
|
||||
viewFrom,
|
||||
});
|
||||
entityRecord(layerState._trackedEntity).selectionOrigin = origin;
|
||||
|
||||
Reference in new issue
Block a user