Load the Cesium SDK and its widget styles only when a Cesium globe first starts

This commit is contained in:
German Khokhlov committed 2026-11-03 22:56:24 +04:00
1 parent 9f8381ff71
commit ae13a56f6d
27 files changed
+269 -124

No files matched your search

+7 -7
View File
@@ -47,8 +47,8 @@ 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 +1077,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 +2570,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 +2619,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,
+12 -12
View File
@@ -144,10 +144,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,
@@ -518,7 +518,7 @@ export function createBhoteKoshiLocatorLayer({
sequenceStartedAt,
visibleAfterMs = 0,
) {
addCallout(dataSource, INCIDENT, INCIDENT_COLOR, {
addCallout(dataSource, INCIDENT, INCIDENT_COLOR(), {
sequenceStartedAt,
visibleAfterMs,
});
@@ -552,12 +552,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),
@@ -695,7 +695,7 @@ export function createBhoteKoshiLocatorLayer({
labelPlacement = 'right',
{ showAnchor = true } = {},
) {
addCallout(dataSource, NEPAL, BORDER_COLOR, {
addCallout(dataSource, NEPAL, BORDER_COLOR(), {
labelPlacement,
sequenceStartedAt,
showAnchor,
@@ -810,12 +810,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),
@@ -880,7 +880,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,
},
});
@@ -905,7 +905,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,
},
});
@@ -915,7 +915,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,
},
});
@@ -925,7 +925,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,
},
});
+9 -9
View File
@@ -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);
+3 -12
View File
@@ -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();
+5 -4
View File
@@ -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;
}