mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the installations layer through the renderer ports
The site dots, outlines and selected footprint fill are now draw-port sets (points, draped lines, clamped shapes) instead of Cesium entities. The selected site's dot is drawn by a set of its own, so selecting a site redraws no other dot. Selection is registered through plain carrier objects in the context store, as the local GeoJSON layer does, and the tracked card reads the site's label and position from the carrier's entity record. A double-click on a site dot now follows it through camera.follow (gated on the stock double-click follow), centred on the surface under the dot when its height is loaded; one on an outline or fill zooms to it. Hiding the layer stops a follow it started. The layer no longer lowers the shared camera change sensitivity: its own camera-port listener carries its threshold. The follow offset fitting moves to src/geo/frames.js and is shared with the local GeoJSON layer. rendering.js leaves the Cesium allow-list (33 -> 32); the layer's entry joins DRAW_FROM_CALLER.
This commit is contained in:
1 parent
a59f9b10b2
commit
1bff078097
21 files changed
+864
-337
No files matched your search
@@ -1795,6 +1795,100 @@ test('the installations layer draws its named markers as outlined point primitiv
|
||||
assert.equal(scene.added.includes(host), false);
|
||||
});
|
||||
|
||||
test('the installations layer draws its site dots, outlines and selected dot on a viewer of its own', async () => {
|
||||
const { createRendering } =
|
||||
await import('../../layers/installations/rendering.js');
|
||||
const scene = fakeScene();
|
||||
const viewer = { scene };
|
||||
const record = (id, lon) => ({
|
||||
id,
|
||||
name: `Site ${id}`,
|
||||
class: 'base',
|
||||
latitude: 30,
|
||||
longitude: lon,
|
||||
namedArea: false,
|
||||
outlineLines: [
|
||||
[
|
||||
[lon, 30],
|
||||
[lon + 0.01, 30],
|
||||
],
|
||||
],
|
||||
});
|
||||
const records = [record('a', -97), record('b', -98)];
|
||||
const state = {
|
||||
viewer,
|
||||
enabled: true,
|
||||
selectedId: null,
|
||||
records,
|
||||
recordById: new Map(records.map((r) => [r.id, r])),
|
||||
renderedKeys: new Map(),
|
||||
};
|
||||
const noop = () => {};
|
||||
const rendering = createRendering({
|
||||
state,
|
||||
services: {
|
||||
ground: { floorAltitudeM: () => 0, cachedGroundFloor: () => 0 },
|
||||
anchors: {},
|
||||
render: { governorRequestRender: noop },
|
||||
context: {
|
||||
registerEntityContext: noop,
|
||||
removeEntityContextsForLayer: noop,
|
||||
selectEntityContext: noop,
|
||||
getSelectedEntityContext: () =>
|
||||
state.selectedId ? { id: state.selectedId } : null,
|
||||
clearSelectedEntityContextForLayer: noop,
|
||||
},
|
||||
},
|
||||
parts: {
|
||||
model: {
|
||||
colorFor: (r, alpha = 1) => [1, 165 / 255, 0, alpha],
|
||||
installationSourceLabel: () => 'OpenStreetMap',
|
||||
},
|
||||
},
|
||||
});
|
||||
rendering.attach(viewer);
|
||||
rendering.renderRecords();
|
||||
const billboards = (setId) => {
|
||||
const out = [];
|
||||
const visit = (node) => {
|
||||
for (let i = 0; i < (node?.length ?? 0); i += 1) {
|
||||
const child = node.get(i);
|
||||
if (child?.id?.set === setId) out.push(child);
|
||||
else if (typeof child?.get === 'function') visit(child);
|
||||
}
|
||||
};
|
||||
for (const host of scene.added)
|
||||
if (host.id?.set === setId) out.push(host);
|
||||
else visit(host);
|
||||
return out;
|
||||
};
|
||||
const dotsId = state.sets.dots.id;
|
||||
const dots = billboards(dotsId);
|
||||
assert.equal(dots.length, 2);
|
||||
assert.ok(dots.every((dot) => dot instanceof Cesium.Billboard));
|
||||
assert.ok(
|
||||
dots.every(
|
||||
(dot) => dot.heightReference === Cesium.HeightReference.CLAMP_TO_GROUND,
|
||||
),
|
||||
);
|
||||
assert.ok(dots.every((dot) => dot.id.meta?.installationId));
|
||||
// Selecting a site hides its dot where it is and draws the selected one
|
||||
// in its own set: no other dot is drawn again.
|
||||
state.selectedId = 'b';
|
||||
rendering.renderRecords();
|
||||
const after = billboards(dotsId);
|
||||
assert.equal(after.length, 2);
|
||||
assert.ok(after.every((dot, i) => dot === dots[i]), 'the same billboards');
|
||||
assert.equal(after.find((dot) => dot.id.id === 'b').show, false);
|
||||
assert.equal(after.find((dot) => dot.id.id === 'a').show, true);
|
||||
const [selected] = billboards(state.sets.selected.id);
|
||||
assert.ok(selected instanceof Cesium.Billboard);
|
||||
assert.equal(selected.id.id, 'b');
|
||||
assert.equal(selected.id.meta, dots.find((dot) => dot.id.id === 'b').id.meta);
|
||||
rendering.detach();
|
||||
assert.equal(scene.added.length, 0, 'gone with the layer');
|
||||
});
|
||||
|
||||
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');
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
"src/input/dispatcher.js",
|
||||
"src/input/sensorPick.js",
|
||||
"src/layers/ghostMaps/index.js",
|
||||
"src/layers/installations/rendering.js",
|
||||
"src/layers/launches/launchPad.js",
|
||||
"src/layers/launches/orbitRendering.js",
|
||||
"src/layers/launches/rendering.js",
|
||||
|
||||
@@ -95,6 +95,9 @@ const DRAW_FROM_CALLER = new Set([
|
||||
// Its station dots, clusters and selected marker draw through `drawOf`;
|
||||
// it clusters them on screen through the camera and query ports.
|
||||
'./layers/radio',
|
||||
// Its site dots, outlines and selected fill draw through `drawOf`; it
|
||||
// follows a site and reads the globe through the camera and globe ports.
|
||||
'./layers/installations',
|
||||
// Its data packs draw through `drawOf`; its flights ask `cameraOf`, which
|
||||
// throws until then too.
|
||||
'./scenes',
|
||||
|
||||
Reference in new issue
Block a user