feat(globe): implement the engine on Cesium

createCesiumEngine wraps an existing viewer without changing it: camera, picker, projector, frames, render (through the render governor), surface, input, credits and maps, with geo values out and Cesium values in at the boundary. Map and surface code is shared with src/maps and services/groundSnap instead of copied. scripts/qa-globe-contract.mjs runs the contract suite against the engine in headless Chrome; the camera-events check now waits for the previous move to end, as Cesium's moveStart marks a move from rest.
This commit is contained in:
German Khokhlov committed 2026-10-15 17:43:05 +04:00
1 parent cd94a26b9f
commit d831cbd23a
33 files changed
+2374 -32

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
// GlobePicker on a Cesium scene. Pick results keep Cesium's `id` and
// `primitive`; the untouched Cesium result rides along as `object` for
// Cesium-only callers.
import { toCesium2, toGeo3 } from './convert.js';
const normalise = (picked) =>
picked == null
? undefined
: { id: picked.id, primitive: picked.primitive, object: picked };
/**
* @param {Cesium.Viewer} viewer
* @returns {{ picker: object, destroy: () => void }}
*/
export function createCesiumPicker(viewer) {
const { scene } = viewer;
const picker = {
pick(screen, width, height) {
return normalise(scene.pick(toCesium2(screen), width, height));
},
drillPick(screen, limit) {
return scene.drillPick(toCesium2(screen), limit).map(normalise);
},
pickPosition(screen) {
if (!scene.pickPositionSupported) return undefined;
try {
// A new Cesium.Cartesian2 per call: Cesium caches by its toString().
return toGeo3(scene.pickPosition(toCesium2(screen)));
} catch {
return undefined;
}
},
get pickPositionSupported() {
return Boolean(scene.pickPositionSupported);
},
};
return { picker, destroy() {} };
}