mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the installations layer's named markers through the renderer's ports
The named-site dots are a draw-port point set with horizon culling instead of a raw point collection; their on-screen count tests the ellipsoid horizon and projects through the query port, and they follow the camera port's changed and moveEnd events and the frame port's preRender. Points that only change look (a selection) are restyled in place. Clicks on a dot read the draw hit; the item id is not the bare record id, so sibling layers' pick-owner checks still treat a dot click as nobody's. Code that only asks whether a click hit anything (the CCTV layer) now sees a dot click as a hit, as it already did for the site markers: a draw item's pick always resolves to its id. The named markers leave the Cesium allow-list. The site markers in rendering.js stay entities.
This commit is contained in:
1 parent
e327760074
commit
faded8a418
10 files changed
+377
-115
No files matched your search
@@ -1098,6 +1098,101 @@ test('the context layer draws its rim as an outlined ellipse on a viewer of its
|
||||
assert.equal(other.added.length, 0);
|
||||
});
|
||||
|
||||
test('the installations layer draws its named markers as outlined point primitives on a viewer of its own', async () => {
|
||||
const { createNamedMarkers, namedPointId } =
|
||||
await import('../../layers/installations/namedMarkers.js');
|
||||
const scene = fakeScene();
|
||||
scene.canvas = { clientWidth: 800, clientHeight: 600 };
|
||||
const viewer = { scene };
|
||||
const state = { viewer, enabled: false, selectedId: null };
|
||||
const markers = createNamedMarkers({
|
||||
state,
|
||||
services: { render: { governorRequestRender() {} } },
|
||||
parts: {
|
||||
model: { colorFor: () => [1, 165 / 255, 0, 1] },
|
||||
rendering: { installationSurfaceHeightM: () => 40 },
|
||||
},
|
||||
overlayHost: { setEntries() {}, clearSource() {}, setVisible() {} },
|
||||
});
|
||||
const records = [
|
||||
{
|
||||
id: 'a',
|
||||
name: 'A',
|
||||
namedArea: true,
|
||||
areaM2: 2,
|
||||
latitude: 30,
|
||||
longitude: -97,
|
||||
pointOnly: false,
|
||||
},
|
||||
{
|
||||
id: 'b',
|
||||
name: 'B',
|
||||
namedArea: true,
|
||||
areaM2: 1,
|
||||
latitude: 31,
|
||||
longitude: -98,
|
||||
pointOnly: true,
|
||||
},
|
||||
];
|
||||
markers.sync(records);
|
||||
const host = scene.added.find((h) => h.get?.(0)?.id?.set === markers.setId);
|
||||
assert.ok(host instanceof Cesium.PointPrimitiveCollection);
|
||||
assert.equal(host.show, false, 'hidden while the layer is off');
|
||||
assert.equal(host.length, 2);
|
||||
const a = host.get(0);
|
||||
assert.equal(a.id.id, namedPointId('a'));
|
||||
assert.deepEqual(a.id.meta, { installationId: 'a' });
|
||||
assert.equal(a.pixelSize, 7);
|
||||
assert.equal(a.outlineWidth, 1);
|
||||
assert.ok(Cesium.Color.equals(a.outlineColor, Cesium.Color.BLACK));
|
||||
assert.ok(Cesium.Color.equals(a.color, new Cesium.Color(1, 165 / 255, 0, 1)));
|
||||
assert.equal(a.disableDepthTestDistance, Infinity);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(
|
||||
a.position,
|
||||
Cesium.Cartesian3.fromDegrees(-97, 30, 40),
|
||||
0,
|
||||
1e-6,
|
||||
),
|
||||
);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(
|
||||
host.get(1).position,
|
||||
Cesium.Cartesian3.fromDegrees(-98, 31, 0),
|
||||
0,
|
||||
1e-6,
|
||||
),
|
||||
'a point-only site sits on the ellipsoid',
|
||||
);
|
||||
// Selecting a drawn site restyles nothing that moves: the points stay.
|
||||
state.selectedId = 'b';
|
||||
markers.sync(records);
|
||||
assert.equal(scene.added.includes(host), true);
|
||||
assert.equal(host.get(0), a);
|
||||
// A selected site that is not a named area draws no point.
|
||||
state.selectedId = 'c';
|
||||
markers.sync([
|
||||
...records,
|
||||
{
|
||||
id: 'c',
|
||||
name: 'C',
|
||||
areaM2: 3,
|
||||
latitude: 32,
|
||||
longitude: -99,
|
||||
pointOnly: true,
|
||||
},
|
||||
]);
|
||||
const rebuilt = scene.added.find(
|
||||
(h) => h.get?.(0)?.id?.set === markers.setId,
|
||||
);
|
||||
const c = [0, 1, 2]
|
||||
.map((i) => rebuilt.get(i))
|
||||
.find((p) => p.id.id === namedPointId('c'));
|
||||
assert.equal(c.show, false);
|
||||
markers.destroy();
|
||||
assert.equal(scene.added.includes(host), false);
|
||||
});
|
||||
|
||||
/** Run `fn` with the image classes Cesium's materials test uniforms against. */
|
||||
function withImageClasses(fn) {
|
||||
const names = [
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
"src/layers/flights/testing.js",
|
||||
"src/layers/flights/tracking.js",
|
||||
"src/layers/ghostMaps/index.js",
|
||||
"src/layers/installations/namedMarkers.js",
|
||||
"src/layers/installations/rendering.js",
|
||||
"src/layers/launches/launchPad.js",
|
||||
"src/layers/launches/orbitRendering.js",
|
||||
|
||||
Reference in new issue
Block a user