mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
fix(cctv): paint count markers on the world overlay canvas
The scene renders at CSS resolution and is stretched on a high-density display, so a count marker drawn as a scene sprite looked coarse next to the camera callouts, which the world overlay paints at device density. Paint the markers through the overlay's custom paint lane instead, in the callouts' typeface. Each paint reprojects the group centres; a click is resolved against the rectangles painted in the last frame and still zooms to the group without choosing a camera. A marker that would cover HUD chrome is skipped, as overlay entries are. With no aggregate sprites left, the contact sweep no longer needs to skip them, so that exclusion is removed.
This commit is contained in:
1 parent
87bff9957b
commit
aabfa5e084
12 files changed
+583
-249
No files matched your search
@@ -1953,7 +1953,8 @@ accepts forwarding headers, so cameras work behind a reverse proxy; a forwarded
|
|||||||
request skips the key-bearing Street View fallback and gets the placeholder.
|
request skips the key-bearing Street View fallback and gets the placeholder.
|
||||||
|
|
||||||
The CCTV layer draws only the cameras on or near the screen. Zoomed out, a
|
The CCTV layer draws only the cameras on or near the screen. Zoomed out, a
|
||||||
ground cell containing multiple cameras shows a cyan count at their centre.
|
ground cell containing multiple cameras shows a cyan count at their centre,
|
||||||
|
drawn on the world overlay at the same resolution as camera callouts.
|
||||||
The count includes cameras beyond the screen edge and excludes cameras beyond
|
The count includes cameras beyond the screen edge and excludes cameras beyond
|
||||||
the horizon. Counts that would overlap on screen merge into one that carries
|
the horizon. Counts that would overlap on screen merge into one that carries
|
||||||
their sum. Clicking a count zooms to its group. Single cameras keep their icons,
|
their sum. Clicking a count zooms to its group. Single cameras keep their icons,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { DEFAULT_FOCUS_DEEMPHASIS_PARAMS } from './focusDeemphasis.js';
|
|||||||
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
|
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
|
||||||
import cctvLayer, {
|
import cctvLayer, {
|
||||||
_cctvIconsForTest,
|
_cctvIconsForTest,
|
||||||
_extractPickedCameraIdForTest,
|
|
||||||
bindCctvWorldClickGesture,
|
bindCctvWorldClickGesture,
|
||||||
applyCctvFocusDeemphasis,
|
applyCctvFocusDeemphasis,
|
||||||
reopenNearestCamera,
|
reopenNearestCamera,
|
||||||
@@ -90,27 +89,113 @@ function viewerAt(heightM, lonDeg = 0, flights = []) {
|
|||||||
|
|
||||||
/** The renderers bound for the running test, let go when it ends. */
|
/** The renderers bound for the running test, let go when it ends. */
|
||||||
const bindings = [];
|
const bindings = [];
|
||||||
const paintedLabels = new Map();
|
let painter;
|
||||||
|
let paintRequests;
|
||||||
|
let measured;
|
||||||
|
let glyphWidth;
|
||||||
|
let ctx;
|
||||||
|
const fonts = new EventTarget();
|
||||||
|
|
||||||
|
function seedCoverage(options) {
|
||||||
|
_setCctvCoverageStateForTest({
|
||||||
|
...options,
|
||||||
|
registerPaintLane(_lane, paint) {
|
||||||
|
painter = paint;
|
||||||
|
return {
|
||||||
|
requestPaint() {
|
||||||
|
paintRequests++;
|
||||||
|
},
|
||||||
|
setActive() {},
|
||||||
|
unregister() {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
paintRequests = 0;
|
||||||
|
measured = 0;
|
||||||
|
glyphWidth = 8;
|
||||||
globalThis.document = {
|
globalThis.document = {
|
||||||
|
fonts,
|
||||||
createElement: () => ({
|
createElement: () => ({
|
||||||
getContext: () => ({
|
getContext: () => ({
|
||||||
beginPath() {},
|
measureText(text) {
|
||||||
arc() {},
|
measured++;
|
||||||
roundRect() {},
|
return { width: text.length * glyphWidth };
|
||||||
measureText: (text) => ({ width: text.length * 15 }),
|
|
||||||
fill() {},
|
|
||||||
stroke() {},
|
|
||||||
fillText(text, x, y, maxWidth) {
|
|
||||||
paintedLabels.set(text, maxWidth ?? Infinity);
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
let savedState;
|
||||||
|
ctx = {
|
||||||
|
font: 'initial',
|
||||||
|
globalAlpha: 1,
|
||||||
|
fillStyle: 'initial',
|
||||||
|
strokeStyle: 'initial',
|
||||||
|
textAlign: 'start',
|
||||||
|
textBaseline: 'top',
|
||||||
|
lineWidth: 1,
|
||||||
|
labels: [],
|
||||||
|
shapes: [],
|
||||||
|
save() {
|
||||||
|
savedState = { ...this };
|
||||||
|
},
|
||||||
|
restore() {
|
||||||
|
Object.assign(this, savedState);
|
||||||
|
},
|
||||||
|
beginPath() {},
|
||||||
|
fill() {},
|
||||||
|
stroke() {},
|
||||||
|
roundRect(...args) {
|
||||||
|
this.shapes.push(args);
|
||||||
|
},
|
||||||
|
fillText(text, x, y) {
|
||||||
|
this.labels.push({
|
||||||
|
text,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
|
alpha: this.globalAlpha,
|
||||||
|
font: this.font,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** Reproject on each paint in CSS pixels, as the host does. */
|
||||||
|
function paint(overrides = {}) {
|
||||||
|
ctx.labels.length = ctx.shapes.length = 0;
|
||||||
|
painter({
|
||||||
|
ctx,
|
||||||
|
width: WIDTH,
|
||||||
|
height: HEIGHT,
|
||||||
|
dpr: 2,
|
||||||
|
viewProjectionMatrix: new Float64Array([
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2 / (30 * WIDTH),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
2 / (30 * HEIGHT),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
]),
|
||||||
|
occluder: { isPointVisible: () => true },
|
||||||
|
overlapsHardUi: () => false,
|
||||||
|
...overrides,
|
||||||
|
});
|
||||||
|
return ctx.labels;
|
||||||
|
}
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
paintedLabels.clear();
|
|
||||||
delete globalThis.document;
|
delete globalThis.document;
|
||||||
for (const unbind of bindings.splice(0)) unbind();
|
for (const unbind of bindings.splice(0)) unbind();
|
||||||
});
|
});
|
||||||
@@ -131,36 +216,38 @@ const CLUSTER = [
|
|||||||
[0.2, 0],
|
[0.2, 0],
|
||||||
];
|
];
|
||||||
|
|
||||||
/** Count billboards the layer currently shows. */
|
/** Groups from the latest view pass. */
|
||||||
function markers() {
|
function markers() {
|
||||||
const book = cctvLayer._cctvDrawnForTest().counts;
|
return cctvLayer._cctvDrawnForTest().counts.markers;
|
||||||
return book.show
|
|
||||||
? book
|
|
||||||
.ids()
|
|
||||||
.map(book.item)
|
|
||||||
.filter((item) => item.show)
|
|
||||||
: [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send a clean count-marker click through the layer's world click handler. */
|
/** Click the CSS position of the painted count with a camera underneath it. */
|
||||||
function clickMarker(marker) {
|
function clickMarker(marker) {
|
||||||
const set = cctvLayer._cctvDrawnForTest().counts.setId;
|
const { x, y } = paint().find((label) => label.text === marker.text);
|
||||||
const hit = { set, id: marker.id, meta: marker.meta };
|
const hit = { set: _cctvIconsForTest().setId, id: 'cam-0' };
|
||||||
assert.equal(_extractPickedCameraIdForTest(hit), null);
|
let fallback;
|
||||||
const click = bindCctvWorldClickGesture({ onClick: (fn) => fn }, () => {
|
const click = bindCctvWorldClickGesture({ onClick: (fn) => fn }, (event) => {
|
||||||
assert.fail('a count click reached activation or empty-click deselection');
|
fallback = event.drawHit;
|
||||||
});
|
});
|
||||||
click({ drawHit: hit, gesture: { travelPx: 0, durationMs: 20 } });
|
const gesture = { travelPx: 0, durationMs: 20 };
|
||||||
|
click({ drawHit: hit, screenPosition: { x, y }, gesture });
|
||||||
|
assert.equal(fallback, undefined);
|
||||||
|
click({
|
||||||
|
drawHit: hit,
|
||||||
|
screenPosition: { x: x + marker.width / 2 + 1, y },
|
||||||
|
gesture,
|
||||||
|
});
|
||||||
|
assert.equal(fallback, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('a crowded cell shows its count and a singleton keeps its icon', () => {
|
test('a crowded cell shows its count and a singleton keeps its icon', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
assert.equal(refreshHorizonCulling(), true);
|
assert.equal(refreshHorizonCulling(), true);
|
||||||
assert.deepEqual(shownIds(records), ['cam-3']);
|
assert.deepEqual(shownIds(records), ['cam-3']);
|
||||||
assert.deepEqual(_viewRecordIdsForTest(), ['cam-3']);
|
assert.deepEqual(_viewRecordIdsForTest(), ['cam-3']);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
markers().map((item) => item.meta.count),
|
markers().map((item) => item.cell.count),
|
||||||
[3],
|
[3],
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -171,7 +258,7 @@ test('a crowded cell shows its count and a singleton keeps its icon', () => {
|
|||||||
|
|
||||||
test('a pan keeps the same winners, and an unchanged view keeps its list', () => {
|
test('a pan keeps the same winners, and an unchanged view keeps its list', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000),
|
viewer: viewerAt(20_000),
|
||||||
records,
|
records,
|
||||||
});
|
});
|
||||||
@@ -180,7 +267,7 @@ test('a pan keeps the same winners, and an unchanged view keeps its list', () =>
|
|||||||
const list = _viewRecordIdsForTest();
|
const list = _viewRecordIdsForTest();
|
||||||
// A pan of a few to some 40 px (a pixel is about 30 m from 20 km up).
|
// A pan of a few to some 40 px (a pixel is about 30 m from 20 km up).
|
||||||
for (const shiftM of [90, 330, 600, 1110]) {
|
for (const shiftM of [90, 330, 600, 1110]) {
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000, shiftM / 111_320),
|
viewer: viewerAt(20_000, shiftM / 111_320),
|
||||||
records,
|
records,
|
||||||
});
|
});
|
||||||
@@ -191,7 +278,7 @@ test('a pan keeps the same winners, and an unchanged view keeps its list', () =>
|
|||||||
`pan by ${shiftM} m`,
|
`pan by ${shiftM} m`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.equal(refreshHorizonCulling(), false, 'the same view changes nothing');
|
assert.equal(refreshHorizonCulling(), false, 'the same view changes nothing');
|
||||||
assert.deepEqual(_viewRecordIdsForTest(), list);
|
assert.deepEqual(_viewRecordIdsForTest(), list);
|
||||||
@@ -200,7 +287,7 @@ test('a pan keeps the same winners, and an unchanged view keeps its list', () =>
|
|||||||
test('a small zoom within one cell size keeps the same winners', () => {
|
test('a small zoom within one cell size keeps the same winners', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
const shownAt = (heightM) => {
|
const shownAt = (heightM) => {
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(heightM),
|
viewer: viewerAt(heightM),
|
||||||
records,
|
records,
|
||||||
});
|
});
|
||||||
@@ -217,7 +304,7 @@ test('the picker prefers the healthy camera and the marker stays at the mean', (
|
|||||||
// Whichever camera the id order would pick, the healthy one must win.
|
// Whichever camera the id order would pick, the healthy one must win.
|
||||||
let first;
|
let first;
|
||||||
for (const id of ['cam-0', 'cam-1']) {
|
for (const id of ['cam-0', 'cam-1']) {
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000),
|
viewer: viewerAt(20_000),
|
||||||
records,
|
records,
|
||||||
healthById: new Map([[id, { status: 'ok' }]]),
|
healthById: new Map([[id, { status: 'ok' }]]),
|
||||||
@@ -239,14 +326,14 @@ test('the picker prefers the healthy camera and the marker stays at the mean', (
|
|||||||
test('the active camera always shows, even in a crowded cell', () => {
|
test('the active camera always shows, even in a crowded cell', () => {
|
||||||
const { records } = recordsAt(CLUSTER.slice(0, 3));
|
const { records } = recordsAt(CLUSTER.slice(0, 3));
|
||||||
for (const active of records) {
|
for (const active of records) {
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000),
|
viewer: viewerAt(20_000),
|
||||||
records,
|
records,
|
||||||
activeCameraId: active.camera.id,
|
activeCameraId: active.camera.id,
|
||||||
});
|
});
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
markers().map((item) => item.meta.count),
|
markers().map((item) => item.cell.count),
|
||||||
[2],
|
[2],
|
||||||
);
|
);
|
||||||
const icons = _cctvIconsForTest();
|
const icons = _cctvIconsForTest();
|
||||||
@@ -264,7 +351,7 @@ test('close up, every camera near the screen shows and far-off ones hide', () =>
|
|||||||
[0.0001, 0],
|
[0.0001, 0],
|
||||||
[0.01, 0],
|
[0.01, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(300),
|
viewer: viewerAt(300),
|
||||||
records,
|
records,
|
||||||
});
|
});
|
||||||
@@ -274,7 +361,7 @@ test('close up, every camera near the screen shows and far-off ones hide', () =>
|
|||||||
|
|
||||||
test('a disabled layer skips the view pass', () => {
|
test('a disabled layer skips the view pass', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000),
|
viewer: viewerAt(20_000),
|
||||||
records,
|
records,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@@ -285,7 +372,7 @@ test('a disabled layer skips the view pass', () => {
|
|||||||
|
|
||||||
test('UI state builds the full camera list only when it is read', () => {
|
test('UI state builds the full camera list only when it is read', () => {
|
||||||
const { records } = recordsAt(CLUSTER.slice(0, 2));
|
const { records } = recordsAt(CLUSTER.slice(0, 2));
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(300),
|
viewer: viewerAt(300),
|
||||||
records,
|
records,
|
||||||
});
|
});
|
||||||
@@ -322,7 +409,7 @@ test('the camera picker lists the view, with the active camera first', () => {
|
|||||||
[0.01, 0],
|
[0.01, 0],
|
||||||
[0.0002, 0],
|
[0.0002, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(300),
|
viewer: viewerAt(300),
|
||||||
records,
|
records,
|
||||||
activeCameraId: 'cam-1',
|
activeCameraId: 'cam-1',
|
||||||
@@ -344,10 +431,10 @@ test('panning a cell across the padded screen edge keeps its full count', () =>
|
|||||||
[0.29, 0],
|
[0.29, 0],
|
||||||
]);
|
]);
|
||||||
for (const lon of [0.015, 0]) {
|
for (const lon of [0.015, 0]) {
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000, lon), records });
|
seedCoverage({ viewer: viewerAt(20_000, lon), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
markers().map((item) => item.meta.count),
|
markers().map((item) => item.cell.count),
|
||||||
[3],
|
[3],
|
||||||
);
|
);
|
||||||
if (lon === 0)
|
if (lon === 0)
|
||||||
@@ -377,10 +464,10 @@ test('only members on the near side of the horizon count', () => {
|
|||||||
query: { project: () => ({ x: 400, y: 300 }) },
|
query: { project: () => ({ x: 400, y: 300 }) },
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
_setCctvCoverageStateForTest({ viewer, records });
|
seedCoverage({ viewer, records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
markers().map((item) => item.meta.count),
|
markers().map((item) => item.cell.count),
|
||||||
[2],
|
[2],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -390,7 +477,7 @@ test('co-located cameras separate below the minimum cell size', () => {
|
|||||||
[0, 0],
|
[0, 0],
|
||||||
[0, 0],
|
[0, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(300), records });
|
seedCoverage({ viewer: viewerAt(300), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(shownIds(records), ['cam-0', 'cam-1']);
|
assert.deepEqual(shownIds(records), ['cam-0', 'cam-1']);
|
||||||
assert.deepEqual(markers(), []);
|
assert.deepEqual(markers(), []);
|
||||||
@@ -404,7 +491,7 @@ test('a count click frames its members and preserves an explicit camera choice',
|
|||||||
[spread, 0],
|
[spread, 0],
|
||||||
[0.2, 0],
|
[0.2, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000, 0, flights),
|
viewer: viewerAt(20_000, 0, flights),
|
||||||
records,
|
records,
|
||||||
activeCameraId: 'cam-2',
|
activeCameraId: 'cam-2',
|
||||||
@@ -430,7 +517,7 @@ test('a count click frames its members and preserves an explicit camera choice',
|
|||||||
);
|
);
|
||||||
assert.equal(reopenNearestCamera(), false);
|
assert.equal(reopenNearestCamera(), false);
|
||||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'cam-2');
|
assert.equal(cctvLayer.getUIState().activeCameraId, 'cam-2');
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: destination,
|
viewer: destination,
|
||||||
records,
|
records,
|
||||||
activeCameraId: 'cam-2',
|
activeCameraId: 'cam-2',
|
||||||
@@ -443,11 +530,13 @@ test('a count click frames its members and preserves an explicit camera choice',
|
|||||||
|
|
||||||
test('disabling the layer hides its counts', () => {
|
test('disabling the layer hides its counts', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.equal(markers().length, 1);
|
assert.equal(markers().length, 1);
|
||||||
|
const [label] = paint();
|
||||||
cctvLayer.disable();
|
cctvLayer.disable();
|
||||||
assert.deepEqual(markers(), []);
|
assert.deepEqual(paint(), []);
|
||||||
|
assert.equal(cctvLayer._cctvDrawnForTest().counts.pickedCell(label), null);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('coverage leaves grouped neighbors and returns when their icons separate', () => {
|
test('coverage leaves grouped neighbors and returns when their icons separate', () => {
|
||||||
@@ -459,7 +548,7 @@ test('coverage leaves grouped neighbors and returns when their icons separate',
|
|||||||
// Lines already materialised at close zoom.
|
// Lines already materialised at close zoom.
|
||||||
for (const record of records) record.coverageEntities = [{ show: true }];
|
for (const record of records) record.coverageEntities = [{ show: true }];
|
||||||
const viewer = viewerAt(20_000);
|
const viewer = viewerAt(20_000);
|
||||||
_setCctvCoverageStateForTest({ viewer, records, activeCameraId: 'cam-0' });
|
seedCoverage({ viewer, records, activeCameraId: 'cam-0' });
|
||||||
refreshCoverageStyles();
|
refreshCoverageStyles();
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@@ -478,7 +567,7 @@ test('coverage leaves grouped neighbors and returns when their icons separate',
|
|||||||
|
|
||||||
test('count markers share the camera focus fade and recover on release', () => {
|
test('count markers share the camera focus fade and recover on release', () => {
|
||||||
const { records } = recordsAt(CLUSTER);
|
const { records } = recordsAt(CLUSTER);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
const target = {
|
const target = {
|
||||||
screenRect: { left: 40, top: 40, right: 60, bottom: 60 },
|
screenRect: { left: 40, top: 40, right: 60, bottom: 60 },
|
||||||
@@ -499,10 +588,10 @@ test('count markers share the camera focus fade and recover on release', () => {
|
|||||||
};
|
};
|
||||||
tick(0, target);
|
tick(0, target);
|
||||||
tick(params.attackMs + 1, target);
|
tick(params.attackMs + 1, target);
|
||||||
assert.equal(markers()[0].focus, params.dimFloor);
|
assert.equal(paint()[0].alpha, params.dimFloor);
|
||||||
tick(params.attackMs + 2, null);
|
tick(params.attackMs + 2, null);
|
||||||
tick(params.attackMs + params.releaseMs + 3, null);
|
tick(params.attackMs + params.releaseMs + 3, null);
|
||||||
assert.equal(markers()[0].focus, 1);
|
assert.equal(paint()[0].alpha, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('overlapping cells merge at their weighted centre and keep every camera in the flight bounds', () => {
|
test('overlapping cells merge at their weighted centre and keep every camera in the flight bounds', () => {
|
||||||
@@ -524,7 +613,7 @@ test('overlapping cells merge at their weighted centre and keep every camera in
|
|||||||
[0, records],
|
[0, records],
|
||||||
[0.003, [...records].reverse()],
|
[0.003, [...records].reverse()],
|
||||||
]) {
|
]) {
|
||||||
_setCctvCoverageStateForTest({
|
seedCoverage({
|
||||||
viewer: viewerAt(20_000, pan, flights),
|
viewer: viewerAt(20_000, pan, flights),
|
||||||
records: order,
|
records: order,
|
||||||
activeCameraId: 'cam-7',
|
activeCameraId: 'cam-7',
|
||||||
@@ -534,21 +623,21 @@ test('overlapping cells merge at their weighted centre and keep every camera in
|
|||||||
const shown = markers();
|
const shown = markers();
|
||||||
assert.deepEqual(shownIds(records), ['cam-7', 'cam-8']);
|
assert.deepEqual(shownIds(records), ['cam-7', 'cam-8']);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
shown.reduce((sum, m) => sum + m.meta.count, 0),
|
shown.reduce((sum, m) => sum + m.cell.count, 0),
|
||||||
7,
|
7,
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
shown.map((m) => m.meta.count).sort((a, b) => a - b),
|
shown.map((m) => m.cell.count).sort((a, b) => a - b),
|
||||||
[2, 5],
|
[2, 5],
|
||||||
);
|
);
|
||||||
const merged = shown.find((m) => m.meta.count === 5);
|
const merged = shown.find((m) => m.cell.count === 5);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
Cesium.Cartesian3.distance(
|
Cesium.Cartesian3.distance(
|
||||||
merged.pos,
|
merged.pos,
|
||||||
Cesium.Cartesian3.fromDegrees(0.0008, 0, 10),
|
Cesium.Cartesian3.fromDegrees(0.0008, 0, 10),
|
||||||
) < 0.01,
|
) < 0.01,
|
||||||
);
|
);
|
||||||
const positions = shown.map((m) => [m.id, m.pos]);
|
const positions = shown.map((m) => [m.cell.key, m.pos]);
|
||||||
if (previous) assert.deepEqual(positions, previous);
|
if (previous) assert.deepEqual(positions, previous);
|
||||||
previous = positions;
|
previous = positions;
|
||||||
clickMarker(merged);
|
clickMarker(merged);
|
||||||
@@ -569,7 +658,7 @@ test('overlapping cells merge at their weighted centre and keep every camera in
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('long localized labels use their measured width on the canvas and billboard', () => {
|
test('the overlay paints short counts as circles and long localized labels as pills', () => {
|
||||||
const locale = getLocale();
|
const locale = getLocale();
|
||||||
try {
|
try {
|
||||||
setLocale('ru');
|
setLocale('ru');
|
||||||
@@ -578,25 +667,38 @@ test('long localized labels use their measured width on the canvas and billboard
|
|||||||
[0.06, 0],
|
[0.06, 0],
|
||||||
[0.06, 0],
|
[0.06, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
const short = markers().find((m) => m.meta.count === 2);
|
const short = markers().find((m) => m.cell.count === 2);
|
||||||
const long = markers().find((m) => m.meta.count === 1300);
|
const long = markers().find((m) => m.cell.count === 1300);
|
||||||
assert.equal(short.image.canvas.width, short.image.canvas.height);
|
const measurements = measured;
|
||||||
assert.ok(long.image.canvas.width > long.image.canvas.height);
|
assert.equal(measurements, 1);
|
||||||
assert.equal(long.size[1], short.size[1]);
|
const labels = paint();
|
||||||
assert.equal(
|
refreshHorizonCulling();
|
||||||
long.size[0] / long.size[1],
|
assert.equal(measured, measurements);
|
||||||
long.image.canvas.width / long.image.canvas.height,
|
|
||||||
);
|
|
||||||
const text = new Intl.NumberFormat('ru', { notation: 'compact' }).format(
|
const text = new Intl.NumberFormat('ru', { notation: 'compact' }).format(
|
||||||
1300,
|
1300,
|
||||||
);
|
);
|
||||||
assert.ok(paintedLabels.get(text) >= text.length * 15);
|
assert.equal(labels.length, 2);
|
||||||
assert.ok(
|
assert.equal(ctx.shapes.length, labels.length);
|
||||||
long.image.canvas.width > text.length * 15,
|
const [sx, sy, sw, sh] =
|
||||||
'the digits have padding',
|
ctx.shapes[labels.findIndex((l) => l.text === '2')];
|
||||||
);
|
const [lx, ly, lw, lh] =
|
||||||
|
ctx.shapes[labels.findIndex((l) => l.text === text)];
|
||||||
|
assert.equal(sw, sh);
|
||||||
|
assert.ok(lw > text.length * glyphWidth);
|
||||||
|
assert.equal(lh, sh);
|
||||||
|
// The four-pixel outer stroke extends two pixels on each side of the path.
|
||||||
|
assert.equal(sw + 4, short.width);
|
||||||
|
assert.equal(lw + 4, long.width);
|
||||||
|
assert.equal(sy + sh / 2, HEIGHT / 2);
|
||||||
|
assert.equal(ly + lh / 2, HEIGHT / 2);
|
||||||
|
assert.ok(Math.abs(sx + sw / 2 - (WIDTH / 2 + short.pos.y / 30)) < 1e-9);
|
||||||
|
assert.ok(Math.abs(lx + lw / 2 - (WIDTH / 2 + long.pos.y / 30)) < 1e-9);
|
||||||
|
assert.match(labels[0].font, /JetBrains Mono/);
|
||||||
|
assert.equal(ctx.font, 'initial');
|
||||||
|
assert.equal(ctx.fillStyle, 'initial');
|
||||||
|
assert.equal(ctx.lineWidth, 1);
|
||||||
} finally {
|
} finally {
|
||||||
setLocale(locale);
|
setLocale(locale);
|
||||||
}
|
}
|
||||||
@@ -613,9 +715,9 @@ test('a wider localized pill merges a horizontal neighbor beyond the circle diam
|
|||||||
[0.008, 0],
|
[0.008, 0],
|
||||||
[0.008, 0],
|
[0.008, 0],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
return markers().map((m) => m.meta.count);
|
return markers().map((m) => m.cell.count);
|
||||||
};
|
};
|
||||||
assert.deepEqual(at(2), [2, 2]);
|
assert.deepEqual(at(2), [2, 2]);
|
||||||
assert.deepEqual(at(1300), [1302]);
|
assert.deepEqual(at(1300), [1302]);
|
||||||
@@ -635,10 +737,95 @@ test('a merged centre can pick up a third count marker', () => {
|
|||||||
[0, -0.0126],
|
[0, -0.0126],
|
||||||
[0, -0.0126],
|
[0, -0.0126],
|
||||||
]);
|
]);
|
||||||
_setCctvCoverageStateForTest({ viewer: viewerAt(20_000), records });
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
refreshHorizonCulling();
|
refreshHorizonCulling();
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
markers().map((m) => m.meta.count),
|
markers().map((m) => m.cell.count),
|
||||||
[6],
|
[6],
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('each paint follows the overlay projection, horizon and hard HUD exclusions', () => {
|
||||||
|
const { records } = recordsAt([
|
||||||
|
[-0.001, 0],
|
||||||
|
[-0.001, 0],
|
||||||
|
[0.001, 0],
|
||||||
|
[0.001, 0],
|
||||||
|
]);
|
||||||
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
|
refreshHorizonCulling();
|
||||||
|
const counts = cctvLayer._cctvDrawnForTest().counts;
|
||||||
|
assert.ok(paintRequests > 0);
|
||||||
|
const requests = paintRequests;
|
||||||
|
const widths = measured;
|
||||||
|
assert.deepEqual(
|
||||||
|
paint().map(({ text, x, y }) => [text, x, y]),
|
||||||
|
[['4', 400, 300]],
|
||||||
|
);
|
||||||
|
const first = { x: 400, y: 300 };
|
||||||
|
assert.equal(counts.pickedCell(first).count, 4);
|
||||||
|
const at = (x) => {
|
||||||
|
const matrix = new Float64Array(16);
|
||||||
|
matrix[12] = (2 * x) / WIDTH - 1;
|
||||||
|
matrix[15] = 1;
|
||||||
|
return { viewProjectionMatrix: matrix };
|
||||||
|
};
|
||||||
|
assert.equal(paint(at(100))[0].x, 100);
|
||||||
|
assert.equal(counts.pickedCell(first), null);
|
||||||
|
assert.deepEqual(paint(at(-100)), []);
|
||||||
|
assert.deepEqual(paint({ occluder: { isPointVisible: () => false } }), []);
|
||||||
|
assert.deepEqual(paint({ overlapsHardUi: () => true }), []);
|
||||||
|
assert.equal(counts.pickedCell(first), null);
|
||||||
|
refreshHorizonCulling();
|
||||||
|
assert.equal(measured, widths);
|
||||||
|
assert.equal(paintRequests, requests);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('loaded font metrics remerge visible cells without waiting for a move', () => {
|
||||||
|
const locale = getLocale();
|
||||||
|
try {
|
||||||
|
setLocale('ru');
|
||||||
|
glyphWidth = 3;
|
||||||
|
const { records } = recordsAt([
|
||||||
|
...Array(1300).fill([-0.009, 0]),
|
||||||
|
[0.009, 0],
|
||||||
|
[0.009, 0],
|
||||||
|
]);
|
||||||
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
|
refreshHorizonCulling();
|
||||||
|
assert.equal(markers().length, 2);
|
||||||
|
glyphWidth = 12;
|
||||||
|
fonts.dispatchEvent(new Event('loadingdone'));
|
||||||
|
assert.deepEqual(
|
||||||
|
markers().map((m) => m.cell.count),
|
||||||
|
[1302],
|
||||||
|
);
|
||||||
|
assert.equal(paint().length, 1);
|
||||||
|
} finally {
|
||||||
|
setLocale(locale);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('hits follow paint order and keep the last painted group until the overlay clears', () => {
|
||||||
|
const { records } = recordsAt([
|
||||||
|
[0, 0],
|
||||||
|
[0, 0],
|
||||||
|
[0.05, 0],
|
||||||
|
[0.05, 0],
|
||||||
|
[0.05, 0],
|
||||||
|
]);
|
||||||
|
seedCoverage({ viewer: viewerAt(20_000), records });
|
||||||
|
refreshHorizonCulling();
|
||||||
|
const point = { x: WIDTH / 2, y: HEIGHT / 2 };
|
||||||
|
const matrix = new Float64Array(16);
|
||||||
|
matrix[15] = 1;
|
||||||
|
const labels = paint({ viewProjectionMatrix: matrix });
|
||||||
|
const counts = cctvLayer._cctvDrawnForTest().counts;
|
||||||
|
assert.equal(labels.length, 2);
|
||||||
|
const top = counts.pickedCell(point);
|
||||||
|
assert.equal(String(top.count), labels.at(-1).text);
|
||||||
|
counts.update([], () => null);
|
||||||
|
assert.equal(counts.pickedCell(point), top);
|
||||||
|
assert.deepEqual(paint(), []);
|
||||||
|
assert.equal(counts.pickedCell(point), null);
|
||||||
|
});
|
||||||
+186
-101
@@ -1,80 +1,62 @@
|
|||||||
import { createIconBook } from '../../render/motion/iconBook.js';
|
|
||||||
import {
|
import {
|
||||||
cellCenter,
|
cellCenter,
|
||||||
formatCameraCount,
|
formatCameraCount,
|
||||||
mergeCountCells,
|
mergeCountCells,
|
||||||
} from '../../data/cctvCellCounts.js';
|
} from '../../data/cctvCellCounts.js';
|
||||||
import { getLocale } from '../../i18n/index.js';
|
import { WORLD_OVERLAY_STYLE } from '../../overlays/worldOverlayTokens.js';
|
||||||
import {
|
import {
|
||||||
COUNT_MARKER_PX,
|
COUNT_MARKER_PX,
|
||||||
COUNT_MERGE_DISTANCE_PX,
|
COUNT_MERGE_DISTANCE_PX,
|
||||||
COUNT_MERGE_PASSES,
|
COUNT_MERGE_PASSES,
|
||||||
} from './policy.js';
|
} from './policy.js';
|
||||||
|
|
||||||
/** A pool of static count billboards sharing one canvas for each label. */
|
const FONT = WORLD_OVERLAY_STYLE.fontTitle;
|
||||||
export function createCountMarkers(set) {
|
const RING = '#75e7ff';
|
||||||
const book = createIconBook(set);
|
|
||||||
const images = new Map();
|
|
||||||
const groups = [];
|
|
||||||
let locale;
|
|
||||||
|
|
||||||
/** Rasterise at twice the CSS size to keep small digits sharp. */
|
/** Merged camera groups and their last painted hit rectangles in CSS pixels. */
|
||||||
function imageFor(text) {
|
export function createCountMarkers(registerPaintLane, id, refreshView) {
|
||||||
if (images.has(text)) return images.get(text);
|
const markers = [];
|
||||||
const canvas = document.createElement('canvas');
|
const hits = [];
|
||||||
const size = COUNT_MARKER_PX * 2;
|
const widths = new Map();
|
||||||
const ctx = canvas.getContext('2d');
|
const fonts = globalThis.document?.fonts;
|
||||||
const font = 'bold 24px sans-serif';
|
let measureCtx;
|
||||||
ctx.font = font;
|
let hitCount = 0;
|
||||||
// A two-pixel ring survives the halving to screen size, and the clear
|
const lane = registerPaintLane?.('ambient-label', paint, {
|
||||||
// margin leaves its outer edge room to antialias inside the sprite.
|
id,
|
||||||
const ring = 4;
|
active: false,
|
||||||
const margin = 4;
|
target: 'shared',
|
||||||
const inset = margin + ring / 2;
|
});
|
||||||
// Up to three digits sit inside the circle; a longer label gets a pill
|
fonts?.addEventListener?.('loadingdone', fontsLoaded);
|
||||||
// with room for its rounded ends.
|
|
||||||
const textWidth = Math.ceil(ctx.measureText(text).width);
|
/** Font changes can widen a pill enough to merge it with its neighbor. */
|
||||||
const fitsCircle = textWidth <= size - 2 * (margin + ring) - 4;
|
function fontsLoaded() {
|
||||||
canvas.width = fitsCircle ? size : textWidth + 2 * (margin + ring + 12);
|
widths.clear();
|
||||||
canvas.height = size;
|
if (!markers.length) return;
|
||||||
ctx.beginPath();
|
refreshView();
|
||||||
ctx.roundRect(
|
lane?.requestPaint();
|
||||||
inset,
|
|
||||||
inset,
|
|
||||||
canvas.width - 2 * inset,
|
|
||||||
size - 2 * inset,
|
|
||||||
size / 2 - inset,
|
|
||||||
);
|
|
||||||
// A dark rim outside the ring keeps it off bright ground.
|
|
||||||
ctx.lineWidth = ring + 4;
|
|
||||||
ctx.strokeStyle = 'rgba(8, 14, 20, 0.85)';
|
|
||||||
ctx.stroke();
|
|
||||||
ctx.fillStyle = '#0e1720';
|
|
||||||
ctx.fill();
|
|
||||||
ctx.lineWidth = ring;
|
|
||||||
ctx.strokeStyle = '#75e7ff';
|
|
||||||
ctx.stroke();
|
|
||||||
ctx.fillStyle = ctx.strokeStyle;
|
|
||||||
ctx.font = font;
|
|
||||||
ctx.textAlign = 'center';
|
|
||||||
ctx.textBaseline = 'middle';
|
|
||||||
ctx.fillText(text, canvas.width / 2, size / 2);
|
|
||||||
const image = { canvas, key: `cctv-count:${text}` };
|
|
||||||
images.set(text, image);
|
|
||||||
return image;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reuse the first slots for visible cells and hide the unused tail. */
|
/** Short labels fit the circle. A longer label leaves room for rounded ends. */
|
||||||
|
function widthForText(text) {
|
||||||
|
if (text.length <= 3) return COUNT_MARKER_PX;
|
||||||
|
let width = widths.get(text);
|
||||||
|
if (width === undefined) {
|
||||||
|
measureCtx ??= document.createElement('canvas').getContext('2d');
|
||||||
|
measureCtx.font = FONT;
|
||||||
|
width = Math.max(
|
||||||
|
COUNT_MARKER_PX + 1,
|
||||||
|
Math.ceil(measureCtx.measureText(text).width) + 20,
|
||||||
|
);
|
||||||
|
widths.set(text, width);
|
||||||
|
}
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reuse marker slots in ground-key order, and invalidate only changed frames. */
|
||||||
function update(cells, project) {
|
function update(cells, project) {
|
||||||
const writes = [];
|
|
||||||
const nextLocale = getLocale();
|
|
||||||
let slot = 0;
|
|
||||||
// Ground-key order keeps the pooled slots stable across pans and health changes.
|
|
||||||
let visible = cells
|
let visible = cells
|
||||||
.filter((cell) => cell.count > 1)
|
.filter((cell) => cell.count > 1)
|
||||||
.sort((a, b) => a.key.localeCompare(b.key));
|
.sort((a, b) => a.key.localeCompare(b.key));
|
||||||
const widthFor = (count) =>
|
|
||||||
imageFor(formatCameraCount(count)).canvas.width / 2;
|
|
||||||
for (
|
for (
|
||||||
let pass = 0;
|
let pass = 0;
|
||||||
pass < COUNT_MERGE_PASSES && visible.length > 1;
|
pass < COUNT_MERGE_PASSES && visible.length > 1;
|
||||||
@@ -83,57 +65,160 @@ export function createCountMarkers(set) {
|
|||||||
const merged = mergeCountCells(
|
const merged = mergeCountCells(
|
||||||
visible,
|
visible,
|
||||||
project,
|
project,
|
||||||
widthFor,
|
(count) => widthForText(formatCameraCount(count)),
|
||||||
COUNT_MARKER_PX,
|
COUNT_MARKER_PX,
|
||||||
COUNT_MERGE_DISTANCE_PX,
|
COUNT_MERGE_DISTANCE_PX,
|
||||||
);
|
);
|
||||||
if (merged.length === visible.length) break;
|
if (merged.length === visible.length) break;
|
||||||
visible = merged;
|
visible = merged;
|
||||||
}
|
}
|
||||||
for (const cell of visible) {
|
let changed = visible.length !== markers.length;
|
||||||
const index = slot++;
|
for (let i = 0; i < visible.length; i++) {
|
||||||
const last = groups[index];
|
const cell = visible[i];
|
||||||
groups[index] = cell;
|
const marker = markers[i] ?? (markers[i] = { focus: 1 });
|
||||||
// Bounds are live for picking even when the drawn label and mean stay put.
|
const last = marker.cell;
|
||||||
|
const text = formatCameraCount(cell.count);
|
||||||
|
const width = widthForText(text);
|
||||||
if (
|
if (
|
||||||
nextLocale === locale &&
|
!last ||
|
||||||
last?.count === cell.count &&
|
last.count !== cell.count ||
|
||||||
last.lonSum === cell.lonSum &&
|
last.latSum !== cell.latSum ||
|
||||||
last.latSum === cell.latSum &&
|
last.lonSum !== cell.lonSum ||
|
||||||
last.heightSum === cell.heightSum
|
last.heightSum !== cell.heightSum
|
||||||
|
) {
|
||||||
|
marker.pos = cellCenter(cell);
|
||||||
|
changed = true;
|
||||||
|
} else if (
|
||||||
|
last.west !== cell.west ||
|
||||||
|
last.east !== cell.east ||
|
||||||
|
last.south !== cell.south ||
|
||||||
|
last.north !== cell.north ||
|
||||||
|
last.low !== cell.low ||
|
||||||
|
last.high !== cell.high
|
||||||
|
) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
changed ||= text !== marker.text || width !== marker.width;
|
||||||
|
marker.cell = cell;
|
||||||
|
marker.text = text;
|
||||||
|
marker.width = width;
|
||||||
|
// Paint never grows the hit buffer, even when a pan reveals every group.
|
||||||
|
hits[i] ??= {};
|
||||||
|
}
|
||||||
|
markers.length = visible.length;
|
||||||
|
// Keep the last frame pickable until the host clears its pixels.
|
||||||
|
lane?.setActive(markers.length > 0 || hitCount > 0);
|
||||||
|
if (changed) lane?.requestPaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Draw at device density using the host's CSS-pixel transform and projection. */
|
||||||
|
function paint(frame) {
|
||||||
|
if (!markers.length) {
|
||||||
|
// Deactivating invalidates the host, so finish the shared frame first.
|
||||||
|
if (hitCount) queueMicrotask(deactivateIfEmpty);
|
||||||
|
hitCount = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hitCount = 0;
|
||||||
|
const { ctx, occluder, viewProjectionMatrix: m } = frame;
|
||||||
|
const height = COUNT_MARKER_PX;
|
||||||
|
ctx.save();
|
||||||
|
try {
|
||||||
|
ctx.font = FONT;
|
||||||
|
ctx.textAlign = 'center';
|
||||||
|
ctx.textBaseline = 'middle';
|
||||||
|
for (let i = 0; i < markers.length; i++) {
|
||||||
|
const marker = markers[i];
|
||||||
|
const { x: px, y: py, z: pz } = marker.pos;
|
||||||
|
const w = m[3] * px + m[7] * py + m[11] * pz + m[15];
|
||||||
|
if (!(w > 0) || (occluder && !occluder.isPointVisible(marker.pos)))
|
||||||
|
continue;
|
||||||
|
const x =
|
||||||
|
(0.5 + (0.5 * (m[0] * px + m[4] * py + m[8] * pz + m[12])) / w) *
|
||||||
|
frame.width;
|
||||||
|
const y =
|
||||||
|
(0.5 - (0.5 * (m[1] * px + m[5] * py + m[9] * pz + m[13])) / w) *
|
||||||
|
frame.height;
|
||||||
|
const rect = hits[hitCount];
|
||||||
|
rect.x = x - marker.width / 2;
|
||||||
|
rect.y = y - height / 2;
|
||||||
|
rect.w = marker.width;
|
||||||
|
rect.h = height;
|
||||||
|
if (
|
||||||
|
rect.x >= frame.width ||
|
||||||
|
rect.y >= frame.height ||
|
||||||
|
rect.x + rect.w <= 0 ||
|
||||||
|
rect.y + rect.h <= 0 ||
|
||||||
|
frame.overlapsHardUi(rect)
|
||||||
|
)
|
||||||
|
continue;
|
||||||
|
ctx.globalAlpha = marker.focus;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.roundRect(
|
||||||
|
rect.x + 2,
|
||||||
|
rect.y + 2,
|
||||||
|
rect.w - 4,
|
||||||
|
height - 4,
|
||||||
|
height / 2 - 2,
|
||||||
|
);
|
||||||
|
ctx.strokeStyle = 'rgba(8, 14, 20, 0.85)';
|
||||||
|
ctx.lineWidth = 4;
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.fillStyle = '#0e1720';
|
||||||
|
ctx.fill();
|
||||||
|
ctx.strokeStyle = RING;
|
||||||
|
ctx.lineWidth = 2;
|
||||||
|
ctx.stroke();
|
||||||
|
ctx.fillStyle = RING;
|
||||||
|
ctx.fillText(marker.text, x, y);
|
||||||
|
rect.cell = marker.cell;
|
||||||
|
hitCount++;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Resolve the topmost group actually painted at this screen position. */
|
||||||
|
function pickedCell(point) {
|
||||||
|
if (!point) return null;
|
||||||
|
for (let i = hitCount - 1; i >= 0; i--) {
|
||||||
|
const rect = hits[i];
|
||||||
|
if (
|
||||||
|
point.x >= rect.x &&
|
||||||
|
point.x <= rect.x + rect.w &&
|
||||||
|
point.y >= rect.y &&
|
||||||
|
point.y <= rect.y + rect.h
|
||||||
)
|
)
|
||||||
continue;
|
return rect.cell;
|
||||||
const id = `cctv-count:${index}`;
|
|
||||||
const previous = book.item(id);
|
|
||||||
const pos = cellCenter(cell);
|
|
||||||
const image = imageFor(formatCameraCount(cell.count));
|
|
||||||
const meta = previous?.meta ?? { aggregate: true, slot: index };
|
|
||||||
meta.count = cell.count;
|
|
||||||
writes.push({
|
|
||||||
id,
|
|
||||||
pos,
|
|
||||||
image,
|
|
||||||
meta,
|
|
||||||
size: [image.canvas.width / 2, COUNT_MARKER_PX],
|
|
||||||
disableDepthTest: Infinity,
|
|
||||||
show: true,
|
|
||||||
focus: previous?.focus,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
locale = nextLocale;
|
return null;
|
||||||
groups.length = slot;
|
|
||||||
for (let i = slot; i < book.size; i++) {
|
|
||||||
const item = book.item(`cctv-count:${i}`);
|
|
||||||
if (item.show) writes.push({ ...item, show: false });
|
|
||||||
}
|
|
||||||
book.putMany(writes);
|
|
||||||
if (!book.show) book.show = true;
|
|
||||||
}
|
}
|
||||||
/** Resolve only a visible pooled billboard belonging to this layer. */
|
|
||||||
function pickedCell(hit) {
|
/** A new group may already have arrived since the empty frame. */
|
||||||
if (!book.show || !hit || hit.set !== book.setId) return null;
|
function deactivateIfEmpty() {
|
||||||
const item = book.item(hit.id);
|
if (!markers.length) lane?.setActive(false);
|
||||||
return item?.show ? groups[item.meta.slot] : null;
|
|
||||||
}
|
}
|
||||||
return { book, update, pickedCell };
|
|
||||||
|
/** Release the visible groups and clear their hit targets immediately. */
|
||||||
|
function hide() {
|
||||||
|
markers.length = hits.length = hitCount = 0;
|
||||||
|
lane?.setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Unhook this viewer's painter and its font listener. */
|
||||||
|
function dispose() {
|
||||||
|
markers.length = hits.length = hitCount = 0;
|
||||||
|
fonts?.removeEventListener?.('loadingdone', fontsLoaded);
|
||||||
|
lane?.unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
markers,
|
||||||
|
update,
|
||||||
|
pickedCell,
|
||||||
|
hide,
|
||||||
|
dispose,
|
||||||
|
requestPaint: () => lane?.requestPaint(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
IDLE_COVERAGE_EDGE_MUTED,
|
IDLE_COVERAGE_EDGE_MUTED,
|
||||||
ACTIVE_COVERAGE_EDGE_DEPTHFAIL,
|
ACTIVE_COVERAGE_EDGE_DEPTHFAIL,
|
||||||
IDLE_COVERAGE_COLOR,
|
IDLE_COVERAGE_COLOR,
|
||||||
|
COUNT_MARKER_PX,
|
||||||
VIEW_CELL_PX,
|
VIEW_CELL_PX,
|
||||||
VIEW_ICON_MARGIN,
|
VIEW_ICON_MARGIN,
|
||||||
VIEW_MIN_CELL_M,
|
VIEW_MIN_CELL_M,
|
||||||
@@ -142,12 +143,9 @@ export function createRendering({
|
|||||||
set.setColumns?.({ ids: [] });
|
set.setColumns?.({ ids: [] });
|
||||||
layerState._icons = createIconBook(set);
|
layerState._icons = createIconBook(set);
|
||||||
layerState._counts = createCountMarkers(
|
layerState._counts = createCountMarkers(
|
||||||
drawOf(viewer).icons({
|
services.overlays?.registerWorldOverlayPaintLane,
|
||||||
id: `cctv:${iconSets}:counts`,
|
`cctv:${iconSets}:counts`,
|
||||||
horizonCull: true,
|
refreshHorizonCulling,
|
||||||
show: false,
|
|
||||||
drawOrder: services.sprites?.spriteDrawOrder?.('cctv') ?? 0,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
return set.id;
|
return set.id;
|
||||||
}
|
}
|
||||||
@@ -156,7 +154,7 @@ export function createRendering({
|
|||||||
function destroyCameraIcons() {
|
function destroyCameraIcons() {
|
||||||
layerState._icons?.dispose();
|
layerState._icons?.dispose();
|
||||||
layerState._icons = null;
|
layerState._icons = null;
|
||||||
layerState._counts?.book.dispose();
|
layerState._counts?.dispose();
|
||||||
layerState._counts = null;
|
layerState._counts = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,38 +286,52 @@ export function createRendering({
|
|||||||
let writes = 0;
|
let writes = 0;
|
||||||
let transitioning = false;
|
let transitioning = false;
|
||||||
let activeCount = 0;
|
let activeCount = 0;
|
||||||
/** Advance one icon or count billboard on the shared focus clock. */
|
/** A changed focus factor for a camera icon or a painted count. */
|
||||||
function apply(book, id, position) {
|
function changedFocus(owner, position, shown, width, height, current) {
|
||||||
const item = book?.item(id);
|
const focus = advanceSpriteFocus(owner, {
|
||||||
if (!item) return;
|
screenPosition: shown && position ? screenPositionFor(position) : null,
|
||||||
const scale = item.scale ?? 1;
|
|
||||||
// CCTV never publishes a tracked focus target, so every icon is ambient.
|
|
||||||
const focus = advanceSpriteFocus(item.meta, {
|
|
||||||
// Keep hidden icons in the state/release pass so the active count cannot
|
|
||||||
// drop while a stale dim alpha remains waiting to reappear.
|
|
||||||
screenPosition:
|
|
||||||
item.show === false || !position ? null : screenPositionFor(position),
|
|
||||||
cameraDistance: position ? cameraDistanceFor(position) : Number.NaN,
|
cameraDistance: position ? cameraDistanceFor(position) : Number.NaN,
|
||||||
nowMs,
|
nowMs,
|
||||||
target,
|
target,
|
||||||
params,
|
params,
|
||||||
spriteHalfWidthPx: item.size[0] * scale * 0.5,
|
spriteHalfWidthPx: width / 2,
|
||||||
spriteHalfHeightPx: item.size[1] * scale * 0.5,
|
spriteHalfHeightPx: height / 2,
|
||||||
});
|
});
|
||||||
transitioning ||= focus.transitioning;
|
transitioning ||= focus.transitioning;
|
||||||
if (focus.active) activeCount += 1;
|
if (focus.active) activeCount++;
|
||||||
// Order-independent narrow amendment to always-visible icons: CCTV
|
if (!focusAlphaNeedsWrite(current, focus.factor, params)) return null;
|
||||||
// contacts retain a non-zero floor while yielding near the tracked target.
|
writes++;
|
||||||
if (focusAlphaNeedsWrite(book.focus(id), focus.factor, params)) {
|
return focus.factor;
|
||||||
book.setFocus(id, focus.factor);
|
|
||||||
writes += 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (const record of records || [])
|
for (const record of records || []) {
|
||||||
apply(icons, record.camera?.id, record.position);
|
const id = record.camera?.id;
|
||||||
const counts = layerState._counts?.book;
|
const item = icons?.item(id);
|
||||||
for (const id of counts?.ids() ?? [])
|
if (!item) continue;
|
||||||
apply(counts, id, counts.item(id).pos);
|
const scale = item.scale ?? 1;
|
||||||
|
const factor = changedFocus(
|
||||||
|
item.meta,
|
||||||
|
record.position,
|
||||||
|
item.show !== false,
|
||||||
|
item.size[0] * scale,
|
||||||
|
item.size[1] * scale,
|
||||||
|
icons.focus(id),
|
||||||
|
);
|
||||||
|
if (factor !== null) icons.setFocus(id, factor);
|
||||||
|
}
|
||||||
|
const counts = layerState._counts;
|
||||||
|
const iconWrites = writes;
|
||||||
|
for (const marker of counts?.markers ?? []) {
|
||||||
|
const factor = changedFocus(
|
||||||
|
marker,
|
||||||
|
marker.pos,
|
||||||
|
true,
|
||||||
|
marker.width,
|
||||||
|
COUNT_MARKER_PX,
|
||||||
|
marker.focus,
|
||||||
|
);
|
||||||
|
if (factor !== null) marker.focus = factor;
|
||||||
|
}
|
||||||
|
if (writes > iconWrites) counts.requestPaint();
|
||||||
return { writes, transitioning, activeCount, ran: true };
|
return { writes, transitioning, activeCount, ran: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +579,7 @@ export function createRendering({
|
|||||||
);
|
);
|
||||||
parts.projection.clearProjectionOverlay();
|
parts.projection.clearProjectionOverlay();
|
||||||
if (layerState._icons) layerState._icons.show = false;
|
if (layerState._icons) layerState._icons.show = false;
|
||||||
if (layerState._counts) layerState._counts.book.show = false;
|
layerState._counts?.hide();
|
||||||
parts.projection.pauseInactiveProjectionFeeds(null);
|
parts.projection.pauseInactiveProjectionFeeds(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,6 +923,7 @@ export function createRendering({
|
|||||||
* @returns {string|null}
|
* @returns {string|null}
|
||||||
*/
|
*/
|
||||||
function pickCameraIdAt(position) {
|
function pickCameraIdAt(position) {
|
||||||
|
if (layerState._counts?.pickedCell(position)) return null;
|
||||||
let hit = null;
|
let hit = null;
|
||||||
try {
|
try {
|
||||||
hit = findQuery(layerState._viewer)?.pick(position.x, position.y) ?? null;
|
hit = findQuery(layerState._viewer)?.pick(position.x, position.y) ?? null;
|
||||||
|
|||||||
@@ -120,28 +120,46 @@ test('the icons go with the viewer that drew them, whichever tears down', () =>
|
|||||||
const one = bindFakeDraw(first);
|
const one = bindFakeDraw(first);
|
||||||
const two = bindFakeDraw(second);
|
const two = bindFakeDraw(second);
|
||||||
const state = { _viewer: first };
|
const state = { _viewer: first };
|
||||||
|
const lanes = [];
|
||||||
|
const overlays = {
|
||||||
|
registerWorldOverlayPaintLane(name, paint, options) {
|
||||||
|
const lane = {
|
||||||
|
name,
|
||||||
|
paint,
|
||||||
|
options,
|
||||||
|
unregister() {
|
||||||
|
this.disposed = true;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
lanes.push(lane);
|
||||||
|
return lane;
|
||||||
|
},
|
||||||
|
};
|
||||||
const { createCameraIcons, destroyCameraIcons } = createRendering({
|
const { createCameraIcons, destroyCameraIcons } = createRendering({
|
||||||
state,
|
state,
|
||||||
services: { focus: {} },
|
services: { focus: {}, overlays },
|
||||||
parts: {},
|
parts: {},
|
||||||
source: {},
|
source: {},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const old = createCameraIcons(first);
|
const old = createCameraIcons(first);
|
||||||
const oldCounts = state._counts.book.setId;
|
assert.equal(one.draw.sets.size, 1);
|
||||||
|
assert.equal(lanes[0].name, 'ambient-label');
|
||||||
|
assert.equal(lanes[0].options.target, 'shared');
|
||||||
|
assert.equal(lanes[0].options.active, false);
|
||||||
state._viewer = second;
|
state._viewer = second;
|
||||||
const current = createCameraIcons(second);
|
const current = createCameraIcons(second);
|
||||||
assert.notEqual(old, current);
|
assert.notEqual(old, current);
|
||||||
assert.equal(one.draw.sets.get(old).disposed, true, 'a re-init lets go');
|
assert.equal(one.draw.sets.get(old).disposed, true, 'a re-init lets go');
|
||||||
assert.equal(two.draw.sets.get(current).disposed, false);
|
assert.equal(two.draw.sets.get(current).disposed, false);
|
||||||
assert.equal(one.draw.sets.get(oldCounts).disposed, true);
|
assert.equal(lanes[0].disposed, true);
|
||||||
const counts = two.draw.set(state._counts.book.setId);
|
lanes[0].paint({});
|
||||||
assert.equal(counts.spec.horizonCull, true);
|
|
||||||
|
|
||||||
destroyCameraIcons();
|
destroyCameraIcons();
|
||||||
assert.equal(two.draw.sets.get(current).disposed, true);
|
assert.equal(two.draw.sets.get(current).disposed, true);
|
||||||
assert.equal(state._icons, null);
|
assert.equal(state._icons, null);
|
||||||
assert.equal(counts.disposed, true);
|
assert.equal(lanes[1].disposed, true);
|
||||||
|
lanes[1].paint({});
|
||||||
assert.equal(state._counts, null);
|
assert.equal(state._counts, null);
|
||||||
} finally {
|
} finally {
|
||||||
one.unbind();
|
one.unbind();
|
||||||
@@ -382,3 +400,35 @@ test('a pose with no perspective field of view is projected by the renderer', ()
|
|||||||
unbind();
|
unbind();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('hover picks the underlying camera only outside a painted count', () => {
|
||||||
|
const viewer = {};
|
||||||
|
const icon = { set: 'icons', id: 'camera' };
|
||||||
|
let picks = 0;
|
||||||
|
const unbind = bindRenderer(viewer, {
|
||||||
|
query: {
|
||||||
|
pick() {
|
||||||
|
picks++;
|
||||||
|
return icon;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const state = {
|
||||||
|
_viewer: viewer,
|
||||||
|
_counts: { pickedCell: ({ x }) => (x <= 17 ? {} : null) },
|
||||||
|
_icons: { setId: icon.set, has: () => true },
|
||||||
|
_recordById: new Map([[icon.id, {}]]),
|
||||||
|
};
|
||||||
|
const rendering = createRendering({
|
||||||
|
state,
|
||||||
|
services: { focus: {} },
|
||||||
|
parts: {},
|
||||||
|
});
|
||||||
|
assert.equal(rendering.pickCameraIdAt({ x: 17, y: 0 }), null);
|
||||||
|
assert.equal(picks, 0);
|
||||||
|
assert.equal(rendering.pickCameraIdAt({ x: 18, y: 0 }), icon.id);
|
||||||
|
} finally {
|
||||||
|
unbind();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -42,7 +42,8 @@ export function createSelection({
|
|||||||
return input.onClick((event) => {
|
return input.onClick((event) => {
|
||||||
if (!isTrackingClickGesture(event.gesture)) return;
|
if (!isTrackingClickGesture(event.gesture)) return;
|
||||||
const cell =
|
const cell =
|
||||||
layerState._enabled && layerState._counts?.pickedCell(event.drawHit);
|
layerState._enabled &&
|
||||||
|
layerState._counts?.pickedCell(event.screenPosition);
|
||||||
if (cell) {
|
if (cell) {
|
||||||
parts.navigation.zoomToCell(cell);
|
parts.navigation.zoomToCell(cell);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -72,7 +72,9 @@ test('a count click preserves the provisional opening pick until the view settle
|
|||||||
_viewer: viewer,
|
_viewer: viewer,
|
||||||
_openingCameraProvisional: true,
|
_openingCameraProvisional: true,
|
||||||
_activeCameraId: 'opening',
|
_activeCameraId: 'opening',
|
||||||
_counts: { pickedCell: () => cell },
|
_counts: {
|
||||||
|
pickedCell: (point) => (point?.x === 14 && point.y === 26 ? cell : null),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const parts = {};
|
const parts = {};
|
||||||
parts.navigation = createNavigation({ state, parts });
|
parts.navigation = createNavigation({ state, parts });
|
||||||
@@ -87,7 +89,13 @@ test('a count click preserves the provisional opening pick until the view settle
|
|||||||
assert.fail('a count click reached activation or deselection');
|
assert.fail('a count click reached activation or deselection');
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
click({ drawHit: {}, gesture: { travelPx: 0, durationMs: 20 } });
|
click({
|
||||||
|
screenPosition: { x: 14, y: 26 },
|
||||||
|
get drawHit() {
|
||||||
|
assert.fail('the camera underneath was picked');
|
||||||
|
},
|
||||||
|
gesture: { travelPx: 0, durationMs: 20 },
|
||||||
|
});
|
||||||
assert.equal(flights.length, 1);
|
assert.equal(flights.length, 1);
|
||||||
assert.equal(state._activeCameraId, 'opening');
|
assert.equal(state._activeCameraId, 'opening');
|
||||||
assert.equal(state._openingCameraProvisional, true);
|
assert.equal(state._openingCameraProvisional, true);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
|||||||
* @param {'off'|'on'|'viewshed'} [options.coverageMode='on'] Coverage mode.
|
* @param {'off'|'on'|'viewshed'} [options.coverageMode='on'] Coverage mode.
|
||||||
* @param {boolean} [options.showProjection=false] Projection visibility.
|
* @param {boolean} [options.showProjection=false] Projection visibility.
|
||||||
* @param {Map<string, Object>} [options.healthById] Health rows by camera id.
|
* @param {Map<string, Object>} [options.healthById] Health rows by camera id.
|
||||||
|
* @param {Function} [options.registerPaintLane] Receives the count painter.
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -103,6 +104,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
|||||||
showProjection = false,
|
showProjection = false,
|
||||||
healthById = new Map(),
|
healthById = new Map(),
|
||||||
openingCameraProvisional = false,
|
openingCameraProvisional = false,
|
||||||
|
registerPaintLane,
|
||||||
} = {}) {
|
} = {}) {
|
||||||
layerState._viewer = viewer;
|
layerState._viewer = viewer;
|
||||||
layerState._records = Array.isArray(records) ? records : [];
|
layerState._records = Array.isArray(records) ? records : [];
|
||||||
@@ -132,10 +134,12 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
|||||||
// A real book (over a set that draws nothing): every record gets its
|
// A real book (over a set that draws nothing): every record gets its
|
||||||
// icon as init adds it.
|
// icon as init adds it.
|
||||||
layerState._icons = createIconBook(testIconSet());
|
layerState._icons = createIconBook(testIconSet());
|
||||||
layerState._counts = createCountMarkers({
|
layerState._counts?.dispose();
|
||||||
...testIconSet(),
|
layerState._counts = createCountMarkers(
|
||||||
id: 'cctv:test:counts',
|
registerPaintLane,
|
||||||
});
|
'cctv:test:counts',
|
||||||
|
parts.rendering.refreshHorizonCulling,
|
||||||
|
);
|
||||||
for (const record of layerState._records)
|
for (const record of layerState._records)
|
||||||
if (record?.camera?.id) parts.rendering.addCameraIcon(record);
|
if (record?.camera?.id) parts.rendering.addCameraIcon(record);
|
||||||
}
|
}
|
||||||
@@ -155,7 +159,7 @@ export function createTesting({ state: layerState, services, parts, source }) {
|
|||||||
for (const runtime of layerState._projectionEntities)
|
for (const runtime of layerState._projectionEntities)
|
||||||
if (runtime?.plane) planes[runtime.plane.id] = runtime.plane;
|
if (runtime?.plane) planes[runtime.plane.id] = runtime.plane;
|
||||||
return {
|
return {
|
||||||
counts: layerState._counts?.book,
|
counts: layerState._counts,
|
||||||
gizmo: layerState._gizmo?.partsForTest() ?? {},
|
gizmo: layerState._gizmo?.partsForTest() ?? {},
|
||||||
coverage,
|
coverage,
|
||||||
planes,
|
planes,
|
||||||
|
|||||||
@@ -243,6 +243,9 @@ const _customPaintFrame = {
|
|||||||
cameraHeight: Number.NaN,
|
cameraHeight: Number.NaN,
|
||||||
occluder: null,
|
occluder: null,
|
||||||
keyhole: null,
|
keyhole: null,
|
||||||
|
// Anchored custom glyphs yield to the same below-host chrome as entries.
|
||||||
|
overlapsHardUi: (rect) =>
|
||||||
|
overlayRectIntersectsAnyHard(rect, _uiOcclusionRects),
|
||||||
uiRects: _uiOcclusionRects,
|
uiRects: _uiOcclusionRects,
|
||||||
uiRectCount: 0,
|
uiRectCount: 0,
|
||||||
layoutRevision: 0,
|
layoutRevision: 0,
|
||||||
|
|||||||
@@ -1514,9 +1514,14 @@ test('a placement is only ever kept under chrome that composites ABOVE the host'
|
|||||||
const paintedUnder = (occluders) => {
|
const paintedUnder = (occluders) => {
|
||||||
const env = installMockEnvironment({ width: 400, height: 300, dpr: 1, occluders });
|
const env = installMockEnvironment({ width: 400, height: 300, dpr: 1, occluders });
|
||||||
initWorldOverlay(env.viewer);
|
initWorldOverlay(env.viewer);
|
||||||
|
let hardUi;
|
||||||
|
registerWorldOverlayPaintLane('ambient-label', (frame) => {
|
||||||
|
hardUi = frame.overlapsHardUi({ x: 180, y: 130, w: 40, h: 40 });
|
||||||
|
}, { id: 'anchored-label', active: true });
|
||||||
setOverlayEntries('ambient', [selectedEntry('CONTACT')]);
|
setOverlayEntries('ambient', [selectedEntry('CONTACT')]);
|
||||||
env.postRender.raise();
|
env.postRender.raise();
|
||||||
const { paintedCount } = getWorldOverlayDiagnostics();
|
const { paintedCount } = getWorldOverlayDiagnostics();
|
||||||
|
assert.equal(hardUi, paintedCount === 0);
|
||||||
env.cleanup();
|
env.cleanup();
|
||||||
return paintedCount;
|
return paintedCount;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -485,13 +485,6 @@ export function createCesiumScreenModulation(scene, { frame, onChange }) {
|
|||||||
? 'icon'
|
? 'icon'
|
||||||
: null;
|
: null;
|
||||||
if (!kind || !native.shaderProgram || !native.uniformMap) continue;
|
if (!kind || !native.shaderProgram || !native.uniformMap) continue;
|
||||||
// Aggregate billboards occupy their own collection and represent groups.
|
|
||||||
if (
|
|
||||||
kind === 'billboard' &&
|
|
||||||
native.owner.length &&
|
|
||||||
native.owner.get(0).id?.meta?.aggregate === true
|
|
||||||
)
|
|
||||||
continue;
|
|
||||||
const source = native.shaderProgram;
|
const source = native.shaderProgram;
|
||||||
// Label backgrounds are non-SDF billboard batches. The version-tested
|
// Label backgrounds are non-SDF billboard batches. The version-tested
|
||||||
// engine pick association distinguishes them without enumerating
|
// engine pick association distinguishes them without enumerating
|
||||||
|
|||||||
@@ -606,19 +606,3 @@ test('disposal does not overwrite a successor update owner', () => {
|
|||||||
assert.equal(f.primitives.update, successor);
|
assert.equal(f.primitives.update, successor);
|
||||||
f.primitives.destroy();
|
f.primitives.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('aggregate markers keep their native billboard command during a contact sweep', () => {
|
|
||||||
const owner = new Cesium.BillboardCollection();
|
|
||||||
owner.add({ id: { meta: { aggregate: true } } });
|
|
||||||
const command = { owner, uniformMap: {}, shaderProgram: {} };
|
|
||||||
const f = fixture({ commands: [command] });
|
|
||||||
try {
|
|
||||||
f.part.set(sweep());
|
|
||||||
assert.equal(f.draw()[0], command);
|
|
||||||
assert.equal(f.part.stats.supported, true);
|
|
||||||
} finally {
|
|
||||||
f.part.dispose();
|
|
||||||
owner.destroy();
|
|
||||||
f.primitives.destroy();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Reference in new issue
Block a user