drone-path 0.13.0 → 1.0.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +20 -74
  2. package/THIRD-PARTY-NOTICES.md +3 -82
  3. package/bin/drone-path.mjs +0 -0
  4. package/dist/cli.d.ts +14 -0
  5. package/dist/cli.js +7 -7
  6. package/dist/version.d.ts +1 -0
  7. package/package.json +21 -68
  8. package/CHANGELOG.md +0 -349
  9. package/app/ipc.d.mts +0 -44
  10. package/app/ipc.mjs +0 -237
  11. package/app/main.mjs +0 -369
  12. package/app/preload.cjs +0 -36
  13. package/app/update-policy.d.mts +0 -6
  14. package/app/update-policy.mjs +0 -6
  15. package/app/update.d.mts +0 -10
  16. package/app/update.mjs +0 -54
  17. package/dist/appassets.js +0 -35
  18. package/dist/apppaths.js +0 -20
  19. package/dist/appsession.js +0 -121
  20. package/dist/appstate.js +0 -101
  21. package/dist/assets.js +0 -60
  22. package/dist/buildinfo.js +0 -64
  23. package/dist/cammeta-decode.js +0 -237
  24. package/dist/cammeta.js +0 -92
  25. package/dist/changeset-gate.js +0 -39
  26. package/dist/config.js +0 -631
  27. package/dist/configfile.js +0 -86
  28. package/dist/decimate.js +0 -84
  29. package/dist/desktop-i18n/generated/catalogs.js +0 -1230
  30. package/dist/desktop-i18n/messages.js +0 -47
  31. package/dist/errors.js +0 -34
  32. package/dist/exec-tool.js +0 -13
  33. package/dist/exportjob.js +0 -90
  34. package/dist/ffmpeg-tools.js +0 -56
  35. package/dist/ffmpeg.js +0 -98
  36. package/dist/frametime.js +0 -32
  37. package/dist/geo.js +0 -60
  38. package/dist/logging.js +0 -1
  39. package/dist/manual/anchors.js +0 -17
  40. package/dist/manual/build.js +0 -67
  41. package/dist/manual/cliref.js +0 -34
  42. package/dist/manual/links.js +0 -59
  43. package/dist/manual/markdown.js +0 -98
  44. package/dist/manual/model.js +0 -1
  45. package/dist/manual/module.js +0 -5
  46. package/dist/manual/nav.js +0 -11
  47. package/dist/manual/reference.js +0 -18
  48. package/dist/paths.js +0 -16
  49. package/dist/pipeline.js +0 -402
  50. package/dist/plan.js +0 -106
  51. package/dist/png.js +0 -32
  52. package/dist/protobuf-wire.js +0 -102
  53. package/dist/range.js +0 -50
  54. package/dist/recordings.js +0 -55
  55. package/dist/render-page.js +0 -85
  56. package/dist/render.js +0 -268
  57. package/dist/renderer/boot.js +0 -7
  58. package/dist/renderer/dom.js +0 -179
  59. package/dist/renderer/framemath.js +0 -30
  60. package/dist/renderer/scene.js +0 -388
  61. package/dist/renderer/theme.js +0 -82
  62. package/dist/renderer/tilesources.js +0 -38
  63. package/dist/renderer/trail.js +0 -42
  64. package/dist/restyle.js +0 -16
  65. package/dist/serve.js +0 -27
  66. package/dist/srt.js +0 -98
  67. package/dist/telemetry-json-schema.js +0 -18
  68. package/dist/telemetry-json.js +0 -126
  69. package/dist/telemetry-math.js +0 -267
  70. package/dist/telemetry-summary.js +0 -19
  71. package/dist/telemetry.js +0 -95
  72. package/dist/tilecache.js +0 -21
  73. package/dist/tiles.js +0 -155
  74. package/dist/track-format.js +0 -13
  75. package/dist/track-geojson.js +0 -44
  76. package/dist/track-gpx.js +0 -34
  77. package/dist/track-kml.js +0 -47
  78. package/dist/track-kmz.js +0 -68
  79. package/dist/track-write.js +0 -41
  80. package/dist/track.js +0 -79
