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

+4 -1
View File
@@ -167,6 +167,7 @@ export function createNavaraMovers(view, { overlay }) {
});
return {
ready: mover.ready,
pickRadiusPx: mover.pickRadiusPx,
commit() {
mover.commit(store.dirty());
request();
@@ -183,9 +184,11 @@ export function createNavaraMovers(view, { overlay }) {
resolvePick: (batchId) => pickIndex.resolve(batchId),
/** The live sets' options and stores, for CPU picks. */
pickables: () =>
[...registry.sets.values()].map(({ options, store }) => ({
[...registry.sets.values()].map(({ options, store, part }) => ({
options,
store,
// Models: the drawn radius the CPU checks a model hit against.
pickRadiusPx: part?.pickRadiusPx ?? null,
})),
destroy: () => registry.destroyAll(),
};
+13
View File
@@ -109,6 +109,8 @@ export function createModelMover(options, store, { load, onLoad = () => {} }) {
let disposed = false;
const colorAttributes = [];
const materials = [];
// Each instance's drawn diameter (px) at its last write (CPU picks).
const drawnPx = new Float32Array(capacity);
// Translucent only while an instance is faded (opaque models keep the
// opaque pass).
const syncTransparency = () => {
@@ -128,6 +130,7 @@ export function createModelMover(options, store, { load, onLoad = () => {} }) {
const { positions, orientations, scales, shows, colors } = store;
for (let index = from; index < to; index++) {
let scale = shows[index] === 1 ? scales[index] : 0;
drawnPx[index] = 0;
if (scale > 0 && cameraPosition && footprint > 0) {
const dx = positions[index * 3] - cameraPosition.x;
const dy = positions[index * 3 + 1] - cameraPosition.y;
@@ -146,6 +149,7 @@ export function createModelMover(options, store, { load, onLoad = () => {} }) {
if (pixels < model.minimumPixelSize)
scale *= model.minimumPixelSize / pixels;
scale = Math.min(scale, model.maximumScale);
drawnPx[index] = (pixels * scale) / scales[index];
}
scratchTranslation.set(
positions[index * 3] - origin.x,
@@ -237,6 +241,15 @@ export function createModelMover(options, store, { load, onLoad = () => {} }) {
uniforms,
ready: () => loaded,
origin: () => origin,
/**
* The drawn radius (px) of an instance at its last write, or null when
* not known yet (not loaded, no camera): CPU picks check a model hit
* against it.
*/
pickRadiusPx: (index) =>
loaded && index < store.count && drawnPx[index] > 0
? drawnPx[index] / 2
: null,
commit(range) {
if (!origin && store.count > 0)
placeAt({
+4 -1
View File
@@ -85,7 +85,10 @@ test('a far model keeps its minimum pixel size', async () => {
assert.ok(
Math.abs(scale - expected) / expected < 1e-6,
`${scale} vs ${expected}`,
);
); // CPU picks read the drawn radius: half the 40 px minimum (the pixel
// size at the pre-minimum distance, so within a radius's worth).
assert.ok(Math.abs(mover.pickRadiusPx(0) - 20) < 1e-3, mover.pickRadiusPx(0));
assert.equal(mover.pickRadiusPx(1), null);
});
test("the instance colour (sRGB, decoded) tints by the set's blend amount; its alpha is opacity, as Cesium's model colour", async () => {