mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Main brings the reviewed one-time-control and timeline-mark changes. They keep this branch's renderer work: earthquakes draw through the draw port and register their strong quakes as marks; the weather clock keeps `follows` beside `world`; the weather layer measures ages and delays from the timeline time; the Visual panel keeps its sky and weather groups under Effects. Tests that moved time through the weather clock now move it on the world clock.
This commit is contained in:
commit
0ecbfbecd0
123 files changed
+5917
-1471
No files matched your search
@@ -14,6 +14,64 @@ const DEEP = Object.freeze({ rgba: [1, 1, 0, 1], css: 'rgb(255,255,0)' });
|
||||
const depthBand = (depthKm) =>
|
||||
depthKm < 70 ? SHALLOW : depthKm < 300 ? INTERMEDIATE : DEEP;
|
||||
|
||||
/**
|
||||
* The smallest magnitude the timeline marks. Most quakes are small shakes;
|
||||
* M6 and up come about once every two days worldwide, so each is an event
|
||||
* worth stepping to. The map still draws every quake.
|
||||
*/
|
||||
export const EARTHQUAKE_MARK_MAGNITUDE = 6;
|
||||
|
||||
/** The longest place a timeline mark's label carries, ellipsis and all. */
|
||||
const MARK_PLACE_LENGTH = 40;
|
||||
|
||||
/** A magnitude as the map's labels show it: `M6.4`. */
|
||||
export const earthquakeMagnitudeTitle = (magnitude) =>
|
||||
`M${Number(magnitude).toFixed(1)}`;
|
||||
|
||||
/**
|
||||
* A strong quake's timeline label: its magnitude and, where the feed names
|
||||
* one, its place, cut short (`M6.4 · 113 km SSE of Lata, Solomon Islands`).
|
||||
* @param {{mag: number, place?: string | null}} event
|
||||
* @returns {string}
|
||||
*/
|
||||
export function earthquakeMarkLabel({ mag, place }) {
|
||||
const title = earthquakeMagnitudeTitle(mag);
|
||||
const where =
|
||||
typeof place === 'string' ? place.replace(/\s+/g, ' ').trim() : '';
|
||||
if (!where) return title;
|
||||
const short =
|
||||
where.length > MARK_PLACE_LENGTH
|
||||
? `${where.slice(0, MARK_PLACE_LENGTH - 1).trimEnd()}…`
|
||||
: where;
|
||||
return `${title} · ${short}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time a world clock's timeline can show for `events` (`{mag, time,
|
||||
* place?, usgsId?}`, time in ms): the span of the quakes of
|
||||
* EARTHQUAKE_MARK_MAGNITUDE and up, each one a mark labelled with its
|
||||
* magnitude and place, or null with none, so the layer never stretches the
|
||||
* timeline past what its feed covers.
|
||||
* @returns {{start: number, end: number, marks: Array<{time: number, label: string, id?: string, kind: string}>} | null}
|
||||
*/
|
||||
export function earthquakeCoverage(events) {
|
||||
const marks = events
|
||||
.filter(
|
||||
({ mag, time }) =>
|
||||
mag >= EARTHQUAKE_MARK_MAGNITUDE && Number.isFinite(time),
|
||||
)
|
||||
.map((event) => ({
|
||||
time: event.time,
|
||||
label: earthquakeMarkLabel(event),
|
||||
...(event.usgsId ? { id: String(event.usgsId) } : {}),
|
||||
kind: 'earthquake',
|
||||
}))
|
||||
.sort((a, b) => a.time - b.time);
|
||||
return marks.length
|
||||
? { start: marks[0].time, end: marks.at(-1).time, marks }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Color by depth, as a renderer colour `[r, g, b, a]` (0..1):
|
||||
* - Shallow (<70km): Red
|
||||
@@ -50,7 +108,7 @@ export function createEarthquakeOverlayEntry({
|
||||
id: String(id),
|
||||
position,
|
||||
variant: 'label',
|
||||
title: `M${mag.toFixed(1)}`,
|
||||
title: earthquakeMagnitudeTitle(mag),
|
||||
accent,
|
||||
priority: Math.round(mag * 1000),
|
||||
collisionGroup: 'ambient-label',
|
||||
|
||||
Reference in new issue
Block a user