mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
src/services/groundSnap.js and src/services/meshFloorSampler.js no longer reach Cesium. Whether the surface has streamed comes from the globe port (the snap waits for the 'tiles' and 'surface' settle kinds; the sampler runs only with the globe hidden and 'surface' settled), the camera height gate from camera.pose(), heights from the query port, and the maths from src/geo/ellipsoid.js. The raw exclusion path is gone: callers see through their own draw sets by id. Cockpit's ground probe names the tracked contact's icon and model sets, which the flights and military layers keep on its entity record (groundSets), instead of the tracked holder object. Probing is unchanged: at the caller's point, up to eight readings per cell about 17 m apart, a read answering from the nearest one. The application operations entry is now Cesium-free: a viewer with no renderer bound needs ./render/cesium/unbound loaded first. Tests that used to get the adapter's factories through ground snapping load it themselves.
110 lines
3.2 KiB
JavaScript
110 lines
3.2 KiB
JavaScript
import { radioLayer } from '../data/radio.js';
|
|
import { bindRenderer } from '../render/rendererOf.js';
|
|
import { bindFakeDraw } from './fakeDrawPort.mjs';
|
|
// The layer's clicks and floors take a viewer of the test's own, as a
|
|
// renderer bound: its factories load as `./render/cesium/unbound` loads them.
|
|
import '../render/cesium/unbound.js';
|
|
|
|
export function radioStationRow(overrides = {}) {
|
|
return {
|
|
id: '00000000-0000-4000-8000-000000000001',
|
|
name: 'Station',
|
|
lat: 30,
|
|
lon: -97,
|
|
streamUrl: 'https://radio.example.com/station.mp3',
|
|
homepage: null,
|
|
tags: ['news'],
|
|
languages: ['English'],
|
|
state: 'Texas',
|
|
country: 'United States',
|
|
countryCode: 'US',
|
|
metadataTrust: 'untrusted-community',
|
|
codec: 'MP3',
|
|
bitrate: 128,
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Run `body` against an enabled `radioLayer` that serves `stations`, drawing
|
|
* through `renderer.draw`, or a fake draw port (with `renderer`'s other
|
|
* ports, if given).
|
|
* Streams listed in `failingUrls` (mutable) reject play(); `body` receives the
|
|
* played URLs, the catalog, whose rows and generation the next update()
|
|
* serves, and the fake draw port.
|
|
*/
|
|
export async function withRadioLayer(
|
|
{ stations, failingUrls = [], renderer = {} },
|
|
body,
|
|
) {
|
|
const originalFetch = globalThis.fetch;
|
|
const originalAudio = globalThis.Audio;
|
|
const playUrls = [];
|
|
const catalog = { rows: stations, generation: 1 };
|
|
globalThis.Audio = class FakeAudio {
|
|
constructor() {
|
|
this.volume = 0.8;
|
|
this.src = '';
|
|
}
|
|
|
|
addEventListener() {}
|
|
pause() {}
|
|
play() {
|
|
playUrls.push(this.src);
|
|
if (failingUrls.includes(this.src)) {
|
|
return Promise.reject(
|
|
new DOMException('unavailable', 'NotSupportedError'),
|
|
);
|
|
}
|
|
return Promise.resolve();
|
|
}
|
|
removeAttribute() {
|
|
this.src = '';
|
|
}
|
|
load() {}
|
|
};
|
|
globalThis.fetch = async (url) =>
|
|
String(url).startsWith('/api/radio/click/')
|
|
? { ok: true }
|
|
: new Response(
|
|
JSON.stringify({
|
|
stations: catalog.rows,
|
|
stale: false,
|
|
degraded: false,
|
|
acceptedGeneration: catalog.generation,
|
|
catalogInstance: 'qa-instance-a',
|
|
updatedAt: new Date().toISOString(),
|
|
}),
|
|
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
|
);
|
|
const viewer = {
|
|
camera: { positionWC: { x: 7_000_000, y: 0, z: 0 } },
|
|
scene: {
|
|
canvas: {
|
|
disableRootEvents: true,
|
|
onwheel: null,
|
|
addEventListener() {},
|
|
removeEventListener() {},
|
|
},
|
|
},
|
|
};
|
|
// The stations draw through the renderer's draw port: `renderer.draw`
|
|
// when given, else a fake one.
|
|
const { draw, unbind } = renderer.draw
|
|
? { draw: renderer.draw, unbind: bindRenderer(viewer, renderer) }
|
|
: bindFakeDraw(viewer, renderer);
|
|
radioLayer.destroy();
|
|
try {
|
|
radioLayer.init(viewer);
|
|
radioLayer.enable();
|
|
await radioLayer.update();
|
|
await body({ playUrls, catalog, draw });
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
if (originalAudio === undefined) delete globalThis.Audio;
|
|
else globalThis.Audio = originalAudio;
|
|
radioLayer.destroy();
|
|
unbind();
|
|
}
|
|
}
|