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:
German Khokhlov committed 2026-10-16 19:20:47 +04:00
1 parent 0957d9712b
commit 6436f580d9
7 files changed
+310 -7

No files matched your search

+8 -5
View File
@@ -51,8 +51,11 @@ export function createNavaraPicking({
// Navara 0.2.1 answers clicks in quick succession (within a frame or so)
// with the first click's pick: a GPU answer whose instance is not drawn
// near the click is stale, and the CPU pick answers instead.
const answerFrom = (info, at) => {
const hit = info ? resolveBatch(info.batchId) : null;
// `hit` is the batch id resolved when Navara answered (the pick's own
// frame): a set that changes its instances after it still names the
// instance that was under the pointer.
const resolveInfo = (info) => (info ? resolveBatch(info.batchId) : null);
const answerFrom = (hit, at) => {
if (hit && !drillPick.near(hit.set, hit.instance, at)) {
stats.stale++;
return drillPick(at, 1)[0];
@@ -68,12 +71,12 @@ export function createNavaraPicking({
const onFeatureClick = (info) => {
const next = waiting.shift();
if (!next) {
early = { info, at: now() };
early = { hit: resolveInfo(info), at: now() };
return;
}
cancel(next.timer);
answered(next, 'gpu');
next.resolve(answerFrom(info, next.at));
next.resolve(answerFrom(resolveInfo(info), next.at));
};
view.on('featureClick', onFeatureClick);
@@ -87,7 +90,7 @@ export function createNavaraPicking({
if (gesture && now() - gesture.at <= EARLY_ANSWER_MS) {
const entry = { startedAt: gesture.at };
answered(entry, 'gpu');
return Promise.resolve(answerFrom(gesture.info, at));
return Promise.resolve(answerFrom(gesture.hit, at));
}
return new Promise((resolve) => {
const entry = {
+24
View File
@@ -272,3 +272,27 @@ test('a thin line is picked within 8 px of its segments', () => {
assert.equal(picking.pick({ x: 100, y: 57.5 })?.id, 'trail-1');
assert.equal(picking.pick({ x: 100, y: 58.5 }), undefined);
});
test('the pick id is the one the instance had when Navara answered', async () => {
const view = fakeView();
const sets = [moverSet('flights', [[10, 10, 5, 'before']])];
let time = 0;
const picking = createNavaraPicking({
view,
projector,
camera,
movers: () => sets,
lines: () => [],
resolveBatch: (batchId) =>
batchId === 1
? { set: 'flights', instance: 0, pickId: sets[0].store.pickIds[0] }
: null,
now: () => time,
...timers(),
});
view.emit('featureClick', { batchId: 1 });
// The layer reuses the instance before the engine's click arrives.
sets[0].store.set(0, { pickId: 'after' });
time += 1;
assert.equal((await picking.clickPick({ x: 10, y: 10 })).id, 'before');
});