Draw earthquakes through the renderer's draw port

The earthquake discs are now one draw set of ground-clamped filled
ellipses per layer, with the same colours, alphas and radii; they had no
visible outline before either (Cesium turns outlines off on clamped
entity ellipses). The layer and its model no longer import Cesium and
leave the allow-list.

depthColor now returns a renderer colour [r, g, b, a] rather than a
Cesium colour, and depthAccent its CSS. A caller handing the layer a
Cesium viewer of their own, with no renderer bound, first loads the new
./render/cesium/unbound export, which provides every unbound factory; the
camera factory now loads the draw factory too, so entries that already
load it draw as well. A fake draw port for layer tests comes with it.
This commit is contained in:
Sameh Khamis committed 2026-11-06 19:15:08 -08:00
1 parent 8b2859e501
commit bb3106991e
16 files changed
+384 -149

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
/**
* A draw port (`src/render/contract/draw.d.ts`) that keeps what it is
* given, for layer tests: each set's spec, items by id, `show` and whether
* it was disposed. `bindFakeDraw` binds it to a viewer double, as the
* application binds its renderer, so the layer's `drawOf(viewer)` finds it.
*/
import { bindRenderer } from '../render/rendererOf.js';
export function fakeDrawPort() {
const sets = new Map();
const make = (kind) => (spec) => {
const live = sets.get(spec.id);
if (live && !live.disposed)
throw new Error(`a set with id ${spec.id} is live`);
const record = {
kind,
spec: { ...spec },
items: new Map(),
show: spec.show !== false,
disposed: false,
writes: 0,
};
sets.set(spec.id, record);
const write = (fn) => {
if (record.disposed) throw new Error(`set ${spec.id} is disposed`);
fn();
record.writes += 1;
};
return {
id: spec.id,
set: (items) =>
write(() => {
record.items.clear();
for (const item of items) record.items.set(item.id, item);
}),
upsert: (items) =>
write(() => {
for (const item of items) record.items.set(item.id, item);
}),
remove: (ids) =>
write(() => {
for (const id of ids) record.items.delete(id);
}),
clear: () => write(() => record.items.clear()),
setOptions(options) {
Object.assign(record.spec, options);
if ('show' in options) record.show = options.show !== false;
},
size: () => record.items.size,
get show() {
return record.show;
},
set show(value) {
record.show = value;
},
on: () => () => {},
dispose() {
record.disposed = true;
},
};
};
return {
sets,
/** The live set with this id, or undefined. */
set: (id) => (sets.get(id)?.disposed ? undefined : sets.get(id)),
/** The live set whose id starts with `prefix`, or undefined. */
find: (prefix) =>
[...sets.values()].find(
(record) => !record.disposed && record.spec.id.startsWith(prefix),
),
icons: make('icons'),
points: make('points'),
lines: make('lines'),
shapes: make('shapes'),
clampState: () => 'draped',
on: () => () => {},
atlas() {},
};
}
/**
* Bind a fake draw port to `viewer`; `renderer` adds other ports.
* @returns {{draw: ReturnType<typeof fakeDrawPort>, unbind: () => void}}
*/
export function bindFakeDraw(viewer, renderer = {}) {
const draw = fakeDrawPort();
const unbind = bindRenderer(viewer, { ...renderer, draw });
return { draw, unbind };
}