Files
gods-eye-view/src/testSupport/fleetModelFakes.mjs
T
Sameh Khamis 866a9816f2 Merge origin/main into the renderer seam
Brings in main up to f24abfc88: cockpit subject providers, the render
failure notice, aircraft drawn in their own mesh colours, airport ground
vehicles, and an aircraft with no ground track facing its true heading.

Under the seam:
- The render failure notice lives in the Cesium adapter
  (src/render/cesium/renderFailure.js) and is the application hook
  renderFailureNotice({allowReload, store}); its private Cesium fields
  (Event's raise queue, the widget's render loop flag) are read through
  internals.js. The inline panel's timer waits while the frame port reports
  the loop stopped, and goes on after a Retry.
- Ordinary aircraft models draw white with the 'highlight' colour blend
  through the draw port; tracked and emergency colours tint the mesh.
- Held trains and transit vehicles hide their route set and markers through
  the draw port; the fleet model test fakes answer loads through the fake
  draw port instead of Cesium's glTF loader.
- The Cockpit's subject view follows and places the camera through the
  camera port.
2026-11-14 09:59:55 -08:00

68 lines
2.1 KiB
JavaScript

// Fleet models for a layer test (fleetModelInstances.js): the project's model
// set loaded from public/, a DISPLAY 3D toggle that is on, and the layer's
// draw port (testSupport/fakeDrawPort.mjs) answering each model's load.
import { loadFleetModelSet } from '../data/fleetModels.js';
import { fetchPublicFile } from './fleetGlb.mjs';
/** A model policy whose eligibility is read again on every frame. */
export const FLEET_TEST_POLICY = Object.freeze({
altitudeCeilingM: 800_000,
minimumPixelSize: 16,
cap: 4,
capAll: 8,
addM: 5_000,
addAllM: 20_000,
keepM: 6_000,
keepAllM: 24_000,
intervalMs: 0,
});
/**
* Load the fleet set (once a process, as the app does). Call it before the
* layer's harness, which replaces `fetch`; then `watch` the harness's draw
* port.
* @returns {Promise<{fleet: object, watch: (draw: object) => void,
* load: () => void, drawn: (id: string) => object[]}>} `fleet` for the
* layer's services; `load()` finishes the load of every model the layer
* has asked for, as the renderer does off the frame; `drawn(id)` the
* models drawn for the vehicle `id` now.
*/
export async function fleetModelFakes() {
const info = console.info;
console.info = () => {};
try {
await loadFleetModelSet({ fetchImpl: fetchPublicFile });
} finally {
console.info = info;
}
let draw = null;
const sets = () =>
draw
? [...draw.sets.values()].filter(
(set) =>
!set.disposed &&
set.kind === 'models' &&
set.spec.id.startsWith('fleet-models:'),
)
: [];
return {
fleet: {
policy: FLEET_TEST_POLICY,
display: () => ({ models3d: true, models3dMode: 'proximity' }),
resolveAsset: (url) => url,
},
watch(port) {
draw = port;
},
load() {
for (const set of sets())
for (const id of [...set.items.keys()]) draw.ready(set.spec.id, id);
},
drawn: (id) =>
sets().flatMap((set) => {
const item = set.items.get(id);
return item && item.show !== false && set.show ? [item] : [];
}),
};
}