Read the wind layer's map-centre reading and its marker through the query and frame ports

The wind reading at the map centre now asks the renderer's query port where
the ellipsoid lies under the middle of the canvas and converts it with the app's
WGS84 helpers, instead of Cesium's camera pick and Cartographic. The
inspection marker projects its point with the query port, hides it beyond
the ellipsoid's horizon with isOccluded, and follows rendered frames through
the frame port's postRender phase instead of the scene's event. The layer
entry no longer carries a Cesium namespace: the rendering part, which stays
Cesium-bound, defaults it, owns the fallback globe imagery host, and loads
the adapter factories a viewer with no renderer bound gets its ports from.

The wind entry, its inspection reading and its marker leave the allow-list.
They still read the viewer's canvas size and container element.
This commit is contained in:
Sameh Khamis committed 2026-11-07 01:50:42 -08:00
1 parent f0e5540561
commit 03ff8f291f
9 files changed
+121 -121

No files matched your search

+15 -11
View File
@@ -3,6 +3,8 @@ import assert from 'node:assert/strict';
import { createWindLayer, formatWindValidTime, windStats } from './index.js';
import { useWindInspectionStore } from '../../ui/stores/windInspection.js';
import { applicationPinia } from '../../ui/vueRuntime.js';
import { fromDegrees } from '../../geo/ellipsoid.js';
import { bindRenderer } from '../../render/rendererOf.js';
const snapshot = (model) => ({
model,
@@ -312,25 +314,27 @@ test('sample stays fixed across model, field and unit changes; dismissal and dis
ownerDocument: {},
getBoundingClientRect: () => ({ left: 0, top: 0 }),
};
let center = fromDegrees(0, 0);
const viewer = {
container,
camera: { positionWC: {}, pickEllipsoid: () => { samples++; return { longitude: 0, latitude: 0 }; } },
scene: {
mode: 3,
canvas: { clientWidth: 800, clientHeight: 600, getBoundingClientRect: () => ({ left: 0, top: 0 }) },
cartesianToCanvasCoordinates: () => ({ x: 400, y: 300 }),
postRender: { addEventListener(fn) { listener = fn; return () => { listener = null; }; } },
requestRender() {},
},
};
bindRenderer(viewer, {
query: {
pickEllipsoid: () => { samples++; return center; },
project: () => ({ x: 400, y: 300 }),
isOccluded: () => false,
},
frame: {
on(phase, fn) { listener = fn; return () => { listener = null; }; },
requestRender() {},
},
});
const rendering = Object.fromEntries(['attach', 'start', 'stop', 'clear', 'destroy', 'setField'].map(name => [name, () => {}]));
const layer = createWindLayer({
feed: { getSnapshot: async ({ model }) => complete(model) },
cesium: {
Cartesian2: class {}, Ellipsoid: { WGS84: {} }, SceneMode: { SCENE3D: 3 },
Cartographic: { fromCartesian: point => point }, Math: { toDegrees: value => value },
EllipsoidalOccluder: class { isPointVisible() { return true; } },
},
createRendering: () => rendering,
});
@@ -352,7 +356,7 @@ test('sample stays fixed across model, field and unit changes; dismissal and dis
assert.deepEqual(layer.getRowControls().summary.settings.map(({ label }) => label), ['MODEL', 'FIELD', 'UNITS', 'MOTION']);
assert.ok(marker());
assert.equal(typeof listener, 'function');
viewer.camera.pickEllipsoid = () => { samples++; return { longitude: 70, latitude: 20 }; };
center = fromDegrees(70, 20);
layer.setParams({ overlay: 'speed' });
assert.equal(layer.getRowControls().summary.reading.coordinates, captured.coordinates);
layer.setParams({ model: 'ifs' });