mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-22 11:12:18 +00:00
Draw movers and lines on Cesium and require them of every engine
Layers are to draw through the globe contract on both engines, so Cesium gets back the movers and lines removed as unused: - engine.movers draws sprite sets as a BillboardCollection (atlas cells cropped once per set), point sets as a PointPrimitiveCollection and model sets as one Model per instance. depthTest, disableWithinM, order, scaleByDistance, colorBlend, unlit and minimumPixelSize follow the contract; a model's matrix is written in place, so instances no longer share one scratch matrix. - engine.lines draws each line as a polyline Primitive with width in CSS px, geodesic arcs, dashes, the tactical and arrow materials, depthFailAlpha and modelMatrix; a rebuild keeps its show, matrix, colour and place in order. - The picker returns the pickId a layer wrote last, skips sets that are not pickable and instances behind the horizon, and falls through to what lies under them. Surface samples can exclude mover sets again. movers and lines move from the optional capabilities into the required contract shape, and the contract suite always runs their checks.
This commit is contained in:
1 parent
59a233db51
commit
2213be6566
19 files changed
+1758
-75
No files matched your search
@@ -1,23 +1,43 @@
|
||||
// GlobePicker on a Cesium scene. Pick results keep Cesium's `id`,
|
||||
// `primitive` and `content` (3D tile content, read by surface-pick checks);
|
||||
// the untouched Cesium result rides along as `object` for Cesium-only callers.
|
||||
// A pick of an engine mover or line (`identify`) names its owner and
|
||||
// instance and returns the pickId the layer gave it as `id`, as on Navara.
|
||||
|
||||
import { toCesium2, toGeo3 } from './convert.js';
|
||||
|
||||
/**
|
||||
* @param {Cesium.Viewer} viewer
|
||||
* @param {{
|
||||
* identify?: (picked: object) => ({ owner: string, instance?: number, id: any, pickable?: boolean, visible?: boolean } | null),
|
||||
* }} [options]
|
||||
* `identify` names the mover set or line (and instance) a pick belongs to,
|
||||
* with its pickId; `pickable: false` (a set made without pickable) and
|
||||
* `visible: false` (an instance behind the horizon, which Cesium's GPU
|
||||
* pick sees through the globe when drawn without a depth test) drop it.
|
||||
* @returns {{ picker: object, destroy: () => void }}
|
||||
*/
|
||||
export function createCesiumPicker(viewer) {
|
||||
export function createCesiumPicker(viewer, { identify = () => null } = {}) {
|
||||
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);
|
||||
if (known && (known.pickable === false || known.visible === false))
|
||||
return undefined;
|
||||
return {
|
||||
id: picked.id,
|
||||
id: known ? known.id : picked.id,
|
||||
primitive: picked.primitive,
|
||||
content: picked.content,
|
||||
object: picked,
|
||||
...(known
|
||||
? {
|
||||
owner: known.owner,
|
||||
...(known.instance !== undefined
|
||||
? { instance: known.instance }
|
||||
: {}),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
const { scene } = viewer;
|
||||
@@ -32,8 +52,9 @@ export function createCesiumPicker(viewer) {
|
||||
if (top == null) return undefined;
|
||||
const picked = normalise(top);
|
||||
if (picked) return picked;
|
||||
// The top result is the follow proxy: what lies under it, the first
|
||||
// with an id (an object), else the first kept (map tiles).
|
||||
// The top result is filtered (the follow proxy, an unpickable or
|
||||
// hidden mover): 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];
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user