Load the Cesium SDK from index.html again, since engine-neutral modules read its global when they load

This reverts ae13a56f. In the production build every 'cesium' import is the global that Cesium.js defines; with the script loaded only when a Cesium globe started, modules evaluated at boot (cesiumConstants, annotationEngine) threw ReferenceError and neither engine started. A cold Navara start loading Cesium.js stays a known gap.
This commit is contained in:
German Khokhlov committed 2026-11-03 23:21:00 +04:00
1 parent 9cc108835e
commit 125fbc5a3b
27 files changed
+125 -275

No files matched your search

+8 -9
View File
@@ -68,11 +68,10 @@ export function presentRoutingFailure(error) {
/** Route colour — the annotation palette's cyan, so voice routes and Directions match. */
export const DIRECTIONS_ROUTE_COLOR = '#39d0ff';
const MARKER_A_COLOR = () => Cesium.Color.fromCssColorString('#5dff9f');
const MARKER_B_COLOR = () => Cesium.Color.fromCssColorString('#ff6b6b');
const STEP_COLOR = () => Cesium.Color.WHITE.withAlpha(0.95);
const STEP_OUTLINE = () =>
Cesium.Color.fromCssColorString(DIRECTIONS_ROUTE_COLOR);
const MARKER_A_COLOR = Cesium.Color.fromCssColorString('#5dff9f');
const MARKER_B_COLOR = Cesium.Color.fromCssColorString('#ff6b6b');
const STEP_COLOR = Cesium.Color.WHITE.withAlpha(0.95);
const STEP_OUTLINE = Cesium.Color.fromCssColorString(DIRECTIONS_ROUTE_COLOR);
const STEP_PIXEL_SIZE = 8;
const STEP_SELECTED_PIXEL_SIZE = 13;
/** Route request timeout (ms) — the proxy itself gives OSRM 12 s. */
@@ -1027,10 +1026,10 @@ export function createDirectionsLayer({
if (!_viewer && !_native) return;
if (letter === 'a') {
removeEntity(_markerA);
_markerA = markerEntity('A', point, MARKER_A_COLOR());
_markerA = markerEntity('A', point, MARKER_A_COLOR);
} else {
removeEntity(_markerB);
_markerB = markerEntity('B', point, MARKER_B_COLOR());
_markerB = markerEntity('B', point, MARKER_B_COLOR);
}
}
@@ -1137,9 +1136,9 @@ export function createDirectionsLayer({
_stepPoints.add({
id: `directions:step:${index}`,
position: Cesium.Cartesian3.fromDegrees(step.lon, step.lat, 0),
color: STEP_COLOR(),
color: STEP_COLOR,
pixelSize: STEP_PIXEL_SIZE,
outlineColor: STEP_OUTLINE(),
outlineColor: STEP_OUTLINE,
outlineWidth: 2,
show: false,
// The shared ground floor is a coarse cell, and on the photoreal stack
+1 -2
View File
@@ -4,8 +4,7 @@ import {
horizonOccluder,
} from '../../../data/render/cesiumProjection.js';
// Cesium ScreenSpaceEventType.LEFT_CLICK; available before the SDK loads.
export const FIRMS_LEFT_CLICK = 2;
export const FIRMS_LEFT_CLICK = Cesium.ScreenSpaceEventType.LEFT_CLICK;
export const projectFirmsWindow = worldToWindowCoordinates;
export const firmsHorizonOccluder = horizonOccluder;
+11 -8
View File
@@ -1,6 +1,17 @@
import * as Cesium from 'cesium';
import { GNSS_LEVEL_COLORS } from '../records.js';
/**
* GroundPrimitive allowPicking:false suppresses ids but still submits stencil
* commands in Cesium's pick pass, erasing picks of overlapping ground geometry.
* This fill participates only in rendering, so sibling polygons remain pickable.
*/
class GnssGroundFill extends Cesium.GroundPrimitive {
update(frameState) {
if (!frameState.passes.pick) super.update(frameState);
}
}
/** Degrees at the centre of the current view, or null before the camera settles. */
export function defaultGnssViewAnchor(viewer) {
const canvas = viewer?.scene?.canvas;
@@ -33,14 +44,6 @@ export function createGnssCesiumRenderer({
viewer,
viewAnchor = defaultGnssViewAnchor,
}) {
// GroundPrimitive allowPicking:false still submits stencil commands in
// the pick pass. Keep this fill from erasing overlapping geometry's picks.
class GnssGroundFill extends Cesium.GroundPrimitive {
update(frameState) {
if (!frameState.passes.pick) super.update(frameState);
}
}
const primitives = new Cesium.PrimitiveCollection();
primitives.id = 'gnss-integrity';
primitives.show = false;
+6 -8
View File
@@ -227,7 +227,11 @@ export function viewFocus(
* (NYC −22 m), and an occluder at 0 m would hide the cones around it.
*/
const HORIZON_CULL_DEPTH_M = 1000;
let HORIZON_CULL_ELLIPSOID;
const HORIZON_CULL_ELLIPSOID = new Cesium.Ellipsoid(
Cesium.Ellipsoid.WGS84.radii.x - HORIZON_CULL_DEPTH_M,
Cesium.Ellipsoid.WGS84.radii.y - HORIZON_CULL_DEPTH_M,
Cesium.Ellipsoid.WGS84.radii.z - HORIZON_CULL_DEPTH_M,
);
/**
* Hide billboards and points behind the horizon: they skip the depth test, so
@@ -236,18 +240,12 @@ let HORIZON_CULL_ELLIPSOID;
* @param {{getViewer: () => object|null, items: () => Iterable<{position: object, show: boolean}>, onChange?: () => void}} options
*/
export function createHorizonCull({ getViewer, items, onChange }) {
let occluder;
const occluder = new Cesium.EllipsoidalOccluder(HORIZON_CULL_ELLIPSOID);
let from = null;
let stopListening = null;
/** Show what is in front of the horizon, hide the rest; the count seen. */
function cull(list, position) {
HORIZON_CULL_ELLIPSOID ??= new Cesium.Ellipsoid(
Cesium.Ellipsoid.WGS84.radii.x - HORIZON_CULL_DEPTH_M,
Cesium.Ellipsoid.WGS84.radii.y - HORIZON_CULL_DEPTH_M,
Cesium.Ellipsoid.WGS84.radii.z - HORIZON_CULL_DEPTH_M,
);
occluder ??= new Cesium.EllipsoidalOccluder(HORIZON_CULL_ELLIPSOID);
occluder.cameraPosition = position;
let seen = 0;
let changed = false;
+2 -6
View File
@@ -86,15 +86,11 @@ export const CABLE_GLOBE_STACK_IDS = Object.freeze(
export const MARKER_COLLECTION_EXPECTATIONS = Object.freeze([
Object.freeze({
key: '_billboardCollection',
get type() {
return Cesium.BillboardCollection;
},
type: Cesium.BillboardCollection,
}),
Object.freeze({
key: '_pointCollection',
get type() {
return Cesium.PointPrimitiveCollection;
},
type: Cesium.PointPrimitiveCollection,
}),
]);
+3 -5
View File
@@ -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();
let ray;
const ray = new Cesium.Ray();
return (viewer, altitude, engine) => {
const camera = engine?.camera ?? viewer?.camera;
if (!camera?.getPickRay && !camera?.pickRay) return null;
@@ -91,9 +91,7 @@ export function createReticleFootprint() {
p = pixels[i];
p.x = left + (side * col) / 4;
p.y = top + (side * row) / 4;
const hit = engine
? camera.pickEllipsoid(p)
: camera.pickEllipsoid(p, Cesium.Ellipsoid.WGS84, hits[i]);
const hit = camera.pickEllipsoid(p, Cesium.Ellipsoid.WGS84, hits[i]);
let dx, dy;
if (hit) {
geo.cartographic.fromCartesian(hit, geo.ellipsoid.WGS84, carto);
@@ -104,7 +102,7 @@ export function createReticleFootprint() {
} else {
const picked = engine
? camera.pickRay(p)
: camera.getPickRay(p, (ray ??= new Cesium.Ray())) || ray;
: camera.getPickRay(p, ray) || ray;
if (!picked) continue;
const d = picked.direction;
dx =
+7 -6
View File
@@ -1,4 +1,4 @@
import { rgbaFromCss } from '../shared/color.js';
import * as Cesium from 'cesium';
/**
* @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: rgbaFromCss('#2ecc71').withAlpha(0.9),
slow: rgbaFromCss('#f0b23e').withAlpha(0.9),
jam: rgbaFromCss('#e05252').withAlpha(0.9),
free: Cesium.Color.fromCssColorString('#2ecc71').withAlpha(0.9),
slow: Cesium.Color.fromCssColorString('#f0b23e').withAlpha(0.9),
jam: Cesium.Color.fromCssColorString('#e05252').withAlpha(0.9),
};
// ─── Jam-viz prototype (live mode only — see 2026-07-21 design doc) ────────
@@ -140,11 +140,12 @@ export const HEAT_JAM_PULSE_ALPHA = 0.2;
/** @const {Cesium.Color} Jam corridor color (bucket red, alpha pulsed live). */
export const HEAT_JAM_COLOR = rgbaFromCss('#e05252');
export const HEAT_JAM_COLOR = Cesium.Color.fromCssColorString('#e05252');
/** @const {Cesium.Color} Slow corridor color (bucket amber, faint + static). */
export const HEAT_SLOW_COLOR = rgbaFromCss('#f0b23e').withAlpha(0.2);
export const HEAT_SLOW_COLOR =
Cesium.Color.fromCssColorString('#f0b23e').withAlpha(0.2);
/** @const {number} Far-distance scale floor for jam dots (shipped: 0.3). */
+4 -4
View File
@@ -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 = { 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 };
const heightStep = new Cesium.Cartesian3();
const screenFrom = new Cesium.Cartesian2();
const screenTo = new Cesium.Cartesian2();
const eye = new Cesium.Cartesian3();
function projectSafely(scene, point, screen) {
if (scene.project) return Boolean(scene.project(point, screen));
if (scene.camera.viewMatrix) {
+2 -1
View File
@@ -1,4 +1,5 @@
import { normalizeRoadMode } from './roadModes.js';
import * as Cesium from 'cesium';
import { FLOW_BUCKET_COLORS } from './policy.js';
export function createState({ services }) {
@@ -293,7 +294,7 @@ export function createState({ services }) {
/** Reusable scratch Cartesian3 to avoid per-frame allocation / GC pressure */
layerState._scratchLerp = { x: 0, y: 0, z: 0 };
layerState._scratchLerp = new Cesium.Cartesian3();
// ─── Animation ─────────────────────────────────────────────