Read aircraft model placement from the app's mirror

Flights, military and local ADS-B now write their models' show and world
matrix through setModel in src/data/modelMirror.js, and read them back
through modelState: the fleet and tracked handoffs, the tracked visual and
trail anchors, detection anchors and modelAnchorWorld. A matrix is copied
into the app's record and into the model's own matrix, so the shared scratch
can be passed directly and models still never share one matrix object.

What Cesium measures (ready, computedScale) is still read from the model,
and colour stays live as on billboards, because cyber sonar writes it too.
Test seams mirror the models they install, as they do billboards.
This commit is contained in:
Sameh Khamis committed 2026-11-03 12:58:50 -08:00
1 parent 6639c4bb80
commit 05904edfc9
15 files changed
+273 -88

No files matched your search

+16 -10
View File
@@ -16,6 +16,7 @@ import {
} from '../flights/policy.js';
import { AIRCRAFT_ENVIRONMENT_MAP_OPTIONS } from '../../data/aircraftModelLighting.js';
import { aircraftVisuals } from '../aircraft/visualState.js';
import { setModel } from '../../data/modelMirror.js';
const specKey = (spec) => `${spec.url}@${spec.scale}`;
@@ -56,6 +57,7 @@ export function createLocalAdsbModels({
let lastEligibilityAt = 0;
let eligible = new Set();
const scratchHpr = new Cesium.HeadingPitchRoll();
const scratchMatrix = new Cesium.Matrix4();
const scratchSphere = new Cesium.BoundingSphere(Cesium.Cartesian3.ZERO, 1);
const scratchCarto = new Cesium.Cartographic();
const scratchGround = new Cesium.Cartesian3();
@@ -118,7 +120,7 @@ export function createLocalAdsbModels({
visual.specKey = key;
visual.bellyM = spec.bellyM;
// Admitted, not yet the visual: placement turns it on.
model.show = false;
setModel(model, 'show', false);
collection.add(model);
models.set(id, model);
}
@@ -224,7 +226,7 @@ export function createLocalAdsbModels({
if (!model || !marker.position) continue;
const position = placement(id, marker);
if (!position || !occluder.isPointVisible(marker.position)) {
model.show = false;
setModel(model, 'show', false);
continue;
}
scratchHpr.heading = Cesium.Math.toRadians(
@@ -232,18 +234,22 @@ export function createLocalAdsbModels({
);
scratchHpr.pitch = 0;
scratchHpr.roll = 0;
Cesium.Transforms.headingPitchRollToFixedFrame(
position,
scratchHpr,
Cesium.Ellipsoid.WGS84,
undefined,
model.modelMatrix,
setModel(
model,
'modelMatrix',
Cesium.Transforms.headingPitchRollToFixedFrame(
position,
scratchHpr,
Cesium.Ellipsoid.WGS84,
undefined,
scratchMatrix,
),
);
if (!model.ready) {
model.show = false;
setModel(model, 'show', false);
continue;
}
model.show = true;
setModel(model, 'show', true);
marker.modelOwnsVisual = true;
}
for (const id of [...models.keys()]) if (!markers.has(id)) release(id);