mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 11:12:18 +00:00
Cut duplicated and dead code across the engines, the layers and the QA scripts
- src/geo drops the ported debug argument checks and the tests that bitExact already covers; package boundaries accept a directory entry, so src/geo/ is listed once per group. - Cesium no longer carries movers and lines nobody draws with: they are optional engine capabilities. The fake engine and the Cesium camera use the shared cameraMath; unused contract tables, clock.ticked, the 'finest' surface detail and Navara click statistics are gone. - ALPR keeps one overlay core and one presentation model for both engines, bikeshare one station bookkeeping, the Navara ground effects one definition helper; image atlases, view centres, mover banks and colours are shared. - The legacy switch route, the clock offset and rate controls and other unused exports are removed. - The acceptance runs the Navara draw, geo import and scope checks; scenarios use the harness switch and page helpers; the main chunk check keeps the size budget only and runs once in CI.
This commit is contained in:
1 parent
c502404e1d
commit
7abf74518f
272 files changed
+4828
-10213
No files matched your search
@@ -6,44 +6,18 @@ import { toCesium2, toGeo3 } from './convert.js';
|
||||
|
||||
/**
|
||||
* @param {Cesium.Viewer} viewer
|
||||
* @param {{
|
||||
* identify?: (picked: object) => ({ owner: string, instance?: number, pickable?: boolean } | null),
|
||||
* visible?: (known: { owner: string, instance?: number }) => boolean,
|
||||
* }} [options]
|
||||
* `identify` names the mover set or line (and instance) a pick belongs to;
|
||||
* `visible` says whether that instance is in front of the horizon
|
||||
* (Cesium's GPU pick sees billboards drawn without a depth test through
|
||||
* the globe).
|
||||
* @returns {{ picker: object, destroy: () => void }}
|
||||
*/
|
||||
export function createCesiumPicker(
|
||||
viewer,
|
||||
{ identify = () => null, visible = () => true } = {},
|
||||
) {
|
||||
export function createCesiumPicker(viewer) {
|
||||
const normalise = (picked) => {
|
||||
if (picked == null) return undefined;
|
||||
// The follow camera's proxy entity (follow.js) is not an object.
|
||||
if (picked.id?.gevFollowProxy) return undefined;
|
||||
const known = identify(picked);
|
||||
// A mover set created with pickable: false is not picked (Cesium's GPU
|
||||
// pick sees every primitive; Navara's only the pickable ones), nor an
|
||||
// instance behind the horizon.
|
||||
if (known?.pickable === false) return undefined;
|
||||
if (known && known.instance !== undefined && !visible(known))
|
||||
return undefined;
|
||||
return {
|
||||
id: picked.id,
|
||||
primitive: picked.primitive,
|
||||
content: picked.content,
|
||||
object: picked,
|
||||
...(known
|
||||
? {
|
||||
owner: known.owner,
|
||||
...(known.instance !== undefined
|
||||
? { instance: known.instance }
|
||||
: {}),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
const { scene } = viewer;
|
||||
@@ -58,8 +32,8 @@ export function createCesiumPicker(
|
||||
if (top == null) return undefined;
|
||||
const picked = normalise(top);
|
||||
if (picked) return picked;
|
||||
// The top result is filtered: what lies under it, the first with an
|
||||
// id (an object), else the first kept (map tiles).
|
||||
// The top result is the follow proxy: what lies under it, the first
|
||||
// with an id (an object), else the first kept (map tiles).
|
||||
const under = drill(screen, undefined, width, height);
|
||||
return under.find((entry) => entry.id !== undefined) ?? under[0];
|
||||
},
|
||||
@@ -81,8 +55,7 @@ export function createCesiumPicker(
|
||||
pickGlobe(screen) {
|
||||
if (!scene.globe) return undefined;
|
||||
try {
|
||||
const camera = viewer.camera ?? scene.camera;
|
||||
const ray = camera.getPickRay(toCesium2(screen));
|
||||
const ray = viewer.camera.getPickRay(toCesium2(screen));
|
||||
return ray ? toGeo3(scene.globe.pick(ray, scene)) : undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
|
||||
Reference in new issue
Block a user