The renderer seam: clicks go to the newest tool, recession and display groups through the contract, drawing at parity with Cesium

- Clicks: when two tools want the globe's clicks, the newest takes them and the older is told and turns itself off; a click is decided when it arrives, and ambient selection fires only when no tool holds the pointer. The "map is busy" paths and their strings are removed.
- Recession: the limb fade is shared (src/render/recession.js) and reaches icon and model sets through SetSpec.recede; tuning applies on the next frame.
- Display panel groups are published through src/ui/displayGroups.js; the Weather group and src/viewWeather.js are removed.
- Draw port: a set whose icons only move is moved in place, and models that did not change are not restyled each frame, so moving fleets cost what they did when drawn directly; an untinted, fully opaque model is drawn without a colour.
- Conformance: input.lease.lost checks the new lease inside onLost and reports a throwing onLost; draw.sets.recede covers model sets.
- QA scripts read the renderer host instead of internals the seam replaced.
This commit is contained in:
Sameh Khamis committed 2026-11-15 17:03:09 -08:00
1 parent a0d299523d
commit 0ab31d4fb8
130 files changed
+5438 -1674

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
/** A row of a group an application adds to the Display panel. */
export type DisplayGroupRow =
| {
kind: 'toggle';
id: string;
label: string;
icon?: string;
title?: string;
checked: boolean;
onChange(checked: boolean): void;
}
| {
kind: 'slider';
id: string;
label: string;
min: number;
max: number;
/** Shown in percent. */
value: number;
onChange(value: number): void;
}
| { kind: 'note'; id: string; text: string };
/**
* Show the group `id` on the page's Display panel, under Effects, in place
* where it is shown already; null takes it away.
*/
export function publishDisplayGroup(
id: string,
group: { rows: DisplayGroupRow[] } | null,
): void;
+20
View File
@@ -0,0 +1,20 @@
/**
* Groups of controls an application adds to the Display panel, under
* Effects: toggles, sliders and notes it describes and answers itself.
*/
import { applicationPinia } from './vueRuntime.js';
import { useDisplayStore } from './stores/display.js';
/**
* Show the group `id` on the page's Display panel as `group` describes it,
* in place where it is shown already; null takes it away. A row is a
* `toggle` (`{kind, id, label, icon?, title?, checked, onChange(checked)}`),
* a `slider` (`{kind, id, label, min, max, value, onChange(value)}`, its
* value shown in percent) or a `note` (`{kind, id, text}`). Publish it again
* whenever what it shows changes.
* @param {string} id
* @param {?{rows: object[]}} group
*/
export function publishDisplayGroup(id, group) {
useDisplayStore(applicationPinia()).publishGroup(id, group);
}
+20
View File
@@ -0,0 +1,20 @@
// src/ui/displayGroups.test.mjs — an application's groups reach the Display
// panel's store on the page's Pinia.
import test from 'node:test';
import assert from 'node:assert/strict';
import { publishDisplayGroup } from './displayGroups.js';
import { useDisplayStore } from './stores/display.js';
import { applicationPinia } from './vueRuntime.js';
test('publishDisplayGroup shows a group on the page’s Display panel, and takes it away', () => {
const store = useDisplayStore(applicationPinia());
publishDisplayGroup('conditions', {
rows: [{ kind: 'note', id: 'status', text: 'Nothing here' }],
});
assert.deepEqual(
store.groups.map((g) => [g.id, g.rows.length]),
[['conditions', 1]],
);
publishDisplayGroup('conditions', null);
assert.deepEqual(store.groups, []);
});
+41
View File
@@ -802,3 +802,44 @@ test('the real portal lays out once the groups have moved and puts back the focu
await nextTick();
assert.deepEqual(layouts, [true]);
});
test('a group an application adds to Effects shows its toggles, notes and sliders, and goes', async (t) => {
const { store, $ } = fixture(t);
const changes = [];
store.publishGroup('conditions', {
rows: [
{
kind: 'toggle',
id: 'live',
icon: 'partly_cloudy_day',
label: 'Live',
title: 'Live conditions',
checked: true,
onChange: (on) => changes.push(['live', on]),
},
{ kind: 'note', id: 'status', text: 'Nothing here' },
{
kind: 'slider',
id: 'level',
label: 'Level',
min: 0,
max: 100,
value: 40,
onChange: (value) => changes.push(['level', value]),
},
],
});
await nextTick();
const toggle = $('conditions-live-toggle');
assert.ok(toggle, 'its toggle is drawn');
assert.equal(toggle.checked, true);
assert.equal(toggle.closest('label').title, 'Live conditions');
assert.equal($('conditions-status').textContent.trim(), 'Nothing here');
assert.equal($('conditions-level-value').textContent.trim(), '40%');
toggle.checked = false;
toggle.dispatchEvent(new Event('change'));
assert.deepEqual(changes, [['live', false]]);
store.publishGroup('conditions', null);
await nextTick();
assert.equal($('conditions-group'), null, 'gone once removed');
});
+16 -17
View File
@@ -1,16 +1,13 @@
/**
* Box selection for the Recent Imagery layer: press on the world, drag, and
* release to hand the layer a degrees box. Follows the draw tool's ownership
* rules — the pointer is claimed for the session, the viewer's own click
* actions are suppressed and given back, and `destroy()` returns everything —
* and holds the camera only while a drag is in progress.
* rules — the pointer is claimed for the session (a newer claim cancels it),
* the viewer's own click actions are suppressed and given back, and
* `destroy()` returns everything — and holds the camera only while a drag is
* in progress.
*/
import { pickWorldFromScreen } from '../annotations/annotationResolver.js';
import {
claimPointer,
pointerOwner,
releasePointer,
} from '../data/inputOwnership.js';
import { claimPointer, releasePointer } from '../data/inputOwnership.js';
import { inputFor as defaultInputFor } from '../input/dispatcher.js';
import { validateBox } from '../layers/recentImagery/model.js';
import { createImageryBoxPreview } from '../layers/recentImagery/rendering.js';
@@ -154,14 +151,16 @@ export function initImageryBoxTool({
function setActive(next) {
if (next === active) return active;
if (next) {
lease = claimPointer(IMAGERY_BOX_POINTER_OWNER);
if (!lease) {
onCancel?.(
'pointer-busy',
`${pointerOwner()} is using the pointer — close it first`,
);
return active;
}
// The newest claim takes over: a tool holding the pointer is told and
// turns itself off, and a newer one cancels this session as if the
// person had.
const claimed = claimPointer(IMAGERY_BOX_POINTER_OWNER, {
onLost: () => {
if (lease === claimed) cancel();
},
});
if (!claimed) return active;
lease = claimed;
active = true;
bindScene();
} else {
@@ -182,7 +181,7 @@ export function initImageryBoxTool({
}
return {
/** Begin a box session. False when the pointer is held elsewhere. */
/** Begin a box session, taking the pointer from any tool holding it. */
start() {
return !destroyed && setActive(true);
},
+25 -6
View File
@@ -160,17 +160,36 @@ test('an Escape interceptor that claims the key leaves the tool armed; the next
await f.tool.destroy();
});
test('a held pointer refuses the session and nothing is borrowed', async () => {
test('a session takes the pointer from another tool, which is told', async () => {
const f = fixture();
let lost = 0;
claimPointer('draw', { onLost: () => (lost += 1) });
assert.equal(f.tool.start(), true);
assert.equal(pointerOwner(), IMAGERY_BOX_POINTER_OWNER);
assert.equal(lost, 1);
assert.deepEqual(f.cancels, []);
await f.tool.destroy();
});
test('a newer tool taking the pointer mid-drag cancels the session and returns everything', async () => {
const f = fixture();
f.tool.start();
f.fire('LEFT_DOWN', { position: { x: 250, y: 125 } });
f.fire('MOUSE_MOVE', { endPosition: { x: 500, y: 250 } });
assert.equal(f.camera.enableInputs, false);
const lease = claimPointer('draw');
assert.equal(f.tool.start(), false);
assert.deepEqual(f.cancels, [
['pointer-busy', 'draw is using the pointer — close it first'],
]);
assert.equal(f.tool.isActive(), false);
assert.deepEqual(f.cancels, [['cancel', undefined]], 'as if cancelled');
assert.deepEqual(f.actives, [true, false]);
assert.equal(f.camera.enableInputs, true, 'the camera is back');
assert.equal(f.preview(), false, 'no box is left on the globe');
assert.equal(f.stockAction('LEFT_CLICK'), f.originalClick);
assert.equal(f.bound(), false);
assert.equal(f.documentRef.classes.has('gev-imagery-box'), false);
assert.equal(pointerOwner(), 'draw', 'the newer tool keeps it');
f.fire('LEFT_UP', { position: { x: 500, y: 250 } });
assert.deepEqual(f.boxes, [], 'the drag it ended hands over no box');
releasePointer(lease);
assert.equal(f.tool.start(), true);
await f.tool.destroy();
});
-1
View File
@@ -119,7 +119,6 @@ export class LayerBindings {
this.runImmediateNavigation('route', navigate),
floorFn: (lat, lon) => this.services.cachedGroundFloor(lat, lon),
warmFn: (cells) => this.services.warmGroundFloor(cells),
showToast: (message) => this._showToast(message),
});
}
-7
View File
@@ -26,7 +26,6 @@ import {
} from '../layers/recentImagery/model.js';
import { displayDay, displayMetres } from '../layers/recentImagery/display.js';
import { formatQuantity } from './unitLabels.js';
import { pointerOwnerName } from '../data/pointerOwnerNames.js';
import { canvasOf, findFrame, findGlobe } from '../render/rendererOf.js';
const PANEL_ID = 'recent-imagery-panel';
@@ -50,7 +49,6 @@ const LAYER_NOTICES = new Set([
// imageryBoxTool.js); fixed refusals there are msg() text for translateKnown.
const TOO_LARGE = /^(Box|View) is ([\d,]+) km wide · limit ([\d,]+) km$/;
const POLAR = /^Imagery stops at ±([\d.]+)° latitude$/;
const POINTER_BUSY = /^(.+) is using the pointer — close it first$/;
/**
* The notice line in the UI language: notices and box refusals arrive in
@@ -69,11 +67,6 @@ export function localizeNotice(text) {
maximumFractionDigits: 2,
}),
});
const busy = POINTER_BUSY.exec(text);
if (busy)
return t('{owner} is using the pointer — close it first', {
owner: translateKnown(pointerOwnerName(busy[1])),
});
const tooLarge = TOO_LARGE.exec(text);
if (!tooLarge) return translateKnown(text);
const values = {
+1 -56
View File
@@ -10,7 +10,6 @@ import { localizeNotice } from './recentImagery.js';
const REFUSALS = [
'Drag to size the box', // imageryBoxTool.js, click without drag
'Press on the ground, not the sky', // imageryBoxTool.js
'draw is using the pointer — close it first', // imageryBoxTool.js, pointer busy
'Point the camera at the ground to use the view', // layers/recentImagery/index.js
'That point cannot anchor a box', // layers/recentImagery/index.js
...[
@@ -26,62 +25,12 @@ const REFUSALS = [
}),
];
// The pointer-busy refusal names the owner by its internal id; the notice
// shows the tool's name instead, in English too.
const SHOWN_EN = new Map([
[
'draw is using the pointer — close it first',
'Draw is using the pointer — close it first',
],
]);
test('en: refusals stay English', () => {
setLocale('en');
for (const text of REFUSALS)
assert.equal(localizeNotice(text), SHOWN_EN.get(text) ?? text);
for (const text of REFUSALS) assert.equal(localizeNotice(text), text);
assert.ok(REFUSALS.includes('Imagery stops at ±85.05° latitude'));
});
test('E3/E12: the pointer owner is named by its tool, never by its id', () => {
const owners = {
en: {
draw: 'Draw',
directions: 'Directions',
'recent-imagery-box': 'Recent imagery',
},
ru: {
draw: 'Рисование',
directions: 'Маршруты',
'recent-imagery-box': 'Свежие снимки',
},
es: {
draw: 'Dibujo',
directions: 'Indicaciones',
'recent-imagery-box': 'Imágenes recientes',
},
};
try {
for (const [locale, names] of Object.entries(owners)) {
setLocale(locale);
for (const [id, name] of Object.entries(names)) {
const shown = localizeNotice(
`${id} is using the pointer — close it first`,
);
assert.ok(shown.includes(name), `${locale} ${id}: ${shown}`);
assert.ok(!shown.includes(id), `${locale} ${id} leaked: ${shown}`);
}
}
setLocale('en');
assert.equal(
localizeNotice('measure is using the pointer — close it first'),
'measure is using the pointer — close it first',
'an unregistered owner falls back to its id',
);
} finally {
setLocale('en');
}
});
for (const locale of ['es', 'ru']) {
test(`${locale}: box-tool and model refusals are translated`, () => {
setLocale(locale);
@@ -92,10 +41,6 @@ for (const locale of ['es', 'ru']) {
localizeNotice('Imagery stops at ±85.05° latitude'),
/85,05/,
);
assert.doesNotMatch(
localizeNotice('draw is using the pointer — close it first'),
/\bdraw\b/,
);
} finally {
setLocale('en');
}
+3 -1
View File
@@ -168,10 +168,12 @@ for (const offset of [
reference.lookAtTransform(reference.transform, goal);
const viewer = following(start);
// The camera port's own listeners stay; the offset's goes on arrival.
const own = viewer.scene.preUpdate.numberOfListeners;
applyShareFollowOffset(viewer, followedOf(viewer), offset);
viewer.scene.preUpdate.raiseEvent();
viewer.scene.preUpdate.raiseEvent();
assert.equal(viewer.scene.preUpdate.numberOfListeners, 0, 'it arrives');
assert.equal(viewer.scene.preUpdate.numberOfListeners, own, 'it arrives');
samePose(snapshot(viewer.camera), snapshot(reference));
});
+8 -5
View File
@@ -643,16 +643,18 @@ test('a shared offset on the far side swings round, never jumping through the en
followIn(viewer, entity);
// Looking south at the nose: the opposite side of the app's framing.
const offset = { range: 5800, heading: 180, pitch: -35 };
// The camera port's own listeners stay; the offset's is the one added.
const own = listeners.length;
applyShareFollowOffset(viewer, followedOf(viewer), offset);
let previous = viewer.camera.position;
for (let frame = 0; frame < 10 && listeners.length; frame += 1) {
listeners[0]();
for (let frame = 0; frame < 10 && listeners.length > own; frame += 1) {
listeners[own]();
const now = viewer.camera.position;
// The follow's guard treats a turn of 90° or more as a crossing.
assert.ok(Cesium.Cartesian3.angleBetween(previous, now) < Math.PI / 2);
previous = now;
}
assert.equal(listeners.length, 0, 'it arrives');
assert.equal(listeners.length, own, 'it arrives');
assert.ok(looks.length >= 2, `${looks.length} steps`);
const expected = followOffsetToEnu(offset);
const last = looks.at(-1);
@@ -676,9 +678,10 @@ test('applying a follow offset gives up when the follow ends', () => {
camera: {},
};
bindFakeCesiumCamera(viewer, { frame: preUpdateFrame(viewer) });
const own = listeners.length;
applyShareFollowOffset(viewer, {}, OFFSET);
listeners[0]();
assert.equal(listeners.length, 0);
listeners[own]();
assert.equal(listeners.length, own);
});
test('long links and hash navigation are unaffected by a share code start', async (t) => {
+26 -8
View File
@@ -29,14 +29,32 @@ export const useDisplayStore = defineStore('gev-display', () => {
}
/**
* The Weather group, `{live, status, values}` (values in percent by
* condition); null where the renderer draws no weather.
* The groups an application adds under Effects, in the order first
* published: each `{id, rows}`. A row is a `toggle` (`{kind, id, label,
* icon?, title?, checked, onChange(checked)}`), a `slider` (`{kind, id,
* label, min, max, value, onChange(value)}`, its value shown in percent)
* or a `note` (`{kind, id, text}`).
*/
const weather = shallowRef(null);
const groups = shallowRef([]);
/** @param {?object} next A fresh presentation of the Weather group. */
function publishWeather(next) {
weather.value = next && markRaw(next);
/**
* Show the group `id` as `group` describes it, in place where it is shown
* already; null takes it away.
* @param {string} id
* @param {?{rows: object[]}} group
*/
function publishGroup(id, group) {
const at = groups.value.findIndex((g) => g.id === id);
const next = [...groups.value];
if (!group) {
if (at < 0) return;
next.splice(at, 1);
} else {
const shown = markRaw({ id, rows: [...(group.rows ?? [])] });
if (at < 0) next.push(shown);
else next[at] = shown;
}
groups.value = next;
}
/**
@@ -130,8 +148,8 @@ export const useDisplayStore = defineStore('gev-display', () => {
publish,
models3d,
publishModels3d,
weather,
publishWeather,
groups,
publishGroup,
sky,
publishSky,
draw,
+18 -22
View File
@@ -19,7 +19,7 @@ import VisualPresets from './VisualPresets.vue';
// and each publishes them; until they do, the panel shows its initial markup.
// Draw and Import live in UTILITIES (LayerPanelsView).
const display = useDisplayStore();
const { view, models3d, parameters, cockpitPortal, weather, sky } = storeToRefs(display);
const { view, models3d, parameters, cockpitPortal, groups, sky } = storeToRefs(display);
// A control's change goes to its owner (DisplayBindings).
const act = (name, ...args) => display.act(name, ...args);
const pct = (value) => `${value}%`;
@@ -44,12 +44,6 @@ const celestialTitle = computed(() =>
? t('Celestial ring — available in Normal style')
: t('Celestial ring — reveal the full globe'),
);
const weatherRows = computed(() => [
{ key: 'clouds', label: t('Clouds') },
{ key: 'fog', label: t('Fog') },
{ key: 'rain', label: t('Rain') },
{ key: 'snow', label: t('Snow') },
]);
const skyRows = computed(() => [
{ key: 'atmosphere', label: t('Atmosphere'), icon: 'public' },
{ key: 'lighting', label: t('Day and night'), icon: 'adjust' },
@@ -223,21 +217,23 @@ const allocationOptions = computed(() => [
<span class="pp-slider-value">{{ pct(sky.milkyWay) }}</span>
</div>
</div>
<!-- Weather: only where the renderer draws it. -->
<div v-if="weather" class="pp-toggle-group" id="weather-group">
<label class="pp-toggle-btn pp-scope-toggle" :title="t('Live weather: the conditions under the camera')">
<span class="pp-icon material-symbols-outlined" aria-hidden="true">partly_cloudy_day</span>
<span class="pp-label">{{ t('Weather') }} · {{ t('Live') }}</span>
<input type="checkbox" id="weather-live-toggle" @change="act('setWeatherLive', $event.target.checked)" :checked="weather.live" />
</label>
<div v-if="weather.live && weather.status === 'unavailable'" class="pp-slider-row visible" id="weather-status">
<span class="pp-slider-mini-label">{{ t('No weather report here') }}</span>
</div>
<div v-for="row in weatherRows" :key="row.key" class="pp-slider-row visible" :id="`weather-${row.key}-row`">
<span class="pp-slider-mini-label">{{ row.label }}</span>
<UiSlider class="pp-slider" :id="`weather-${row.key}-slider`" @update:model-value="act('setWeatherValue', row.key, $event)" min="0" max="100" :model-value="weather.values[row.key] ?? 0" :aria-label="row.label" />
<span class="pp-slider-value">{{ pct(weather.values[row.key] ?? 0) }}</span>
</div>
<!-- Groups the application adds (store `publishGroup`). -->
<div v-for="group in groups" :key="group.id" class="pp-toggle-group" :id="`${group.id}-group`">
<template v-for="row in group.rows" :key="row.id">
<label v-if="row.kind === 'toggle'" class="pp-toggle-btn pp-scope-toggle" :title="row.title">
<span v-if="row.icon" class="pp-icon material-symbols-outlined" aria-hidden="true">{{ row.icon }}</span>
<span class="pp-label">{{ row.label }}</span>
<input type="checkbox" :id="`${group.id}-${row.id}-toggle`" @change="row.onChange?.($event.target.checked)" :checked="row.checked" />
</label>
<div v-else-if="row.kind === 'note'" class="pp-slider-row visible" :id="`${group.id}-${row.id}`">
<span class="pp-slider-mini-label">{{ row.text }}</span>
</div>
<div v-else-if="row.kind === 'slider'" class="pp-slider-row visible" :id="`${group.id}-${row.id}-row`">
<span class="pp-slider-mini-label">{{ row.label }}</span>
<UiSlider class="pp-slider" :id="`${group.id}-${row.id}-slider`" @update:model-value="row.onChange?.($event)" :min="String(row.min)" :max="String(row.max)" :model-value="row.value" :aria-label="row.label" />
<span class="pp-slider-value" :id="`${group.id}-${row.id}-value`">{{ pct(row.value) }}</span>
</div>
</template>
</div>
<div class="pp-toggle-group">
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" :aria-pressed="String(Boolean(view?.bloom.active))" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">