fix(cockpit): a new ride's TRACK ACQUIRED keeps its own time; an arrow during the ease back tilts on from the view; a site beyond the reach ends a focus; the horizon uses the WGS84 surface normal; a hop to the opposite side goes round the Earth; drop the unused in-frame listing

This commit is contained in:
Sameh Khamis committed 2026-11-08 17:12:04 -08:00
1 parent 7d6314b981
commit 6be8af17f1
10 files changed
+142 -170

No files matched your search

+23 -35
View File
@@ -10,10 +10,7 @@
*/
import * as Cesium from 'cesium';
import { clampOrbitalLook, easeLook } from '../cockpitLook.js';
import {
ORBITAL_EARTH_RADIUS_M,
offNadirOrientation,
} from '../cockpitOrbital.js';
import { ORBITAL_EARTH_RADIUS_M } from '../cockpitOrbital.js';
import {
easeFocusRemainder,
focusEaseDtMs,
@@ -181,8 +178,12 @@ function startFocus(site) {
export function releaseOrbitalFocus({ handOver = false } = {}) {
const state = this.orbital;
if (!state?.focus) {
// An arrow during the ease back takes the arrows' own clock again.
if (handOver && state) state.focusReleasing = false;
// An arrow during the ease back takes the arrows' own clock again and
// tilts on from where the view is, not from the nadir it was easing to.
if (handOver && state?.focusReleasing) {
state.lookTarget = clampOrbitalLook(state.lookView);
state.focusReleasing = false;
}
return false;
}
state.focus = null;
@@ -249,8 +250,7 @@ export function onOrbitalClick(position) {
if (site) {
if (state.focus?.key === String(site.id)) return true;
if (startFocus.call(this, site)) return true;
// A mapped site beyond the reach leaves the view as it is.
return false;
// A mapped site beyond the reach is a click elsewhere: the focus ends.
}
releaseOrbitalFocus.call(this);
return false;
@@ -283,8 +283,9 @@ export function routeSceneClick() {
/**
* The orbital view's look for one frame, while a focus holds or is ending.
* A held focus aims at its target: the live look plus whatever is left of
* the turn onto it. The focus ends, easing back, when its site is gone (its
* layer off, the site no longer loaded) or beyond the reach. Also rebuilds
* the turn onto it. The focus ends, easing back, when its layer is turned
* off or its site is beyond the reach (a site the layer stops loading is
* held from its last record). Also rebuilds
* the orbital Live Signals rows on their own clock.
* @param {object} state The orbital session.
* @param {{direction: object, up: object, right: object}} nadir This
@@ -389,9 +390,8 @@ export function orbitalFocusReadout() {
* with the layer off.
* @param {{latitude: number, longitude: number, altitudeM: number}} info
* The ridden satellite.
* @returns {{count: number, entries: Array<{site: object,
* offNadirDeg: number, focused: boolean}>}} `count` also counts sites in
* the frame but beyond the reach.
* @returns {{entries: Array<{site: object, offNadirDeg: number,
* focused: boolean}>}}
*/
export function orbitalSitesInReach(info) {
const state = this.orbital;
@@ -401,9 +401,9 @@ export function orbitalSitesInReach(info) {
// then, and no row is left to focus from.
if (state && !sitesLayerOn(this)) state.listedSites = new Map();
if (!frame || typeof layer?.getNearby !== 'function' || !sitesLayerOn(this))
return { count: 0, entries: [] };
return { entries: [] };
if (!Number.isFinite(info?.latitude) || !Number.isFinite(info?.longitude))
return { count: 0, entries: [] };
return { entries: [] };
const rangeM = reachGroundRangeM(info.altitudeM);
let sites = [];
try {
@@ -449,27 +449,15 @@ export function orbitalSitesInReach(info) {
seenMs: nowMs,
});
state.listedSites = remembered;
const frustum = this.viewer.camera?.frustum;
const reach = pointsInReach(candidates, {
nadir: frame.nadir,
view: offNadirOrientation(frame.nadir, {
northDeg: state.lookView.pitchDeg,
eastDeg: state.lookView.yawDeg,
}),
satellite: frame.position,
verticalFovRad: state.verticalFov,
aspect: Number.isFinite(frustum?.aspectRatio) ? frustum.aspectRatio : 1,
max: Infinity,
});
const focusKey = state.focus?.key ?? null;
return {
count: reach.count,
entries: reach.entries
.filter((entry) => entry.reachable)
.map(({ key, offNadirDeg }) => ({
site: byId.get(key),
offNadirDeg,
focused: key === focusKey,
})),
entries: pointsInReach(candidates, {
nadir: frame.nadir,
satellite: frame.position,
}).map(({ key, offNadirDeg }) => ({
site: byId.get(key),
offNadirDeg,
focused: key === focusKey,
})),
};
}
+19 -1
View File
@@ -573,9 +573,14 @@ test('a click on a site marker focuses it through the layer; a click elsewhere e
const largest = run(scene, LAND_FRAMES, { drift: 0 });
assert.ok(largest < MAX_TURN_PER_FRAME_DEG);
assert.ok(offNadir(scene.shots.at(-1)) < 1e-6);
// A site beyond the reach is not focused.
// A site beyond the reach is not focused, and ends a focus as a click
// elsewhere does.
scene.click(SITES.far.at);
assert.equal(cockpit.orbital.focus ?? null, null);
scene.click(SITES.alpha.at);
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
scene.click(SITES.far.at);
assert.equal(cockpit.orbital.focus, null);
});
test('a click a tool owns is left alone', async (t) => {
@@ -676,7 +681,12 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
run(scene, 5);
const before = Cesium.Cartesian3.clone(scene.shots.at(-1).destination);
const firstTrack = cockpit.signalItems.find((item) => item.key === 'track');
firstTrack.timestamp -= 60_000;
satelliteRow(scene, 49260).click();
const newTrack = cockpit.signalItems.filter((item) => item.key === 'track');
assert.equal(newTrack.length, 1);
assert.ok(newTrack[0].timestamp > firstTrack.timestamp, 'the new ride’s own time');
assert.deepEqual(satellites.calls.slice(-2), [['track', 49260], ['subject', 49260]]);
assert.equal(viewer.trackedEntity, undefined, 'the Cockpit keeps the camera');
assert.equal(cockpit.subjectId, 49260);
@@ -793,6 +803,8 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
scene.click(EMPTY_GROUND);
scene.frame();
assert.equal(cockpit.orbital.focusReleasing, true);
const view = { ...cockpit.orbital.lookView };
assert.ok(Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1, 'still turned');
cockpit.onKeyDown({
key: 'ArrowUp',
target: document.body,
@@ -800,6 +812,12 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
stopImmediatePropagation() {},
});
assert.equal(cockpit.orbital.focusReleasing, false);
// The arrow tilts on from where the view is, not from nadir.
assert.ok(
Math.abs(cockpit.orbital.lookTarget.yawDeg - view.yawDeg) < 1e-6,
'across kept',
);
assert.ok(cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg, 'tilted on up');
});
test('leaving orbit leaves no orbital rows to act on', async (t) => {
+3
View File
@@ -150,6 +150,9 @@ export function switchOrbitalSatellite(noradId) {
this.lastHudUpdateMs = 0;
this.lastContextUpdateMs = 0;
this.dispatchCockpitModeChanged(true, info);
// The new satellite's TRACK ACQUIRED replaces the old one, time and all.
this.signalItems = this.signalItems.filter((item) => item.key !== 'track');
this.signalSignatures.delete('track');
this.pushCockpitSignal(
'track',
'track',