mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Delete the billboard and model mirrors; models become layer-held records
Aircraft draw from GPU icon sets, so the billboard mirror, the billboard treatment and the aircraft visual-state module had no callers left. 3D models are now records the layer holds under the contact's id (modelRecord.js): show and placement are written through showModel/placeModel and read back from the record; renderer-measured values stay on record.model. The tracked-model click check only matches when a tracked model exists, so an id-only pick is never mistaken for a click on the tracked plane.
This commit is contained in:
1 parent
f008120b4c
commit
6035de88e2
35 files changed
+391
-788
No files matched your search
@@ -32,7 +32,6 @@ import {
|
||||
DISPLAY_CORRIDOR_CELL_BUDGET,
|
||||
DISPLAY_CORRIDOR_FAIR_SHARE,
|
||||
} from './policy.js';
|
||||
import { modelState } from '../../data/modelMirror.js';
|
||||
import { readEntityRecord } from '../../data/entityRecords.js';
|
||||
import {
|
||||
aircraftMotionRegime,
|
||||
@@ -476,10 +475,10 @@ export function createMotion({
|
||||
flightState.records.data.get(flightState._trackedIcao)?.klass,
|
||||
);
|
||||
return modelVisualAnchor(
|
||||
modelState(flightState._trackedModel).modelMatrix,
|
||||
flightState._trackedModel.matrix,
|
||||
spec.visualCenterNative,
|
||||
Number.isFinite(flightState._trackedModel.computedScale)
|
||||
? flightState._trackedModel.computedScale
|
||||
Number.isFinite(flightState._trackedModel.model.computedScale)
|
||||
? flightState._trackedModel.model.computedScale
|
||||
: spec.scale,
|
||||
flightState._trackedVisualPos,
|
||||
);
|
||||
@@ -505,7 +504,7 @@ export function createMotion({
|
||||
)
|
||||
return null;
|
||||
return Cesium.Matrix4.getTranslation(
|
||||
modelState(flightState._trackedModel).modelMatrix,
|
||||
flightState._trackedModel.matrix,
|
||||
flightState._scratchTrailClip,
|
||||
);
|
||||
}
|
||||
@@ -520,8 +519,8 @@ export function createMotion({
|
||||
const spec = parts.rendering._modelSpec(
|
||||
flightState.records.data.get(flightState._trackedIcao)?.klass,
|
||||
);
|
||||
const scale = Number.isFinite(flightState._trackedModel.computedScale)
|
||||
? flightState._trackedModel.computedScale
|
||||
const scale = Number.isFinite(flightState._trackedModel.model.computedScale)
|
||||
? flightState._trackedModel.model.computedScale
|
||||
: spec.scale;
|
||||
return spec.nativeRadiusM * scale;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
FLEET_DR_INTERVAL_MS,
|
||||
} from './policy.js';
|
||||
import { emergencyBroadcastPhrase } from '../../data/aircraftEmergency.js';
|
||||
import { modelState } from '../../data/modelMirror.js';
|
||||
|
||||
export function createQueries({
|
||||
flightState,
|
||||
@@ -440,8 +439,11 @@ export function createQueries({
|
||||
const isTracked = icao24 === flightState._trackedIcao;
|
||||
// Keep planes rendered as a 3D model (icon hidden) so the detection box
|
||||
// doesn't vanish on the 2D→3D handoff.
|
||||
const model = flightState._models.get(icao24) ?? null;
|
||||
const modelOwnsVisual = parts.rendering._modelOwnsVisual(icao24, model);
|
||||
const record = flightState._models.get(icao24) ?? null;
|
||||
const modelOwnsVisual = parts.rendering._modelOwnsVisual(
|
||||
icao24,
|
||||
record,
|
||||
);
|
||||
if (!isTracked && !icons.shown(row) && !modelOwnsVisual) continue;
|
||||
const info = flightState.records.data.get(icao24);
|
||||
let object = flightState._detectionObjects.get(icao24);
|
||||
@@ -470,10 +472,10 @@ export function createQueries({
|
||||
icons.position(row, tau, object._iconPos)
|
||||
: modelOwnsVisual
|
||||
? modelVisualAnchor(
|
||||
modelState(model).modelMatrix,
|
||||
record.matrix,
|
||||
spec.visualCenterNative,
|
||||
Number.isFinite(model.computedScale)
|
||||
? model.computedScale
|
||||
Number.isFinite(record.model.computedScale)
|
||||
? record.model.computedScale
|
||||
: spec.scale,
|
||||
object._weldPos || (object._weldPos = new Cesium.Cartesian3()),
|
||||
)
|
||||
|
||||
@@ -6,7 +6,11 @@ import { createRendering } from './rendering.js';
|
||||
import { createIcons } from './icons.js';
|
||||
import { createIconSet } from '../../data/iconSet.js';
|
||||
import { writeHoldSegment } from '../../data/iconSegment.js';
|
||||
import { mirrorModel, setModel } from '../../data/modelMirror.js';
|
||||
import {
|
||||
createModelRecord,
|
||||
placeModel,
|
||||
showModel,
|
||||
} from '../../data/modelRecord.js';
|
||||
|
||||
function fixture() {
|
||||
const info = {
|
||||
@@ -109,7 +113,7 @@ test('candidate collection resolves models once and keeps handoffs live', (t) =>
|
||||
const get = t.mock.method(f.flightState._models, 'get');
|
||||
const [candidate] = f.queries.getDetectableObjects();
|
||||
assert.equal(get.mock.callCount(), 1);
|
||||
const model = mirrorModel({
|
||||
const record = createModelRecord({
|
||||
ready: false,
|
||||
show: true,
|
||||
modelMatrix: Cesium.Matrix4.fromTranslation(
|
||||
@@ -120,25 +124,24 @@ test('candidate collection resolves models once and keeps handoffs live', (t) =>
|
||||
visualCenterNative: Cesium.Cartesian3.ZERO,
|
||||
scale: 1,
|
||||
});
|
||||
f.flightState._models.set('abc123', model);
|
||||
f.flightState._models.set('abc123', record);
|
||||
f.show(false);
|
||||
assert.deepEqual(f.queries.getDetectableObjects(), []);
|
||||
model.ready = true;
|
||||
record.model.ready = true;
|
||||
assert.equal(f.queries.getDetectableObjects()[0], candidate);
|
||||
assert.deepEqual(candidate.position, new Cesium.Cartesian3(10, 20, 30));
|
||||
setModel(
|
||||
model,
|
||||
'modelMatrix',
|
||||
placeModel(
|
||||
record,
|
||||
Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(40, 50, 60)),
|
||||
);
|
||||
f.queries.getDetectableObjects();
|
||||
assert.deepEqual(candidate.position, new Cesium.Cartesian3(40, 50, 60));
|
||||
setModel(model, 'show', false);
|
||||
showModel(record, false);
|
||||
assert.deepEqual(f.queries.getDetectableObjects(), []);
|
||||
f.show(true);
|
||||
assert.deepEqual(f.queries.getDetectableObjects()[0].position, f.drawn());
|
||||
assert.equal(get.mock.callCount(), 6);
|
||||
setModel(model, 'show', true);
|
||||
showModel(record, true);
|
||||
assert.equal(f.parts.rendering._modelOwnsVisual('abc123'), true);
|
||||
assert.equal(get.mock.callCount(), 7);
|
||||
});
|
||||
@@ -146,7 +149,7 @@ test('candidate collection resolves models once and keeps handoffs live', (t) =>
|
||||
test('tracked ownership and live anchors remain independent of fleet models', () => {
|
||||
const f = fixture();
|
||||
f.flightState._trackedIcao = 'abc123';
|
||||
f.flightState._trackedModel = mirrorModel({ ready: true, show: true });
|
||||
f.flightState._trackedModel = createModelRecord({ ready: true, show: true });
|
||||
f.parts.rendering._modelSpec = () => ({});
|
||||
let anchor = new Cesium.Cartesian3(10, 20, 30);
|
||||
f.parts.motion._trackedVisualCached = () => anchor;
|
||||
@@ -158,16 +161,16 @@ test('tracked ownership and live anchors remain independent of fleet models', ()
|
||||
assert.equal(f.queries.getDetectableObjects()[0].position, anchor);
|
||||
for (const tracked of [
|
||||
null,
|
||||
mirrorModel({ ready: false, show: true }),
|
||||
mirrorModel({ ready: true, show: false }),
|
||||
createModelRecord({ ready: false, show: true }),
|
||||
createModelRecord({ ready: true, show: false }),
|
||||
]) {
|
||||
f.flightState._trackedModel = tracked;
|
||||
assert.equal(
|
||||
f.parts.rendering._modelOwnsVisual('abc123', mirrorModel({ ready: true, show: true })),
|
||||
f.parts.rendering._modelOwnsVisual('abc123', createModelRecord({ ready: true, show: true })),
|
||||
false,
|
||||
);
|
||||
}
|
||||
f.flightState._trackedModel = mirrorModel({ ready: true, show: true });
|
||||
f.flightState._trackedModel = createModelRecord({ ready: true, show: true });
|
||||
f.parts.tracking._trackedModelRegimeActive = () => false;
|
||||
assert.equal(f.parts.rendering._modelOwnsVisual('abc123', null), false);
|
||||
});
|
||||
@@ -239,8 +239,8 @@ export function createFlightSnapshotRenderer({
|
||||
sampleMeshFloorCells(flightState._viewer?.scene, floorWarmPoints, {
|
||||
excludeObjects: [
|
||||
...icons._iconIds(),
|
||||
...flightState._models.values(),
|
||||
flightState._trackedModel,
|
||||
...[...flightState._models.values()].map((record) => record.model),
|
||||
flightState._trackedModel?.model,
|
||||
].filter(Boolean),
|
||||
viewerLat: viewerLatDeg,
|
||||
viewerLon: viewerLonDeg,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { CYAN_TRANSPARENT } from './policy.js';
|
||||
import { mirrorModel } from '../../data/modelMirror.js';
|
||||
import { createModelRecord } from '../../data/modelRecord.js';
|
||||
import { createIconSet } from '../../data/iconSet.js';
|
||||
import { aircraftIconTestSeams } from '../../data/aircraftIconLayer.js';
|
||||
|
||||
@@ -49,9 +49,9 @@ export function createTesting({
|
||||
* @param {string} state.icao24
|
||||
* @param {object} state.entity
|
||||
* @param {object} state.meta
|
||||
* @param {{position?: Cesium.Cartesian3, show?: boolean}} [state.billboard]
|
||||
* @param {{position?: Cesium.Cartesian3, show?: boolean}} [state.icon]
|
||||
* Where the contact's icon is held, and whether it is shown.
|
||||
* @param {{show?: boolean}} [state.billboardCollection] Layer visibility.
|
||||
* @param {{show?: boolean}} [state.iconLayer] Layer visibility.
|
||||
* @param {object} state.viewer
|
||||
* @param {Array<Object>} [state.history=[]]
|
||||
* @param {boolean} [state.tracked=true]
|
||||
@@ -63,8 +63,8 @@ export function createTesting({
|
||||
icao24,
|
||||
entity,
|
||||
meta,
|
||||
billboard,
|
||||
billboardCollection,
|
||||
icon,
|
||||
iconLayer,
|
||||
viewer,
|
||||
history = [],
|
||||
tracked = true,
|
||||
@@ -76,13 +76,13 @@ export function createTesting({
|
||||
flightState._icons = createIconSet({
|
||||
epoch: parts.icons._displayTime(new Cesium.JulianDate()),
|
||||
});
|
||||
flightState._icons.show = billboardCollection?.show ?? true;
|
||||
flightState._icons.show = iconLayer?.show ?? true;
|
||||
flightState._grounded.clear();
|
||||
flightState._floorPinned.clear();
|
||||
_seedIconForTest(icao24, billboard, tracked);
|
||||
_seedIconForTest(icao24, icon, tracked);
|
||||
flightState._models.clear();
|
||||
for (const [key, model] of models)
|
||||
flightState._models.set(key, mirrorModel(model));
|
||||
flightState._models.set(key, createModelRecord(model));
|
||||
flightState._detectionObjects = new Map();
|
||||
flightState.records.data = new Map([[icao24, meta]]);
|
||||
flightState._positionHistory = new Map([[icao24, history]]);
|
||||
@@ -125,10 +125,10 @@ export function createTesting({
|
||||
function _addFlightTrackingCandidateForTest({
|
||||
icao24,
|
||||
meta,
|
||||
billboard,
|
||||
icon,
|
||||
history = [],
|
||||
}) {
|
||||
_seedIconForTest(icao24, billboard, false);
|
||||
_seedIconForTest(icao24, icon, false);
|
||||
flightState.records.data.set(icao24, meta);
|
||||
flightState._positionHistory.set(icao24, history);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ export function createTesting({
|
||||
|
||||
async function _ensureFleetModelForTest(icao24) {
|
||||
await parts.rendering._ensureModel(icao24);
|
||||
return flightState._models.get(icao24) || null;
|
||||
return flightState._models.get(icao24)?.model ?? null;
|
||||
}
|
||||
/** Run the fleet tick's grounded floor pass once, at `renderTime`. */
|
||||
|
||||
|
||||
@@ -1193,7 +1193,8 @@ export function createTracking({
|
||||
const rawPick =
|
||||
typeof picked.id === 'string' ? picked.id : picked.primitive?.id;
|
||||
if (
|
||||
picked.primitive === flightState._trackedModel ||
|
||||
(flightState._trackedModel &&
|
||||
picked.primitive === flightState._trackedModel.model) ||
|
||||
rawPick === flightState._trackedIcao
|
||||
)
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user