mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
Deselecting a plane drawn as a model no longer flashes its icon
A selected plane is drawn by its own model, and its fleet model was let go once that model drew. Deselecting showed the icon at once, and the icon stayed for about a second while a new fleet model loaded. The fleet model now stays loaded but hidden while the plane is selected, kept where the plane is. Deselecting hands the plane back to it in the same frame, and the icon shows only when there is no loaded fleet model. Military aircraft share this code. Vessels never swap models on selection, so they had no flash.
This commit is contained in:
1 parent
36624cd329
commit
b041fea7a6
6 files changed
+248
-43
No files matched your search
@@ -8014,7 +8014,7 @@ pins and share links already supply complete boxes.
|
||||
|
||||
### 3D Aircraft + Tracking (June 2026)
|
||||
|
||||
- **The TRACKED contact draws as a model exactly when the fleet would.** `_trackedModelRegimeActive` (`src/layers/flights/tracking.js`, `src/layers/military/tracking.js`) asks the fleet's own rule: the DISPLAY-rail `3D` toggle on, the camera below the fleet ceiling, and a place in the fleet pass's nearest-first cap (`_trackedModelEligible`), so selecting a contact changes its colour, never its form or size. Cockpit and TR-3B suppression are unchanged. The tracked model loads on demand from the fleet set's bytes; on-demand loading is bounded at 3 attempts per selection with a 1.5 s backoff and one console warning naming the asset (the driver runs every `scene.preUpdate`, so an unbounded catch would spin load→reject at frame rate), and the load-failure budget is per-selection state cleared by `_resetTrackedSelectionState()` on deselect / re-track / cross-layer / init / destroy. The icon stays the visual throughout a failed load.
|
||||
- **The TRACKED contact draws as a model exactly when the fleet would.** `_trackedModelRegimeActive` (`src/layers/flights/tracking.js`, `src/layers/military/tracking.js`) asks the fleet's own rule: the DISPLAY-rail `3D` toggle on, the camera below the fleet ceiling, and a place in the fleet pass's nearest-first cap (`_trackedModelEligible`), so selecting a contact changes its colour, never its form or size. Cockpit and TR-3B suppression are unchanged. While a contact is selected its FLEET model stays loaded but hidden (`_keepTrackedFleetModel`, `src/data/aircraftModelLayer.js`): it draws the contact only until the tracked model is ready, and the fleet pass keeps it placed where the icon is (admitting one if the contact was an icon when selected and comes within range). Deselecting hands the contact back in the same frame (`_handBackDeselected`): to that fleet model when it is loaded, else to the icon, so a contact drawn as a model never flashes its icon while a new fleet model loads. The tracked model loads on demand from the fleet set's bytes; on-demand loading is bounded at 3 attempts per selection with a 1.5 s backoff and one console warning naming the asset (the driver runs every `scene.preUpdate`, so an unbounded catch would spin load→reject at frame rate), and the load-failure budget is per-selection state cleared by `_resetTrackedSelectionState()` on deselect / re-track / cross-layer / init / destroy. The icon stays the visual throughout a failed load.
|
||||
- **Grounded 3D handoff is terrain-validity gated (2026-08-23).** A ready civilian or military glTF does not own the visual until `groundSnap` (`src/data/groundSnap.js`) can answer with a MEASURED photoreal-surface height. On success the layer writes `height + the model's measured belly offset` before revealing the model. Cache movement is measured on the WGS84 surface, not across altitude, so a stationary contact keeps its snap through poll-time vertical-datum changes. Model existence or GPU readiness alone never suppresses the billboard floor, and ordinary zoom/style/deselect transitions preserve a valid snap cache. **Two states, and the difference is the whole design.** COLD — nothing has ever resolved for this icao (tiles still streaming on first sight, sample failure, backoff after a first miss): there is no evidence of where the ground is, `heightFor` returns null, the model stays hidden and the depth-test-free 2D billboard remains opaque and floored. Tiles still streaming is not a miss: no sample is taken, so it earns no retry backoff, and the first fleet tick after the tiles settle samples (2026-11-15); only a sample that finds no ground backs off (2 s, doubling to 30 s). WARM — a snap resolved and then a >`MOVE_INVALIDATE_M` (50 m) taxi move stopped it answering directly: the measurement is DEMOTED to a bounded last-known rather than deleted, and it keeps answering while the resample is outstanding, so a taxiing aircraft does not pop 3D→2D→3D across a 2–30 s retry backoff. The bound is `HELD_SNAP_MAX_DRIFT_M` = 250 m from the spot the value was measured at, past which the hold is dropped rather than stretched and the contact is COLD again. It is spatial with no timer beside it (ground under a contact that has not moved does not change; what invalidates the value is the contact MOVING) and deliberately a quarter of the billboard chain's `HELD_FLOOR_MAX_DRIFT_KM` — that hold only ever RAISES a sprite, while a held snap IS the model's placement, so its error shows in both directions. A fresh sample releases the hold, and so does a ground flip (which already calls `forget`). **A loading model is HIDDEN, never zero-scaled:** admission sets `show = false` (Cesium's default is `true`, and an unplaced primitive would claim the visual at the identity matrix), and ownership is `ready && show` — Cesium 1.138's `Model.update` has no `show` guard, so hiding a primitive costs its load nothing.
|
||||
- **Ground-snap clock rollback recovery.** If the wall clock moves before the
|
||||
sampling-window start, ground snap opens a new window while retaining the
|
||||
|
||||
+115
-31
@@ -562,12 +562,11 @@ export function createAircraftModels({
|
||||
state._lastFleetTickMs = 0;
|
||||
}
|
||||
|
||||
/** Admit a fleet model for an aircraft; the icon shows until it is ready. */
|
||||
/** Admit a fleet model for an aircraft; the icon shows until it is ready.
|
||||
* The selected aircraft's is admitted too, and kept loaded but hidden
|
||||
* while its tracked model draws it (`_keepTrackedFleetModel`). */
|
||||
|
||||
function _ensureModel(icao24) {
|
||||
// Never model the TRACKED aircraft — it owns a separate entity billboard, and the fleet
|
||||
// tick skips it, so a model here would be orphaned + double-rendered.
|
||||
if (icao24 === state._trackedIcao) return;
|
||||
onModelEligible(icao24);
|
||||
if (state._models.has(icao24)) return;
|
||||
// Without model sets (the renderer draws none) the icon stays.
|
||||
@@ -672,14 +671,106 @@ export function createAircraftModels({
|
||||
);
|
||||
}
|
||||
|
||||
/** A fleet model still drawing the tracked contact (it was a model when
|
||||
* it was selected) lets go once the tracked model draws, or once the
|
||||
* contact is no longer drawn as a model at all. */
|
||||
/** The tracked contact's fleet model lets go once the contact is no
|
||||
* longer drawn as a model at all (out of range, 3D off, cockpit). */
|
||||
function _releaseTrackedFleetModel() {
|
||||
if (state._trackedIcao && state._models.has(state._trackedIcao))
|
||||
_releaseModel(state._trackedIcao);
|
||||
}
|
||||
|
||||
/** The tracked contact's fleet model (it was a model when it was
|
||||
* selected, or was admitted since) stops drawing once the tracked model
|
||||
* draws, or while the tracked icon carries the contact, but stays loaded:
|
||||
* deselecting hands the contact straight back to it
|
||||
* (`_handBackDeselected`), with no load and no icon in between. */
|
||||
function _hideTrackedFleetModel() {
|
||||
const icao24 = state._trackedIcao;
|
||||
const record = icao24 ? state._models.get(icao24) : null;
|
||||
if (!record?.show) return;
|
||||
showModel(record, false);
|
||||
_send(state._modelSets?.fleet, icao24, record, _modelSpec(_metaOf(icao24)));
|
||||
}
|
||||
|
||||
/** Keep the tracked contact's fleet model loaded and placed where its icon
|
||||
* is, one fleet tick at a time, so it is ready to take the contact back
|
||||
* the moment it is deselected. It never shows here: it draws the contact
|
||||
* only while the tracked model loads, as it did before the selection. */
|
||||
function _keepTrackedFleetModel(icao24, position, course, out) {
|
||||
_ensureModel(icao24);
|
||||
const record = state._models.get(icao24);
|
||||
if (!record) return;
|
||||
const meta = _metaOf(icao24);
|
||||
const set = state._modelSets?.fleet ?? null;
|
||||
_retryFailedFleetModel(set, icao24, record);
|
||||
const displayPos = _modelDisplayPosition(icao24, position);
|
||||
if (displayPos) placeModel(record, displayPos, _modelHeading(course, meta));
|
||||
else showModel(record, false); // nowhere safe to draw it
|
||||
_send(set, icao24, record, _modelSpec(meta), out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hand a contact just deselected back to the fleet in the same frame: to
|
||||
* its fleet model when one is loaded (kept while it was selected), placed
|
||||
* where its icon is and shown, else to its icon. Runs once the contact no
|
||||
* longer reads as tracked.
|
||||
* @param {string} icao24
|
||||
*/
|
||||
function _handBackDeselected(icao24) {
|
||||
const icons = state._icons;
|
||||
const record = state._models.get(icao24);
|
||||
if (!icons?.has(icao24)) {
|
||||
if (record) _releaseModel(icao24);
|
||||
return;
|
||||
}
|
||||
if (!record) {
|
||||
icons.setShown(icao24, true);
|
||||
return;
|
||||
}
|
||||
const pose = _pose();
|
||||
if (!pose || !_modelRegimeActive(pose) || isTr3b(icao24)) {
|
||||
_releaseModel(icao24); // the icon takes it back
|
||||
return;
|
||||
}
|
||||
const t = parts.icons._displayMs();
|
||||
const position = icons.position(icao24, t);
|
||||
_driveFleetModelHandoff(
|
||||
icao24,
|
||||
record,
|
||||
position,
|
||||
icons.course(icao24, t),
|
||||
() =>
|
||||
_treatFleetModel(
|
||||
icao24,
|
||||
record,
|
||||
distance(pose.position, position),
|
||||
pose,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/** A fleet model's tint and alpha this tick: the contact's colour, faded
|
||||
* as its icon is (focus, recession), or the IR boost's full-strength
|
||||
* white. */
|
||||
function _treatFleetModel(icao24, record, cameraDistanceM, pose) {
|
||||
const icons = state._icons;
|
||||
_treat(record, {
|
||||
// IR boost must survive the per-tick treatment write — otherwise
|
||||
// any alpha change would repaint the ordinary tint over the hot
|
||||
// white. Boosted models also skip the recession fade: hot targets
|
||||
// stay full-strength at any range (icons keep their normal
|
||||
// fade — full-opacity glyph walls read as overwhelming).
|
||||
base: state._irBoost ? WHITE : rgba(_modelColor(icao24)),
|
||||
alpha: state._irBoost
|
||||
? 1
|
||||
: aircraftTreatmentAlpha({
|
||||
baseAlpha: icons.alpha(icao24),
|
||||
focusFactor: icons.focus(icao24),
|
||||
cameraDistanceM,
|
||||
cameraHeightM: pose.height,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
/** Per-frame driver for the standalone tracked model. Runs every preUpdate (not the 80 ms fleet
|
||||
* cadence) so the centered plane moves smoothly. The tracked entity stays a pure billboard, so the
|
||||
* follow-camera's bounding sphere is ALWAYS ready — toggling 3D, or tracking while already zoomed
|
||||
@@ -713,7 +804,7 @@ export function createAircraftModels({
|
||||
parts.icons._iconPosition(state._trackedIcao);
|
||||
if (!pos) {
|
||||
_hideTrackedModel();
|
||||
_releaseTrackedFleetModel();
|
||||
_hideTrackedFleetModel();
|
||||
return;
|
||||
}
|
||||
const icao24 = state._trackedIcao;
|
||||
@@ -725,7 +816,7 @@ export function createAircraftModels({
|
||||
// The icon carries it: after the load budget is spent, or until the
|
||||
// fleet model set has loaded.
|
||||
if (!_trackedModelLoadAllowed() || !spec.url) {
|
||||
_releaseTrackedFleetModel();
|
||||
_hideTrackedFleetModel();
|
||||
return;
|
||||
}
|
||||
const record = createModelRecord({
|
||||
@@ -753,7 +844,7 @@ export function createAircraftModels({
|
||||
const displayPos = _modelDisplayPosition(icao24, pos);
|
||||
if (!displayPos) {
|
||||
_hideTrackedModel(); // no ground evidence → the icon carries it
|
||||
_releaseTrackedFleetModel();
|
||||
_hideTrackedFleetModel();
|
||||
return;
|
||||
}
|
||||
placeModel(
|
||||
@@ -763,7 +854,7 @@ export function createAircraftModels({
|
||||
);
|
||||
showModel(record, record.ready);
|
||||
_send(state._modelSets.tracked, icao24, record, spec);
|
||||
if (record.ready) _releaseTrackedFleetModel();
|
||||
if (record.ready) _hideTrackedFleetModel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -915,8 +1006,6 @@ export function createAircraftModels({
|
||||
const items = pendingItems;
|
||||
for (const icao24 of modelEligible) {
|
||||
if (isTr3b(icao24)) continue;
|
||||
// The tracked contact's model is `_updateTrackedModel`'s.
|
||||
if (icao24 === state._trackedIcao) continue;
|
||||
if (!icons.has(icao24)) continue;
|
||||
const position = icons.position(icao24, t);
|
||||
if (
|
||||
@@ -939,6 +1028,17 @@ export function createAircraftModels({
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// The tracked contact draws as `_updateTrackedModel` says; its fleet
|
||||
// model is only kept ready for when it is deselected.
|
||||
if (icao24 === state._trackedIcao) {
|
||||
_keepTrackedFleetModel(
|
||||
icao24,
|
||||
position,
|
||||
icons.course(icao24, t),
|
||||
items,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
_ensureModel(icao24);
|
||||
const record = state._models.get(icao24);
|
||||
const cameraDistanceM = distance(camPos, position);
|
||||
@@ -947,24 +1047,7 @@ export function createAircraftModels({
|
||||
record,
|
||||
position,
|
||||
icons.course(icao24, t),
|
||||
() => {
|
||||
_treat(record, {
|
||||
// IR boost must survive the per-tick treatment write — otherwise
|
||||
// any alpha change would repaint the ordinary tint over the hot
|
||||
// white. Boosted models also skip the recession fade: hot targets
|
||||
// stay full-strength at any range (icons keep their normal
|
||||
// fade — full-opacity glyph walls read as overwhelming).
|
||||
base: state._irBoost ? WHITE : rgba(_modelColor(icao24)),
|
||||
alpha: state._irBoost
|
||||
? 1
|
||||
: aircraftTreatmentAlpha({
|
||||
baseAlpha: icons.alpha(icao24),
|
||||
focusFactor: icons.focus(icao24),
|
||||
cameraDistanceM,
|
||||
cameraHeightM: pose.height,
|
||||
}),
|
||||
});
|
||||
},
|
||||
() => _treatFleetModel(icao24, record, cameraDistanceM, pose),
|
||||
items,
|
||||
);
|
||||
}
|
||||
@@ -992,6 +1075,7 @@ export function createAircraftModels({
|
||||
_releaseModels,
|
||||
_showReleasedIcon,
|
||||
_releaseTrackedModel,
|
||||
_handBackDeselected,
|
||||
_updateTrackedModel,
|
||||
_fleetTick,
|
||||
};
|
||||
|
||||
@@ -449,3 +449,30 @@ test('models are drawn at their true size, with no minimum pixel size', () => {
|
||||
f.tick();
|
||||
assert.equal(f.fleet().items.get('a1').minPixelSize ?? 0, 0);
|
||||
});
|
||||
|
||||
test('the selected contact keeps a loaded, hidden fleet model that takes it back on deselect', () => {
|
||||
const positions = new Map([['a1', near(1)]]);
|
||||
const f = fleetFixture(positions);
|
||||
// Selected while an icon: the fleet pass admits its model all the same.
|
||||
f.state._trackedIcao = 'a1';
|
||||
f.shown.set('a1', false); // selecting it hides its icon
|
||||
f.tick();
|
||||
assert.ok(f.fleet().items.has('a1'), 'admitted and loading while selected');
|
||||
f.draw.ready(f.fleetId, 'a1');
|
||||
positions.set('a1', near(2));
|
||||
f.tick();
|
||||
const item = f.fleet().items.get('a1');
|
||||
assert.equal(item.show, false, 'never drawn while selected');
|
||||
assert.deepEqual(
|
||||
item.pos,
|
||||
{ x: near(2).x, y: near(2).y, z: near(2).z },
|
||||
'placed where its icon is',
|
||||
);
|
||||
assert.equal(f.shown.get('a1'), false, 'the icon stays hidden');
|
||||
|
||||
// Deselected: its model draws it in the same frame, its icon never shows.
|
||||
f.state._trackedIcao = null;
|
||||
f.models._handBackDeselected('a1');
|
||||
assert.equal(f.fleet().items.get('a1').show, true);
|
||||
assert.equal(f.shown.get('a1'), false);
|
||||
});
|
||||
@@ -1176,11 +1176,10 @@ for (const fixture of LAYERS) {
|
||||
|
||||
viewer.draw.ready(modelSet(fixture, viewer, 'tracked').spec.id, ICAO);
|
||||
fixture.driveTrackedModel();
|
||||
assert.equal(
|
||||
fixture.ensureFleetModel(ICAO),
|
||||
null,
|
||||
'once the tracked model draws, the fleet model lets go',
|
||||
);
|
||||
const kept = fixture.ensureFleetModel(ICAO);
|
||||
assert.ok(kept, 'once the tracked model draws, the fleet model is kept');
|
||||
assert.equal(kept.ready, true, 'loaded');
|
||||
assert.equal(kept.show, false, 'but hidden: one model draws the contact');
|
||||
assert.equal(
|
||||
fixture.trackedBillboardColor()[3],
|
||||
0,
|
||||
@@ -1192,6 +1191,99 @@ for (const fixture of LAYERS) {
|
||||
}
|
||||
});
|
||||
|
||||
test(`${fixture.name}: deselecting hands the contact straight back to its loaded fleet model, with no icon flash`, () => {
|
||||
clearTr3bRegistry();
|
||||
try {
|
||||
fixture.layer.setParams({ models3d: true });
|
||||
const viewer = viewerAtHeight(30_000);
|
||||
const position = Cesium.Cartesian3.fromDegrees(-97.71, 30.21, 10_668);
|
||||
const icon = fixture.seed({
|
||||
viewer,
|
||||
models: [
|
||||
[
|
||||
ICAO,
|
||||
{
|
||||
ready: true,
|
||||
show: true,
|
||||
modelMatrix: Cesium.Matrix4.fromTranslation(position),
|
||||
},
|
||||
],
|
||||
],
|
||||
trackedModelEligible: null,
|
||||
});
|
||||
fixture.driveTrackedModel();
|
||||
viewer.draw.ready(modelSet(fixture, viewer, 'tracked').spec.id, ICAO);
|
||||
fixture.driveTrackedModel();
|
||||
assert.equal(
|
||||
fixture.trackedModel().ready,
|
||||
true,
|
||||
'the tracked model draws',
|
||||
);
|
||||
icon.show = false; // as selecting it hides it
|
||||
|
||||
fixture.layer.stopTracking();
|
||||
const fleetItem = modelSet(fixture, viewer, 'fleet').items.get(ICAO);
|
||||
assert.equal(
|
||||
fleetItem?.show,
|
||||
true,
|
||||
'the kept fleet model draws the contact in the same frame',
|
||||
);
|
||||
assert.equal(icon.show, false, 'and its icon never shows');
|
||||
assert.equal(
|
||||
modelSet(fixture, viewer, 'tracked').items.has(ICAO),
|
||||
false,
|
||||
'the tracked model is gone',
|
||||
);
|
||||
} finally {
|
||||
fixture.layer.setParams({ models3d: false });
|
||||
fixture.layer.stopTracking();
|
||||
}
|
||||
});
|
||||
|
||||
test(`${fixture.name}: deselecting shows the icon only when no fleet model is loaded`, () => {
|
||||
clearTr3bRegistry();
|
||||
try {
|
||||
fixture.layer.setParams({ models3d: true });
|
||||
const viewer = viewerAtHeight(30_000);
|
||||
// Selected as an icon: no fleet model at all.
|
||||
let icon = fixture.seed({
|
||||
viewer,
|
||||
models: [],
|
||||
trackedModelEligible: null,
|
||||
});
|
||||
fixture.layer.stopTracking();
|
||||
assert.equal(icon.show, true, 'no fleet model: the icon');
|
||||
|
||||
// A fleet model still loading when it is deselected.
|
||||
icon = fixture.seed({
|
||||
viewer,
|
||||
models: [[ICAO, { ready: false, show: false }]],
|
||||
trackedModelEligible: null,
|
||||
});
|
||||
fixture.layer.stopTracking();
|
||||
assert.equal(icon.show, true, 'a fleet model not loaded yet: the icon');
|
||||
assert.notEqual(
|
||||
modelSet(fixture, viewer, 'fleet').items.get(ICAO)?.show,
|
||||
true,
|
||||
'and the model stays hidden until it loads',
|
||||
);
|
||||
|
||||
// 3D turned off meanwhile: the icon, and the fleet model goes.
|
||||
icon = fixture.seed({
|
||||
viewer,
|
||||
models: [[ICAO, { ready: true, show: false }]],
|
||||
trackedModelEligible: null,
|
||||
});
|
||||
fixture.layer.setParams({ models3d: false });
|
||||
fixture.layer.stopTracking();
|
||||
assert.equal(icon.show, true, '3D off: the icon');
|
||||
assert.equal(fixture.ensureFleetModel(ICAO), null, 'no fleet model kept');
|
||||
} finally {
|
||||
fixture.layer.setParams({ models3d: false });
|
||||
fixture.layer.stopTracking();
|
||||
}
|
||||
});
|
||||
|
||||
test(`${fixture.name}: the tracked model draws at the fleet's scale and minimum pixel size, even up close`, () => {
|
||||
clearTr3bRegistry();
|
||||
try {
|
||||
|
||||
@@ -703,10 +703,11 @@ export function createTracking({
|
||||
// Hand the contact back to its icon only now: settling floors a grounded
|
||||
// contact, and while it still read as tracked its tracked model owned the
|
||||
// visual, so the floor would have stepped aside.
|
||||
if (flightState._icons?.has(clearedIcao)) {
|
||||
flightState._icons.setShown(clearedIcao, true);
|
||||
// Its fleet model, kept loaded while it was selected, takes it back in
|
||||
// this frame; the icon shows only when there is no loaded one.
|
||||
parts.rendering._handBackDeselected(clearedIcao);
|
||||
if (flightState._icons?.has(clearedIcao))
|
||||
parts.icons._settleIcon(clearedIcao, { fromCourseDeg: trackedCourseDeg });
|
||||
}
|
||||
parts.icons._applyIconPresentation(clearedIcao);
|
||||
clearTrackedSubjectContext('flights');
|
||||
_emitAwarenessEvent('gev:awareness-subject-cleared', {
|
||||
|
||||
@@ -932,10 +932,11 @@ export function createTracking({
|
||||
flightState._trackedIcao = null;
|
||||
// Hand the contact back to its icon only now, once it no longer reads as
|
||||
// tracked (the settle plans it as a fleet contact).
|
||||
if (flightState._icons?.has(clearedIcao)) {
|
||||
flightState._icons.setShown(clearedIcao, true);
|
||||
// Its fleet model, kept loaded while it was selected, takes it back in
|
||||
// this frame; the icon shows only when there is no loaded one.
|
||||
parts.rendering._handBackDeselected(clearedIcao);
|
||||
if (flightState._icons?.has(clearedIcao))
|
||||
parts.icons._settleIcon(clearedIcao, { fromCourseDeg: trackedCourseDeg });
|
||||
}
|
||||
parts.icons._applyIconPresentation(clearedIcao);
|
||||
clearTrackedSubjectContext('military');
|
||||
_emitAwarenessEvent('gev:awareness-subject-cleared', {
|
||||
|
||||
Reference in new issue
Block a user