mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +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
@@ -68,7 +68,7 @@ export function createReticleFootprint() {
|
||||
const pixels = Array.from({ length: 25 }, () => geo.cartesian2.create());
|
||||
const hits = Array.from({ length: 25 }, () => geo.cartesian3.create());
|
||||
const carto = geo.cartographic.create();
|
||||
const ray = new Cesium.Ray();
|
||||
let ray;
|
||||
return (viewer, altitude, engine) => {
|
||||
const camera = engine?.camera ?? viewer?.camera;
|
||||
if (!camera?.getPickRay && !camera?.pickRay) return null;
|
||||
@@ -91,7 +91,9 @@ export function createReticleFootprint() {
|
||||
p = pixels[i];
|
||||
p.x = left + (side * col) / 4;
|
||||
p.y = top + (side * row) / 4;
|
||||
const hit = camera.pickEllipsoid(p, Cesium.Ellipsoid.WGS84, hits[i]);
|
||||
const hit = engine
|
||||
? camera.pickEllipsoid(p)
|
||||
: camera.pickEllipsoid(p, Cesium.Ellipsoid.WGS84, hits[i]);
|
||||
let dx, dy;
|
||||
if (hit) {
|
||||
geo.cartographic.fromCartesian(hit, geo.ellipsoid.WGS84, carto);
|
||||
@@ -102,7 +104,7 @@ export function createReticleFootprint() {
|
||||
} else {
|
||||
const picked = engine
|
||||
? camera.pickRay(p)
|
||||
: camera.getPickRay(p, ray) || ray;
|
||||
: camera.getPickRay(p, (ray ??= new Cesium.Ray())) || ray;
|
||||
if (!picked) continue;
|
||||
const d = picked.direction;
|
||||
dx =
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
claimCameraSensitivity,
|
||||
releaseCameraSensitivity,
|
||||
} from '../../data/cameraSensitivity.js';
|
||||
import { whenCesiumSdk } from '../../app/loadCesium.js';
|
||||
|
||||
export function createLifecycle({
|
||||
state: layerState,
|
||||
@@ -245,36 +246,40 @@ export function createLifecycle({
|
||||
*
|
||||
* @param {Cesium.Viewer} viewer - The Cesium viewer instance.
|
||||
*/
|
||||
enable(viewer) {
|
||||
if (layerState._enabled) return;
|
||||
if (viewer) layerState._viewer = viewer;
|
||||
layerState._enabled = true;
|
||||
if (layerState._roadMode !== 'tomtom') source.prefetch?.();
|
||||
bindScene();
|
||||
// Enabling is explicit intent, not a camera gesture that needs settling.
|
||||
parts.viewport.onCameraChanged({ immediate: true });
|
||||
enable(viewer, { signal } = {}) {
|
||||
// The simulation's math is Cesium's on either globe: a Navara page
|
||||
// loads the Cesium SDK first.
|
||||
return whenCesiumSdk(() => {
|
||||
if (layerState._enabled) return;
|
||||
if (viewer) layerState._viewer = viewer;
|
||||
layerState._enabled = true;
|
||||
if (layerState._roadMode !== 'tomtom') source.prefetch?.();
|
||||
bindScene();
|
||||
// Enabling is explicit intent, not a camera gesture that needs settling.
|
||||
parts.viewport.onCameraChanged({ immediate: true });
|
||||
|
||||
// Boot-order guard (field-test round 1: layer sat empty until the user
|
||||
// moved): when the persisted layer state re-enables traffic during the
|
||||
// intro flyTo, the initial check bails at high altitude — and a camera
|
||||
// that then parks never re-fires camera.changed. Retry cheaply until the
|
||||
// first load commits, then self-clear. Also acts as a safety kick if a
|
||||
// failed first fetch left the viewport unloaded while parked.
|
||||
clearInterval(layerState._enableKickTimer);
|
||||
layerState._enableKickTimer = setInterval(() => {
|
||||
if (
|
||||
!layerState._enabled ||
|
||||
layerState._lastUpdate ||
|
||||
layerState._roadRetryStopped ||
|
||||
layerState._retryAttempts >= 3
|
||||
) {
|
||||
clearInterval(layerState._enableKickTimer);
|
||||
layerState._enableKickTimer = null;
|
||||
return;
|
||||
}
|
||||
if (!layerState._fetching && !layerState._retryTimer)
|
||||
parts.viewport.onCameraChanged();
|
||||
}, 1500);
|
||||
// Boot-order guard (field-test round 1: layer sat empty until the user
|
||||
// moved): when the persisted layer state re-enables traffic during the
|
||||
// intro flyTo, the initial check bails at high altitude — and a camera
|
||||
// that then parks never re-fires camera.changed. Retry cheaply until the
|
||||
// first load commits, then self-clear. Also acts as a safety kick if a
|
||||
// failed first fetch left the viewport unloaded while parked.
|
||||
clearInterval(layerState._enableKickTimer);
|
||||
layerState._enableKickTimer = setInterval(() => {
|
||||
if (
|
||||
!layerState._enabled ||
|
||||
layerState._lastUpdate ||
|
||||
layerState._roadRetryStopped ||
|
||||
layerState._retryAttempts >= 3
|
||||
) {
|
||||
clearInterval(layerState._enableKickTimer);
|
||||
layerState._enableKickTimer = null;
|
||||
return;
|
||||
}
|
||||
if (!layerState._fetching && !layerState._retryTimer)
|
||||
parts.viewport.onCameraChanged();
|
||||
}, 1500);
|
||||
}, signal);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { rgbaFromCss } from '../shared/color.js';
|
||||
|
||||
/**
|
||||
* @file Street Traffic selects TomTom, OpenMapTiles or Hybrid motor roads,
|
||||
@@ -112,9 +112,9 @@ export const SIZE_BY_TYPE = {
|
||||
*/
|
||||
|
||||
export const FLOW_BUCKET_COLORS = {
|
||||
free: Cesium.Color.fromCssColorString('#2ecc71').withAlpha(0.9),
|
||||
slow: Cesium.Color.fromCssColorString('#f0b23e').withAlpha(0.9),
|
||||
jam: Cesium.Color.fromCssColorString('#e05252').withAlpha(0.9),
|
||||
free: rgbaFromCss('#2ecc71').withAlpha(0.9),
|
||||
slow: rgbaFromCss('#f0b23e').withAlpha(0.9),
|
||||
jam: rgbaFromCss('#e05252').withAlpha(0.9),
|
||||
};
|
||||
|
||||
// ─── Jam-viz prototype (live mode only — see 2026-07-21 design doc) ────────
|
||||
@@ -140,12 +140,11 @@ export const HEAT_JAM_PULSE_ALPHA = 0.2;
|
||||
|
||||
/** @const {Cesium.Color} Jam corridor color (bucket red, alpha pulsed live). */
|
||||
|
||||
export const HEAT_JAM_COLOR = Cesium.Color.fromCssColorString('#e05252');
|
||||
export const HEAT_JAM_COLOR = rgbaFromCss('#e05252');
|
||||
|
||||
/** @const {Cesium.Color} Slow corridor color (bucket amber, faint + static). */
|
||||
|
||||
export const HEAT_SLOW_COLOR =
|
||||
Cesium.Color.fromCssColorString('#f0b23e').withAlpha(0.2);
|
||||
export const HEAT_SLOW_COLOR = rgbaFromCss('#f0b23e').withAlpha(0.2);
|
||||
|
||||
/** @const {number} Far-distance scale floor for jam dots (shipped: 0.3). */
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ export function roadIdentity(road) {
|
||||
/** Retain one road and its dot population across tile and surface publications. */
|
||||
export function createRetention({ state, parts }) {
|
||||
const records = new Map();
|
||||
const heightStep = new Cesium.Cartesian3();
|
||||
const screenFrom = new Cesium.Cartesian2();
|
||||
const screenTo = new Cesium.Cartesian2();
|
||||
const eye = new Cesium.Cartesian3();
|
||||
const heightStep = { x: 0, y: 0, z: 0 };
|
||||
const screenFrom = { x: 0, y: 0 };
|
||||
const screenTo = { x: 0, y: 0 };
|
||||
const eye = { x: 0, y: 0, z: 0 };
|
||||
function projectSafely(scene, point, screen) {
|
||||
if (scene.project) return Boolean(scene.project(point, screen));
|
||||
if (scene.camera.viewMatrix) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { normalizeRoadMode } from './roadModes.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { FLOW_BUCKET_COLORS } from './policy.js';
|
||||
|
||||
export function createState({ services }) {
|
||||
@@ -294,7 +293,7 @@ export function createState({ services }) {
|
||||
|
||||
/** Reusable scratch Cartesian3 to avoid per-frame allocation / GC pressure */
|
||||
|
||||
layerState._scratchLerp = new Cesium.Cartesian3();
|
||||
layerState._scratchLerp = { x: 0, y: 0, z: 0 };
|
||||
|
||||
// ─── Animation ─────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in new issue
Block a user