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

-1
View File
@@ -14,5 +14,4 @@ export * from '../../data/modelVisualAnchor.js';
export * from '../../data/motionModel.js';
export * from '../../data/renderAltitude.js';
export * from '../../data/routePlausible.js';
export * from '../../data/trackedModelRegime.js';
export * from '../../data/trackingClickGesture.js';
-1
View File
@@ -85,4 +85,3 @@ export function createCivilFlightLayer({
Object.defineProperty(layer, 'testing', { value: parts.testing });
return layer;
}
export { TRACKED_MODEL_MAX_PX } from './policy.js';
+1 -1
View File
@@ -273,7 +273,7 @@ export function createLifecycle({
source: flightState.feed._lastSource,
coverage: flightState.feed._lastCoverage,
};
parts.tracking._resetTrackedSelectionState(); // next lifecycle re-evaluates against the ENTER ceiling
parts.tracking._resetTrackedSelectionState(); // the next lifecycle starts a fresh selection
flightState._viewer = null;
},
};
+4 -16
View File
@@ -41,8 +41,7 @@ import {
} from '../../data/modelVisualAnchor.js';
import {
FOCUS_EVIDENCE_DEV,
TRACKED_MODEL_MAX_PX,
TRACKED_MODEL_MIN_PX,
MODEL_MIN_PX,
TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
DR_CORRECTION_MS,
COURSE_SLEW_DT_MAX_SEC,
@@ -113,7 +112,6 @@ export function createMotion({
corridorFloorCells,
allocateCorridorCells,
} = services.groundFloor;
const { trackedModelScaleForPixelCap } = services.camera;
const {
nearFarScalarValueAtDistance,
clearFocusTarget,
@@ -375,21 +373,11 @@ export function createMotion({
const spec = parts.rendering._modelSpec(
flightState.records.data.get(icao24),
);
const scale = trackedModelScaleForPixelCap({
baseScale: spec.scale,
nativeRadiusM: spec.nativeRadiusM,
rangeM,
viewportHeightPx,
fovyRad: pose.fovy,
maximumPixelSize: TRACKED_MODEL_MAX_PX,
});
// Drawn as the fleet draws it: its own size, never under MODEL_MIN_PX.
const focalLengthPx = viewportHeightPx / (2 * Math.tan(pose.fovy / 2));
const projectedDiameterPx =
(2 * spec.nativeRadiusM * scale * focalLengthPx) / rangeM;
return Math.max(
TRACKED_MODEL_MIN_PX,
Math.min(TRACKED_MODEL_MAX_PX, projectedDiameterPx),
);
(2 * spec.nativeRadiusM * spec.scale * focalLengthPx) / rangeM;
return Math.max(MODEL_MIN_PX, projectedDiameterPx);
}
const sprite = readEntityRecord(flightState._trackedEntity)?.sprite;
-6
View File
@@ -52,12 +52,6 @@ export const MODEL_MIN_PX = 24;
// min-pixel blob (was 54 — far planes at the All radius became white
// star-bursts); ~matches the 2D icon size so the model↔billboard read is consistent
export const TRACKED_MODEL_MIN_PX = 40;
// keep the glTF silhouette comparable to the selected 2D glyph at handoff
export const TRACKED_MODEL_MAX_PX = 200;
// owner-selected close-range tracked-target feel
// Per-mode caps. Each model is its own draw call (no instancing yet), so these bound the frame cost.
export const MODEL_MAX = 150;
+2 -2
View File
@@ -317,8 +317,8 @@ export function createQueries({
* Live layer params.
* `models3d` toggles 3D glTF model rendering for the FLEET (altitude-gated): when on,
* surrounding aircraft become 3D models once the camera is zoomed in past MODEL_ALT_CEIL_M.
* The TRACKED contact is NOT gated by this — it takes its 3D model by camera distance
* regardless (see `_trackedModelRegimeActive` / trackedModelRegime.js).
* The TRACKED contact follows the same rule (`_trackedModelRegimeActive`), so selecting
* a contact never turns its icon into a model or its model into an icon.
* `models3dMode` is 'proximity' (nearest MODEL_MAX in view) or 'all' (every in-view plane).
* @param {{models3d?: boolean, models3dMode?: 'proximity'|'all', selectedFlightsTrackingId?: string|null}} params
*/
+6 -6
View File
@@ -358,13 +358,13 @@ export function createFlightState({ source, services }) {
flightState._scratchTrailHead = { x: 0, y: 0, z: 0 };
/** Hysteresis latch for the tracked contact's zoom regime, plus the selection it
* belongs to. Scoped per selection so a NEW target re-evaluates against the ENTER
* ceiling instead of inheriting the previous target's looser EXIT band. */
/** Whether the fleet's model rule (3D on, below the ceiling, inside the
* nearest-first cap) gives the tracked contact a model: the tracked model
* draws only then, so selecting a contact never changes its form. Seeded
* from the contact's fleet model when it is selected, then kept by the
* fleet pass. */
flightState._trackedZoomLatched = false;
flightState._trackedZoomLatchIcao = null;
flightState._trackedModelEligible = false;
/** The tracked-model load-failure budget: the selection it counts for,
* its failures, and when it may load again (`TRACKED_MODEL_*`). */
+27 -7
View File
@@ -99,6 +99,7 @@ export function createTesting({
tracked = true,
models = [],
draw = null,
trackedModelEligible = true,
}) {
flightState._viewer = viewer;
parts.rendering._disposeModelSets();
@@ -120,11 +121,17 @@ export function createTesting({
flightState._trackedIcao = tracked ? icao24 : null;
flightState._trackedEntity = tracked ? entity : null;
flightState._trackedModel = null;
// Whether the fleet's model rule gives the tracked contact a model (the
// fleet pass keeps it): a model unless the test says otherwise.
flightState._trackedModelEligible = tracked && trackedModelEligible;
// `null`: as a selection seeds it (from the contact's fleet model).
if (trackedModelEligible === null)
parts.tracking._resetTrackedSelectionState();
parts.tracking._cancelPendingTrackingRestore();
// NOTE: deliberately does NOT reset the per-selection latches. They are
// production state owned by the tracking lifecycle (_resetTrackedSelectionState),
// and clearing them here would mask exactly the deselect→re-track hole this
// seam is used to test.
// NOTE: deliberately does NOT reset the load-failure budget. It is
// production state owned by the tracking lifecycle
// (_resetTrackedSelectionState), and clearing it here would mask exactly
// the deselect→re-track hole this seam is used to test.
flightState.feed._backoff = false;
flightState.feed._retryAt = 0;
}
@@ -193,9 +200,8 @@ export function createTesting({
parts.tracking._applyCockpitState({ active, subjectId });
}
/** Evaluate the TRACKED contact's zoom regime through the production predicate.
* The decision is latch-bearing (default-on, hysteretic, cockpit/TR-3B-suppressed)
* and otherwise only observable through a live scene, so tests drive it here. */
/** Evaluate whether the TRACKED contact draws as its model, through the
* production predicate (the fleet's rule; cockpit/TR-3B-suppressed). */
function _trackedModelRegimeActiveForTest() {
return parts.tracking._trackedModelRegimeActive();
@@ -247,6 +253,19 @@ export function createTesting({
return flightState._models.get(icao24) ?? null;
}
/** How the tracked billboard is drawn (`_trackedBillboardLook`,
* `_trackedSprite`) next to how the contact's fleet icon is (`_fleetLook`). */
function _trackedIconLookForTest(icao24) {
return {
tracked: {
...parts.tracking._trackedBillboardLook(),
sprite: parts.tracking._trackedSprite(icao24),
},
fleet: parts.icons._fleetLook(icao24),
};
}
/** The tracked model's record, or null. */
function _trackedModelForTest() {
@@ -289,6 +308,7 @@ export function createTesting({
_iconForTest,
_ensureFleetModelForTest,
_trackedModelForTest,
_trackedIconLookForTest,
_modelSetIdsForTest,
_resetEnrichmentForTest,
};
+77 -81
View File
@@ -7,7 +7,6 @@ import {
import { formatNumber, t } from '../../i18n/index.js';
import { unitLabel } from '../../ui/unitLabels.js';
import { nextCockpitNearContacts } from '../../data/cockpitAirLod.js';
import { trackedModelZoomActive } from '../../data/trackedModelRegime.js';
import {
courseScreenRotation,
stabilizeScreenRotation,
@@ -22,9 +21,7 @@ import { julianToEpochMs } from '../../geo/julian.js';
import { renderedFrames } from '../../data/renderedFrames.js';
import { clone, distance, distanceSquared, vec } from '../../geo/vector.js';
import { trailHeadStart } from '../../data/modelVisualAnchor.js';
import { aircraftIcon, TRACKED_ICON_PX } from '../../data/aircraftIcons.js';
import { routePlausible } from '../../data/routePlausible.js';
import { CLASS_SCALE_2D } from '../../data/aircraftClass.js';
import {
isTrackingSelectionGesture,
isTrackingClickGesture,
@@ -36,7 +33,6 @@ import {
TRAIL_COLOR,
CYAN_TRANSPARENT,
TRACKED_CYAN,
TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
STALE_ALPHA,
displayDelayMs,
followsClock,
@@ -93,7 +89,8 @@ export function createTracking({
const { clearFocusTarget } = services.focus;
const { isMilitaryLayerActive, isMilitaryIcao } = services.militaryRegistry;
const { trackedLabelModelFromText, refreshTrackedReadout } = services.readout;
const { FOLLOW_MIN_RANGE_M } = services.camera;
const { FOLLOW_MIN_RANGE_M, SELECTION_FOLLOW_TRANSITION_S, keptViewFrom } =
services.camera;
const { resolvePickId, isOwnedByOtherLayer } = services.picking;
const flightsLayer = layer;
/** The tracked contact's billboard (an icon set on the draw port). */
@@ -272,67 +269,42 @@ export function createTracking({
_setCockpitContactMode(active);
}
/** Clear the per-SELECTION tracked-model latches: the zoom hysteresis band
* and the load-failure budget.
* Called from each path that changes which contact is
* selected — deselect, re-track, cross-layer handoff, init, destroy.
*
* This must live in the production lifecycle, not only in the predicate's
* icao-change guard: a deselect followed by a same-turn re-track of the SAME
* icao (Contacts re-entry, a cross-layer round trip back to the original
* layer) never makes `_trackedIcao` *observably* change, so the guard never
* fires. Without the reset, a contact dropped inside the hysteresis band comes
* back as a MODEL above the ENTER ceiling. */
/** Start a selection's tracked-model state afresh: the model it draws
* with (whatever the fleet drew it with, a model or its icon) and the
* load-failure budget. Called from each path that changes which contact
* is selected — deselect, re-track, cross-layer handoff, init, destroy. */
function _resetTrackedSelectionState() {
flightState._trackedZoomLatched = false;
flightState._trackedZoomLatchIcao = null;
flightState._trackedModelEligible = Boolean(
flightState._trackedIcao &&
flightState._models?.has(flightState._trackedIcao),
);
flightState._trackedModelFailIcao = null;
flightState._trackedModelFailCount = 0;
flightState._trackedModelRetryAtMs = 0;
}
/**
* The TRACKED aircraft's own model regime — DEFAULT-ON, camera-distance driven
* (owner directive 2026-08-19). Unlike the fleet, this does NOT consult the
* DISPLAY-rail `models3d` toggle: the selected contact is a single model, it is
* what the camera is pointed at, and zooming in on a target should resolve it
* into an aircraft without the operator arming anything. The toggle keeps
* owning the FLEET (`_modelRegimeActive`), which is the draw-call budget.
*
* Thresholds + hysteresis live in trackedModelRegime.js: enter at
* TRACKED_MODEL_ENTER_ALT_M (150_000 m — the owner's playtested swap distance,
* deliberately NEARER than the fleet's 800 km ceiling this used to inherit),
* hand back only above TRACKED_MODEL_EXIT_ALT_M, so orbiting AT the boundary
* cannot flap billboard↔model. See that module's header for why the tracked
* contact now goes 3D closer in than the fleet does.
*
* In cockpit you are sitting 7 m behind and 2.6 m above your own aircraft's
* origin, so its ~26 m airframe would fill the visor. First-person means your
* own airframe is not drawn.
* Whether the TRACKED aircraft draws as its 3D model: exactly when the
* fleet's own rule would draw it so (`_modelRegimeActive` — 3D on and the
* camera below the ceiling — and a place in the nearest-first cap, which
* the fleet pass keeps in `_trackedModelEligible`). Selecting a contact
* therefore never turns its icon into a model or its model into an icon.
* A converted TR-3B has no 3D asset, and in cockpit you sit in your own
* airframe, so neither draws one.
*/
function _trackedModelRegimeActive() {
if (flightState._trackedZoomLatchIcao !== flightState._trackedIcao) {
flightState._trackedZoomLatchIcao = flightState._trackedIcao;
flightState._trackedZoomLatched = false;
}
// A converted TR-3B has no 3D asset — suppressing the regime keeps its
// tracked billboard fully opaque (the colour callback reads this too), so
// the triangle stays the visual all the way in.
if (
!flightState._trackedIcao ||
flightState._cockpitContactMode ||
isTr3b(flightState._trackedIcao)
) {
flightState._trackedZoomLatched = false;
)
return false;
}
flightState._trackedZoomLatched = trackedModelZoomActive(
_pose()?.height,
flightState._trackedZoomLatched,
return (
flightState._trackedModelEligible === true &&
parts.rendering._modelRegimeActive()
);
return flightState._trackedZoomLatched;
}
/** Seed the tracked billboard's 2D orientation before a 3D→2D handoff. */
@@ -967,22 +939,40 @@ export function createTracking({
refreshTrackedSubjectContext(_contextSubjectMetadata(icao24));
}
/** The tracked billboard's image, from the current class/conversion. */
function _trackedBillboardImage() {
return aircraftIcon(
parts.rendering._iconKind(
flightState._trackedIcao,
flightState.records.data.get(flightState._trackedIcao)?.klass,
),
TRACKED_ICON_PX,
);
/** The tracked billboard's images, from the current class/conversion: the
* fleet icon's own (`_fleetLook`), so selecting it changes only its colour. */
function _trackedBillboardLook() {
return parts.icons._fleetLook(flightState._trackedIcao);
}
/**
* What the tracked billboard is drawn at: the size, scale and scale by
* distance its fleet icon has (the scale read live: a landing changes it).
* Kept in its entity record too, so the camera guard and screen
* annotations size it from the app's own state.
* @param {string} icao24
*/
function _trackedSprite(icao24) {
const look = parts.icons._fleetLook(icao24);
return {
width: look.size[0],
height: look.size[1],
get scale() {
return parts.rendering._fleetBillboardScale(
icao24,
flightState.records.data.get(icao24)?.klass,
);
},
scaleByDistance: look.scaleByDistance,
};
}
/** Re-image the tracked billboard from the current class/conversion. */
function _syncTrackedBillboardImage() {
if (!flightState._trackedIcao || !flightState._trackedEntity) return;
trackedIcon.setImage(_trackedBillboardImage());
const look = _trackedBillboardLook();
trackedIcon.setImage(look.image, look.imageLod);
}
/**
@@ -1059,9 +1049,15 @@ export function createTracking({
* camera follows a target that reads it.
*
* @param {string} icao24 - ICAO 24-bit transponder address to track.
* @param {{origin?: string, keepView?: boolean}} [options] `keepView` (a
* click on the plane): follow from the camera's own distance and angle,
* the plane sliding to the centre, rather than the calibrated framing.
*/
function _trackFlight(icao24, { origin = 'programmatic' } = {}) {
function _trackFlight(
icao24,
{ origin = 'programmatic', keepView = false } = {},
) {
_clearTracking(false, { origin }); // switching planes — the new follow-camera takes over
const icons = flightState._icons;
@@ -1079,10 +1075,9 @@ export function createTracking({
flightState._cachedDRFrame = -1;
flightState._lastTrackedRotation =
courseScreenRotation(_pose(), iconPosition, iconCourse, 0) ?? 0;
// Drop any fleet 3D model for this aircraft — the tracked entity now owns its visual (its
// own billboard + model graphic), and the fleet tick skips the tracked icao, so a leftover
// fleet model would be orphaned + double-rendered.
parts.rendering._releaseModel(icao24);
// A fleet 3D model this aircraft had keeps drawing it until the tracked
// model is ready (`_updateTrackedModel` lets it go then), so it never
// turns into its icon for the frames the tracked model takes to load.
// Hide the icon — the tracked entity replaces it visually
icons.setShown(icao24, false);
@@ -1106,17 +1101,7 @@ export function createTracking({
// billboard+model double-image nor a gap. The camera follows its own target through the camera
// port, so nothing here frames the camera. The 3D model for the tracked plane is a draw-set
// item driven by _updateTrackedModel() (see _trackedModel).
// What the tracked billboard is drawn at, kept in its record so the
// camera guard and screen annotations size it from the app.
const sprite = {
width: 28,
height: 28,
scale:
CLASS_SCALE_2D[
flightState.records.data.get(flightState._trackedIcao)?.klass
] || 1,
scaleByDistance: TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
};
const sprite = _trackedSprite(icao24);
// The tracked contact as its readers see it (the tracked card, Cockpit, share links): a
// plain holder of its entity record, drawn while it is the one tracked.
const holder = trackedContactHolder(
@@ -1135,7 +1120,8 @@ export function createTracking({
};
trackedIcon.show({
id: icao24,
image: _trackedBillboardImage(),
image: _trackedBillboardLook().image,
imageLod: _trackedBillboardLook().imageLod,
sprite,
position: getTrackedPosition,
// Solid cyan (faded while stale) when the billboard is the visual (zoomed out, 3D off,
@@ -1172,9 +1158,11 @@ export function createTracking({
entityRecord(flightState._trackedEntity).labelModel =
trackedLabelModelFromText(_trackedLabelText(icao24), '#39d0ff');
// A billboard has a ~zero bounding sphere, so the renderer's default follow distance is
// far too tight (the user had to scroll out to read the plane). Give the target a
// calibrated viewFrom — behind + above, distance scaled to altitude — for a readable
// A click on the plane follows it from where the camera is (`keepView`,
// below). A selection from elsewhere (a search, voice, a share link) has no
// view of the plane to keep: a billboard has a ~zero bounding sphere, so the
// renderer's default follow distance is far too tight. It gets a calibrated
// viewFrom — behind + above, distance scaled to altitude — for a readable
// initial frame with surrounding context. (ENU: east=+X, north=+Y, up=+Z.)
const followRange = Math.min(
Math.max((info.altitude || 1500) * 1.1 + 2500, 3000),
@@ -1202,11 +1190,17 @@ export function createTracking({
// label, sprite, display position) reads the tracked entity's record.
const camera = cameraOf(flightState._viewer);
camera.cancelFlight();
const kept = keepView
? keptViewFrom(camera.pose(), getTrackedPosition())
: null;
flightState._followTarget = entityFollowTarget(flightState._trackedEntity, {
position: getTrackedPosition,
frame: 'enu',
viewFrom,
viewFrom: kept ?? viewFrom,
minRange: FOLLOW_MIN_RANGE_M,
// A click keeps the camera's distance and angle: the plane slides to
// the centre from where the camera is, and is followed from there.
...(kept ? { transitionS: SELECTION_FOLLOW_TRANSITION_S } : {}),
});
camera.follow(flightState._followTarget);
@@ -1338,7 +1332,7 @@ export function createTracking({
if (pickedIcao && flightState._icons?.has(pickedIcao)) {
_cancelPendingTrackingRestore();
_trackFlight(pickedIcao, { origin: 'user' });
_trackFlight(pickedIcao, { origin: 'user', keepView: true });
return;
}
}
@@ -1374,6 +1368,8 @@ export function createTracking({
_applyCockpitState,
_resetTrackedSelectionState,
_trackedModelRegimeActive,
_trackedBillboardLook,
_trackedSprite,
_syncTracked2dRotation,
_appendTrailFix,
_trailTick,
-1
View File
@@ -78,4 +78,3 @@ export function createMilitaryFlightLayer({
Object.defineProperty(layer, 'testing', { value: parts.testing });
return layer;
}
export { TRACKED_MODEL_MAX_PX } from './policy.js';
+1 -1
View File
@@ -240,7 +240,7 @@ export function createLifecycle({
ids: new Set(),
source: flightState.feed._lastSource,
};
parts.tracking._resetTrackedSelectionState(); // next lifecycle re-evaluates against the ENTER ceiling
parts.tracking._resetTrackedSelectionState(); // the next lifecycle starts a fresh selection
flightState._viewer = null;
},
};
+4 -16
View File
@@ -35,8 +35,7 @@ import {
import {
displayDelayMs,
followsClock,
TRACKED_MODEL_MAX_PX,
TRACKED_MODEL_MIN_PX,
MODEL_MIN_PX,
BILLBOARD_SCALE,
TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
DR_CORRECTION_MS,
@@ -70,7 +69,6 @@ export function createMotion({
layer,
resolveAsset,
}) {
const { trackedModelScaleForPixelCap } = services.camera;
const {
nearFarScalarValueAtDistance,
clearFocusTarget,
@@ -275,21 +273,11 @@ export function createMotion({
const spec = parts.rendering._modelSpec(
flightState.records.data.get(icao24),
);
const scale = trackedModelScaleForPixelCap({
baseScale: spec.scale,
nativeRadiusM: spec.nativeRadiusM,
rangeM,
viewportHeightPx,
fovyRad: pose.fovy,
maximumPixelSize: TRACKED_MODEL_MAX_PX,
});
// Drawn as the fleet draws it: its own size, never under MODEL_MIN_PX.
const focalLengthPx = viewportHeightPx / (2 * Math.tan(pose.fovy / 2));
const projectedDiameterPx =
(2 * spec.nativeRadiusM * scale * focalLengthPx) / rangeM;
return Math.max(
TRACKED_MODEL_MIN_PX,
Math.min(TRACKED_MODEL_MAX_PX, projectedDiameterPx),
);
(2 * spec.nativeRadiusM * spec.scale * focalLengthPx) / rangeM;
return Math.max(MODEL_MIN_PX, projectedDiameterPx);
}
const sprite = readEntityRecord(flightState._trackedEntity)?.sprite;
-6
View File
@@ -71,12 +71,6 @@ export const MODEL_ALT_CEIL_M = 800000;
export const MODEL_MIN_PX = 24;
// floor so distant models stay visible without ballooning into a min-pixel blob (mirror of flights.js)
export const TRACKED_MODEL_MIN_PX = 40;
// keep the glTF silhouette comparable to the selected 2D glyph at handoff
export const TRACKED_MODEL_MAX_PX = 200;
// owner-selected close-range tracked-target feel
// Per-mode caps + radii — mirror of flights.js. Modes differ by RADIUS (not just cap) so Proximity
// and All aren't identical when few planes are in range; on-screen planes win the cap (see flights.js).
+2 -2
View File
@@ -250,8 +250,8 @@ export function createQueries({
* Live layer params.
* `models3d` toggles 3D glTF jet-model rendering for the FLEET (altitude-gated): when on,
* surrounding military aircraft become 3D models once the camera is zoomed in past
* MODEL_ALT_CEIL_M. The TRACKED contact is NOT gated by this — it takes its 3D model by
* camera distance regardless (see `_trackedModelRegimeActive` / trackedModelRegime.js).
* MODEL_ALT_CEIL_M. The TRACKED contact follows the same rule (`_trackedModelRegimeActive`),
* so selecting a contact never turns its icon into a model or its model into an icon.
* `models3dMode` is 'proximity' (nearest MODEL_MAX in view) or 'all' (every in-view plane).
* @param {{models3d?: boolean, models3dMode?: 'proximity'|'all', selectedMilitaryTrackingId?: string|null}} params
*/
+6 -6
View File
@@ -293,13 +293,13 @@ export function createFlightState({ source, services }) {
flightState._scratchTrailHead = { x: 0, y: 0, z: 0 };
/** Hysteresis latch for the tracked contact's zoom regime, plus the selection it
* belongs to. Scoped per selection so a NEW target re-evaluates against the ENTER
* ceiling instead of inheriting the previous target's looser EXIT band. */
/** Whether the fleet's model rule (3D on, below the ceiling, inside the
* nearest-first cap) gives the tracked contact a model: the tracked model
* draws only then, so selecting a contact never changes its form. Seeded
* from the contact's fleet model when it is selected, then kept by the
* fleet pass. */
flightState._trackedZoomLatched = false;
flightState._trackedZoomLatchIcao = null;
flightState._trackedModelEligible = false;
/** The tracked-model load-failure budget: the selection it counts for,
* its failures, and when it may load again (`TRACKED_MODEL_*`). */
+27 -7
View File
@@ -71,6 +71,7 @@ export function createTesting({
tracked = true,
models = [],
draw = null,
trackedModelEligible = true,
}) {
flightState._viewer = viewer;
parts.rendering._disposeModelSets();
@@ -90,11 +91,17 @@ export function createTesting({
flightState._trackedIcao = tracked ? icao24 : null;
flightState._trackedEntity = tracked ? entity : null;
flightState._trackedModel = null;
// Whether the fleet's model rule gives the tracked contact a model (the
// fleet pass keeps it): a model unless the test says otherwise.
flightState._trackedModelEligible = tracked && trackedModelEligible;
// `null`: as a selection seeds it (from the contact's fleet model).
if (trackedModelEligible === null)
parts.tracking._resetTrackedSelectionState();
parts.tracking._cancelPendingTrackingRestore();
// NOTE: deliberately does NOT reset the per-selection latches. They are
// production state owned by the tracking lifecycle (_resetTrackedSelectionState),
// and clearing them here would mask exactly the deselect→re-track hole this
// seam is used to test.
// NOTE: deliberately does NOT reset the load-failure budget. It is
// production state owned by the tracking lifecycle
// (_resetTrackedSelectionState), and clearing it here would mask exactly
// the deselect→re-track hole this seam is used to test.
flightState.feed._backoff = false;
flightState.feed._retryAt = 0;
}
@@ -146,9 +153,8 @@ export function createTesting({
parts.tracking._applyCockpitState({ active, subjectId });
}
/** Evaluate the TRACKED contact's zoom regime through the production predicate.
* The decision is latch-bearing (default-on, hysteretic, cockpit/TR-3B-suppressed)
* and otherwise only observable through a live scene, so tests drive it here. */
/** Evaluate whether the TRACKED contact draws as its model, through the
* production predicate (the fleet's rule; cockpit/TR-3B-suppressed). */
function _trackedModelRegimeActiveForTest() {
return parts.tracking._trackedModelRegimeActive();
@@ -187,6 +193,19 @@ export function createTesting({
return flightState._models.get(icao24) ?? null;
}
/** How the tracked billboard is drawn (`_trackedBillboardLook`,
* `_trackedSprite`) next to how the contact's fleet icon is (`_fleetLook`). */
function _trackedIconLookForTest(icao24) {
return {
tracked: {
...parts.tracking._trackedBillboardLook(),
sprite: parts.tracking._trackedSprite(icao24),
},
fleet: parts.icons._fleetLook(icao24),
};
}
/** The tracked model's record, or null. */
function _trackedModelForTest() {
@@ -215,6 +234,7 @@ export function createTesting({
_setIconForTest,
_ensureFleetModelForTest,
_trackedModelForTest,
_trackedIconLookForTest,
_modelSetIdsForTest,
};
}
+77 -76
View File
@@ -7,8 +7,6 @@ import {
import { formatNumber, t } from '../../i18n/index.js';
import { unitLabel } from '../../ui/unitLabels.js';
import { nextCockpitNearContacts } from '../../data/cockpitAirLod.js';
import { aircraftIcon, TRACKED_ICON_PX } from '../../data/aircraftIcons.js';
import { trackedModelZoomActive } from '../../data/trackedModelRegime.js';
import {
courseScreenRotation,
stabilizeScreenRotation,
@@ -23,7 +21,6 @@ import { julianToEpochMs } from '../../geo/julian.js';
import { renderedFrames } from '../../data/renderedFrames.js';
import { clone, distance, distanceSquared, vec } from '../../geo/vector.js';
import { trailHeadStart } from '../../data/modelVisualAnchor.js';
import { CLASS_SCALE_2D } from '../../data/aircraftClass.js';
import {
isTrackingSelectionGesture,
isTrackingClickGesture,
@@ -36,10 +33,8 @@ import {
followsClock,
STALE_ALPHA,
TRAIL_COLOR,
BILLBOARD_SCALE,
AMBER_TRANSPARENT,
TRACKED_ICON_COLOR,
TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
} from './policy.js';
import {
drawTrailSegments,
@@ -95,7 +90,8 @@ export function createTracking({
const { createTrail } = services.trails;
const { ensureGeoidReady, geoidHeight } = services.geoid;
const { clearFocusTarget } = services.focus;
const { FOLLOW_MIN_RANGE_M } = services.camera;
const { FOLLOW_MIN_RANGE_M, SELECTION_FOLLOW_TRANSITION_S, keptViewFrom } =
services.camera;
const { resolvePickId, isOwnedByOtherLayer } = services.picking;
/** The tracked contact's billboard (an icon set on the draw port). */
const trackedIcon = createTrackedAircraftIcon({
@@ -394,22 +390,40 @@ export function createTracking({
refreshTrackedSubjectContext(_contextSubjectMetadata(icao24));
}
/** The tracked billboard's image, from the current class/conversion. */
function _trackedBillboardImage() {
return aircraftIcon(
parts.rendering._iconKind(
flightState._trackedIcao,
flightState.records.data.get(flightState._trackedIcao)?.klass,
),
TRACKED_ICON_PX,
);
/** The tracked billboard's images, from the current class/conversion: the
* fleet icon's own (`_fleetLook`), so selecting it changes only its colour. */
function _trackedBillboardLook() {
return parts.icons._fleetLook(flightState._trackedIcao);
}
/**
* What the tracked billboard is drawn at: the size, scale and scale by
* distance its fleet icon has (the scale read live: a landing changes it).
* Kept in its entity record too, so the camera guard and screen
* annotations size it from the app's own state.
* @param {string} icao24
*/
function _trackedSprite(icao24) {
const look = parts.icons._fleetLook(icao24);
return {
width: look.size[0],
height: look.size[1],
get scale() {
return parts.rendering._fleetBillboardScale(
icao24,
flightState.records.data.get(icao24)?.klass,
);
},
scaleByDistance: look.scaleByDistance,
};
}
/** Re-image the tracked billboard from the current class/conversion. */
function _syncTrackedBillboardImage() {
if (!flightState._trackedIcao || !flightState._trackedEntity) return;
trackedIcon.setImage(_trackedBillboardImage());
const look = _trackedBillboardLook();
trackedIcon.setImage(look.image, look.imageLod);
}
/**
@@ -453,60 +467,42 @@ export function createTracking({
}
}
/** Clear the per-SELECTION tracked-model latches: the zoom hysteresis band
* and the load-failure budget.
* Called from each path that changes which contact is
* selected — deselect, re-track, cross-layer handoff, init, destroy.
*
* This must live in the production lifecycle, not only in the predicate's
* icao-change guard: a deselect followed by a same-turn re-track of the SAME
* icao (Contacts re-entry, a cross-layer round trip back to this layer) never
* makes `_trackedIcao` *observably* change, so the guard never fires. Without
* the reset, a contact dropped inside the hysteresis band comes back as a
* MODEL above the ENTER ceiling. Mirror of flights.js. */
/** Start a selection's tracked-model state afresh: the model it draws
* with (whatever the fleet drew it with, a model or its icon) and the
* load-failure budget. Called from each path that changes which contact
* is selected — deselect, re-track, cross-layer handoff, init, destroy. */
function _resetTrackedSelectionState() {
flightState._trackedZoomLatched = false;
flightState._trackedZoomLatchIcao = null;
flightState._trackedModelEligible = Boolean(
flightState._trackedIcao &&
flightState._models?.has(flightState._trackedIcao),
);
flightState._trackedModelFailIcao = null;
flightState._trackedModelFailCount = 0;
flightState._trackedModelRetryAtMs = 0;
}
/**
* The TRACKED aircraft's own model regime — DEFAULT-ON, camera-distance driven
* (owner directive 2026-08-19). Mirror of flights.js: this does NOT consult the
* DISPLAY-rail `models3d` toggle, which keeps owning the FLEET
* (`_modelRegimeActive`) and its draw-call budget. Thresholds + hysteresis live
* in trackedModelRegime.js — enter at TRACKED_MODEL_ENTER_ALT_M (150_000 m, the
* owner's playtested swap distance, deliberately NEARER than the fleet's 800 km
* ceiling this used to inherit), hand back only above
* TRACKED_MODEL_EXIT_ALT_M so a boundary orbit cannot flap billboard↔model.
* First-person means your own airframe is not drawn in cockpit — the eye sits
* metres from its origin.
* Whether the TRACKED aircraft draws as its 3D model: exactly when the
* fleet's own rule would draw it so (`_modelRegimeActive` — 3D on and the
* camera below the ceiling — and a place in the nearest-first cap, which
* the fleet pass keeps in `_trackedModelEligible`). Selecting a contact
* therefore never turns its icon into a model or its model into an icon.
* A converted TR-3B has no 3D asset, and in cockpit you sit in your own
* airframe, so neither draws one.
*/
function _trackedModelRegimeActive() {
if (flightState._trackedZoomLatchIcao !== flightState._trackedIcao) {
flightState._trackedZoomLatchIcao = flightState._trackedIcao;
flightState._trackedZoomLatched = false;
}
// A converted TR-3B has no 3D asset — suppressing the regime keeps its
// tracked billboard fully opaque (the colour callback reads this too), so
// the triangle stays the visual all the way in. Mirror of flights.js.
if (
!flightState._trackedIcao ||
flightState._cockpitContactMode ||
isTr3b(flightState._trackedIcao)
) {
flightState._trackedZoomLatched = false;
)
return false;
}
flightState._trackedZoomLatched = trackedModelZoomActive(
_pose()?.height,
flightState._trackedZoomLatched,
return (
flightState._trackedModelEligible === true &&
parts.rendering._modelRegimeActive()
);
return flightState._trackedZoomLatched;
}
/** Seed the tracked billboard's 2D orientation before a 3D→2D handoff. */
@@ -1016,9 +1012,15 @@ export function createTracking({
* smooth continuous motion, and sets the viewer's trackedEntity so the camera
* follows.
* @param {string} icao24 - ICAO hex identifier of the aircraft to track
* @param {{origin?: string, keepView?: boolean}} [options] `keepView` (a
* click on the plane): follow from the camera's own distance and angle,
* the plane sliding to the centre, rather than the calibrated framing.
*/
function _trackFlight(icao24, { origin = 'programmatic' } = {}) {
function _trackFlight(
icao24,
{ origin = 'programmatic', keepView = false } = {},
) {
_clearTracking(false, { origin }); // switching planes — the new follow-camera takes over
const icons = flightState._icons;
@@ -1036,10 +1038,9 @@ export function createTracking({
flightState._cachedDRFrame = -1;
flightState._lastTrackedRotation =
courseScreenRotation(_pose(), iconPosition, iconCourse, 0) ?? 0;
// Drop any fleet 3D model for this aircraft — the tracked entity now owns its visual (its
// own billboard + model graphic), and the fleet tick skips the tracked icao, so a leftover
// fleet model would be orphaned + double-rendered.
parts.rendering._releaseModel(icao24);
// A fleet 3D model this aircraft had keeps drawing it until the tracked
// model is ready (`_updateTrackedModel` lets it go then), so it never
// turns into its icon for the frames the tracked model takes to load.
// Hide the icon -- the tracked entity replaces it visually
icons.setShown(icao24, false);
@@ -1063,18 +1064,7 @@ export function createTracking({
// billboard+model double-image nor a gap. The camera follows its own target through the camera
// port, so nothing here frames the camera. The tracked plane's 3D model is a draw-set item
// driven by _updateTrackedModel() (see _trackedModel).
// What the tracked billboard is drawn at, kept in its record so the
// camera guard and screen annotations size it from the app.
const sprite = {
width: 28,
height: 28,
scale:
BILLBOARD_SCALE *
(CLASS_SCALE_2D[
flightState.records.data.get(flightState._trackedIcao)?.klass
] || 1),
scaleByDistance: TRACKED_BILLBOARD_SCALE_BY_DISTANCE,
};
const sprite = _trackedSprite(icao24);
// The tracked contact as its readers see it (the tracked card, Cockpit, share links): a
// plain holder of its entity record, drawn while it is the one tracked.
const holder = trackedContactHolder(
@@ -1093,7 +1083,8 @@ export function createTracking({
};
trackedIcon.show({
id: icao24,
image: _trackedBillboardImage(),
image: _trackedBillboardLook().image,
imageLod: _trackedBillboardLook().imageLod,
sprite,
position: getTrackedPosition,
// Solid amber when the billboard is the visual (zoomed out, 3D off, or model still loading);
@@ -1131,9 +1122,11 @@ export function createTracking({
entityRecord(flightState._trackedEntity).labelModel =
trackedLabelModelFromText(_buildTrackedLabel(info, icao24), '#ffd166');
// A billboard has a ~zero bounding sphere, so the renderer's default follow distance is
// far too tight (the user had to scroll out to read the plane). Give the target a
// calibrated viewFrom — behind + above, distance scaled to altitude — for a readable
// A click on the plane follows it from where the camera is (`keepView`,
// below). A selection from elsewhere (a search, voice, a share link) has no
// view of the plane to keep: a billboard has a ~zero bounding sphere, so the
// renderer's default follow distance is far too tight. It gets a calibrated
// viewFrom — behind + above, distance scaled to altitude — for a readable
// initial frame with surrounding context. (ENU: east=+X, north=+Y, up=+Z.)
const altM = info?.altitudeFt ? info.altitudeFt * 0.3048 : 1500;
const followRange = Math.min(Math.max(altM * 1.1 + 2500, 3000), 30000);
@@ -1157,11 +1150,17 @@ export function createTracking({
// label, sprite, display position) reads the tracked entity's record.
const camera = cameraOf(flightState._viewer);
camera.cancelFlight();
const kept = keepView
? keptViewFrom(camera.pose(), getTrackedPosition())
: null;
flightState._followTarget = entityFollowTarget(flightState._trackedEntity, {
position: getTrackedPosition,
frame: 'enu',
viewFrom,
viewFrom: kept ?? viewFrom,
minRange: FOLLOW_MIN_RANGE_M,
// A click keeps the camera's distance and angle: the plane slides to
// the centre from where the camera is, and is followed from there.
...(kept ? { transitionS: SELECTION_FOLLOW_TRANSITION_S } : {}),
});
camera.follow(flightState._followTarget);
@@ -1249,7 +1248,7 @@ export function createTracking({
if (pickedIcao && flightState._icons?.has(pickedIcao)) {
_cancelPendingTrackingRestore();
_trackFlight(pickedIcao, { origin: 'user' });
_trackFlight(pickedIcao, { origin: 'user', keepView: true });
return;
}
}
@@ -1293,6 +1292,8 @@ export function createTracking({
_refreshTr3bForStyle,
_resetTrackedSelectionState,
_trackedModelRegimeActive,
_trackedBillboardLook,
_trackedSprite,
_syncTracked2dRotation,
_trailFloorPosition,
_appendTrailFix,
+19 -9
View File
@@ -1,5 +1,9 @@
import { findCamera } from '../../render/rendererOf.js';
import { FOLLOW_MIN_RANGE_M } from '../../data/trackedCamera.js';
import {
FOLLOW_MIN_RANGE_M,
keptViewFrom,
SELECTION_FOLLOW_TRANSITION_S,
} from '../../data/trackedCamera.js';
import { copyInto, lerpInto } from '../../geo/vector.js';
import {
FOLLOW_HANDOVER_MS,
@@ -14,12 +18,14 @@ export const RAIL_FOCUS_KIND = 'train';
* The selected train's camera.
*
* A moving train is followed as a tracked aircraft is: the layer hands the
* camera port a follow target that stands on the train's marker, framed by
* the shared world-focus framing for a train and never closer than the
* aircraft's readable minimum, so the camera rides with the train and the
* user still orbits and zooms around it. Any other train gets one fly-to
* through the shared world-focus request, as a vessel does. Inside the
* Cockpit that request is refused with its toast.
* camera port a follow target that stands on the train's marker, seen from
* where the camera is (its distance and angle kept, the train sliding to
* the centre) and never closer than the aircraft's readable minimum, so the
* camera rides with the train and the user still orbits and zooms around it.
* Any other train gets one fly-to through the shared world-focus request,
* keeping the view as a vessel's does. Inside the Cockpit that request is
* refused with its toast. Without a view to keep (no camera pose), the
* shared world-focus framing for a train frames it.
*
* The follow lets go when the train is deselected (an empty click, Escape, its
* category hidden, the train leaving its feed, the layer turned off), when
@@ -106,7 +112,9 @@ export function createFollow({ state, services, parts }) {
}
function startFollow(entry, position, port) {
const offset = railFollowOffset(camera.framing, port.pose()?.heading);
const offset =
keptViewFrom(port.pose(), position) ??
railFollowOffset(camera.framing, port.pose()?.heading);
const follow = {
key: entry.key,
target: null,
@@ -119,8 +127,9 @@ export function createFollow({ state, services, parts }) {
position: () => followedPosition(follow),
frame: 'enu',
viewFrom: { x: offset.x, y: offset.y, z: offset.z },
// Framed exactly once, as a tracked aircraft is, and never closer.
// Framed once, as a tracked aircraft is, and never closer.
minRange: FOLLOW_MIN_RANGE_M,
transitionS: SELECTION_FOLLOW_TRANSITION_S,
selectionOrigin: 'user',
};
state._follow = follow;
@@ -158,6 +167,7 @@ export function createFollow({ state, services, parts }) {
id: entry.key,
label: label || entry.key,
position: { x: position.x, y: position.y, z: position.z },
keepView: true,
}) === true
);
}
+13 -4
View File
@@ -4,7 +4,11 @@
// distance while the rest of the network hides as before.
import test from 'node:test';
import assert from 'node:assert/strict';
import { FOLLOW_MIN_RANGE_M } from '../../data/trackedCamera.js';
import {
FOLLOW_MIN_RANGE_M,
keptViewFrom,
SELECTION_FOLLOW_TRANSITION_S,
} from '../../data/trackedCamera.js';
import { fromDegrees } from '../../geo/ellipsoid.js';
import { distance } from '../../geo/vector.js';
import {
@@ -147,19 +151,24 @@ test('selecting a moving train hands the camera a follow target that rides on it
const key = await bringToMotion(app, 'mbta-rail', 'T1', BOSTON);
app.moveCameraQuietly({ heading: Math.PI / 4 });
const cancelled = app.camera.flightsCancelled;
const pose = app.camera.pose();
const at = { ...app.entry(key).marker.position };
app.parts().selection.selectAndFocusTrain(key);
const target = app.camera.followed;
assert.ok(target, 'the camera follows a target');
assert.equal(app.focusRequests.length, 0, 'no one-shot fly-to');
assert.equal(app.camera.flightsCancelled, cancelled + 1);
// Framed as the aircraft are (exactly once, never closer than their
// minimum), from the train's own framing seen along the camera's heading.
// Framed as the aircraft are (once, never closer than their minimum),
// from where the camera already is: its distance and angle kept, the train
// gliding to the centre.
assert.equal(app.follows.length, 1);
assert.equal(target.frame, 'enu');
assert.equal(target.minRange, FOLLOW_MIN_RANGE_M);
const expected = railFollowOffset(WORLD_FOCUS_FRAMING.train, Math.PI / 4);
assert.equal(target.transitionS, SELECTION_FOLLOW_TRANSITION_S);
const expected = keptViewFrom(pose, at);
assert.ok(Math.abs(target.viewFrom.x - expected.x) < 1e-6);
assert.ok(Math.abs(target.viewFrom.y - expected.y) < 1e-6);
assert.ok(Math.abs(target.viewFrom.z - expected.z) < 1e-6);
// The target stands where the marker is drawn, frame after frame.
-1
View File
@@ -152,7 +152,6 @@ export const TRACK_MAX_GRADE = 0.05;
export const TRACK_SETTLE_MPS = 0.5;
export const TRACK_SNAP_M = 2_000;
export const MARKER_PIXEL_SIZE = 18;
export const SELECTED_PIXEL_SIZE = 28;
export const SELECTED_CARD_REFRESH_MS = 250;
/** While a train is selected, every other train is drawn at this opacity. */
export const UNSELECTED_TRAIN_ALPHA = 0.35;
+3 -5
View File
@@ -34,7 +34,6 @@ import {
FLOOR_WARM_MAX_DIST_KM,
MARKER_PIXEL_SIZE,
RAIL_CATEGORY_COLORS,
SELECTED_PIXEL_SIZE,
UNSELECTED_TRAIN_ALPHA,
} from './policy.js';
import { placeOnPath } from './pathBinding.js';
@@ -736,11 +735,10 @@ export function createRendering({ state, services, parts }) {
function paint(entry) {
if (!entry.marker) return;
const selected = entry.key === state._selectedKey;
const size = selected ? SELECTED_PIXEL_SIZE : MARKER_PIXEL_SIZE;
// Selection dims the other trains; the selected one keeps its size.
entry.marker.image = spriteFor(entry.category, entry.railMode);
entry.marker.width = size;
entry.marker.height = size;
entry.marker.width = MARKER_PIXEL_SIZE;
entry.marker.height = MARKER_PIXEL_SIZE;
entry.marker.color = tintFor(entry);
entry.marker.show = markerShown(entry);
touch(entry);
+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);
+2 -1
View File
@@ -212,7 +212,8 @@ export function createRendering({
pos: visual.position,
image: shipIcon(record, selected),
size: [SHIP_ICON_PX, SHIP_ICON_PX],
scale: shipScale(record) * (selected ? 1.2 : 1),
// Selection changes the colour only, never the size.
scale: shipScale(record),
rotationMode: 'course',
// Held on course; `course` for renderers without motion segments.
course: courseDeg,
+2
View File
@@ -125,6 +125,8 @@ export function createSelection({
id: record.id,
label: record.name || record.mmsi || record.id,
position: components.rendering.iconPosition(record),
// The camera keeps its distance and angle; the vessel slides to the centre.
keepView: true,
});
return true;
}