mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
8b2859e501
commit
bb3106991e
16 files changed
+384
-149
No files matched your search
@@ -12,8 +12,9 @@ import { cameraFlightActive } from './internals.js';
|
||||
import { createCesiumFollow } from './follow.js';
|
||||
import { createCesiumControls } from './cameraControls.js';
|
||||
import { cameraOf, findCamera, provideUnboundCamera } from '../rendererOf.js';
|
||||
// Loads the factory an unbound viewer gets its credits port from.
|
||||
// Loads the factories an unbound viewer gets its credits and draw ports from.
|
||||
import './credits.js';
|
||||
import './draw.js';
|
||||
|
||||
/**
|
||||
* `cameraOf` and `findCamera`, for code that already reaches Cesium:
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { provideUnboundDraw } from '../rendererOf.js';
|
||||
import { listenerList, toCartesian, uncaught } from './common.js';
|
||||
// A caller loads this module for a viewer of its own; what draws there
|
||||
// flies through `cameraOf` too, so the camera factory comes with it.
|
||||
import './camera.js';
|
||||
|
||||
/** The contract's colour as Cesium's. */
|
||||
export function toColor(color, alpha = 1) {
|
||||
|
||||
@@ -322,3 +322,40 @@ test('clamped shapes refuse what they cannot draw', () => {
|
||||
);
|
||||
set.dispose();
|
||||
});
|
||||
|
||||
test('the earthquakes layer draws its discs as ground fills on a viewer of its own', async () => {
|
||||
const { createEarthquakesLayer } =
|
||||
await import('../../layers/earthquakes/index.js');
|
||||
const scene = fakeScene();
|
||||
const viewer = { scene };
|
||||
const row = (stableId, lon, mag) => ({
|
||||
stableId,
|
||||
usgsId: stableId,
|
||||
lon,
|
||||
lat: 0,
|
||||
depthKm: 10,
|
||||
mag,
|
||||
place: null,
|
||||
time: null,
|
||||
});
|
||||
const layer = createEarthquakesLayer({
|
||||
source: { getSnapshot: async () => [row('a', 0, 5), row('b', 0.2, 3)] },
|
||||
overlayHost: { setEntries() {}, setVisible() {}, clearSource() {} },
|
||||
});
|
||||
layer.init(viewer);
|
||||
layer.enable(viewer);
|
||||
assert.equal(await layer.update(viewer), true);
|
||||
const host = scene.added[0];
|
||||
const grounds = [];
|
||||
for (let i = 0; i < host.length; i++)
|
||||
if (host.get(i) instanceof Cesium.GroundPrimitive)
|
||||
grounds.push(host.get(i));
|
||||
// Overlapping discs: one batch each, as the entities' batches had them.
|
||||
assert.equal(grounds.length, 2);
|
||||
const [instance] = grounds[0].geometryInstances;
|
||||
assert.ok(instance.geometry instanceof Cesium.EllipseGeometry);
|
||||
assert.equal(instance.id.id, 'earthquake:a');
|
||||
assert.equal(grounds[0].classificationType, Cesium.ClassificationType.BOTH);
|
||||
layer.destroy();
|
||||
assert.equal(scene.added.length, 0);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @module render/cesium/unbound
|
||||
* @description What to load, once, before handing the Cesium-free
|
||||
* layers a Cesium viewer with no renderer bound: the factories
|
||||
* that build a camera, credits, effects and draw port over such a viewer
|
||||
* when code first asks for one (`rendererOf.js`).
|
||||
*/
|
||||
import './camera.js';
|
||||
import './effects.js';
|
||||
Reference in new issue
Block a user