mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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:
1 parent
cd94a26b9f
commit
d831cbd23a
33 files changed
+2374
-32
No files matched your search
@@ -0,0 +1,54 @@
|
||||
// GlobeSurface on a Cesium scene: the rendered-surface queries that
|
||||
// services/groundSnap and services/meshFloorSampler make today.
|
||||
|
||||
import { firstVisibleTileset } from '../../services/groundSnap.js';
|
||||
import { toGeo3 } from './convert.js';
|
||||
|
||||
const finite = (value) => (Number.isFinite(value) ? value : undefined);
|
||||
|
||||
/**
|
||||
* @param {Cesium.Viewer} viewer
|
||||
* @returns {{ surface: import('../contract.js').GlobeSurface, destroy: () => void }}
|
||||
*/
|
||||
export function createCesiumSurface(viewer) {
|
||||
const { scene } = viewer;
|
||||
const surface = {
|
||||
sampleHeight(cartographic, exclude) {
|
||||
if (!scene.sampleHeightSupported) return undefined;
|
||||
try {
|
||||
// Throws when unsupported (no depth textures); that is a miss.
|
||||
return finite(scene.sampleHeight(cartographic, exclude));
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
get supported() {
|
||||
return Boolean(scene.sampleHeightSupported);
|
||||
},
|
||||
terrainHeight(cartographic) {
|
||||
return scene.globe
|
||||
? finite(scene.globe.getHeight(cartographic))
|
||||
: undefined;
|
||||
},
|
||||
get terrainHeightSupported() {
|
||||
return Boolean(scene.globe);
|
||||
},
|
||||
clampToHeight(position, exclude) {
|
||||
if (!scene.clampToHeightSupported) return undefined;
|
||||
try {
|
||||
return toGeo3(scene.clampToHeight(position, exclude));
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
get clampToHeightSupported() {
|
||||
return Boolean(scene.clampToHeightSupported);
|
||||
},
|
||||
tilesLoaded() {
|
||||
const tileset = firstVisibleTileset(scene.primitives);
|
||||
if (tileset) return tileset.tilesLoaded === true;
|
||||
return scene.globe?.show ? scene.globe.tilesLoaded === true : true;
|
||||
},
|
||||
};
|
||||
return { surface, destroy() {} };
|
||||
}
|
||||
Reference in new issue
Block a user