Draw submarine cables through the renderer's draw and camera ports

Cable lines, landing pins, polygon fills, reference stems and reference
points are now five draw sets per layer (submarine-cables:N:lines and so
on) instead of GeoJSON data sources and entities. Clicks resolve through
the draw hit; flights and the sweep's eye go through the camera port.
The layer keeps the styling the GeoJSON loader gave it: cable colours,
widths and alphas, simplestyle stroke, fill and marker properties, fills
that keep the source's alpha, raised polygons at their heights, the
default pin image, and features without a reference drawn but neither
picked nor culled. Lines are densified along rhumb lines at the
renderer's own granularity, so the draped geodesic arcs land on the same
vertices the rhumb-line polylines did.

Supporting pieces:
- geo/rhumb, geo/horizon and geo/geodesic port the default renderer's
  rhumb line, ellipsoidal occluder and Vincenty inverse; the stub
  renderer now uses the shared horizon test and Vincenty inverse
  instead of its own copies. render/color gains cssColor, which reads
  CSS colours as the renderer does (hex, rgb, hsl; not named colours).
- The Cesium draw port changes a line in place when only whether it
  shows changes (draped, on its ground primitive, waiting for it to be
  ready rather than restarting its build) or where an undraped line
  runs; anything else still rebuilds. Icon sets honour their blend.

Ingestion, interaction, overlay, policy, rendering, state and surface no
longer import Cesium and leave the allow-list. Pins are culled at the
horizon each frame by the draw port instead of on the sweep, and
marker-symbol glyphs are not drawn inside pins.
This commit is contained in:
Sameh Khamis committed 2026-11-06 22:10:53 -08:00
1 parent f24b66d80d
commit e74c7c1f44
29 files changed
+2260 -2064

No files matched your search

+130
View File
@@ -1097,3 +1097,133 @@ test('the context layer draws its rim as an outlined ellipse on a viewer of its
rendering.disposeVisual();
assert.equal(other.added.length, 0);
});
/** Run `fn` with the image classes Cesium's materials test uniforms against. */
function withImageClasses(fn) {
const names = [
'HTMLCanvasElement',
'HTMLImageElement',
'ImageBitmap',
'OffscreenCanvas',
];
const real = names.map((name) => globalThis[name]);
for (const name of names) globalThis[name] ??= class {};
try {
return fn();
} finally {
names.forEach((name, i) => (globalThis[name] = real[i]));
}
}
test('lines that change only whether they show, or where an undraped one runs, change in place', () =>
withImageClasses(() => {
const { scene, draw, frame } = drawOver();
const set = draw.lines({ id: 'patched' });
const draped = (id, show = true, meta) => ({
id,
positions: [
{ lon: 0, lat: 0 },
{ lon: 1, lat: 1 },
],
widthPx: 2.5,
mode: 'draped',
style: { kind: 'solid', color: '#7fe6ed' },
show,
meta,
});
const stem = (id, height, show = true) => ({
id,
positions: [
Cesium.Cartesian3.fromDegrees(0, 0, 0),
Cesium.Cartesian3.fromDegrees(0, 0, height),
],
widthPx: 2,
mode: '3d',
style: { kind: 'solid', color: [1, 1, 1, 0.5] },
show,
meta: height,
});
const attributes = new Map();
const fakeAttributes = (ground) => {
ground.getGeometryInstanceAttributes = (id) => {
if (!attributes.has(id.id))
attributes.set(id.id, { show: new Uint8Array([1]) });
return attributes.get(id.id);
};
};
set.set([draped('a'), draped('b'), stem('s', 100)]);
const host = scene.added[0];
const ground = host.get(1);
fakeAttributes(ground);
// Still building: the show waits for the ground, and the build goes on.
set.upsert([draped('a', false)]);
assert.equal(scene.added[0], host, 'not rebuilt while its ground builds');
assert.equal(attributes.size, 0);
Object.defineProperty(ground, 'ready', { value: true });
frame();
assert.deepEqual([...attributes.get('a').show], [0], 'shown once ready');
set.upsert([draped('b', false)]);
assert.equal(scene.added[0], host, 'changed in place once ready');
assert.deepEqual([...attributes.get('b').show], [0]);
set.upsert([draped('b', true, 'new')]);
assert.deepEqual([...attributes.get('b').show], [1]);
const [, idB] = ground.geometryInstances.map((instance) => instance.id);
assert.equal(idB.meta, 'new', 'picks read the new meta');
// An undraped line moves and hides in place, and keeps its new meta.
const line = host.get(0).get(0);
set.upsert([stem('s', 2500, false)]);
assert.equal(scene.added[0], host);
assert.equal(host.get(0).get(0), line);
assert.equal(line.show, false);
assert.equal(line.id.meta, 2500);
assert.ok(
Cesium.Cartesian3.equalsEpsilon(
line.positions[1],
Cesium.Cartesian3.fromDegrees(0, 0, 2500),
1e-6,
),
);
// One item that cannot change in place rebuilds them all, and patches
// none of the others first.
set.upsert([
draped('a'),
{
...draped('b'),
positions: [
{ lon: 0, lat: 0 },
{ lon: 2, lat: 2 },
],
},
]);
assert.deepEqual([...attributes.get('a').show], [0], 'not patched');
assert.notEqual(scene.added.at(-1), host, 'a draped line that moves');
const moved = scene.added.at(-1);
set.upsert([{ ...stem('s', 2500), widthPx: 3 }]);
assert.notEqual(scene.added.at(-1), moved, 'a line that looks different');
// A ground primitive gone from under the set rebuilds too.
const third = scene.added.at(-1);
third.get(1).destroy();
set.upsert([draped('a', false)]);
assert.notEqual(scene.added.at(-1), third, 'its ground destroyed');
set.dispose();
}));
test('icons blend as their set says', () => {
const { scene, draw } = drawOver();
const set = draw.icons({ id: 'pins', blend: 'translucent' });
set.set([
{
id: 'a',
pos: { lon: 0, lat: 0 },
image: 'pin.png',
size: [6, 6],
},
]);
assert.equal(scene.added[0].blendOption, Cesium.BlendOption.TRANSLUCENT);
set.setOptions({ blend: undefined });
assert.equal(
scene.added[0].blendOption,
Cesium.BlendOption.OPAQUE_AND_TRANSLUCENT,
);
set.dispose();
});