mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
test(globe): mover coverage on both engines; pickable: false honoured
Review of Tasks 2 and 4:
- A contract check draws, on both engines: an atlas cell switch, a
rotation of π (a half-white cell flips from above to below the
centre), scale 2 (about four times the area), scaleByDistance past
`far` (about a quarter), setCount shrinking the set, depth modes for
sprites 30 km under the ground ('always' and a disableWithinM past the
camera draw), a point with its dark outline, and a glTF model
(airplane.glb, minimumPixelSize 80, colorBlend replace) in magenta.
'normal' and a 10 m disableWithinM hide the buried sprite on Navara;
Cesium's billboards are not occluded by the app's photoreal tiles
(globe hidden; measured), so those two are asserted on Navara only.
- pickable: false: Cesium's GPU pick sees every primitive, so the
picker drops picks (and drill entries) of a set created with
pickable: false; Navara only registers pickable sets. The contract's
click check now clicks a pickable: false sprite on both engines.
- Navara resolves a GPU answer's batch id to the pick id when Navara
answers (the pick's own frame), not when the engine's click consumes
it: a set that reuses the instance in between still yields the
instance that was under the pointer.
Contract: Cesium 70/70, Navara 76/76.
This commit is contained in:
1 parent
0957d9712b
commit
6436f580d9
7 files changed
+310
-7
No files matched your search
@@ -316,7 +316,8 @@ export function createCesiumMovers(
|
||||
/** 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;
|
||||
const entry = known && registry.sets.get(known.owner);
|
||||
return entry ? { ...known, pickable: entry.options.pickable } : null;
|
||||
},
|
||||
destroy() {
|
||||
registry.destroyAll();
|
||||
|
||||
@@ -240,6 +240,7 @@ test('a pick of a billboard or point names its set and instance', async () => {
|
||||
assert.deepEqual(identify({ primitive: second, id: 25544 }), {
|
||||
owner: 'sats',
|
||||
instance: 1,
|
||||
pickable: false,
|
||||
});
|
||||
assert.equal(identify({ primitive: {}, id: 'x' }), null);
|
||||
set.destroy();
|
||||
|
||||
@@ -14,6 +14,9 @@ export function createCesiumPicker(viewer, { identify = () => null } = {}) {
|
||||
const normalise = (picked) => {
|
||||
if (picked == null) 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).
|
||||
if (known?.pickable === false) return undefined;
|
||||
return {
|
||||
id: picked.id,
|
||||
primitive: picked.primitive,
|
||||
@@ -37,7 +40,8 @@ export function createCesiumPicker(viewer, { identify = () => null } = {}) {
|
||||
drillPick(screen, limit, width, height) {
|
||||
return scene
|
||||
.drillPick(toCesium2(screen), limit, width, height)
|
||||
.map(normalise);
|
||||
.map(normalise)
|
||||
.filter(Boolean);
|
||||
},
|
||||
pickPosition(screen) {
|
||||
if (!scene.pickPositionSupported) return undefined;
|
||||
|
||||
@@ -134,3 +134,24 @@ test('picks of movers and lines name their owner and instance', () => {
|
||||
assert.equal(drilled[0].owner, 'flights');
|
||||
assert.equal(drilled[1].owner, undefined);
|
||||
});
|
||||
|
||||
test('picks of a mover set made with pickable: false are dropped', () => {
|
||||
const viewer = createFakeViewer();
|
||||
const quiet = { id: 'q' };
|
||||
viewer.scene.pick = () => ({ primitive: quiet, id: 'q' });
|
||||
viewer.scene.drillPick = () => [
|
||||
{ primitive: quiet, id: 'q' },
|
||||
{ primitive: {}, id: 'other' },
|
||||
];
|
||||
const { picker } = createCesiumPicker(viewer, {
|
||||
identify: (raw) =>
|
||||
raw.primitive === quiet
|
||||
? { owner: 'quiet', instance: 0, pickable: false }
|
||||
: null,
|
||||
});
|
||||
assert.equal(picker.pick({ x: 1, y: 2 }), undefined);
|
||||
assert.deepEqual(
|
||||
picker.drillPick({ x: 1, y: 2 }, 5).map(({ id }) => id),
|
||||
['other'],
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user