feat(selection): selecting a contact keeps its size and the camera's view: aircraft, vessels, trains and transit vehicles keep their form and size when selected (colour only); a click follows from the camera's own distance and angle, the contact gliding to the centre over one second (FollowTarget transitionS, shared rule render/camera/followTransition, conformance camera.follow.transition)

This commit is contained in:
Sameh Khamis committed 2026-11-13 15:02:28 -08:00
1 parent e3865f462f
commit 7a61bf04a0
52 files changed
+1648 -891

No files matched your search

+20 -9
View File
@@ -166,6 +166,14 @@ function colourOf(c) {
: new Cesium.Color(c[0], c[1], c[2], c[3]);
}
// A marker's glyph size on screen, CSS pixels: its width less the halo the
// raster pads it with (the SVG's viewBox is the padded frame at 96 units per
// glyph).
function glyphPx(marker) {
const svg = Buffer.from(marker.image.split(',')[1], 'base64').toString();
return (marker.width * 96) / Number(svg.match(/viewBox="-\d+ -\d+ (\d+)/)[1]);
}
// A camera `height` metres above a place, looking straight down at it or,
// with `away`, straight out to space.
function viewFrom(lon, lat, height, away = false) {
@@ -2365,15 +2373,17 @@ test('under FLIR and NVG every sprite is white-hot with a dark halo, and selecti
);
assert.ok(entry.marker.width > plainWidth * 1.2, 'and larger');
}
// Selecting under FLIR grows the sprite and keeps it white — cyan would dim it.
// Selecting under FLIR keeps the sprite white (cyan would dim it) and its
// size: a selected vehicle is drawn no bigger than its neighbours.
app.layer._transitPartsForTest().selection.selectVehicle(bus.key);
assert.ok(
Cesium.Color.equals(colourOf(bus.marker.color), Cesium.Color.WHITE),
'still white when selected',
);
assert.ok(
bus.marker.width > byRoute.get('Red').marker.width,
'and bigger than its neighbours',
assert.equal(
Math.round(glyphPx(bus.marker) * 1e6),
Math.round(glyphPx(byRoute.get('Red').marker) * 1e6),
'and no bigger than its neighbours',
);
app.layer._transitPartsForTest().selection.clearSelection();
assert.ok(
@@ -3019,21 +3029,22 @@ test('every styling path retains the mode palette and exact unpadded size', asyn
const width = Number(svg.match(/viewBox="-\d+ -\d+ (\d+)/)[1]);
assert.ok(Math.abs((entry.marker.width * 96) / width - display) < 1e-9);
};
// Selection never changes the drawn size.
check('#5EF08A', 20);
parts.selection.selectVehicle(entry.key);
check('#5EF08A', 30);
check('#5EF08A', 20);
parts.rendering.paintMode(entry, 'subway');
check('#FF4538', 30);
check('#FF4538', 20);
app.style('thermal');
check('#FFFFFF', 39);
check('#FFFFFF', 26);
parts.selection.clearSelection();
check('#FFFFFF', 26);
app.vision('nvg', true);
check('#FFFFFF', 26);
parts.selection.selectVehicle(entry.key);
check('#FFFFFF', 39);
check('#FFFFFF', 26);
app.vision('normal', false);
check('#FF4538', 30);
check('#FF4538', 20);
parts.selection.clearSelection();
check('#FF4538', 20);
});
-1
View File
@@ -81,7 +81,6 @@ export const FLOOR_REREAD_ATTEMPTS = 6;
// --- Rendering ---
/** On-screen glyph size in CSS px at the near end of the distance ramp. */
export const MARKER_PIXEL_SIZE = 20;
export const SELECTED_PIXEL_SIZE = 30;
/**
* How often the fleet's screen-space rotations may be recomputed. Projecting a
* course into screen space depends on the camera, so a moving camera would
+3 -3
View File
@@ -32,7 +32,6 @@ import {
MARKER_PIXEL_SIZE,
ROTATION_REFRESH_MS,
VISIBILITY_REFRESH_MS,
SELECTED_PIXEL_SIZE,
TRANSIT_MODE_COLORS,
vehicleNearView,
} from './policy.js';
@@ -595,7 +594,8 @@ export function createRendering({ state, services, parts }) {
* Under a mono preset (NVG, FLIR, noir) the sprite is white-hot with a dark
* halo sized in screen pixels; under CRT a saturated mode colour with a
* thinner halo; otherwise the shipped mode colour and hairline. Selection
* grows the glyph and retains the mode colour; sensors use opaque white.
* keeps the glyph's size and mode colour, widening only its halo and
* drawing from a crisper raster; sensors use opaque white.
* @param {object} entry
*/
function applySpriteStyle(entry) {
@@ -603,7 +603,7 @@ export function createRendering({ state, services, parts }) {
if (!marker) return;
const style = state._stylePreset;
const selected = state._selectedKey === entry.key;
const basePx = selected ? SELECTED_PIXEL_SIZE : MARKER_PIXEL_SIZE;
const basePx = MARKER_PIXEL_SIZE;
const halo = presetSpriteOutlinePx(style, selected);
const displayPx = basePx * presetSpriteScale(style, selected);
const frame = haloFrame(halo, displayPx);