mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Run the Navara paths without the Cesium SDK, and load it on demand for the features that still build on it
Every Cesium read that a Navara page made was surveyed with the strict acceptance (GEV_QA_CESIUM_TRAP=record). Math on those paths now uses src/geo: screen annotations, weather and wind center readings, cyclone picks, scene data pack polygons and images (new navaraGeometry.js), the awareness subject, the orbit offset of camera verbs, voice frame_overhead, the agent world packet and Directions colours and ground picks. The celestial ring's Sun and Moon come from a bit-identical port of Cesium's Simon1994 model, JulianDate and TEME rotation (src/geo/simon1994.js, julianDate.js, transforms.js); a Cesium globe still applies its ICRF rotation once loaded. Traffic, Street Level, the Nepal event and locator and geo import build on Cesium's math or entity model on either globe; their enable (or the import) now loads the SDK first through src/app/loadCesium.js, synchronously when it is already there. A production page guards the global so a missed read is reported and starts the load. No module reads Cesium while it loads (scripts/check-cesium-load-time.mjs, run by npm test). Cesium.js is still loaded by index.html here.
This commit is contained in:
1 parent
f87da8523e
commit
b8305de14b
58 files changed
+2130
-325
No files matched your search
@@ -7,22 +7,9 @@ import { inspectWindAtCenter } from './inspection.js';
|
||||
import { windReadingResult } from './presentation.js';
|
||||
import { sampleWind, windColor, windSpeed } from './model.js';
|
||||
import { windStats } from './index.js';
|
||||
import * as geo from '../../geo/index.js';
|
||||
|
||||
const cesium = {
|
||||
Cartesian2: class {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
},
|
||||
Ellipsoid: { WGS84: {} },
|
||||
Cartographic: { fromCartesian: (p) => p },
|
||||
Math: { toDegrees: (x) => (x * 180) / Math.PI },
|
||||
};
|
||||
const at = (lonDeg, latDeg) => ({
|
||||
longitude: (lonDeg * Math.PI) / 180,
|
||||
latitude: (latDeg * Math.PI) / 180,
|
||||
});
|
||||
const at = (lonDeg, latDeg) => geo.cartesian3.fromDegrees(lonDeg, latDeg);
|
||||
const grid = { nx: 4, ny: 3, lo1: 0, la1: 90, dx: 90, dy: 90 };
|
||||
const field = (u, v) => ({
|
||||
grid,
|
||||
@@ -44,11 +31,10 @@ const viaViewer = (snapshot, point) =>
|
||||
camera: { pickEllipsoid: () => point },
|
||||
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
|
||||
},
|
||||
cesium,
|
||||
options,
|
||||
);
|
||||
const viaPosition = (snapshot, point) =>
|
||||
inspectWindAtCenter(snapshot, null, cesium, { ...options, position: point });
|
||||
inspectWindAtCenter(snapshot, null, { ...options, position: point });
|
||||
const windLine = (reading) =>
|
||||
windReadingResult(reading).lines.find(({ id }) => id === 'wind').text;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ export function windStats(manifest) {
|
||||
export function createWindLayer({
|
||||
feed,
|
||||
clock,
|
||||
cesium = Cesium,
|
||||
cesium = null,
|
||||
container,
|
||||
createRendering = createWindRendering,
|
||||
createNativeRendering,
|
||||
@@ -90,7 +90,7 @@ export function createWindLayer({
|
||||
y: canvas.clientHeight / 2,
|
||||
});
|
||||
}
|
||||
reading = inspectWindAtCenter(manifest, viewer, cesium, {
|
||||
reading = inspectWindAtCenter(manifest, viewer, {
|
||||
position,
|
||||
units,
|
||||
overlay,
|
||||
@@ -129,7 +129,9 @@ export function createWindLayer({
|
||||
engine?.kind === 'navara'
|
||||
? createNativeRendering(engine)
|
||||
: createRendering({
|
||||
cesium,
|
||||
// Read on Cesium only: the production build's Cesium global
|
||||
// loads with the first Cesium globe.
|
||||
cesium: cesium ?? Cesium,
|
||||
container: container ?? nextViewer.container,
|
||||
getViewer: () => viewer,
|
||||
getHost: () =>
|
||||
@@ -147,7 +149,7 @@ export function createWindLayer({
|
||||
inspectionMarker = createWindInspectionMarker({
|
||||
container: target,
|
||||
viewer,
|
||||
cesium,
|
||||
cesium: engine ? null : (cesium ?? Cesium),
|
||||
engine,
|
||||
});
|
||||
if (enabled && manifest && !manifest.unavailable) {
|
||||
|
||||
@@ -3,6 +3,7 @@ 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 * as geo from '../../geo/index.js';
|
||||
|
||||
const snapshot = (model) => ({
|
||||
model,
|
||||
@@ -314,7 +315,7 @@ test('sample stays fixed across model, field and unit changes; dismissal and dis
|
||||
};
|
||||
const viewer = {
|
||||
container,
|
||||
camera: { positionWC: {}, pickEllipsoid: () => { samples++; return { longitude: 0, latitude: 0 }; } },
|
||||
camera: { positionWC: {}, pickEllipsoid: () => { samples++; return geo.cartesian3.fromDegrees(0, 0); } },
|
||||
scene: {
|
||||
mode: 3,
|
||||
canvas: { clientWidth: 800, clientHeight: 600, getBoundingClientRect: () => ({ left: 0, top: 0 }) },
|
||||
@@ -352,7 +353,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 }; };
|
||||
viewer.camera.pickEllipsoid = () => { samples++; return geo.cartesian3.fromDegrees(70, 20); };
|
||||
layer.setParams({ overlay: 'speed' });
|
||||
assert.equal(layer.getRowControls().summary.reading.coordinates, captured.coordinates);
|
||||
layer.setParams({ model: 'ifs' });
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { sampleWind, windSpeed } from './model.js';
|
||||
import { sampleScalar } from './fields.js';
|
||||
import * as geo from '../../geo/index.js';
|
||||
|
||||
// The reading stays English: AI tools read it too. Text is marked for i18n
|
||||
// extraction and translated where the WEATHER card shows it (presentation.js).
|
||||
@@ -45,17 +46,17 @@ export function formatWindSpeed(speed, units = 'km/h') {
|
||||
export function inspectWindAtCenter(
|
||||
snapshot,
|
||||
viewer,
|
||||
cesium,
|
||||
{ units, overlay, model, validTime, status, position } = {},
|
||||
) {
|
||||
const scene = viewer?.scene;
|
||||
const canvas = scene?.canvas;
|
||||
const ellipsoid = scene?.globe?.ellipsoid || cesium.Ellipsoid?.WGS84;
|
||||
// The globe's own ellipsoid, else WGS84 (geo's default).
|
||||
const ellipsoid = scene?.globe?.ellipsoid;
|
||||
const point =
|
||||
position ||
|
||||
(canvas &&
|
||||
viewer.camera?.pickEllipsoid?.(
|
||||
new cesium.Cartesian2(canvas.clientWidth / 2, canvas.clientHeight / 2),
|
||||
geo.cartesian2.create(canvas.clientWidth / 2, canvas.clientHeight / 2),
|
||||
ellipsoid,
|
||||
));
|
||||
const noReading = () => ({
|
||||
@@ -69,9 +70,9 @@ export function inspectWindAtCenter(
|
||||
),
|
||||
});
|
||||
if (!point || !snapshot?.u || !snapshot?.v) return noReading();
|
||||
const location = cesium.Cartographic.fromCartesian(point, ellipsoid);
|
||||
const lon = cesium.Math.toDegrees(location.longitude);
|
||||
const lat = cesium.Math.toDegrees(location.latitude);
|
||||
const location = geo.cartographic.fromCartesian(point, ellipsoid);
|
||||
const lon = geo.math.toDegrees(location.longitude);
|
||||
const lat = geo.math.toDegrees(location.latitude);
|
||||
const vector = sampleWind(
|
||||
{ ...snapshot.grid, u: snapshot.u, v: snapshot.v },
|
||||
lon,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as geo from '../../geo/index.js';
|
||||
import {
|
||||
windFrom,
|
||||
formatWindSpeed,
|
||||
@@ -27,21 +28,10 @@ test('center inspection uses a fixed forecast reading without double-converting
|
||||
},
|
||||
};
|
||||
const viewer = {
|
||||
camera: { pickEllipsoid: () => ({ longitude: 0, latitude: 0 }) },
|
||||
camera: { pickEllipsoid: () => geo.cartesian3.fromDegrees(0, 0) },
|
||||
scene: { canvas: { clientWidth: 800, clientHeight: 600 } },
|
||||
};
|
||||
const cesium = {
|
||||
Cartesian2: class {
|
||||
constructor(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
},
|
||||
Ellipsoid: { WGS84: {} },
|
||||
Cartographic: { fromCartesian: (p) => p },
|
||||
Math: { toDegrees: (x) => (x * 180) / Math.PI },
|
||||
};
|
||||
const result = inspectWindAtCenter(snapshot, viewer, cesium, {
|
||||
const result = inspectWindAtCenter(snapshot, viewer, {
|
||||
overlay: 'temperature',
|
||||
units: 'km/h',
|
||||
model: 'GFS',
|
||||
@@ -54,7 +44,7 @@ test('center inspection uses a fixed forecast reading without double-converting
|
||||
assert.equal(result.coordinates, '0.00°N · 0.00°E');
|
||||
viewer.camera.pickEllipsoid = () => null;
|
||||
assert.equal(
|
||||
inspectWindAtCenter(snapshot, viewer, cesium).coordinates,
|
||||
inspectWindAtCenter(snapshot, viewer).coordinates,
|
||||
'No surface reading',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user