mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
fix(selection): selecting or tracking a contact never recolours it
A tracked aircraft's icon and 3D model keep the colours they have untracked in Flights and Military Flights (no cyan, no lighter amber); only the icon's alpha changes (stale fade, clear while its model draws). A selected vessel or aid keeps its type colour instead of white, and a tracked satellite's dot keeps its class colour instead of yellow. An emergency stays red while tracked.
This commit is contained in:
1 parent
2f0c01eaa7
commit
f49352d228
23 files changed
+192
-108
No files matched your search
@@ -31,10 +31,6 @@ export const BILLBOARD_SCALE = 0.7;
|
||||
|
||||
export const MIL_ICON_COLOR = rgba('#FFB800');
|
||||
|
||||
/** @constant {number[]} Lighter amber tint applied to the actively tracked aircraft */
|
||||
|
||||
export const TRACKED_ICON_COLOR = rgba('#FFD166');
|
||||
|
||||
/** @constant {number[]} Red tint for aircraft broadcasting an emergency (mirror of flights) */
|
||||
|
||||
export const EMERGENCY_ICON_COLOR = rgba(EMERGENCY_TINT_CSS);
|
||||
@@ -106,10 +102,6 @@ export const COCKPIT_AIR_ALL_KEEP_M = 450000;
|
||||
export const MODEL_HEADING_OFFSET_DEG = 180;
|
||||
// every fleet model is nose -X: opposite Cesium heading 0
|
||||
|
||||
/** Amber fade target for the tracked billboard once the model takes over (mirrors flights.js CYAN_TRANSPARENT). */
|
||||
|
||||
export const AMBER_TRANSPARENT = rgba('#FFB800', 0);
|
||||
|
||||
export const COCKPIT_CONTACT_SIZE_PX = 6;
|
||||
|
||||
/** The tracked billboard's size by eye distance (the renderer's `NearFar`). */
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
BILLBOARD_SCALE,
|
||||
GROUND_SCALE,
|
||||
MIL_ICON_COLOR,
|
||||
TRACKED_ICON_COLOR,
|
||||
EMERGENCY_ICON_COLOR,
|
||||
MODEL_WHITE,
|
||||
} from './policy.js';
|
||||
@@ -56,11 +55,10 @@ export function createRendering({
|
||||
const _iconKind = (icao24, klass) =>
|
||||
tr3bIconKind(icao24, klass, { hot: flightState._irBoost });
|
||||
|
||||
/** Model colour: the mesh's own (white), tinted amber while tracked and red
|
||||
* while broadcasting an emergency. */
|
||||
/** Model colour: the mesh's own (white), tinted red while broadcasting an
|
||||
* emergency. Tracking never recolours it. */
|
||||
|
||||
function _modelColor(icao24) {
|
||||
if (icao24 === flightState._trackedIcao) return TRACKED_ICON_COLOR;
|
||||
const info = flightState.records.data.get(icao24);
|
||||
return isEmergency(info?.emergency) ? EMERGENCY_ICON_COLOR : MODEL_WHITE;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AMBER_TRANSPARENT, TRACKED_ICON_COLOR } from './policy.js';
|
||||
import { trackedIconColor } from '../../data/trackedAircraftIcon.js';
|
||||
import { createModelRecord } from '../../data/modelRecord.js';
|
||||
import {
|
||||
aircraftIconTestSeams,
|
||||
@@ -170,9 +170,11 @@ export function createTesting({
|
||||
/** Evaluate the production tracked-billboard handoff colour for focused tests. */
|
||||
|
||||
function _trackedBillboardColorForTest() {
|
||||
return parts.rendering._modelOwnsVisual(flightState._trackedIcao)
|
||||
? AMBER_TRANSPARENT
|
||||
: TRACKED_ICON_COLOR;
|
||||
const icao24 = flightState._trackedIcao;
|
||||
const color = parts.rendering._fleetBillboardColor(icao24);
|
||||
return parts.rendering._modelOwnsVisual(icao24)
|
||||
? trackedIconColor(color, 0)
|
||||
: color;
|
||||
}
|
||||
|
||||
/** Drive the exact fleet icon-to-model handoff used by `_fleetTick`. */
|
||||
@@ -194,15 +196,20 @@ export function createTesting({
|
||||
}
|
||||
|
||||
/** How the tracked billboard is drawn (`_trackedBillboardLook`,
|
||||
* `_trackedSprite`) next to how the contact's fleet icon is (`_fleetLook`). */
|
||||
* `_trackedSprite`, `_trackedIconColor`) next to how the contact's fleet
|
||||
* icon is (`_fleetLook`, `_fleetBillboardColor`). */
|
||||
|
||||
function _trackedIconLookForTest(icao24) {
|
||||
return {
|
||||
tracked: {
|
||||
...parts.tracking._trackedBillboardLook(),
|
||||
sprite: parts.tracking._trackedSprite(icao24),
|
||||
color: parts.tracking._trackedIconColor(),
|
||||
},
|
||||
fleet: {
|
||||
...parts.icons._fleetLook(icao24),
|
||||
color: parts.rendering._fleetBillboardColor(icao24),
|
||||
},
|
||||
fleet: parts.icons._fleetLook(icao24),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
createTrackedAircraftIcon,
|
||||
isOtherTrackedIconSet,
|
||||
trackedContactHolder,
|
||||
trackedIconColor,
|
||||
} from '../../data/trackedAircraftIcon.js';
|
||||
import { fromDegrees, toLonLatH } from '../../geo/ellipsoid.js';
|
||||
import { julianToEpochMs } from '../../geo/julian.js';
|
||||
@@ -36,8 +37,6 @@ import {
|
||||
followsClock,
|
||||
STALE_ALPHA,
|
||||
TRAIL_COLOR,
|
||||
AMBER_TRANSPARENT,
|
||||
TRACKED_ICON_COLOR,
|
||||
} from './policy.js';
|
||||
import {
|
||||
drawTrailSegments,
|
||||
@@ -64,11 +63,6 @@ function aircraftPickId(hit) {
|
||||
return isOtherTrackedIconSet(hit.set, 'military') ? undefined : hit.id;
|
||||
}
|
||||
|
||||
const STALE_TRACKED_COLOR = Object.freeze([
|
||||
...TRACKED_ICON_COLOR.slice(0, 3),
|
||||
STALE_ALPHA,
|
||||
]);
|
||||
|
||||
export function createTracking({
|
||||
flightState,
|
||||
services,
|
||||
@@ -312,14 +306,18 @@ export function createTracking({
|
||||
return { text: '', dimmed: false };
|
||||
}
|
||||
|
||||
/** The tracked billboard's colour: amber, faded while stale, clear while the 3D model is the visual. */
|
||||
/** The tracked billboard's colour: the contact's own fleet colour (tracking
|
||||
* never recolours it), faded while stale, clear while the 3D model is the
|
||||
* visual. */
|
||||
|
||||
function _trackedIconColor() {
|
||||
if (parts.rendering._modelOwnsVisual(flightState._trackedIcao))
|
||||
return AMBER_TRANSPARENT;
|
||||
return _trackedStaleCue(flightState._trackedIcao).dimmed
|
||||
? STALE_TRACKED_COLOR
|
||||
: TRACKED_ICON_COLOR;
|
||||
const icao24 = flightState._trackedIcao;
|
||||
const color = parts.rendering._fleetBillboardColor(icao24);
|
||||
if (parts.rendering._modelOwnsVisual(icao24))
|
||||
return trackedIconColor(color, 0);
|
||||
return _trackedStaleCue(icao24).dimmed
|
||||
? trackedIconColor(color, STALE_ALPHA)
|
||||
: color;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1048,14 +1046,13 @@ export function createTracking({
|
||||
imageLod: _trackedBillboardLook().imageLod,
|
||||
sprite,
|
||||
position: getTrackedPosition,
|
||||
// Solid amber when the billboard is the visual (zoomed out, 3D off, or model still loading);
|
||||
// transparent once the tracked model is actually up (ready + shown).
|
||||
// Amber (faded while stale), transparent once the tracked model is the visual.
|
||||
// Its own colour (faded while stale) when the billboard is the visual (zoomed out, 3D off,
|
||||
// or model still loading); transparent once the tracked model is actually up (ready + shown).
|
||||
color: _trackedIconColor,
|
||||
// Screen-projected rotation, evaluated per frame on the camera's own
|
||||
// axes, so it stays exact through a tracked orbit. The tracked target
|
||||
// must never vanish into tile geometry — tracking a taxiing plane at
|
||||
// street level would otherwise bury the amber icon inside the runway
|
||||
// street level would otherwise bury the icon inside the runway
|
||||
// skin, so it draws over depth like the fleet icon set; its
|
||||
// shared-host tracked card is top-composited separately.
|
||||
rotation: () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { createStubRenderer } from '../../render/stub/index.js';
|
||||
import { createMotion } from './motion.js';
|
||||
import { createFlightState } from './state.js';
|
||||
import { createTracking } from './tracking.js';
|
||||
import { RENDER_DELAY_SEC, STALE_ALPHA } from './policy.js';
|
||||
import { MIL_ICON_COLOR, RENDER_DELAY_SEC, STALE_ALPHA } from './policy.js';
|
||||
|
||||
// A tracked military contact's trail is its reports joined along the curve
|
||||
// the icon is drawn along between them, so the icon always sits on its trail
|
||||
@@ -104,7 +104,11 @@ function harness({ fixes, info, nowMs, ground = () => null }) {
|
||||
flightState.now = () => clock;
|
||||
flightState._positionHistory.set(ICAO, fixes);
|
||||
const parts = {
|
||||
rendering: { _modelOwnsVisual: () => false, _modelSpec: () => ({}) },
|
||||
rendering: {
|
||||
_modelOwnsVisual: () => false,
|
||||
_modelSpec: () => ({}),
|
||||
_fleetBillboardColor: () => MIL_ICON_COLOR,
|
||||
},
|
||||
queries: {
|
||||
_toCleanText: (value) => (typeof value === 'string' ? value.trim() : ''),
|
||||
_formatAltitude: (ft) => `${ft} ft`,
|
||||
@@ -649,6 +653,11 @@ test('military: a stalled feed dims the tracked plane as STALE', () => {
|
||||
dimmed: true,
|
||||
});
|
||||
assert.equal(h.tracking._trackedIconColor()[3], STALE_ALPHA);
|
||||
assert.deepEqual(
|
||||
h.tracking._trackedIconColor().slice(0, 3),
|
||||
MIL_ICON_COLOR.slice(0, 3),
|
||||
'faded in its own colour, never recoloured',
|
||||
);
|
||||
assert.equal(h.flightState.records.missingPolls.has(ICAO), false);
|
||||
} finally {
|
||||
h.restore();
|
||||
|
||||
Reference in new issue
Block a user