fix(vessels, transit, rail): fleet models keep their cards and detection, stand on the floor, clip ships at the waterline and follow NVG/FLIR

- a vehicle drawn as a model keeps its selected card and stays in the detection overlay
- transit and rail models drop the 1.5 m floor lift their icons carry
- vessel models are clipped below the waterline
- models switch to an unlit white look under NVG/FLIR and back
- unknown transit modes keep their icon
- aircraft model specs are cached per set; no key-array copies per frame
This commit is contained in:
Sameh Khamis committed 2026-11-13 07:16:25 -08:00
1 parent 058ed0ffeb
commit a44c42eb94
11 files changed
+342 -89

No files matched your search

+3 -1
View File
@@ -129,7 +129,9 @@ export function createQueries({ state, parts }) {
const visible = [];
for (const entry of state._visible) {
const marker = entry.marker;
if (!marker?.position || marker.show === false) continue;
// A vehicle drawn as its 3D model is present though its marker is hidden.
if (!marker?.position) continue;
if (marker.show === false && entry.modelOwnsVisual !== true) continue;
visible.push(entry);
}
let chosen = visible;
+20 -6
View File
@@ -468,7 +468,11 @@ export function createRendering({ state, services, parts }) {
// icon-to-model rules (services.fleet). The fleet set loads once, up front,
// when the layer starts.
let fleetModels = null;
/** Items drawn last frame, and the map the next frame's are gathered into. */
let modelItems = new Map();
let spareItems = new Map();
/** The lift icons are drawn with above the floor; a model stands on the floor. */
const groundLiftM = services.ground?.GROUND_FLOOR_LIFT_M || 0;
/** Load the fleet set and create the layer's models (on enable). */
function startModels() {
@@ -500,19 +504,27 @@ export function createRendering({ state, services, parts }) {
if (!fleetModels) return;
if (!fleetModels.active() || state._vehicles.size === 0) {
if (modelItems.size) {
fleetModels.frame(new Map(), performance.now());
for (const item of modelItems.values()) handBack(item.entry);
modelItems = new Map();
modelItems.clear();
fleetModels.frame(modelItems, performance.now());
}
return;
}
const set = fleetModelSet();
const next = new Map();
const next = spareItems;
next.clear();
for (const entry of state._visible) {
if (!entry.marker || !entry.hasRendered) continue;
// A vehicle of no known mode keeps its icon: no model says what it is.
if (!entry.marker || !entry.hasRendered || entry.mode === 'unknown')
continue;
let item = modelItems.get(entry.key);
if (!item || item.entry !== entry) {
item = { entry, pickId: entry.key, modelOwnsVisual: false };
item = {
entry,
pickId: entry.key,
modelOwnsVisual: false,
groundLiftM,
};
}
if (item.mode !== entry.mode) {
item.mode = entry.mode;
@@ -527,6 +539,7 @@ export function createRendering({ state, services, parts }) {
}
for (const [key, item] of modelItems)
if (next.get(key) !== item) handBack(item.entry);
spareItems = modelItems;
modelItems = next;
fleetModels.frame(modelItems, performance.now());
for (const item of modelItems.values()) {
@@ -542,7 +555,8 @@ export function createRendering({ state, services, parts }) {
/** Drop every model (layer disabled); `destroy` also removes the collection. */
function stopModels(destroy = false) {
for (const item of modelItems.values()) item.entry.modelOwnsVisual = false;
modelItems = new Map();
modelItems.clear();
spareItems.clear();
if (destroy) {
fleetModels?.destroy();
fleetModels = null;
+4 -2
View File
@@ -24,14 +24,16 @@ export function createSelection({ state, services, parts }) {
* (the tracked-aircraft readout uses the same), so the anchor moves with the
* sprite at frame rate, through poll arrivals, settling, a late floor and a
* reset alike, with no per-frame work here. Null when there is nothing to
* anchor to: a hidden or removed marker draws no card.
* anchor to: a hidden or removed marker draws no card, unless the vehicle's
* 3D model is drawing it in the marker's place.
* @param {object} entry
* @returns {() => Cesium.Cartesian3|null}
*/
function anchorFor(entry) {
return () => {
const marker = entry.marker;
const p = marker?.show !== false ? marker?.position : null;
const drawn = marker?.show !== false || entry.modelOwnsVisual === true;
const p = drawn ? marker?.position : null;
return p &&
Number.isFinite(p.x) &&
Number.isFinite(p.y) &&