mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22: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
@@ -1,5 +1,6 @@
|
||||
import { waitForSignal } from '../sources/requestDeadline.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { cesiumSdkReady, loadCesiumSdk } from '../app/loadCesium.js';
|
||||
import { isPointerFree } from './inputOwnership.js';
|
||||
import {
|
||||
clearOverlaySource,
|
||||
@@ -47,8 +48,9 @@ const SCENE_PATH_RENDER_HOLD = 'bhote-koshi-scene-path-travel';
|
||||
const SCENE_MEDIA_MIN_PLAYBACK_SECONDS = 6;
|
||||
const SCENE_MEDIA_EXIT_SECONDS = 0.65;
|
||||
const BHOTE_EVENT_ACCENT = WORLD_OVERLAY_STYLE.accent;
|
||||
const FLOOD_COLOR = Cesium.Color.fromCssColorString('#d8954e').withAlpha(0.68);
|
||||
const SURGE_COLOR = Cesium.Color.fromCssColorString('#e8b47c');
|
||||
const FLOOD_COLOR = () =>
|
||||
Cesium.Color.fromCssColorString('#d8954e').withAlpha(0.68);
|
||||
const SURGE_COLOR = () => Cesium.Color.fromCssColorString('#e8b47c');
|
||||
const CINEMATIC_INPUT_EVENTS = Object.freeze(['pointerdown', 'wheel']);
|
||||
const CINEMATIC_VIEW_SPECS = Object.freeze([
|
||||
{
|
||||
@@ -1077,8 +1079,8 @@ export function createBhoteKoshiEventLayer({
|
||||
let _cinematicKeyframes = [];
|
||||
let _cinematicActive = false;
|
||||
let _cinematicReplayArmed = false;
|
||||
let _cinematicPose = { target: new Cesium.Cartesian3() };
|
||||
let _cinematicOffset = new Cesium.HeadingPitchRange();
|
||||
let _cinematicPose = { target: { x: 0, y: 0, z: 0 } };
|
||||
let _cinematicOffset = { heading: 0, pitch: 0, range: 0 };
|
||||
let _lastCinematicProgress = null;
|
||||
let _cameraInputTarget = null;
|
||||
let _evidenceClickTarget = null;
|
||||
@@ -2570,11 +2572,11 @@ export function createBhoteKoshiEventLayer({
|
||||
const tileSafe = usesPhotorealFloodSurface();
|
||||
_floodSurfaceMode = tileSafe ? 'tiles' : 'terrain';
|
||||
const haloMaterial = new Cesium.PolylineDashMaterialProperty({
|
||||
color: FLOOD_COLOR.withAlpha(0.38),
|
||||
color: FLOOD_COLOR().withAlpha(0.38),
|
||||
dashLength: 18,
|
||||
});
|
||||
const coreMaterial = new Cesium.PolylineGlowMaterialProperty({
|
||||
color: FLOOD_COLOR.withAlpha(0.96),
|
||||
color: FLOOD_COLOR().withAlpha(0.96),
|
||||
glowPower: 0.24,
|
||||
taperPower: 0.7,
|
||||
});
|
||||
@@ -2619,7 +2621,7 @@ export function createBhoteKoshiEventLayer({
|
||||
position: Cesium.Cartesian3.ZERO,
|
||||
point: {
|
||||
pixelSize: 11,
|
||||
color: SURGE_COLOR,
|
||||
color: SURGE_COLOR(),
|
||||
outlineColor: Cesium.Color.BLACK.withAlpha(0.85),
|
||||
outlineWidth: 3,
|
||||
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
|
||||
@@ -3540,6 +3542,11 @@ export function createBhoteKoshiEventLayer({
|
||||
if (!_viewer && _engine) _native = createNativeRenderer(engine);
|
||||
_embeddedMedia?.attachScene?.(viewer, engine);
|
||||
if (!_enabled) return;
|
||||
// Its enable has loaded the SDK; a restored attachment waits for it too.
|
||||
if (!cesiumSdkReady()) {
|
||||
await untilSceneReleased(loadCesiumSdk(), signal);
|
||||
if (!current()) return;
|
||||
}
|
||||
// The catalog has rebound the incoming map controller before this call.
|
||||
if (_mapStackController) {
|
||||
_comparisonLease = acquireImageryComparison(_mapStackController, {
|
||||
@@ -3618,6 +3625,12 @@ export function createBhoteKoshiEventLayer({
|
||||
}
|
||||
|
||||
async function enable(viewer, { origin = 'local-restore', signal } = {}) {
|
||||
// The imagery, flood and corridor are Cesium entities on either globe, so
|
||||
// a Navara page loads the Cesium SDK for them first.
|
||||
if (!cesiumSdkReady()) {
|
||||
await loadCesiumSdk();
|
||||
throwIfEnableCancelled(signal, true);
|
||||
}
|
||||
_viewer = viewer;
|
||||
_enabled = true;
|
||||
// Public lifecycle passes signal, not intent origin, to enable. Its atomic
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { cesiumSdkReady, loadCesiumSdk } from '../app/loadCesium.js';
|
||||
import {
|
||||
clearOverlaySource,
|
||||
setOverlayEntries,
|
||||
@@ -144,10 +145,10 @@ const NEARBY_CITIES = Object.freeze([
|
||||
placement: 'right-lower',
|
||||
}),
|
||||
]);
|
||||
const BORDER_COLOR = Cesium.Color.fromCssColorString('#20e7f2');
|
||||
const BORDER_COLOR = () => Cesium.Color.fromCssColorString('#20e7f2');
|
||||
const BORDER_ACCENT = '#20e7f2';
|
||||
const INCIDENT_ACCENT = '#ffad55';
|
||||
const INCIDENT_COLOR = Cesium.Color.fromCssColorString(INCIDENT_ACCENT);
|
||||
const INCIDENT_COLOR = () => Cesium.Color.fromCssColorString(INCIDENT_ACCENT);
|
||||
|
||||
const DEFAULT_OVERLAY_HOST = Object.freeze({
|
||||
setEntries: setOverlayEntries,
|
||||
@@ -521,7 +522,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
sequenceStartedAt,
|
||||
visibleAfterMs = 0,
|
||||
) {
|
||||
addCallout(dataSource, INCIDENT, INCIDENT_COLOR, {
|
||||
addCallout(dataSource, INCIDENT, INCIDENT_COLOR(), {
|
||||
sequenceStartedAt,
|
||||
visibleAfterMs,
|
||||
});
|
||||
@@ -555,12 +556,12 @@ export function createBhoteKoshiLocatorLayer({
|
||||
false,
|
||||
),
|
||||
color: new Cesium.CallbackProperty((_time, result) => {
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR, result);
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR(), result);
|
||||
color.alpha = 0.16 * (1 - pulseProgress());
|
||||
return color;
|
||||
}, false),
|
||||
outlineColor: new Cesium.CallbackProperty((_time, result) => {
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR, result);
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR(), result);
|
||||
color.alpha = isVisible() ? 0.08 + 0.78 * (1 - pulseProgress()) : 0;
|
||||
return color;
|
||||
}, false),
|
||||
@@ -705,7 +706,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
labelPlacement = 'right',
|
||||
{ showAnchor = true } = {},
|
||||
) {
|
||||
addCallout(dataSource, NEPAL, BORDER_COLOR, {
|
||||
addCallout(dataSource, NEPAL, BORDER_COLOR(), {
|
||||
labelPlacement,
|
||||
sequenceStartedAt,
|
||||
showAnchor,
|
||||
@@ -820,12 +821,12 @@ export function createBhoteKoshiLocatorLayer({
|
||||
false,
|
||||
),
|
||||
color: new Cesium.CallbackProperty((_time, result) => {
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR, result);
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR(), result);
|
||||
color.alpha = 0.16 * (1 - pulseProgress());
|
||||
return color;
|
||||
}, false),
|
||||
outlineColor: new Cesium.CallbackProperty((_time, result) => {
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR, result);
|
||||
const color = Cesium.Color.clone(INCIDENT_COLOR(), result);
|
||||
color.alpha = 0.08 + 0.78 * (1 - pulseProgress());
|
||||
return color;
|
||||
}, false),
|
||||
@@ -890,7 +891,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
positions: animatedPositions,
|
||||
width: 3.5,
|
||||
clampToGround: true,
|
||||
material: BORDER_COLOR.withAlpha(0.96),
|
||||
material: BORDER_COLOR().withAlpha(0.96),
|
||||
classificationType: Cesium.ClassificationType.BOTH,
|
||||
},
|
||||
});
|
||||
@@ -915,7 +916,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
show: new Cesium.CallbackProperty(() => now() >= drawStartedAt, false),
|
||||
polygon: {
|
||||
hierarchy,
|
||||
material: BORDER_COLOR.withAlpha(0.055),
|
||||
material: BORDER_COLOR().withAlpha(0.055),
|
||||
classificationType: Cesium.ClassificationType.BOTH,
|
||||
},
|
||||
});
|
||||
@@ -925,7 +926,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
positions: animatedPositions,
|
||||
width: 5,
|
||||
clampToGround: true,
|
||||
material: BORDER_COLOR.withAlpha(0.12),
|
||||
material: BORDER_COLOR().withAlpha(0.12),
|
||||
classificationType: Cesium.ClassificationType.BOTH,
|
||||
},
|
||||
});
|
||||
@@ -935,7 +936,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
positions: animatedPositions,
|
||||
width: 2.5,
|
||||
clampToGround: true,
|
||||
material: BORDER_COLOR.withAlpha(0.96),
|
||||
material: BORDER_COLOR().withAlpha(0.96),
|
||||
classificationType: Cesium.ClassificationType.BOTH,
|
||||
},
|
||||
});
|
||||
@@ -1084,6 +1085,12 @@ export function createBhoteKoshiLocatorLayer({
|
||||
}
|
||||
|
||||
async function enable(viewer, { signal } = {}) {
|
||||
// The callouts and flood path are Cesium entities on either globe, so a
|
||||
// Navara page loads the Cesium SDK for them first.
|
||||
if (!cesiumSdkReady()) {
|
||||
await loadCesiumSdk();
|
||||
if (signal?.aborted) throw abortError();
|
||||
}
|
||||
_viewer = viewer;
|
||||
_enabled = true;
|
||||
_boundaryReady = false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** Session-local geodata loading with bounded geometry and local-only file references. */
|
||||
import * as Cesium from 'cesium';
|
||||
import { cesiumSdkReady, loadCesiumSdk } from '../app/loadCesium.js';
|
||||
import { createImportImageBudget } from './geoImportImages.js';
|
||||
import { createImportedPins } from './geoImportPins.js';
|
||||
import { msg } from '../i18n/marker.js';
|
||||
@@ -1416,6 +1417,9 @@ export async function loadGeoFile(
|
||||
throw new GeoImportError(
|
||||
msg('Only GeoJSON, KML, KMZ and GPX files can be imported.'),
|
||||
);
|
||||
// The import builds Cesium data sources on either globe: a Navara page
|
||||
// loads the Cesium SDK first.
|
||||
if (!cesiumSdkReady()) await boundedImport(loadCesiumSdk(), signal);
|
||||
const stroke = Cesium.Color.fromCssColorString(color);
|
||||
const urls = [];
|
||||
let pins;
|
||||
|
||||
@@ -21,17 +21,17 @@ const STYLE = [
|
||||
'imageSubRegion',
|
||||
];
|
||||
|
||||
class ImportedBillboards extends Cesium.BillboardCollection {
|
||||
update(frameState) {
|
||||
// Height queries should find the map, never another imported marker.
|
||||
// Ordinary click picks and rendered screenshots still include the pins.
|
||||
if (frameState.passes.pick && frameState.passes.offscreen) return;
|
||||
super.update(frameState);
|
||||
}
|
||||
}
|
||||
|
||||
/** Own static imported pins without a per-frame Entity visualizer walk. */
|
||||
export function createImportedPins(dataSource, viewer) {
|
||||
class ImportedBillboards extends Cesium.BillboardCollection {
|
||||
update(frameState) {
|
||||
// Height queries should find the map, never another imported marker.
|
||||
// Ordinary click picks and rendered screenshots still include the pins.
|
||||
if (frameState.passes.pick && frameState.passes.offscreen) return;
|
||||
super.update(frameState);
|
||||
}
|
||||
}
|
||||
|
||||
const all = dataSource.entities.values.slice();
|
||||
const now = Cesium.JulianDate.now();
|
||||
const pins = all.filter((entity) => entity.billboard && entity.position);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { modelAxis } from './render/cesiumConstants.js';
|
||||
import * as geo from '../geo/index.js';
|
||||
/**
|
||||
* Model-space visual centres measured from the shipped GLBs' scene-space AABBs.
|
||||
@@ -71,17 +70,9 @@ export const MODEL_TRAIL_ANCHOR_NATIVE = Object.freeze({
|
||||
'/models/atr72.glb': Object.freeze([12.9785, -1.2935, 0]),
|
||||
});
|
||||
|
||||
/** @constant Cesium's OWN axis correction for a glTF loaded with the
|
||||
* `Model.fromGltfAsync` defaults (upAxis Y, forwardAxis Z), assembled from its
|
||||
* exported constants rather than restated as numbers here. `ModelSceneGraph`
|
||||
* renders with `modelMatrix x components.transform x axisCorrection`, and the
|
||||
* trail anchor has to ride the same chain or it lands on a different axis than
|
||||
* the aircraft it is supposed to be attached to. */
|
||||
const AXIS_CORRECTION = geo.matrix4.multiplyTransformation(
|
||||
modelAxis.Y_UP_TO_Z_UP,
|
||||
modelAxis.Z_UP_TO_X_UP,
|
||||
geo.matrix4.create(),
|
||||
);
|
||||
// glTF Y-up/Z-forward to the model frame: Cesium's Y_UP_TO_Z_UP ×
|
||||
// Z_UP_TO_X_UP, shared with Navara before the Cesium SDK is loaded.
|
||||
const AXIS_CORRECTION = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1];
|
||||
const _anchorScratch = geo.cartesian3.create();
|
||||
const _chainScratch = geo.matrix4.create();
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Native constants shared by the W1 adapters; keep the SDK import here.
|
||||
export {
|
||||
Axis as modelAxis,
|
||||
ScreenSpaceEventType as trackingEventTypes,
|
||||
} from 'cesium';
|
||||
// Read on call: the production build's Cesium global loads with the first
|
||||
// Cesium globe, after this module has loaded on a Navara start.
|
||||
import { Axis, ScreenSpaceEventType } from 'cesium';
|
||||
|
||||
export const modelAxis = () => Axis;
|
||||
export const trackingEventTypes = () => ScreenSpaceEventType;
|
||||
@@ -6,11 +6,12 @@ export function worldToWindowCoordinates(scene, position, result) {
|
||||
result,
|
||||
);
|
||||
}
|
||||
const occluder = new Cesium.EllipsoidalOccluder(
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
let occluder;
|
||||
export function horizonOccluder(camera) {
|
||||
occluder ??= new Cesium.EllipsoidalOccluder(
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
occluder.cameraPosition = camera.positionWC;
|
||||
return occluder;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export function isTrackingClickGesture(gesture = {}) {
|
||||
*/
|
||||
export function bindTrackingClickGesture(handler, onClick, options = {}) {
|
||||
const now = options.now || (() => performance.now());
|
||||
const eventTypes = options.eventTypes || trackingEventTypes;
|
||||
const eventTypes = options.eventTypes || trackingEventTypes();
|
||||
let pressActive = false;
|
||||
let pressStartedAt = 0;
|
||||
let previousPosition = null;
|
||||
|
||||
Reference in new issue
Block a user