mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the ALPR layer's markers through the renderer's ports
The ALPR badges were Cesium entities whose billboards the layer changed in place: the canvas overlay swapped a badge to a faint pick target at its anchor, selection swapped the image, and unresolved floors clamped to the ground. They are now one icon set from the draw port, updated in place through upsert, so selection and the overlay swap change the same billboard without a rebuild or a blink. Badges keep their scale by distance, ground clamping and depth-test settings. Marker state lives in the app (markerState.js): a plain carrier per camera, registered as the camera's context entity, and a marker set that batches changes and sends only the icons that draw differently. Clicks on native badges come from the dispatcher's draw hit. Projection, the on-screen count, height samples (excluding the layer's own set), the screen-centre ellipsoid pick and the camera reach the renderer through the query, camera and frame ports. A resync of the overlay now hands back only the cameras that leave it, so kept ones are not written twice. index.js, overlay.js and presentation.js leave the Cesium allow-list; the layer's entry is Cesium-free, and a caller's own viewer loads the unbound factories. Differences the contract does not let us avoid: - Double-clicking a badge no longer starts the viewer's entity follow, since draw items are not entities. - The terrain fallback for anchors is no longer skipped while the globe is hidden: the globe port has no visibility getter. - Without depth support the query port answers no heights, terrain included, so anchors wait for a cached floor there. - On a viewer with no renderer bound, the surface counts as settled when anchors are refined.
This commit is contained in:
1 parent
faded8a418
commit
2592289612
11 files changed
+722
-537
No files matched your search
@@ -1193,6 +1193,88 @@ test('the installations layer draws its named markers as outlined point primitiv
|
||||
assert.equal(scene.added.includes(host), false);
|
||||
});
|
||||
|
||||
test('the ALPR layer draws its badges as icons that follow the ground, restyled in place', async () => {
|
||||
const { alprMarkers, createAlprMarkerSet } =
|
||||
await import('../../layers/alpr/markerState.js');
|
||||
const { MARKER_IMAGE, SELECTED_IMAGE } =
|
||||
await import('../../layers/alpr/visuals.js');
|
||||
const scene = fakeScene();
|
||||
const part = createCesiumDraw({
|
||||
scene,
|
||||
report: (error) => assert.fail(error),
|
||||
});
|
||||
const markers = createAlprMarkerSet();
|
||||
markers.attach(part.port.icons({ id: 'alpr-cameras:1:markers' }));
|
||||
const place = (id, lon, clamped) => {
|
||||
const carrier = markers.add(id);
|
||||
Object.assign(alprMarkers.write(carrier), {
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, 30, clamped ? 0 : 150),
|
||||
clamped,
|
||||
});
|
||||
return carrier;
|
||||
};
|
||||
const a = place('alpr:a', -97, true);
|
||||
place('alpr:b', -97.01, false);
|
||||
markers.flush();
|
||||
const [host] = scene.added;
|
||||
assert.ok(host instanceof Cesium.BillboardCollection);
|
||||
assert.equal(host.length, 2);
|
||||
const badge = host.get(0);
|
||||
assert.equal(badge.id.id, 'alpr:a');
|
||||
assert.equal(badge.id.set, 'alpr-cameras:1:markers');
|
||||
assert.equal(badge.heightReference, Cesium.HeightReference.CLAMP_TO_GROUND);
|
||||
assert.equal(
|
||||
host.get(1).heightReference,
|
||||
Cesium.HeightReference.NONE,
|
||||
'a marker on its floor sits at its height',
|
||||
);
|
||||
assert.equal(badge.image, MARKER_IMAGE);
|
||||
assert.equal(badge.width, 38);
|
||||
assert.equal(badge.disableDepthTestDistance, Infinity);
|
||||
assert.ok(
|
||||
Cesium.NearFarScalar.equals(
|
||||
badge.scaleByDistance,
|
||||
new Cesium.NearFarScalar(500, 1.15, 40000, 0.45),
|
||||
),
|
||||
);
|
||||
|
||||
// Selection swaps the image on the same billboard: no blink.
|
||||
alprMarkers.write(a).selected = true;
|
||||
markers.changed(a);
|
||||
markers.flush();
|
||||
assert.equal(scene.added[0], host);
|
||||
assert.equal(host.get(0), badge);
|
||||
assert.equal(badge.image, SELECTED_IMAGE);
|
||||
assert.equal(badge.width, 60);
|
||||
|
||||
// Under a canvas badge: a faint pick target at the canvas anchor.
|
||||
const anchor = Cesium.Cartesian3.fromDegrees(-97, 30, 172);
|
||||
Object.assign(alprMarkers.write(a), {
|
||||
canvasOwned: true,
|
||||
canvasPosition: anchor,
|
||||
});
|
||||
markers.changed(a);
|
||||
markers.flush();
|
||||
assert.equal(host.get(0), badge, 'still the same billboard');
|
||||
assert.equal(badge.color.alpha, 0.01);
|
||||
assert.equal(badge.heightReference, Cesium.HeightReference.NONE);
|
||||
assert.equal(badge.scaleByDistance, undefined);
|
||||
assert.ok(Cesium.Cartesian3.equalsEpsilon(badge.position, anchor, 0, 1e-6));
|
||||
|
||||
// A marker that arrives later joins the same collection.
|
||||
place('alpr:c', -97.02, false);
|
||||
markers.flush();
|
||||
assert.equal(scene.added[0], host, 'appended, not rebuilt');
|
||||
assert.equal(host.get(0), badge);
|
||||
assert.equal(host.length, 3);
|
||||
|
||||
markers.remove(['alpr:b']);
|
||||
assert.equal(scene.added[0], host);
|
||||
assert.equal(host.length, 2);
|
||||
markers.dispose();
|
||||
assert.equal(scene.added.length, 0);
|
||||
});
|
||||
|
||||
/** Run `fn` with the image classes Cesium's materials test uniforms against. */
|
||||
function withImageClasses(fn) {
|
||||
const names = [
|
||||
|
||||
@@ -40,9 +40,6 @@
|
||||
"src/input/dispatcher.js",
|
||||
"src/input/sensorPick.js",
|
||||
"src/layers/airQuality/index.js",
|
||||
"src/layers/alpr/index.js",
|
||||
"src/layers/alpr/overlay.js",
|
||||
"src/layers/alpr/presentation.js",
|
||||
"src/layers/cctv/cards.js",
|
||||
"src/layers/cctv/geometry.js",
|
||||
"src/layers/cctv/geometryQueue.js",
|
||||
|
||||
@@ -77,6 +77,7 @@ const DRAW_FROM_CALLER = new Set([
|
||||
'./layers/perimeters',
|
||||
'./layers/awareness',
|
||||
'./layers/submarine-cables',
|
||||
'./layers/alpr',
|
||||
]);
|
||||
|
||||
const pkg = JSON.parse(readFileSync(path.join(root, 'package.json'), 'utf8'));
|
||||
|
||||
Reference in new issue
Block a user