mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52: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
@@ -17,6 +17,7 @@ import { createCameraModel } from './cameraModel.js';
|
||||
import { createNavaraClock } from './clock.js';
|
||||
import { createNavaraCredits } from './credits.js';
|
||||
import { createNavaraInput } from './input.js';
|
||||
import { createNavaraPicking } from './picking.js';
|
||||
import { createNavaraMaps } from './maps.js';
|
||||
import { createNavaraSurface } from './surface.js';
|
||||
import { createGroundFloor, GROUND_FLOOR } from './groundFloor.js';
|
||||
@@ -163,9 +164,24 @@ export function createNavaraEngine(
|
||||
for (const [name, handler] of Object.entries(handlers))
|
||||
view.on(name, handler);
|
||||
|
||||
// Picks over the movers and lines (picking.js); the input answers
|
||||
// listeners with { pick, drill } from it.
|
||||
const picking = createNavaraPicking({
|
||||
view,
|
||||
projector: {
|
||||
worldToWindow: (position, result) =>
|
||||
model.worldToWindow(position, result),
|
||||
horizonVisible: (position) => model.horizonVisible(position),
|
||||
},
|
||||
camera: model.camera,
|
||||
movers: () => moversPort?.pickables?.() ?? [],
|
||||
lines: () => linesPort?.pickables?.() ?? [],
|
||||
resolveBatch: (batchId) => moversPort?.resolvePick?.(batchId) ?? null,
|
||||
});
|
||||
const input = createNavaraInput(view, {
|
||||
// A gesture is the user, not a new camera owner: no camera.commanded.
|
||||
onCameraInput: () => model.stopFlight(),
|
||||
picker: picking,
|
||||
});
|
||||
const credits = createNavaraCredits(view);
|
||||
const maps = createNavaraMaps(view, fetch ? { fetch } : {});
|
||||
@@ -182,10 +198,12 @@ export function createNavaraEngine(
|
||||
});
|
||||
|
||||
const picker = {
|
||||
// Navara picks its own meshes only on click gestures (featureClick); there
|
||||
// is no synchronous pick, and 3D tiles carry no ids. No layers yet.
|
||||
pick: () => undefined,
|
||||
drillPick: () => [],
|
||||
// The CPU pick of movers and lines (picking.js); 3D tiles carry no ids.
|
||||
// Clicks with { pick } get Navara's GPU pick of the gesture instead.
|
||||
pick: (screen) => picking.pick(screen),
|
||||
drillPick: (screen, limit) => picking.drillPick(screen, limit),
|
||||
// Navara-only diagnostics: how clicks with { pick } were answered.
|
||||
clickStats: () => picking.clickStats(),
|
||||
pickPosition(screen) {
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
const hit = view.pickDepthPosition(
|
||||
@@ -262,6 +280,7 @@ export function createNavaraEngine(
|
||||
view.off(name, handler);
|
||||
model.destroy();
|
||||
input.destroy();
|
||||
picking.destroy();
|
||||
credits.destroy();
|
||||
maps.destroy();
|
||||
sharpenPort?.destroy();
|
||||
|
||||
Reference in new issue
Block a user