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

+3 -3
View File
@@ -9,11 +9,11 @@ import { toCesium2, toCesium3, toGeo3 } from './convert.js';
import { createCesiumFollow } from './follow.js';
const { math } = geo;
const easings = () => ({
const EASINGS = {
cubicInOut: Cesium.EasingFunction.CUBIC_IN_OUT,
sinusoidalInOut: Cesium.EasingFunction.SINUSOIDAL_IN_OUT,
linear: Cesium.EasingFunction.LINEAR_NONE,
});
};
// Cesium reports heading and roll in [0, 2π]; the contract wants [0, 2π).
function wrapAngle(angle) {
@@ -43,7 +43,7 @@ const cesiumDestination = (destination) =>
)
: toCesium3(destination);
const cesiumEasing = (easing) => (easing ? easings()[easing] : undefined);
const cesiumEasing = (easing) => (easing ? EASINGS[easing] : undefined);
// A HeadingPitchRange or a Cartesian offset, as Cesium's lookAt takes them.
const cesiumOffset = (offset) =>
+1 -2
View File
@@ -4,7 +4,7 @@
import * as Cesium from 'cesium';
import { bridgeEvent } from './events.js';
let scratchGregorian;
const scratchGregorian = new Cesium.GregorianDate();
// JulianDate.toDate(time).getTime() without the Date: frame events must not
// allocate. A raise without a time (not Cesium's own) reads the clock.
@@ -27,7 +27,6 @@ function unixMilliseconds(scene, time) {
* @returns {{ frames: object, destroy: () => void }}
*/
export function createCesiumFrames(viewer) {
scratchGregorian ??= new Cesium.GregorianDate();
const { scene } = viewer;
const bridges = ['preUpdate', 'preRender', 'postRender'].map((name) => [
name,
+13 -13
View File
@@ -6,6 +6,19 @@ import { normalizeInputOptions } from '../contract.js';
import { createPickDelivery } from '../pickDelivery.js';
import { toGeo2 } from './convert.js';
const TYPES = {
click: Cesium.ScreenSpaceEventType.LEFT_CLICK,
doubleClick: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
move: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
down: Cesium.ScreenSpaceEventType.LEFT_DOWN,
up: Cesium.ScreenSpaceEventType.LEFT_UP,
};
const KEYS = {
ctrl: Cesium.KeyboardEventModifier.CTRL,
shift: Cesium.KeyboardEventModifier.SHIFT,
alt: Cesium.KeyboardEventModifier.ALT,
};
// Cesium reuses its event objects; listeners get geo copies.
const toEvent = (event) => {
const result = {};
@@ -31,19 +44,6 @@ export function createCesiumInput(
scheduleFrame = (run) => requestAnimationFrame(run),
} = {},
) {
const TYPES = {
click: Cesium.ScreenSpaceEventType.LEFT_CLICK,
doubleClick: Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
move: Cesium.ScreenSpaceEventType.MOUSE_MOVE,
down: Cesium.ScreenSpaceEventType.LEFT_DOWN,
up: Cesium.ScreenSpaceEventType.LEFT_UP,
};
const KEYS = {
ctrl: Cesium.KeyboardEventModifier.CTRL,
shift: Cesium.KeyboardEventModifier.SHIFT,
alt: Cesium.KeyboardEventModifier.ALT,
};
const { scene } = viewer;
let handler = null;
let destroyed = false;
+5 -10
View File
@@ -8,12 +8,12 @@
import * as Cesium from 'cesium';
import { createMoverRegistry } from '../movers.js';
let scratchPosition;
let scratchColor;
let scratchQuaternion;
let scratchRotation;
const scratchPosition = new Cesium.Cartesian3();
const scratchColor = new Cesium.Color();
const scratchQuaternion = new Cesium.Quaternion();
const scratchRotation = new Cesium.Matrix3();
// Model.modelMatrix and Model.color copy what they are given.
let scratchModelMatrix;
const scratchModelMatrix = new Cesium.Matrix4();
/** The atlas cells as canvases, by key (a DOM canvas or image source). */
async function cropAtlasCells(atlas, keys) {
@@ -287,11 +287,6 @@ export function createCesiumMovers(
viewer,
{ requestRender = () => viewer.scene.requestRender(), factories = {} } = {},
) {
scratchPosition ??= new Cesium.Cartesian3();
scratchColor ??= new Cesium.Color();
scratchQuaternion ??= new Cesium.Quaternion();
scratchRotation ??= new Cesium.Matrix3();
scratchModelMatrix ??= new Cesium.Matrix4();
const make = { ...DEFAULT_FACTORIES, ...factories };
const { scene } = viewer;
let root = null;