mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 11:12:18 +00:00
fix(globe): Cesium picks fall through filtered results; no picks behind the horizon
Review of Task 4: - a Cesium pick whose top result is filtered (a pickable: false set, the follow camera's proxy entity) took nothing; it now drills and answers the first result under it with an id (an object), else the first kept one (map tiles); - billboards and points drawn without a depth test reach Cesium's GPU pick through the globe: mover instances behind the horizon (projector horizonVisible on the instance position) are left out of picks and drills, as Navara's CPU drill already did; - the follow proxy entity (1 px point, cesium/follow.js) carries gevFollowProxy and is never a pick (review item 6).
This commit is contained in:
1 parent
4e195dac6b
commit
a4e753d550
6 files changed
+148
-11
No files matched your search
@@ -6,17 +6,31 @@ import { toCesium2, toGeo3 } from './convert.js';
|
||||
|
||||
/**
|
||||
* @param {Cesium.Viewer} viewer
|
||||
* @param {{ identify?: (picked: object) => ({ owner: string, instance?: number } | null) }} [options]
|
||||
* `identify` names the mover set or line (and instance) a pick belongs to.
|
||||
* @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 } = {}) {
|
||||
export function createCesiumPicker(
|
||||
viewer,
|
||||
{ identify = () => null, visible = () => true } = {},
|
||||
) {
|
||||
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).
|
||||
// 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,
|
||||
@@ -33,15 +47,24 @@ export function createCesiumPicker(viewer, { identify = () => null } = {}) {
|
||||
};
|
||||
};
|
||||
const { scene } = viewer;
|
||||
const drill = (screen, limit, width, height) =>
|
||||
scene
|
||||
.drillPick(toCesium2(screen), limit, width, height)
|
||||
.map(normalise)
|
||||
.filter(Boolean);
|
||||
const picker = {
|
||||
pick(screen, width, height) {
|
||||
return normalise(scene.pick(toCesium2(screen), width, height));
|
||||
const top = scene.pick(toCesium2(screen), width, height);
|
||||
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).
|
||||
const under = drill(screen, undefined, width, height);
|
||||
return under.find((entry) => entry.id !== undefined) ?? under[0];
|
||||
},
|
||||
drillPick(screen, limit, width, height) {
|
||||
return scene
|
||||
.drillPick(toCesium2(screen), limit, width, height)
|
||||
.map(normalise)
|
||||
.filter(Boolean);
|
||||
return drill(screen, limit, width, height);
|
||||
},
|
||||
pickPosition(screen) {
|
||||
if (!scene.pickPositionSupported) return undefined;
|
||||
|
||||
Reference in new issue
Block a user