@@ -1,179 +0,0 @@
1
- function mapCss(at, src, theme, width, height) {
2
- return `
3
- ${at} { margin: 0; padding: 0; overflow: hidden; background: ${src.bg}; }
4
- ${at}, ${at} * { animation: none !important; transition: none !important; }
5
- ${at} #map-frame {
6
- position: absolute; inset: 0; overflow: hidden; background: ${src.bg};
7
- }
8
- ${at} #map {
9
- position: absolute; left: 0; top: 0; width: ${width}px; height: ${height}px;
10
- /* Leaflet's own container default is a light gray; the un-tiled field
11
- takes the style's background so it never flashes bright (#167). */
12
- background: ${src.bg};
13
- }
14
- ${at} .leaflet-tile-pane { filter: ${src.tileFilter ?? 'none'}; }
15
- ${at} #vignette {
16
- position: absolute; inset: 0; z-index: 500; pointer-events: none;
17
- background: radial-gradient(ellipse 78% 78% at 50% 44%,
18
- rgba(0,0,0,0) 52%, rgba(0,0,0,${theme.vignette}) 100%);
19
- }`;
20
- }
21
- function droneCss(at, theme, scale) {
22
- return `
23
- ${at} .drone-wrap {
24
- width: ${Math.round(46 * scale)}px; height: ${Math.round(46 * scale)}px;
25
- border-radius: 50%;
26
- background: ${theme.discBg};
27
- border: ${Math.max(2, Math.round(2.2 * scale))}px solid rgba(255,255,255,0.92);
28
- box-shadow:
29
- 0 0 0 ${Math.round(7 * scale)}px ${theme.glow},
30
- 0 ${Math.round(3 * scale)}px ${Math.round(12 * scale)}px rgba(0,0,0,0.45);
31
- display: flex; align-items: center; justify-content: center;
32
- box-sizing: border-box;
33
- }
34
- ${at} .drone-arrow { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
35
- ${at} .drone-arrow svg { width: 72%; height: 72%; display: block; }`;
36
- }
37
- function chipCss(at, theme, scale) {
38
- return `
39
- ${at} #hud {
40
- position: absolute; top: ${Math.round(16 * scale)}px; left: ${Math.round(16 * scale)}px;
41
- display: flex; flex-direction: column; gap: ${Math.round(8 * scale)}px;
42
- font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
43
- z-index: 1200; pointer-events: none;
44
- }
45
- ${at} .chip {
46
- background: rgba(14,19,28,0.9);
47
- backdrop-filter: blur(${Math.round(14 * scale)}px) saturate(1.25);
48
- -webkit-backdrop-filter: blur(${Math.round(14 * scale)}px) saturate(1.25);
49
- color: #ffffff;
50
- padding: ${Math.round(6 * scale)}px ${Math.round(14 * scale)}px ${Math.round(6 * scale)}px ${Math.round(13 * scale)}px;
51
- border-radius: ${Math.round(13 * scale)}px;
52
- font-size: ${Math.round(21 * scale)}px;
53
- font-weight: 600;
54
- font-variant-numeric: tabular-nums;
55
- letter-spacing: 0.3px;
56
- display: inline-flex; align-items: baseline; gap: ${Math.round(7 * scale)}px;
57
- width: fit-content;
58
- border: 1px solid rgba(255,255,255,0.20);
59
- box-shadow:
60
- inset ${Math.max(3, Math.round(3 * scale))}px 0 0 ${theme.core},
61
- 0 ${Math.round(6 * scale)}px ${Math.round(18 * scale)}px rgba(0,0,0,0.30);
62
- }
63
- ${at} .chip .label {
64
- font-size: 0.55em; font-weight: 700; letter-spacing: 1.2px;
65
- color: ${theme.core}; opacity: 0.95;
66
- }
67
- ${at} .chip .unit { font-weight: 500; opacity: 0.72; font-size: 0.68em; }
68
- ${at} .chip .chip-arrow {
69
- /* The heading arrow lives in a fixed square slot like the preview chip's,
70
- so its ink never crowds the pill padding at any rotation angle. */
71
- display: inline-flex; align-items: center; justify-content: center;
72
- width: ${Math.round(24 * scale)}px; height: ${Math.round(24 * scale)}px;
73
- font-size: ${Math.round(19 * scale)}px; line-height: 1;
74
- color: ${theme.core};
75
- }`;
76
- }
77
- function attrCss(at, scale) {
78
- return `
79
- ${at} #attr {
80
- position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%;
81
- background: rgba(12, 14, 22, 0.62); color: rgba(255,255,255,0.78);
82
- font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
83
- font-size: ${Math.round(11 * scale)}px; line-height: 1.35;
84
- padding: ${Math.round(2 * scale)}px ${Math.round(8 * scale)}px;
85
- border-radius: ${Math.round(4 * scale)}px 0 0 0;
86
- pointer-events: none;
87
- }
88
- ${at} #attr a { color: rgba(255,255,255,0.92); text-decoration: none; }`;
89
- }
90
- function scaleBarCss(at, scale) {
91
- return `
92
- ${at} #scalebar {
93
- position: absolute; left: ${Math.round(10 * scale)}px; bottom: ${Math.round(8 * scale)}px;
94
- z-index: 1000; pointer-events: none;
95
- font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
96
- }
97
- ${at} #scaletext {
98
- display: block; color: #ffffff; font-size: ${Math.round(11 * scale)}px;
99
- text-shadow: 0 1px 2px rgba(0,0,0,0.8); margin-bottom: 2px;
100
- }
101
- ${at} #scaleline {
102
- height: ${Math.max(4, Math.round(5 * scale))}px;
103
- border: 1px solid rgba(255,255,255,0.85); border-top: none;
104
- box-shadow: 0 1px 2px rgba(0,0,0,0.6);
105
- }`;
106
- }
107
- export function sceneCss(src, theme, width, height, scale, scope) {
108
- const at = `.${scope}`;
109
- return (mapCss(at, src, theme, width, height) +
110
- droneCss(at, theme, scale) +
111
- chipCss(at, theme, scale) +
112
- attrCss(at, scale) +
113
- scaleBarCss(at, scale));
114
- }
115
- export const EXPORT_HUD_LABELS = {
116
- heading: 'HDG',
117
- alt: 'ALT',
118
- speed: 'SPD',
119
- };
120
- export function hudMarkup(hud) {
121
- const chips = [];
122
- if (hud.heading) {
123
- chips.push(`<div class="chip" id="chip-heading"><span class="label">${EXPORT_HUD_LABELS.heading}</span><span class="chip-arrow">▲</span><span class="num">--</span></div>`);
124
- }
125
- if (hud.alt) {
126
- chips.push(`<div class="chip" id="chip-alt"><span class="label">${EXPORT_HUD_LABELS.alt}</span><span class="num">--</span><span class="unit">m</span></div>`);
127
- }
128
- if (hud.speed) {
129
- chips.push(`<div class="chip" id="chip-speed"><span class="label">${EXPORT_HUD_LABELS.speed}</span><span class="num">--</span><span class="unit">m/s</span></div>`);
130
- }
131
- return chips.map((chip) => ` ${chip}`).join('\n');
132
- }
133
- function escapeText(value) {
134
- return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
135
- }
136
- export function stripReadoutMarkup(hud, labels) {
137
- const column = (id, label, unit, live) => `<div class="map-readout${live ? '' : ' map-readout-off'}" id="chip-${id}">` +
138
- `<span class="label">${escapeText(label)}</span>` +
139
- `<span class="value"><span class="num">--</span><span class="unit">${unit}</span></span>` +
140
- `</div>`;
141
- return [
142
- column('speed', labels?.speed ?? 'Speed', 'm/s', hud.speed),
143
- column('alt', labels?.altitude ?? 'Altitude', 'm', hud.alt),
144
- ]
145
- .map((col) => ` ${col}`)
146
- .join('\n');
147
- }
148
- /** A null hud keeps the chips out of the map frame: the caller mounts them in
149
- a strip outside the map image instead. */
150
- export function mapMarkup(hud, attribution) {
151
- const hudBlock = hud === null ? '' : `<div id="hud">
152
- ${hudMarkup(hud)}
153
- </div>
154
- `;
155
- return `<div id="map-frame">
156
- <div id="map"></div>
157
- <div id="vignette"></div>
158
- ${hudBlock}<div id="attr">${attribution}</div>
159
- <div id="scalebar"><span id="scaletext"></span><div id="scaleline"></div></div>
160
- </div>`;
161
- }
162
- /** Attribution links are on-screen credits, not controls: keyboard skips them. */
163
- export function quietAttributionLinks(attr) {
164
- for (const a of attr.querySelectorAll('a'))
165
- a.setAttribute('tabindex', '-1');
166
- }
167
- export function droneMarkerMarkup(coreColor) {
168
- return ('<div class="drone-wrap"><div class="drone-arrow" id="drone-arrow">' +
169
- '<svg viewBox="0 0 24 24"><path d="M12 1.8 L21 22 L12 16.9 L3 22 Z" fill="' +
170
- coreColor +
171
- '" stroke="rgba(255,255,255,0.9)" stroke-width="0.9" stroke-linejoin="round"/></svg>' +
172
- '</div></div>');
173
- }
174
- export function el(root, selector) {
175
- const found = root.querySelector(selector);
176
- if (!found)
177
- throw new Error(`renderer element missing: ${selector}`);
178
- return found;
179
- }
@@ -1,30 +0,0 @@
1
- export function computeScale(width, height) {
2
- return Math.max(0.7, Math.min(2.2, Math.min(width, height) / 1024));
3
- }
4
- export function smoothstep(t) {
5
- const clamped = Math.max(0, Math.min(1, t));
6
- return clamped * clamped * (3 - 2 * clamped);
7
- }
8
- export function introOutroScale(i, introN, outroN, totalN) {
9
- let kIn = 1;
10
- let kOut = 1;
11
- if (introN > 0 && i < introN) {
12
- kIn = Math.pow(2, -(1 - smoothstep(i / introN)));
13
- }
14
- if (outroN > 0 && i > totalN - 1 - outroN) {
15
- kOut = Math.pow(2, -(1 - smoothstep((totalN - 1 - i) / outroN)));
16
- }
17
- return Math.min(kIn, kOut);
18
- }
19
- export function metersPerPixel(lat, zoom) {
20
- return (156543.033928 * Math.cos((lat * Math.PI) / 180)) / Math.pow(2, zoom);
21
- }
22
- export function scaleBarMeters(mPerPx, maxPx) {
23
- const steps = [5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000, 10000];
24
- let best = steps[0];
25
- for (const step of steps) {
26
- if (step / mPerPx <= maxPx)
27
- best = step;
28
- }
29
- return best;
30
- }
@@ -1,388 +0,0 @@
1
- import { TILE_SOURCES } from './tilesources.js';
2
- import { droneMarkerMarkup, el, hudMarkup, mapMarkup, quietAttributionLinks, sceneCss, stripReadoutMarkup } from './dom.js';
3
- import { computeScale, introOutroScale, metersPerPixel, scaleBarMeters } from './framemath.js';
4
- import { themeFor } from './theme.js';
5
- import { createTrailController } from './trail.js';
6
- function hudEq(a, b) {
7
- return (a.heading === b.heading && a.alt === b.alt && a.speed === b.speed);
8
- }
9
- function setChipText(chip, value, format) {
10
- if (!chip)
11
- return;
12
- chip.textContent = value === null || value === undefined ? '--' : format(value);
13
- }
14
- /** A missing value renders exactly like a disabled chip: the dimmed "--". */
15
- function isPlaceholder(value) {
16
- return value === null || value === undefined;
17
- }
18
- let scopeCount = 0;
19
- class SceneState {
20
- ready;
21
- data;
22
- L;
23
- host;
24
- scopeClass = `scene-scope-${(scopeCount += 1)}`;
25
- styleEl;
26
- readyTimer;
27
- settleReady = () => { };
28
- attrEl;
29
- mapEl;
30
- frameEl;
31
- scalelineEl;
32
- scaletextEl;
33
- map;
34
- tiles;
35
- latlngs;
36
- bb;
37
- layout;
38
- decor;
39
- headingChip = null;
40
- altChip = null;
41
- speedChip = null;
42
- /** Chip container: inside the map frame for exports, or an external strip. */
43
- hudRoot;
44
- /** External strips get the column markup; the export frame keeps its pills. */
45
- externalHud;
46
- curIdx = 0;
47
- constructor(host, firstData, L, hudHost) {
48
- this.host = host;
49
- this.data = firstData;
50
- this.L = L;
51
- host.classList.add(this.scopeClass);
52
- this.styleEl = document.createElement('style');
53
- document.head.appendChild(this.styleEl);
54
- // One definedness rule for both: a caller either supplies the external
55
- // strip host or gets the in-frame export HUD, never a mix of the two.
56
- const externalHud = hudHost !== undefined;
57
- host.innerHTML = mapMarkup(externalHud ? null : firstData.hud, firstData.attribution);
58
- this.hudRoot = hudHost ?? el(host, '#hud');
59
- this.externalHud = externalHud;
60
- this.attrEl = el(host, '#attr');
61
- this.applyChrome();
62
- this.mapEl = el(host, '#map');
63
- this.map = L.map(this.mapEl, {
64
- zoomControl: false,
65
- attributionControl: false,
66
- dragging: false,
67
- scrollWheelZoom: false,
68
- doubleClickZoom: false,
69
- boxZoom: false,
70
- keyboard: false,
71
- touchZoom: false,
72
- fadeAnimation: false,
73
- zoomAnimation: false,
74
- markerZoomAnimation: false,
75
- preferCanvas: true,
76
- zoomSnap: 1,
77
- });
78
- this.tiles = this.makeTileLayer(firstData.tileUrl, firstData.style);
79
- this.tiles.addTo(this.map);
80
- this.latlngs = this.latlngsOf(firstData);
81
- this.bb = L.latLngBounds(this.latlngs);
82
- this.frameEl = el(host, '#map-frame');
83
- this.scalelineEl = el(host, '#scaleline');
84
- this.scaletextEl = el(host, '#scaletext');
85
- // Leaflet only creates marker DOM once the map has a view: layoutMap() must precede buildDecor() so the arrow/wrap elements exist.
86
- this.layoutMap();
87
- this.decor = this.buildDecor();
88
- this.rebuildHud();
89
- this.ready = new Promise((resolve) => {
90
- const markReady = () => resolve();
91
- this.settleReady = markReady;
92
- this.tiles.on('load', markReady);
93
- this.readyTimer = setTimeout(markReady, 12000);
94
- });
95
- }
96
- scale() {
97
- return computeScale(this.data.width, this.data.height);
98
- }
99
- makeTileLayer(tileUrl, style) {
100
- return this.L.tileLayer(tileUrl, {
101
- maxZoom: TILE_SOURCES[style].maxZoom,
102
- maxNativeZoom: TILE_SOURCES[style].maxNativeZoom ?? undefined,
103
- });
104
- }
105
- latlngsOf(data) {
106
- return data.lat.map((la, i) => [la, data.lon[i]]);
107
- }
108
- applyChrome() {
109
- this.styleEl.textContent = sceneCss(TILE_SOURCES[this.data.style], themeFor(this.data.style, this.data.trailColor), this.data.width, this.data.height, this.scale(), this.scopeClass);
110
- this.attrEl.innerHTML = this.data.attribution;
111
- // The compact map card truncates the credit to one line; the hover title
112
- // carries the full text wherever the browser can show it.
113
- this.attrEl.title = this.attrEl.textContent ?? '';
114
- quietAttributionLinks(this.attrEl);
115
- }
116
- layoutMap() {
117
- const { data, map, mapEl, frameEl } = this;
118
- const vw = frameEl.clientWidth || data.width;
119
- const vh = frameEl.clientHeight || data.height;
120
- let bigW;
121
- let bigH;
122
- if (data.view === 'follow') {
123
- const pb1 = map.project(this.bb.getNorthWest(), data.zoom);
124
- const pb2 = map.project(this.bb.getSouthEast(), data.zoom);
125
- bigW = Math.max(2 * vw, Math.ceil(Math.abs(pb2.x - pb1.x) + 2 * vw));
126
- bigH = Math.max(2 * vh, Math.ceil(Math.abs(pb2.y - pb1.y) + 2 * vh));
127
- }
128
- else {
129
- bigW = 2 * vw;
130
- bigH = 2 * vh;
131
- }
132
- mapEl.style.width = bigW + 'px';
133
- mapEl.style.height = bigH + 'px';
134
- map.invalidateSize();
135
- map.setView(data.view === 'follow' ? this.bb.getCenter() : [data.center.lat, data.center.lon], data.zoom);
136
- const c0 = map.project(map.getCenter(), data.zoom);
137
- const latC = data.view === 'follow' ? this.bb.getCenter().lat : data.center.lat;
138
- const mPerPx = metersPerPixel(latC, data.zoom);
139
- const bestM = scaleBarMeters(mPerPx, 110 * this.scale());
140
- this.scalelineEl.style.width = Math.round(bestM / mPerPx) + 'px';
141
- this.scaletextEl.textContent = bestM >= 1000 ? bestM / 1000 + ' km' : bestM + ' m';
142
- this.layout = { vw, vh, bigW, bigH, c0, bestM, mPerPx };
143
- }
144
- buildGhostLayers(theme, ghostLatlngs, ghostDash) {
145
- const s = this.scale();
146
- const layers = [];
147
- if (theme.ghostCasing) {
148
- const ghostCasing = this.L.polyline(ghostLatlngs, {
149
- color: theme.ghostCasing,
150
- weight: Math.max(3, 4.6 * s),
151
- opacity: 1,
152
- dashArray: ghostDash,
153
- lineCap: 'round',
154
- smoothFactor: 0,
155
- });
156
- ghostCasing.addTo(this.map);
157
- layers.push(ghostCasing);
158
- }
159
- const ghost = this.L.polyline(ghostLatlngs, {
160
- color: theme.ghost,
161
- weight: Math.max(2, 2.8 * s),
162
- opacity: theme.ghostOpacity,
163
- dashArray: ghostDash,
164
- lineCap: 'round',
165
- smoothFactor: 0,
166
- });
167
- ghost.addTo(this.map);
168
- layers.push(ghost);
169
- return layers;
170
- }
171
- // Creation order sets stacking: thickest first so the core stays on top.
172
- buildTrailLayers(theme) {
173
- // smoothFactor 0 keeps Leaflet from re-simplifying the pre-decimated path.
174
- const wCore = Math.max(3, 5.5 * this.scale());
175
- const trailGlow = this.L.polyline([], {
176
- color: theme.glow,
177
- weight: wCore * 2.6,
178
- opacity: 1,
179
- lineCap: 'round',
180
- lineJoin: 'round',
181
- smoothFactor: 0,
182
- });
183
- trailGlow.addTo(this.map);
184
- const trailCasing = this.L.polyline([], {
185
- color: theme.casing,
186
- weight: wCore * 1.6,
187
- opacity: 0.9,
188
- lineCap: 'round',
189
- lineJoin: 'round',
190
- smoothFactor: 0,
191
- });
192
- trailCasing.addTo(this.map);
193
- const trail = this.L.polyline([], {
194
- color: theme.trailCore,
195
- weight: wCore,
196
- opacity: 1,
197
- lineCap: 'round',
198
- lineJoin: 'round',
199
- smoothFactor: 0,
200
- });
201
- trail.addTo(this.map);
202
- return [trail, trailGlow, trailCasing];
203
- }
204
- buildMarker(theme, s) {
205
- const startDot = this.L.circleMarker(this.latlngs[0], {
206
- radius: Math.round(7 * s),
207
- color: '#ffffff',
208
- weight: Math.max(2, 2 * s),
209
- fillColor: theme.core,
210
- fillOpacity: 1,
211
- });
212
- startDot.addTo(this.map);
213
- const drone = this.L.marker(this.latlngs[0], {
214
- icon: this.L.divIcon({
215
- className: 'drone-icon',
216
- html: droneMarkerMarkup(theme.core),
217
- iconSize: [Math.round(46 * s), Math.round(46 * s)],
218
- iconAnchor: [Math.round(23 * s), Math.round(23 * s)],
219
- }),
220
- interactive: false,
221
- keyboard: false,
222
- });
223
- drone.addTo(this.map);
224
- return { startDot, drone };
225
- }
226
- buildDecor() {
227
- const theme = themeFor(this.data.style, this.data.trailColor);
228
- const s = this.scale();
229
- const ghostLatlngs = this.data.trailLat.map((la, i) => [la, this.data.trailLon[i]]);
230
- const ghostDash = Math.round(7 * s) + ' ' + Math.round(9 * s);
231
- const ghostLayers = this.buildGhostLayers(theme, ghostLatlngs, ghostDash);
232
- const trailLayers = this.buildTrailLayers(theme);
233
- const { startDot, drone } = this.buildMarker(theme, s);
234
- const decor = {
235
- layers: [...trailLayers, startDot, drone, ...ghostLayers],
236
- trailLayers,
237
- drone,
238
- trailCtl: createTrailController({
239
- lat: this.data.trailLat,
240
- lon: this.data.trailLon,
241
- frame: this.data.trailFrame,
242
- }, { lat: this.data.lat, lon: this.data.lon }, trailLayers),
243
- arrowEl: this.host.querySelector('#drone-arrow'),
244
- wrapEl: this.host.querySelector('.drone-wrap'),
245
- };
246
- if (!this.data.hud.heading && decor.arrowEl)
247
- decor.arrowEl.style.display = 'none';
248
- return decor;
249
- }
250
- rebuildDecor() {
251
- for (const layer of this.decor.layers)
252
- layer.remove();
253
- this.decor = this.buildDecor();
254
- }
255
- rebuildHud() {
256
- // Scoped to the chip container so an external strip and a second scene
257
- // (the export preview) can never cross-write. A scene whose caller
258
- // overlays its own pills draws none of its own (#283).
259
- this.hudRoot.innerHTML = this.externalHud
260
- ? stripReadoutMarkup(this.data.hud, this.data.stripLabels)
261
- : this.data.hudPills === false
262
- ? ''
263
- : hudMarkup(this.data.hud);
264
- this.headingChip = this.hudRoot.querySelector('#chip-heading');
265
- this.altChip = this.hudRoot.querySelector('#chip-alt');
266
- this.speedChip = this.hudRoot.querySelector('#chip-speed');
267
- if (this.decor.arrowEl) {
268
- this.decor.arrowEl.style.display = this.data.hud.heading ? '' : 'none';
269
- }
270
- }
271
- updateTransform(i, k) {
272
- const { data, layout, decor, mapEl } = this;
273
- let dx = 0;
274
- let dy = 0;
275
- if (data.view === 'follow') {
276
- const p = this.map.project(this.latlngs[i], data.zoom);
277
- dx = p.x - layout.c0.x;
278
- dy = p.y - layout.c0.y;
279
- }
280
- mapEl.style.transform =
281
- 'translate(' + (layout.vw / 2 - layout.bigW / 2 - k * dx) + 'px,' +
282
- (layout.vh / 2 - layout.bigH / 2 - k * dy) + 'px) scale(' + k + ')';
283
- if (decor.wrapEl) {
284
- decor.wrapEl.style.transform = k === 1 ? '' : 'scale(' + 1 / k + ')';
285
- }
286
- this.scalelineEl.style.width = Math.round((layout.bestM / layout.mPerPx) * k) + 'px';
287
- if (data.hud.heading && decor.arrowEl) {
288
- decor.arrowEl.style.transform = 'rotate(' + data.headingDeg[i] + 'deg)';
289
- }
290
- }
291
- updateHud(i) {
292
- // A disabled chip and a missing sample share one presentation: the dimmed
293
- // "--" placeholder instead of a value (#272 review).
294
- this.setReadout(this.altChip, this.data.hud.alt ? this.data.alt[i] : null, (a) => String(Math.round(a)));
295
- this.setReadout(this.speedChip, this.data.hud.speed ? this.data.speed[i] : null, (s) => s.toFixed(1));
296
- this.setHeading(this.headingChip, this.data.headingDeg[i]);
297
- }
298
- /** The heading pill rotates its arrow like the marker does; a missing
299
- sample falls back to the dimmed "--", matching the preview chip (#283). */
300
- setHeading(chip, deg) {
301
- if (!chip)
302
- return;
303
- const missing = deg === null || deg === undefined;
304
- const arrow = chip.querySelector('.chip-arrow');
305
- const num = chip.querySelector('.num');
306
- if (arrow) {
307
- arrow.style.display = missing ? 'none' : '';
308
- if (!missing)
309
- arrow.style.transform = 'rotate(' + deg + 'deg)';
310
- }
311
- if (num)
312
- num.style.display = missing ? '' : 'none';
313
- }
314
- setReadout(chip, value, format) {
315
- if (!chip)
316
- return;
317
- setChipText(chip.querySelector('.num'), value, format);
318
- if (this.externalHud)
319
- chip.classList.toggle('map-readout-off', isPlaceholder(value));
320
- }
321
- setFrame(i) {
322
- this.curIdx = i;
323
- this.decor.trailCtl.setFrame(i);
324
- this.decor.drone.setLatLng(this.latlngs[i]);
325
- const k = introOutroScale(i, this.data.introN, this.data.outroN, this.data.lat.length);
326
- this.updateTransform(i, k);
327
- this.updateHud(i);
328
- // Canvas painting is deferred to requestAnimationFrame
329
- return new Promise((resolve) => {
330
- requestAnimationFrame(() => {
331
- requestAnimationFrame(() => resolve());
332
- });
333
- });
334
- }
335
- relayout() {
336
- this.layoutMap();
337
- void this.setFrame(this.curIdx);
338
- }
339
- update(next) {
340
- const prev = this.data;
341
- this.data = next;
342
- if (next.lat !== prev.lat) {
343
- this.latlngs = this.latlngsOf(next);
344
- this.bb = this.L.latLngBounds(this.latlngs);
345
- }
346
- const chromeChanged = next.style !== prev.style ||
347
- next.trailColor !== prev.trailColor ||
348
- next.width !== prev.width ||
349
- next.height !== prev.height ||
350
- next.attribution !== prev.attribution;
351
- if (chromeChanged)
352
- this.applyChrome();
353
- if (next.style !== prev.style) {
354
- // Zoom constraints are per tile layer (topo is native to z17), so a style switch swaps the layer instead of only its URL.
355
- this.tiles.remove();
356
- this.tiles = this.makeTileLayer(next.tileUrl, next.style);
357
- this.tiles.addTo(this.map);
358
- }
359
- else if (next.tileUrl !== prev.tileUrl) {
360
- this.tiles.setUrl(next.tileUrl);
361
- }
362
- const decorInvalidated = next.style !== prev.style ||
363
- next.trailColor !== prev.trailColor ||
364
- next.trailLat !== prev.trailLat ||
365
- next.lat !== prev.lat ||
366
- next.width !== prev.width ||
367
- next.height !== prev.height;
368
- if (decorInvalidated)
369
- this.rebuildDecor();
370
- if (!hudEq(prev.hud, next.hud) ||
371
- next.hudPills !== prev.hudPills ||
372
- next.stripLabels?.speed !== prev.stripLabels?.speed ||
373
- next.stripLabels?.altitude !== prev.stripLabels?.altitude)
374
- this.rebuildHud();
375
- this.layoutMap();
376
- return this.setFrame(this.curIdx);
377
- }
378
- dispose() {
379
- clearTimeout(this.readyTimer);
380
- this.settleReady();
381
- this.map.remove();
382
- this.styleEl.remove();
383
- this.host.classList.remove(this.scopeClass);
384
- }
385
- }
386
- export function createScene(host, firstData, deps) {
387
- return new SceneState(host, firstData, deps.L, deps.hudHost);
388
- }
@@ -1,82 +0,0 @@
1
- const TRAIL_COLOR = '#e87f54';
2
- function parseHexColor(hex) {
3
- const m = /^#([0-9a-f]{6}|[0-9a-f]{8})$/i.exec(hex);
4
- if (!m)
5
- throw new Error(`invalid trail color: ${hex}`);
6
- const [r, g, b, a] = [0, 2, 4, 6].map((i) => i < m[1].length ? Number.parseInt(m[1].slice(i, i + 2), 16) : 255);
7
- return { r, g, b, a: a / 255 };
8
- }
9
- function rgba(c, alpha) {
10
- return `rgba(${c.r},${c.g},${c.b},${Math.round(alpha * 10000) / 10000})`;
11
- }
12
- function luminance(c) {
13
- const linear = (v) => {
14
- const s = v / 255;
15
- return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
16
- };
17
- return 0.2126 * linear(c.r) + 0.7152 * linear(c.g) + 0.0722 * linear(c.b);
18
- }
19
- function mix(base, tint, amount) {
20
- const k = (x, y) => Math.round(x + (y - x) * amount);
21
- return { r: k(base.r, tint.r), g: k(base.g, tint.g), b: k(base.b, tint.b), a: 1 };
22
- }
23
- const CASING_ANCHORS = {
24
- satellite: {
25
- anchor: { r: 10, g: 14, b: 20, a: 1 },
26
- opposite: { r: 255, g: 255, b: 255, a: 1 },
27
- alpha: 0.9,
28
- },
29
- topo: {
30
- anchor: { r: 255, g: 255, b: 255, a: 1 },
31
- opposite: { r: 10, g: 14, b: 20, a: 1 },
32
- alpha: 1,
33
- },
34
- };
35
- const CONTRAST_FLIP = 0.18;
36
- const CORE_TINT = 0.2;
37
- function deriveCasing(style, core) {
38
- const { anchor, opposite, alpha } = CASING_ANCHORS[style];
39
- const base = Math.abs(luminance(core) - luminance(anchor)) < CONTRAST_FLIP ? opposite : anchor;
40
- return rgba(mix(base, core, CORE_TINT), alpha);
41
- }
42
- const GLOW_ALPHA = { satellite: 0.32, topo: 0.26 };
43
- function trailGlow(alpha) {
44
- return rgba(parseHexColor(TRAIL_COLOR), alpha);
45
- }
46
- const THEMES = {
47
- satellite: {
48
- core: TRAIL_COLOR,
49
- trailCore: TRAIL_COLOR,
50
- glow: trailGlow(GLOW_ALPHA.satellite),
51
- casing: 'rgba(10,14,20,0.9)',
52
- ghost: '#ffffff',
53
- ghostOpacity: 0.85,
54
- ghostCasing: 'rgba(8,12,18,0.55)',
55
- discBg: 'rgba(10,14,20,0.82)',
56
- vignette: 0.16,
57
- },
58
- topo: {
59
- core: TRAIL_COLOR,
60
- trailCore: TRAIL_COLOR,
61
- glow: trailGlow(GLOW_ALPHA.topo),
62
- casing: '#ffffff',
63
- ghost: '#6b6252',
64
- ghostOpacity: 0.7,
65
- ghostCasing: 'rgba(255,255,255,0.8)',
66
- discBg: 'rgba(26,22,18,0.85)',
67
- vignette: 0.06,
68
- },
69
- };
70
- export function themeFor(style, trailColor = null) {
71
- const base = THEMES[style];
72
- if (trailColor === null)
73
- return base;
74
- const core = parseHexColor(trailColor);
75
- return {
76
- ...base,
77
- core: rgba(core, 1),
78
- trailCore: trailColor,
79
- glow: rgba(core, GLOW_ALPHA[style] * core.a),
80
- casing: deriveCasing(style, core),
81
- };
82
- }