mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
World annotation renderer draws through the renderer's ports
Areas, buildings, routes, arrows, pins and labels are draw-port shapes, lines and points, one set per mark, faded by upserting their colours. Pins pulse their ring and size it by camera height; arrows drape. Ground heights come from the heights service. The module leaves the Cesium allow-list.
This commit is contained in:
1 parent
6b4b04d082
commit
d9e72dfc8b
10 files changed
+791
-630
No files matched your search
@@ -1186,6 +1186,101 @@ test('the earthquakes layer draws its discs as ground fills on a viewer of its o
|
||||
assert.equal(scene.added.length, 0);
|
||||
});
|
||||
|
||||
test('the world annotation renderer draws, fades, hides and lets go of every kind on a viewer of its own', async () => {
|
||||
const { createWorldAnnotationRenderer } =
|
||||
await import('../../annotations/worldAnnotationRenderer.js');
|
||||
await withImageClasses(() =>
|
||||
withTerrainHeights(() => {
|
||||
const scene = fakeScene();
|
||||
const viewer = { scene };
|
||||
const renderer = createWorldAnnotationRenderer(viewer);
|
||||
const box = (lon, d) => [
|
||||
[lon - d, -d],
|
||||
[lon + d, -d],
|
||||
[lon + d, d],
|
||||
[lon - d, d],
|
||||
];
|
||||
const marks = [
|
||||
{
|
||||
id: 'building',
|
||||
type: 'area',
|
||||
color: 'amber',
|
||||
footprintKind: 'building',
|
||||
buildingHeight: 40,
|
||||
anchor: { lon: 0, lat: 0, height: 200 },
|
||||
ring: box(0, 0.0004),
|
||||
},
|
||||
{
|
||||
id: 'area',
|
||||
type: 'area',
|
||||
color: 'green',
|
||||
footprintKind: 'area',
|
||||
anchor: { lon: 0.01, lat: 0 },
|
||||
ring: box(0.01, 0.002),
|
||||
polygons: [[box(0.01, 0.002), box(0.01, 0.0005)]],
|
||||
},
|
||||
{
|
||||
id: 'synth',
|
||||
type: 'area',
|
||||
color: 'cyan',
|
||||
synthesized: true,
|
||||
anchor: { lon: 0.02, lat: 0 },
|
||||
ring: box(0.02, 0.002),
|
||||
},
|
||||
{
|
||||
id: 'route',
|
||||
type: 'route',
|
||||
color: 'red',
|
||||
anchor: { lon: 0, lat: 0.01 },
|
||||
path: [
|
||||
{ lon: 0, lat: 0.01 },
|
||||
{ lon: 0.01, lat: 0.012 },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'arrow',
|
||||
type: 'arrow',
|
||||
color: 'primary',
|
||||
anchor: { lon: 0, lat: 0.02 },
|
||||
to: { lon: 0.01, lat: 0.02 },
|
||||
},
|
||||
{
|
||||
id: 'pin',
|
||||
type: 'pin',
|
||||
color: 'primary',
|
||||
anchor: { lon: 0.03, lat: 0 },
|
||||
},
|
||||
{
|
||||
id: 'label',
|
||||
type: 'label',
|
||||
color: 'amber',
|
||||
anchor: { lon: 0.04, lat: 0 },
|
||||
},
|
||||
];
|
||||
for (const mark of marks) {
|
||||
mark.alpha = 0.25;
|
||||
renderer.add(
|
||||
mark,
|
||||
mark.footprintKind === 'building' ? { sampledGroundHeight: 150 } : {},
|
||||
);
|
||||
}
|
||||
assert.ok(scene.added.length >= marks.length, 'every kind drew');
|
||||
for (const alpha of [0.5, 1]) {
|
||||
for (const mark of marks) mark.alpha = alpha;
|
||||
assert.doesNotThrow(() => renderer.sync());
|
||||
scene.preRender.raiseEvent();
|
||||
scene.postRender.raiseEvent();
|
||||
}
|
||||
for (const mark of marks) mark.hidden = true;
|
||||
renderer.sync();
|
||||
for (const mark of marks) mark.hidden = false;
|
||||
renderer.sync();
|
||||
renderer.destroy();
|
||||
assert.equal(scene.added.length, 0, 'nothing left drawn');
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
test('the air quality layer draws its stations as ground fills on a viewer of its own', async () => {
|
||||
const { createAirQualityLayer } =
|
||||
await import('../../layers/airQuality/index.js');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[
|
||||
"dev/conformance/main.js",
|
||||
"src/annotations/worldAnnotationRenderer.js",
|
||||
"src/app/embed.js",
|
||||
"src/app/scene.js",
|
||||
"src/app/viewer.js",
|
||||
|
||||
@@ -117,6 +117,9 @@ const DRAW_FROM_CALLER = new Set([
|
||||
'./infrastructure/geojson',
|
||||
// Its missions draw, pick and fly through the ports alone.
|
||||
'./layers/launches',
|
||||
// Its world marks draw through `drawOf` and probe heights through
|
||||
// `heightsOf`; its screen marks project through the camera and query ports.
|
||||
'./annotations',
|
||||
// Its pins, footprints and outlines draw through `drawOf`; its horizon
|
||||
// cull reads the camera and frame ports.
|
||||
'./layers/ghostmaps',
|
||||
|
||||
Reference in new issue
Block a user