fix(globe): Navara picks rank as drawn and check model hits at their drawn radius

T11 review follow-up to ed9ea7e6. CPU hits rank as the engine draws them:
sets without a depth test over depth-tested ones, then by set order
(the tracked bank over the fleet, flights over local ADS-B), then depth —
so the CPU's top hit that checks a GPU answer is the instance drawn on
top. A model hit is no longer taken as answered: the model mover keeps
each instance's drawn diameter (after minimumPixelSize/maximumScale) and
the CPU checks the hit against its projected position within that radius
(+3 px); the CPU pick sees models at that radius too.
This commit is contained in:
German Khokhlov committed 2026-10-17 13:26:42 +04:00
1 parent 1fe8267550
commit 620ada6df3
6 files changed
+146 -15

No files matched your search

+81
View File
@@ -330,3 +330,84 @@ test('a stale GPU answer for a neighbour of the click never wins over the instan
}
assert.equal(picking.clickStats().stale, 20);
});
function modelSet(id, rows, radiusPx) {
const options = normalizeMoverSetOptions({
id,
kind: 'model',
capacity: rows.length,
pickable: true,
model: { url: 'model.glb', minimumPixelSize: 24 },
});
const store = createMoverStore(options);
rows.forEach(([x, y, z, pickId], index) =>
store.set(index, { position: { x, y, z }, pickId }),
);
store.setCount(rows.length);
return { options, store, pickRadiusPx: () => radiusPx };
}
test('CPU hits rank as drawn: always-on-top sets, then set order, then depth', () => {
const ordered = (id, order, depthTest, z) => {
const options = normalizeMoverSetOptions({
id,
kind: 'point',
capacity: 1,
pickable: true,
order,
depthTest,
point: { sizePx: 20 },
});
const store = createMoverStore(options);
store.set(0, { position: { x: 100, y: 100, z }, pickId: id });
store.setCount(1);
return { options, store };
};
const sets = [
ordered('local-adsb', -1, 'always', 5), // nearest, drawn under flights
ordered('fleet', 0, 'always', 50),
ordered('tracked', 2, 'always', 500), // farthest, drawn on top
ordered('depth-tested', 5, 'normal', 1), // nearest of all, depth-tested
];
const picking = createNavaraPicking({
view: fakeView(),
projector,
camera,
movers: () => sets,
lines: () => [],
resolveBatch: () => null,
...timers(),
});
assert.deepEqual(
picking.drillPick({ x: 100, y: 100 }).map(({ id }) => id),
['tracked', 'fleet', 'local-adsb', 'depth-tested'],
);
});
test('a model hit is checked against its projected position within its drawn radius', async () => {
const view = fakeView();
// A model drawn 40 px across (radius 20) at (100, 100).
const sets = [modelSet('models', [[100, 100, 50, 'jet']], 20)];
const picking = createNavaraPicking({
view,
projector,
camera,
movers: () => sets,
lines: () => [],
resolveBatch: () => ({ set: 'models', instance: 0, pickId: 'jet' }),
...timers(),
});
// Within its radius (+3 px): the GPU answer stands.
const inside = picking.clickPick({ x: 118, y: 100 });
view.emit('featureClick', { batchId: 1 });
assert.equal((await inside)?.id, 'jet');
// A stale answer naming it from 60 px away: the CPU pick answers (nothing
// drawn there).
const outside = picking.clickPick({ x: 160, y: 100 });
view.emit('featureClick', { batchId: 1 });
assert.equal(await outside, undefined);
assert.equal(picking.clickStats().stale, 1);
// The CPU pick sees the model at its drawn radius, not the 24 px minimum.
assert.equal(picking.drillPick({ x: 121, y: 100 })[0]?.id, 'jet');
assert.equal(picking.drillPick({ x: 125, y: 100 }).length, 0);
});