mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Take the input dispatcher off Cesium: pointer input from the renderer's input port, picks from the query port
The dispatcher now builds on renderer.input and the query port, with
positions as plain {x, y}. Its viewer access count is zero and it leaves
the Cesium allow-list. Layers that read the raw engine pick read the Hit,
drawHit or event.native instead, and pickRegistry's resolvePickId and
pickContact take a Hit, with the raw versions kept in the Cesium adapter.
rendererOf gains findInput, provideUnboundInput and provideNativeClick.
event.native carries the engine's pick, drill and pickWindow, and picks
through the follow helper happen inside it. An unbound input port
survives the viewer being bound until it is released.
The query port's pick memo is now per task rather than per frame,
because Cesium's own picks advance the frame number. A click on the sky
skips the depth pass when nothing is on the ray. Touch contact search
keeps its eight-deep drill in a 14x14 window.
This commit is contained in:
1 parent
6eb9ceef46
commit
8bcaced6ad
52 files changed
+1836
-484
No files matched your search
@@ -2,9 +2,9 @@
|
||||
* Pick-ownership contract tests (pre-ship audit H2).
|
||||
*
|
||||
* Locks the cross-layer pick coercion rules:
|
||||
* - resolvePickId reduces every layer's pick shape (string icao/station ids,
|
||||
* numeric NORAD ids, AIS vessel record objects, Cesium Entity objects) to
|
||||
* ONE canonical String id.
|
||||
* - resolvePickId reads a click's hit (the contract's `Hit`, or one with no
|
||||
* set for something drawn outside the draw port) as ONE canonical String
|
||||
* id: its item's id.
|
||||
* - isOwnedByOtherLayer consults sibling predicates only, never the asker's,
|
||||
* and never throws on a broken predicate.
|
||||
*/
|
||||
@@ -23,27 +23,25 @@ import {
|
||||
// resolvePickId — canonical String coercion for every layer's pick shape
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
test('resolvePickId: string pick id (flights/military/bikeshare/cctv billboards)', () => {
|
||||
assert.equal(resolvePickId({ id: 'aaa001' }), 'aaa001');
|
||||
assert.equal(resolvePickId({ id: undefined, primitive: { id: 'station:austin:1' } }), 'station:austin:1');
|
||||
const item = (set, id) => ({ set, id, surface: false });
|
||||
const SURFACE = { set: '', id: '', surface: true };
|
||||
|
||||
test("resolvePickId: a draw-set item's hit → its item id", () => {
|
||||
assert.equal(resolvePickId(item('flights:1', 'aaa001')), 'aaa001');
|
||||
assert.equal(resolvePickId(item('satellites:1:dots', '25544')), '25544');
|
||||
});
|
||||
|
||||
test('resolvePickId: numeric pick id (satellite NORAD numbers) → String', () => {
|
||||
assert.equal(resolvePickId({ id: 25544 }), '25544');
|
||||
assert.equal(resolvePickId({ id: undefined, primitive: { id: 43013 } }), '43013');
|
||||
test('resolvePickId: something drawn outside the draw port → its own id', () => {
|
||||
assert.equal(resolvePickId(item('', 'transit:bus-1')), 'transit:bus-1');
|
||||
assert.equal(resolvePickId(item('', null)), null, 'it has none');
|
||||
assert.equal(resolvePickId(item('', '')), '', 'an empty id is still an id');
|
||||
});
|
||||
|
||||
test('resolvePickId: Cesium-Entity-like object → its string id', () => {
|
||||
const entity = { id: 'cctv-atx-cam-3-center', properties: {} };
|
||||
assert.equal(resolvePickId({ id: entity }), 'cctv-atx-cam-3-center');
|
||||
});
|
||||
|
||||
test('resolvePickId: unresolvable picks → null', () => {
|
||||
test('resolvePickId: the map and nothing → null', () => {
|
||||
assert.equal(resolvePickId(null), null);
|
||||
assert.equal(resolvePickId(undefined), null);
|
||||
assert.equal(resolvePickId({}), null);
|
||||
assert.equal(resolvePickId({ id: {} }), null); // object with no id
|
||||
assert.equal(resolvePickId({ primitive: {} }), null);
|
||||
assert.equal(resolvePickId(SURFACE), null);
|
||||
assert.equal(resolvePickId({ ...SURFACE, id: 'tile' }), null);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -60,9 +58,9 @@ test('ownership: sibling layers recognize each other via String-coerced ids', ()
|
||||
registerPickOwner('ais-live-vessels', (pickedId) => vessels.has(pickedId));
|
||||
try {
|
||||
// Flights asking about a satellite pick (raw numeric id → String upstream)
|
||||
assert.equal(isOwnedByOtherLayer('flights', resolvePickId({ id: 25544 })), true);
|
||||
assert.equal(isOwnedByOtherLayer('flights', resolvePickId(item('sat:1', '25544'))), true);
|
||||
// Flights asking about a vessel pick (an icon row id: the mmsi)
|
||||
assert.equal(isOwnedByOtherLayer('flights', resolvePickId({ id: '367123450' })), true);
|
||||
assert.equal(isOwnedByOtherLayer('flights', resolvePickId(item('ais:1', '367123450'))), true);
|
||||
// A layer never owns its own pick via the sibling scan
|
||||
assert.equal(isOwnedByOtherLayer('satellites', '25544'), false);
|
||||
// Unknown ids belong to nobody
|
||||
@@ -115,38 +113,48 @@ function contactOwners(t) {
|
||||
});
|
||||
}
|
||||
|
||||
const mapTile = { primitive: { isCesium3DTileset: true } };
|
||||
/** A query port double: one pick, and a drill that records its asks. */
|
||||
function query(picked, drillPick = () => assert.fail('must not drill')) {
|
||||
return {
|
||||
pick: () => picked,
|
||||
drillPick,
|
||||
};
|
||||
}
|
||||
|
||||
test('touch contact pick expands only a surface miss, bounded to 8 hits in 14 CSS pixels', (t) => {
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
const position = { x: 30, y: 50 };
|
||||
const contact = { primitive: { id: 'civil' } };
|
||||
const contact = item('flights:1', 'civil');
|
||||
let drills = 0;
|
||||
const scene = {
|
||||
pick(point) {
|
||||
assert.equal(point, position);
|
||||
return mapTile;
|
||||
},
|
||||
drillPick(...args) {
|
||||
drills++;
|
||||
assert.deepEqual(args, [position, 8, 14, 14]);
|
||||
return [mapTile, contact];
|
||||
},
|
||||
};
|
||||
assert.equal(pickContact(scene, position), contact);
|
||||
const port = query(SURFACE, (...args) => {
|
||||
drills++;
|
||||
assert.deepEqual(args, [30, 50, { width: 14, height: 14, limit: 8 }]);
|
||||
return [contact];
|
||||
});
|
||||
assert.equal(pickContact(port, position), contact);
|
||||
assert.equal(drills, 1);
|
||||
});
|
||||
|
||||
test("touch contact pick uses the click's own pick and drill", (t) => {
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
const contact = item('flights:1', 'civil');
|
||||
const asked = [];
|
||||
const found = pickContact(query(null), { x: 1, y: 1 }, {
|
||||
picked: null,
|
||||
drill: (...args) => (asked.push(args), [contact]),
|
||||
});
|
||||
assert.equal(found, contact);
|
||||
assert.deepEqual(asked, [[8, 14, 14]]);
|
||||
});
|
||||
|
||||
test('touch contact pick returns the first registered sibling, never a caller-specific preference', (t) => {
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
for (const first of [{ id: 'military' }, { id: '123456789' }]) {
|
||||
const scene = {
|
||||
pick: () => mapTile,
|
||||
drillPick: () => [mapTile, first, { id: 'civil' }],
|
||||
};
|
||||
assert.equal(pickContact(scene, { x: 1, y: 1 }), first);
|
||||
for (const first of [item('mil:1', 'military'), item('ais:1', '123456789')]) {
|
||||
const port = query(SURFACE, () => [first, item('flights:1', 'civil')]);
|
||||
assert.equal(pickContact(port, { x: 1, y: 1 }), first);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -154,60 +162,38 @@ test('touch contact pick does not drill through exact registered or unregistered
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
for (const exact of [
|
||||
{ id: 'military' },
|
||||
{ id: 'custom-annotation' },
|
||||
{ primitive: { id: 'custom-gizmo' } },
|
||||
{ primitive: { id: 'civil', isCesium3DTileset: true } },
|
||||
]) {
|
||||
const scene = {
|
||||
pick: () => exact,
|
||||
drillPick: () => assert.fail('must keep exact interactive hit'),
|
||||
};
|
||||
assert.equal(pickContact(scene, { x: 1, y: 1 }), exact);
|
||||
}
|
||||
item('mil:1', 'military'),
|
||||
item('notes:1', 'custom-annotation'),
|
||||
item('', 'custom-gizmo'),
|
||||
])
|
||||
assert.equal(pickContact(query(exact), { x: 1, y: 1 }), exact);
|
||||
});
|
||||
|
||||
test('touch expansion stops at a non-surface object and respects the drill bound', (t) => {
|
||||
test('touch expansion stops at an unowned item and respects the drill bound', (t) => {
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
for (const hits of [
|
||||
[mapTile, { id: 'custom-annotation' }, { id: 'civil' }],
|
||||
[...Array(8).fill(mapTile), { id: 'civil' }],
|
||||
[mapTile],
|
||||
]) {
|
||||
assert.equal(
|
||||
pickContact(
|
||||
{ pick: () => mapTile, drillPick: () => hits },
|
||||
{ x: 1, y: 1 },
|
||||
),
|
||||
mapTile,
|
||||
);
|
||||
}
|
||||
[item('notes:1', 'custom-annotation'), item('flights:1', 'civil')],
|
||||
[...Array(8).fill(item('notes:1', 'x')), item('flights:1', 'civil')],
|
||||
[],
|
||||
])
|
||||
assert.equal(pickContact(query(SURFACE, () => hits), { x: 1, y: 1 }), SURFACE);
|
||||
});
|
||||
|
||||
test('fine primary pointers keep the existing exact mouse pick without a drill', (t) => {
|
||||
test('fine primary pointers keep the exact mouse pick without a drill', (t) => {
|
||||
primaryPointer(t, false);
|
||||
contactOwners(t);
|
||||
const scene = {
|
||||
pick: () => mapTile,
|
||||
drillPick: () => assert.fail('mouse must not expand'),
|
||||
};
|
||||
assert.equal(pickContact(scene, { x: 1, y: 1 }), mapTile);
|
||||
assert.equal(pickContact(query(SURFACE), { x: 1, y: 1 }), SURFACE);
|
||||
});
|
||||
|
||||
test('touch picking tolerates unavailable or failing drill support and preserves empty sky', (t) => {
|
||||
test('touch picking tolerates a failing drill and preserves empty sky', (t) => {
|
||||
primaryPointer(t, true);
|
||||
contactOwners(t);
|
||||
for (const drillPick of [
|
||||
undefined,
|
||||
() => {
|
||||
throw new Error('context lost');
|
||||
},
|
||||
() => [],
|
||||
]) {
|
||||
assert.equal(
|
||||
pickContact({ pick: () => undefined, drillPick }, { x: 1, y: 1 }),
|
||||
undefined,
|
||||
);
|
||||
}
|
||||
])
|
||||
assert.equal(pickContact(query(null, drillPick), { x: 1, y: 1 }), null);
|
||||
});
|
||||
Reference in new issue
Block a user