Fix tone-only signal changes, the first anchor step, row order and emoji widths

- A provider's Live Signals row now changes when only its tone does; fields
  are compared one by one instead of through a joined signature.
- The frame that first sets an inertial subject's anchor puts it on the
  subject, so the view no longer jumps ahead after waiting for the floor.
- The subject HUD drops vanished rows before it adds new ones, so
  TRACK ACQUIRED and a steady warning keep their place.
- Progress labels give astral-plane glyphs such as emoji at least main's
  width, so they are not clipped.
This commit is contained in:
German Khokhlov committed 2026-11-18 14:32:45 +04:00
1 parent c2f73cdc04
commit a72c0ba237
8 files changed
+171 -31

No files matched your search

+5 -2
View File
@@ -459,7 +459,10 @@ function updateSubject(nowMs) {
* Aircraft pass none and look along the heading at the profile pitch.
*/
function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
if (!this.cockpitAnchorValid) {
// The update that first sets the anchor stands it on the target: the time
// before it (an entry, a floor wait) moved nothing, so it has no step.
const anchoring = !this.cockpitAnchorValid;
if (anchoring) {
this.cockpitAnchor = clone(target);
this.cockpitAnchorValid = true;
this.subjectLiftM = null;
@@ -485,7 +488,7 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
: 0;
const groundClamp = info.groundClamp !== false;
if (info.stale || info.anchor === 'exact') {
if (anchoring || info.stale || info.anchor === 'exact') {
// A feed backoff has no authoritative velocity epoch to advance from.
// Hold the cockpit on the exact layer-rendered position so the camera
// cannot coast away while the icon correctly remains fixed.
+8 -9
View File
@@ -256,24 +256,23 @@ function updateSubjectHud(info, nowMs, forceContext) {
this.updateLocalPosition(info);
this.maybeRefreshRegionalBrief(info);
this.showContextCard(false);
const keys = new Set();
const keys = new Set(hud.signals.map(({ id }) => `subject:${id}`));
// Rows the view no longer lists leave first, so new ones take their
// places rather than push a listed one (or TRACK ACQUIRED) off.
for (const key of this.subjectSignalKeys ?? [])
if (!keys.has(key)) this.dropCockpitSignal(key);
this.subjectSignalKeys = keys;
// The view's rows are its current signals: each changes where it stands,
// so a changing one (an ETA) never pushes a steady one off the list.
for (const signal of hud.signals) {
const key = `subject:${signal.id}`;
keys.add(key);
for (const signal of hud.signals)
this.pushCockpitSignal(
key,
`subject:${signal.id}`,
SUBJECT_SIGNAL_TONES[signal.tone] ?? 'info',
signal.title,
signal.detail || signal.title,
null,
{ inPlace: true },
);
}
for (const key of this.subjectSignalKeys ?? [])
if (!keys.has(key)) this.dropCockpitSignal(key);
this.subjectSignalKeys = keys;
}
}
+9 -1
View File
@@ -54,7 +54,15 @@ export function pushCockpitSignal(
{ inPlace = false } = {},
) {
if (!title || !detail) return;
const signature = `${title}|${detail}|${target?.layerId || ''}|${target?.id || ''}`;
// Each field on its own, so no title and detail read as another pair; an
// in-place row also changes with its tone alone.
const signature = JSON.stringify([
title,
detail,
target?.layerId || '',
target?.id || '',
inPlace ? tone : '',
]);
// A locale change words the signal again where it stands.
const shown =
this.rewordingSignals || inPlace
+109
View File
@@ -625,6 +625,55 @@ test('an inertial subject drawn at 5 frames a second stays near its target', asy
);
});
for (const [intervalMs, waitMs] of [
[0, 1000],
[500, 2000],
]) {
test(`an inertial subject's first camera update after a ${waitMs} ms floor wait (interval ${intervalMs} ms) stands on it`, async (t) => {
const startMs = 10_000;
const clock = manualClock(t, startMs);
const SPEED_MPS = 30;
const mPerDegLon = 111_320 * Math.cos(Cesium.Math.toRadians(LAT));
const eastOf = () =>
LON + (SPEED_MPS * (performance.now() - startMs)) / 1000 / mPerDegLon;
const ride = subjectProvider({ cameraIntervalMs: intervalMs });
const base = ride.subject.frame;
ride.subject.frame = () => ({
...base,
heightM: null,
longitude: eastOf(),
speedMps: SPEED_MPS,
anchor: 'inertial',
eye: { ...base.eye, forwardM: 0 },
});
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
setFloor(undefined);
cockpit.syncEntry();
assert.equal(cockpit.enter(), true);
const before = shots.length;
const stepMs = intervalMs || 100;
for (let waited = stepMs; waited < waitMs; waited += stepMs) {
clock.advance(stepMs);
cockpit.update();
}
assert.equal(
shots.length,
before,
'no camera update while the floor is cold',
);
setFloor(FLOOR_M);
clock.advance(stepMs);
cockpit.update();
const shot = Cesium.Cartographic.fromCartesian(shots[before].destination);
const leadM =
(Cesium.Math.toDegrees(shot.longitude) - eastOf()) * mPerDegLon;
assert.ok(
Math.abs(leadM) < 1,
`the first camera update leads the subject by ${leadM.toFixed(2)} m`,
);
});
}
test('an exact anchor sits on the subject, wherever the frame moves it', async (t) => {
const clock = manualClock(t, 10_000);
const ride = subjectProvider();
@@ -1373,3 +1422,63 @@ test('a signal still listed stays in Live Signals while another one changes', as
['subject:doors', 'subject:eta'],
);
});
test('a Live Signals row whose tone alone changes takes the new tone', async (t) => {
const clock = manualClock(t, 10_000);
const ride = subjectProvider();
const { cockpit } = fixture(t, { providers: [ride] });
delete cockpit.pushCockpitSignal;
delete cockpit.dropCockpitSignal;
const hudWith = (tone) => ({
...HUD,
signals: [
{ id: 'doors', tone, title: 'DOORS', detail: 'door fault, car 2' },
],
});
const doorsTone = () =>
cockpit.signalItems.find((row) => row.key === 'subject:doors').tone;
ride.subject.hud = hudWith('normal');
cockpit.syncEntry();
assert.equal(cockpit.enter(), true);
const tones = [doorsTone()];
for (const tone of ['warning', 'normal']) {
ride.subject.hud = hudWith(tone);
clock.advance(1000);
cockpit.update();
tones.push(doorsTone());
}
assert.deepEqual(tones, ['info', 'warning', 'info']);
});
test('rows a HUD view replaces leave before new ones push a listed one off', async (t) => {
const clock = manualClock(t, 10_000);
const ride = subjectProvider();
const { cockpit } = fixture(t, { providers: [ride] });
delete cockpit.pushCockpitSignal;
delete cockpit.dropCockpitSignal;
const row = (id, tone) => ({
id,
tone,
title: id.toUpperCase(),
detail: `row ${id}`,
});
ride.subject.hud = {
...HUD,
signals: [row('w', 'warning'), row('a'), row('b'), row('c')],
};
cockpit.syncEntry();
assert.equal(cockpit.enter(), true);
assert.ok(cockpit.signalItems.some((item) => item.key === 'track'));
ride.subject.hud = {
...HUD,
signals: [row('w', 'warning'), row('a'), row('d'), row('e')],
};
clock.advance(1000);
cockpit.update();
const keys = cockpit.signalItems.map((item) => item.key);
assert.deepEqual(
[...keys].sort(),
['subject:a', 'subject:d', 'subject:e', 'subject:w', 'track'],
`rows right after the change: ${keys.join(', ')}`,
);
});