mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(navara): render CCTV media and calibration handles
Port camera markers, coverage, media planes, volumes and calibration to the Navara renderer. Preserve shared source/media policy and add exact plane picking, owned resource cleanup and idle hold handling. Validate paired keyless dev/preview media and physical drags, native legacy, engine contracts and full CPU/build gates. Record remaining shell, viewshed browser and W2 performance gates; defer Dioxus and plan the transit port.
This commit is contained in:
1 parent
798d6636ab
commit
694616d5c2
22 files changed
+1466
-7
No files matched your search
@@ -62,6 +62,11 @@ const toColor = ([r, g, b, a], alphaScale = 1) =>
|
||||
|
||||
/** The Cesium material type and uniforms of a line (pure, for tests). */
|
||||
export function materialSpec(options, color, alphaScale = 1) {
|
||||
if (options.arrow)
|
||||
return {
|
||||
type: 'PolylineArrow',
|
||||
uniforms: { color: toColor(color, alphaScale) },
|
||||
};
|
||||
const { dash } = options;
|
||||
if (dash?.kind === 'pixels')
|
||||
return {
|
||||
|
||||
@@ -143,3 +143,23 @@ test('a pick of a line primitive names the line', () => {
|
||||
});
|
||||
assert.equal(identify({ primitive: {}, id: 'o' }), null);
|
||||
});
|
||||
|
||||
test('arrow lines retain the native arrow material in both depth passes', () => {
|
||||
const { factories, made } = fakePrimitives();
|
||||
const { lines, destroy } = createCesiumLines(createFakeViewer(), {
|
||||
factories,
|
||||
});
|
||||
lines
|
||||
.createLine({
|
||||
id: 'arrow',
|
||||
widthPx: 8,
|
||||
color: [1, 0, 0, 1],
|
||||
arrow: true,
|
||||
depthFailAlpha: 0.45,
|
||||
})
|
||||
.setPositions(points);
|
||||
assert.equal(made[0].appearance.material.type, 'PolylineArrow');
|
||||
assert.equal(made[0].depthFailAppearance.material.type, 'PolylineArrow');
|
||||
assert.equal(made[0].depthFailAppearance.material.uniforms.color.alpha, 0.45);
|
||||
destroy();
|
||||
});
|
||||
@@ -107,7 +107,13 @@ function transformed(matrix, flat, index, result) {
|
||||
* @returns {(at: { x: number, y: number }, limit?: number, options?: { includeMovers?: boolean }) => object[]}
|
||||
* Pick results ({ id, owner, instance? }) under a window position, nearest first.
|
||||
*/
|
||||
export function createCpuPicker({ projector, camera, movers, lines }) {
|
||||
export function createCpuPicker({
|
||||
projector,
|
||||
camera,
|
||||
movers,
|
||||
lines,
|
||||
meshes = () => [],
|
||||
}) {
|
||||
const depthOf = (position) =>
|
||||
geo.cartesian3.distance(position, camera.livePosition);
|
||||
|
||||
@@ -181,11 +187,12 @@ export function createCpuPicker({ projector, camera, movers, lines }) {
|
||||
const drill = (
|
||||
at,
|
||||
limit = Infinity,
|
||||
{ includeMovers = true, includeLines = true } = {},
|
||||
{ includeMovers = true, includeLines = true, includeMeshes = true } = {},
|
||||
) => {
|
||||
const hits = [];
|
||||
if (includeMovers) moverHits(at, hits);
|
||||
if (includeLines) lineHits(at, hits);
|
||||
if (includeMeshes) hits.push(...meshes(at));
|
||||
hits.sort(
|
||||
(a, b) => b.onTop - a.onTop || b.order - a.order || a.depth - b.depth,
|
||||
);
|
||||
|
||||
@@ -82,6 +82,7 @@ export function normalizeLineOptions(options) {
|
||||
arc,
|
||||
depthFailAlpha,
|
||||
dash: dashOf(options.dash),
|
||||
...(options.arrow === true ? { arrow: true } : {}),
|
||||
modelMatrix: modelMatrix ? [...modelMatrix] : null,
|
||||
pickId: options.pickId,
|
||||
order: isFiniteNumber(options.order) ? options.order : 0,
|
||||
|
||||
@@ -222,6 +222,8 @@ export function createNavaraEngine(
|
||||
});
|
||||
|
||||
const picker = {
|
||||
// Navara mesh owners supply exact triangle hits for sync/hover/click picks.
|
||||
registerMeshPicker: (pick) => picking.registerMeshPicker(pick),
|
||||
// The CPU pick of movers and lines (picking.js); 3D tiles carry no ids.
|
||||
// Clicks with { pick } get Navara's GPU pick of the gesture instead.
|
||||
pick: (screen) => picking.pick(screen),
|
||||
|
||||
@@ -65,6 +65,7 @@ uniform float uGevAlphaScale;
|
||||
uniform float uGevPixelRatio;
|
||||
${OVERLAY_DEPTH_FRAGMENT}
|
||||
uniform float uGevDash;
|
||||
uniform bool uGevArrow;
|
||||
uniform vec2 uGevDashPx;
|
||||
uniform vec2 uGevTactical;
|
||||
varying float vGevS;
|
||||
@@ -93,6 +94,12 @@ if (gevOverlayHidden()) discard;
|
||||
// sRGB colours (as Cesium takes them) into the linear output.
|
||||
diffuseColor = sRGBTransferEOTF(uGevColor);
|
||||
diffuseColor.a *= uGevAlphaScale;
|
||||
if (uGevArrow) {
|
||||
float head = max(fwidth(vGevS) * 10.0 * uGevPixelRatio, 1e-6);
|
||||
float halfWidth = vGevS < 1.0 - head ? 0.15 : 0.5 * (1.0 - vGevS) / head;
|
||||
float edge = max(fwidth(vGevT), 1e-5);
|
||||
diffuseColor.a *= 1.0 - smoothstep(halfWidth - edge, halfWidth + edge, abs(vGevT - 0.5));
|
||||
}
|
||||
if (uGevDash > 1.5) {
|
||||
diffuseColor.a *= gevTactical();
|
||||
} else if (uGevDash > 0.5) {
|
||||
@@ -201,6 +208,7 @@ export function createLineMesh(
|
||||
uGevWidthPx: { value: options.widthPx },
|
||||
uGevColor: { value: [...options.color] },
|
||||
uGevDash: { value: dash?.kind === 'tactical' ? 2 : dash ? 1 : 0 },
|
||||
uGevArrow: { value: options.arrow === true },
|
||||
uGevDashPx: {
|
||||
value: dash?.kind === 'pixels' ? [dash.lengthPx, dash.gapPx] : [1, 0],
|
||||
},
|
||||
|
||||
@@ -37,7 +37,14 @@ export function createNavaraPicking({
|
||||
timeoutMs = CLICK_TIMEOUT_MS,
|
||||
now = () => performance.now(),
|
||||
}) {
|
||||
const drillPick = createCpuPicker({ projector, camera, movers, lines });
|
||||
const meshPickers = new Set();
|
||||
const drillPick = createCpuPicker({
|
||||
projector,
|
||||
camera,
|
||||
movers,
|
||||
lines,
|
||||
meshes: (at) => [...meshPickers].flatMap((pick) => pick(at)),
|
||||
});
|
||||
const isModelSet = (id) =>
|
||||
movers().some(
|
||||
({ options }) => options.id === id && options.kind === 'model',
|
||||
@@ -75,7 +82,7 @@ export function createNavaraPicking({
|
||||
!drillPick.near(hit.set, hit.instance, at, 1) ||
|
||||
(top !== undefined &&
|
||||
!(top.owner === hit.set && top.instance === hit.instance) &&
|
||||
!isModelSet(hit.set));
|
||||
(!isModelSet(hit.set) || top.instance === undefined));
|
||||
if (stale) {
|
||||
stats.stale++;
|
||||
return drillPick(at, 1)[0];
|
||||
@@ -102,6 +109,10 @@ export function createNavaraPicking({
|
||||
view.on('featureClick', onFeatureClick);
|
||||
|
||||
return {
|
||||
registerMeshPicker(pick) {
|
||||
meshPickers.add(pick);
|
||||
return () => meshPickers.delete(pick);
|
||||
},
|
||||
pick: (at) => drillPick(at, 1)[0],
|
||||
drillPick: (at, limit) => drillPick(at, limit ?? Infinity),
|
||||
/** The answer for a click at `at`: the GPU pick of its gesture. */
|
||||
@@ -132,6 +143,7 @@ export function createNavaraPicking({
|
||||
/** How clicks were answered: GPU picks, timeouts, recent latencies (ms). */
|
||||
clickStats: () => ({ ...stats, latencies: [...stats.latencies] }),
|
||||
destroy() {
|
||||
meshPickers.clear();
|
||||
view.off('featureClick', onFeatureClick);
|
||||
for (const entry of waiting.splice(0)) {
|
||||
cancel(entry.timer);
|
||||
|
||||
@@ -434,3 +434,85 @@ test('stale GPU model hits cannot select hidden or removed instances', async ()
|
||||
assert.equal(await removed, undefined);
|
||||
picking.destroy();
|
||||
});
|
||||
|
||||
test('owned mesh triangle hits participate in hover, GPU-empty clicks and disposal', async () => {
|
||||
const view = fakeView();
|
||||
const picking = createNavaraPicking({
|
||||
view,
|
||||
projector,
|
||||
camera,
|
||||
movers: () => [],
|
||||
lines: () => [],
|
||||
resolveBatch: () => null,
|
||||
...timers(),
|
||||
});
|
||||
const hit = { id: 'plane', owner: 'plane' };
|
||||
const release = picking.registerMeshPicker((at) =>
|
||||
at.x === 10 ? [{ onTop: 0, order: 0, depth: 100, result: hit }] : [],
|
||||
);
|
||||
assert.equal(picking.pick({ x: 10, y: 20 }), hit);
|
||||
assert.equal(picking.pick({ x: 11, y: 20 }), undefined);
|
||||
const clicked = picking.clickPick({ x: 10, y: 20 });
|
||||
view.emit('featureClick', null);
|
||||
assert.equal(await clicked, hit);
|
||||
release();
|
||||
assert.equal(picking.pick({ x: 10, y: 20 }), undefined);
|
||||
picking.registerMeshPicker(() => [
|
||||
{ onTop: 0, order: 0, depth: 100, result: hit },
|
||||
]);
|
||||
picking.destroy();
|
||||
assert.equal(picking.pick({ x: 10, y: 20 }), undefined);
|
||||
});
|
||||
|
||||
test('mesh picks preserve always-on-top siblings and reject stale sprite GPU answers', async () => {
|
||||
const view = fakeView();
|
||||
const sprite = moverSet('points', [[100, 100, 500, 'sprite']]);
|
||||
const picking = createNavaraPicking({
|
||||
view,
|
||||
projector,
|
||||
camera,
|
||||
movers: () => [sprite],
|
||||
lines: () => [],
|
||||
resolveBatch: () => ({ set: 'points', instance: 0, pickId: 'sprite' }),
|
||||
...timers(),
|
||||
});
|
||||
picking.registerMeshPicker(() => [
|
||||
{ onTop: 0, order: 0, depth: 10, result: { id: 'plane', owner: 'plane' } },
|
||||
]);
|
||||
const pending = picking.clickPick({ x: 100, y: 100 });
|
||||
view.emit('featureClick', { batchId: 1 });
|
||||
assert.equal((await pending).id, 'plane');
|
||||
sprite.options.depthTest = 'always';
|
||||
assert.equal(picking.pick({ x: 100, y: 100 }).id, 'sprite');
|
||||
picking.destroy();
|
||||
});
|
||||
|
||||
test('an exact foreground mesh wins over a GPU model pick behind it', async () => {
|
||||
const view = fakeView();
|
||||
const model = modelSet('models', [[100, 100, 500, 'jet']], 20);
|
||||
const picking = createNavaraPicking({
|
||||
view,
|
||||
projector,
|
||||
camera,
|
||||
movers: () => [model],
|
||||
lines: () => [],
|
||||
resolveBatch: () => ({ set: 'models', instance: 0, pickId: 'jet' }),
|
||||
...timers(),
|
||||
});
|
||||
const release = picking.registerMeshPicker(() => [
|
||||
{
|
||||
onTop: 0,
|
||||
order: 0,
|
||||
depth: 10,
|
||||
result: { id: 'plane', owner: 'plane' },
|
||||
},
|
||||
]);
|
||||
const pending = picking.clickPick({ x: 100, y: 100 });
|
||||
view.emit('featureClick', { batchId: 1 });
|
||||
assert.equal((await pending).id, 'plane');
|
||||
release();
|
||||
const uncovered = picking.clickPick({ x: 100, y: 100 });
|
||||
view.emit('featureClick', { batchId: 1 });
|
||||
assert.equal((await uncovered).id, 'jet');
|
||||
picking.destroy();
|
||||
});
|
||||
Reference in new issue
Block a user