mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): picks on input payloads
input.on('click'|'doubleClick'|'move', fn, { pick, drill }) delivers
{ …event, picked, drilled }: PickResult { id, owner, instance, primitive
(Cesium) } names the mover set (and instance) or line hit. One pick (and
one drill, as deep as the deepest listener) per event, shared by its
listeners; moves with picks are coalesced to one delivery per frame with
the latest position (src/globe/pickDelivery.js). Option checks in the
contract (normalizeInputOptions).
- Cesium: scene.pick / drillPick, and the picker names the owner: movers
map billboards, points and models to their set and instance, lines
their primitives to the line.
- Navara: a click with pick takes Navara's GPU pick of the same gesture
(featureClick; its pick helper answers on the same pointerup, usually
before the engine's click, so a fresh answer waits for it; otherwise
the click waits up to 250 ms, then the CPU pick). Navara 0.2.1 answers
clicks in quick succession with the first click's pick: a GPU answer
whose instance is not drawn near the click is stale and the CPU pick
answers. Hover, drill and the synchronous picker.pick/drillPick are CPU
picks (src/globe/cpuPicks.js) of pickable mover sets and pickable lines
(within half the width + 3 px), behind the globe excluded, nearest
first; lines are picked on the CPU after an empty GPU answer.
picker.clickStats() (Navara only) counts the answers and latencies.
- The fake engine picks its own movers and lines on the CPU unless
scripted.
- The contract suite clicks with real pointer events (puppeteer) on both
engines: a sprite is picked with its owner and instance, the map picks
nothing, two sprites in one place drill both, a line is picked, a
hover picks the sprite under it. Navara, 20 clicks: payload p50 2.8 ms,
p95 4.1 ms after the click (puppeteer dispatch included), 20/20 GPU
answers. The Cesium harness keeps the first-run card closed.
This commit is contained in:
1 parent
86aa0bc9ba
commit
b0cb8ce881
26 files changed
+1267
-68
No files matched your search
@@ -85,7 +85,7 @@ function readColor(store, index) {
|
||||
return scratchColor;
|
||||
}
|
||||
|
||||
function spritePart(scene, options, store, factories, requestRender) {
|
||||
function spritePart(scene, options, store, factories, requestRender, owners) {
|
||||
const collection = factories.billboards(scene);
|
||||
const { sprite, depthTest, id } = options;
|
||||
const style = {
|
||||
@@ -108,6 +108,7 @@ function spritePart(scene, options, store, factories, requestRender) {
|
||||
if (!billboard) {
|
||||
billboard = collection.add({ ...style });
|
||||
billboards[index] = billboard;
|
||||
owners.set(billboard, { owner: id, instance: index });
|
||||
shownCell[index] = -1;
|
||||
}
|
||||
billboard.position = readPosition(store, index);
|
||||
@@ -146,7 +147,7 @@ function spritePart(scene, options, store, factories, requestRender) {
|
||||
};
|
||||
}
|
||||
|
||||
function pointPart(options, store, factories, requestRender) {
|
||||
function pointPart(options, store, factories, requestRender, owners) {
|
||||
const collection = factories.points();
|
||||
const { point, depthTest } = options;
|
||||
const style = {
|
||||
@@ -169,6 +170,7 @@ function pointPart(options, store, factories, requestRender) {
|
||||
if (!item) {
|
||||
item = collection.add({ ...style });
|
||||
points[index] = item;
|
||||
owners.set(item, { owner: options.id, instance: index });
|
||||
}
|
||||
item.position = readPosition(store, index);
|
||||
item.pixelSize = point.sizePx * store.scales[index];
|
||||
@@ -182,7 +184,7 @@ function pointPart(options, store, factories, requestRender) {
|
||||
};
|
||||
}
|
||||
|
||||
function modelPart(options, store, factories, requestRender) {
|
||||
function modelPart(options, store, factories, requestRender, owners) {
|
||||
const collection = factories.models();
|
||||
const { model } = options;
|
||||
const blendMode =
|
||||
@@ -235,6 +237,7 @@ function modelPart(options, store, factories, requestRender) {
|
||||
return;
|
||||
}
|
||||
models[index] = item;
|
||||
owners.set(item, { owner: options.id, instance: index });
|
||||
place(item, index);
|
||||
collection.add(item);
|
||||
requestRender('movers');
|
||||
@@ -273,6 +276,8 @@ export function createCesiumMovers(
|
||||
const { scene } = viewer;
|
||||
let root = null;
|
||||
const ordered = [];
|
||||
// Billboard, point or model → its set and instance, for picks.
|
||||
const owners = new WeakMap();
|
||||
const rootCollection = () => {
|
||||
if (!root) {
|
||||
root = new Cesium.PrimitiveCollection({ destroyPrimitives: true });
|
||||
@@ -283,10 +288,10 @@ export function createCesiumMovers(
|
||||
const registry = createMoverRegistry((options, store) => {
|
||||
const part =
|
||||
options.kind === 'sprite'
|
||||
? spritePart(scene, options, store, make, requestRender)
|
||||
? spritePart(scene, options, store, make, requestRender, owners)
|
||||
: options.kind === 'point'
|
||||
? pointPart(options, store, make, requestRender)
|
||||
: modelPart(options, store, make, requestRender);
|
||||
? pointPart(options, store, make, requestRender, owners)
|
||||
: modelPart(options, store, make, requestRender, owners);
|
||||
const { primitive } = part;
|
||||
primitive.gevMoverSet = options.id;
|
||||
// Later (higher) order draws later: after every set of lower or equal order.
|
||||
@@ -308,6 +313,11 @@ export function createCesiumMovers(
|
||||
});
|
||||
return {
|
||||
movers: registry.movers,
|
||||
/** The set and instance a Cesium pick result belongs to, or null. */
|
||||
identify(picked) {
|
||||
const known = picked?.primitive ? owners.get(picked.primitive) : null;
|
||||
return known && registry.sets.has(known.owner) ? { ...known } : null;
|
||||
},
|
||||
destroy() {
|
||||
registry.destroyAll();
|
||||
if (root) {
|
||||
|
||||
Reference in new issue
Block a user