mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +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
@@ -1,27 +1,40 @@
|
||||
import * as Cesium from 'cesium';
|
||||
export const EARTHQUAKE_OVERLAY_SOURCE_ID = 'earthquakes';
|
||||
export const EARTHQUAKE_OVERLAY_COHORT_LIMIT = 96;
|
||||
export const EARTHQUAKE_OVERLAY_COLLISION_CAPACITY = 48;
|
||||
|
||||
// The depth bands' colours: CSS red, orange and yellow, as the renderer's
|
||||
// colour tuples (`[r, g, b, a]`, 0..1) and as CSS for the labels' accent.
|
||||
const SHALLOW = Object.freeze({ rgba: [1, 0, 0, 1], css: 'rgb(255,0,0)' });
|
||||
const INTERMEDIATE = Object.freeze({
|
||||
rgba: [1, 165 / 255, 0, 1],
|
||||
css: 'rgb(255,165,0)',
|
||||
});
|
||||
const DEEP = Object.freeze({ rgba: [1, 1, 0, 1], css: 'rgb(255,255,0)' });
|
||||
|
||||
const depthBand = (depthKm) =>
|
||||
depthKm < 70 ? SHALLOW : depthKm < 300 ? INTERMEDIATE : DEEP;
|
||||
|
||||
/**
|
||||
* Color by depth:
|
||||
* Color by depth, as a renderer colour `[r, g, b, a]` (0..1):
|
||||
* - Shallow (<70km): Red
|
||||
* - Intermediate (70-300km): Orange
|
||||
* - Deep (>300km): Yellow
|
||||
*/
|
||||
export function depthColor(depthKm) {
|
||||
if (depthKm < 70) return Cesium.Color.RED;
|
||||
if (depthKm < 300) return Cesium.Color.ORANGE;
|
||||
return Cesium.Color.YELLOW;
|
||||
return [...depthBand(depthKm).rgba];
|
||||
}
|
||||
|
||||
/** The depth band's colour as CSS, for the magnitude label's accent. */
|
||||
export const depthAccent = (depthKm) => depthBand(depthKm).css;
|
||||
|
||||
/**
|
||||
* Build the source-owned presentation for one ambient magnitude label.
|
||||
* Magnitude formatting deliberately remains here instead of moving into the
|
||||
* shared renderer.
|
||||
* @param {object} input
|
||||
* @param {string} input.id Stable USGS or deterministic fallback id.
|
||||
* @param {Cesium.Cartesian3} input.position Ground anchor shared with the pulse.
|
||||
* @param {{x: number, y: number, z: number}} input.position ECEF ground
|
||||
* anchor, shared with the disc.
|
||||
* @param {number} input.magnitude USGS magnitude.
|
||||
* @param {string} input.accent Source-owned depth-band color.
|
||||
* @returns {object}
|
||||
|
||||
Reference in new issue
Block a user