drone-path 0.12.1 → 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.
- package/README.md +20 -74
- package/THIRD-PARTY-NOTICES.md +3 -82
- package/bin/drone-path.mjs +0 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +7 -7
- package/dist/version.d.ts +1 -0
- package/package.json +21 -68
- package/CHANGELOG.md +0 -336
- package/app/ipc.d.mts +0 -43
- package/app/ipc.mjs +0 -216
- package/app/main.mjs +0 -356
- package/app/preload.cjs +0 -34
- package/app/update-policy.d.mts +0 -6
- package/app/update-policy.mjs +0 -6
- package/app/update.d.mts +0 -10
- package/app/update.mjs +0 -54
- package/dist/appassets.js +0 -35
- package/dist/apppaths.js +0 -20
- package/dist/appsession.js +0 -121
- package/dist/appstate.js +0 -94
- package/dist/assets.js +0 -60
- package/dist/buildinfo.js +0 -64
- package/dist/cammeta-decode.js +0 -237
- package/dist/cammeta.js +0 -92
- package/dist/changeset-gate.js +0 -39
- package/dist/config.js +0 -631
- package/dist/configfile.js +0 -86
- package/dist/decimate.js +0 -84
- package/dist/errors.js +0 -34
- package/dist/exec-tool.js +0 -13
- package/dist/exportjob.js +0 -90
- package/dist/ffmpeg-tools.js +0 -56
- package/dist/ffmpeg.js +0 -98
- package/dist/frametime.js +0 -32
- package/dist/geo.js +0 -60
- package/dist/logging.js +0 -1
- package/dist/manual/anchors.js +0 -17
- package/dist/manual/build.js +0 -67
- package/dist/manual/cliref.js +0 -34
- package/dist/manual/links.js +0 -59
- package/dist/manual/markdown.js +0 -98
- package/dist/manual/model.js +0 -1
- package/dist/manual/module.js +0 -5
- package/dist/manual/nav.js +0 -11
- package/dist/manual/reference.js +0 -18
- package/dist/paths.js +0 -16
- package/dist/pipeline.js +0 -402
- package/dist/plan.js +0 -106
- package/dist/png.js +0 -32
- package/dist/protobuf-wire.js +0 -102
- package/dist/range.js +0 -50
- package/dist/recordings.js +0 -55
- package/dist/render-page.js +0 -85
- package/dist/render.js +0 -268
- package/dist/renderer/boot.js +0 -7
- package/dist/renderer/dom.js +0 -177
- package/dist/renderer/framemath.js +0 -30
- package/dist/renderer/scene.js +0 -385
- package/dist/renderer/theme.js +0 -82
- package/dist/renderer/tilesources.js +0 -38
- package/dist/renderer/trail.js +0 -42
- package/dist/restyle.js +0 -16
- package/dist/serve.js +0 -27
- package/dist/srt.js +0 -98
- package/dist/telemetry-json-schema.js +0 -18
- package/dist/telemetry-json.js +0 -126
- package/dist/telemetry-math.js +0 -267
- package/dist/telemetry-summary.js +0 -19
- package/dist/telemetry.js +0 -95
- package/dist/tilecache.js +0 -21
- package/dist/tiles.js +0 -155
- package/dist/track-format.js +0 -13
- package/dist/track-geojson.js +0 -44
- package/dist/track-gpx.js +0 -34
- package/dist/track-kml.js +0 -47
- package/dist/track-kmz.js +0 -68
- package/dist/track-write.js +0 -41
- package/dist/track.js +0 -79
package/dist/render.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { once } from 'node:events';
|
|
4
|
-
import { MIME } from './assets.js';
|
|
5
|
-
import { ERR_RENDER_CANCELED, errorMessage } from './errors.js';
|
|
6
|
-
import { RENDERER_DIR, serveAsset } from './serve.js';
|
|
7
|
-
const PAGE_LOAD_TIMEOUT_MS = 60000;
|
|
8
|
-
const SCREENSHOT_TIMEOUT_MS = 60000;
|
|
9
|
-
function startServer({ html, style, tileCache, }) {
|
|
10
|
-
const server = http.createServer((req, res) => {
|
|
11
|
-
let url;
|
|
12
|
-
try {
|
|
13
|
-
url = decodeURIComponent((req.url ?? '/').split('?')[0]);
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
17
|
-
res.end('bad request');
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (url === '/' || url === '/index.html') {
|
|
21
|
-
res.writeHead(200, { 'Content-Type': MIME['.html'] });
|
|
22
|
-
res.end(html);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
if (serveAsset(url, res, { style, tileCache, rendererDir: RENDERER_DIR }))
|
|
26
|
-
return;
|
|
27
|
-
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
28
|
-
res.end('not found');
|
|
29
|
-
});
|
|
30
|
-
return new Promise((resolve) => {
|
|
31
|
-
server.listen(0, '127.0.0.1', () => {
|
|
32
|
-
const addr = server.address();
|
|
33
|
-
const port = addr && typeof addr === 'object' ? addr.port : 0;
|
|
34
|
-
resolve({ server, url: `http://127.0.0.1:${port}/` });
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async function launchBrowser(log, browserPath) {
|
|
39
|
-
const { chromium } = await import('playwright-core');
|
|
40
|
-
const attempts = [];
|
|
41
|
-
if (browserPath)
|
|
42
|
-
attempts.push({ executablePath: browserPath });
|
|
43
|
-
attempts.push({ channel: 'chrome' }, { channel: 'msedge' }, {});
|
|
44
|
-
const attemptErrors = [];
|
|
45
|
-
for (const opt of attempts) {
|
|
46
|
-
try {
|
|
47
|
-
const browser = await chromium.launch({ headless: true, ...opt });
|
|
48
|
-
log(`browser: ${opt.executablePath ?? opt.channel ?? 'playwright-registry'}`);
|
|
49
|
-
return browser;
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
attemptErrors.push(e);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
throw new Error(`could not launch a Chromium browser (tried explicit path, channel=chrome, channel=msedge, playwright registry): ${errorMessage(attemptErrors[attemptErrors.length - 1])}. ` +
|
|
56
|
-
'Install Google Chrome or Microsoft Edge, run "npx playwright install chromium", ' +
|
|
57
|
-
'or pass --browser <path>.', { cause: new AggregateError(attemptErrors, 'all browser launch attempts failed') });
|
|
58
|
-
}
|
|
59
|
-
// x265's CRF scale sits ~5 points above x264's for the same perceived quality.
|
|
60
|
-
const CRF = {
|
|
61
|
-
h264: { 'near-lossless': 16, high: 18, medium: 21, low: 26 },
|
|
62
|
-
h265: { 'near-lossless': 20, high: 22, medium: 25, low: 30 },
|
|
63
|
-
};
|
|
64
|
-
function spawnEncoder(ffmpeg, fpsStr, encode, outPath) {
|
|
65
|
-
// h265 gets hvc1: the ffmpeg-default hev1 tag is refused by QuickTime and some NLEs.
|
|
66
|
-
const codecArgs = encode.codec === 'h265' ? ['-c:v', 'libx265', '-tag:v', 'hvc1'] : ['-c:v', 'libx264'];
|
|
67
|
-
const ffmpegProcess = spawn(ffmpeg, [
|
|
68
|
-
'-hide_banner', '-loglevel', 'error', '-y',
|
|
69
|
-
'-f', 'image2pipe', '-framerate', fpsStr, '-i', '-',
|
|
70
|
-
...codecArgs,
|
|
71
|
-
'-preset', encode.preset,
|
|
72
|
-
'-crf', String(CRF[encode.codec][encode.quality]),
|
|
73
|
-
'-pix_fmt', 'yuv420p', '-r', fpsStr,
|
|
74
|
-
'-movflags', '+faststart', outPath,
|
|
75
|
-
], { stdio: ['pipe', 'ignore', 'pipe'] });
|
|
76
|
-
let stderr = '';
|
|
77
|
-
ffmpegProcess.stderr?.on('data', (d) => {
|
|
78
|
-
stderr += d.toString();
|
|
79
|
-
});
|
|
80
|
-
// ffmpeg's stdin must never surface an unhandled 'error' (EPIPE on early exit); a drain-waiter must wake when the encoder dies.
|
|
81
|
-
const closed = new Promise((resolve) => {
|
|
82
|
-
ffmpegProcess.once('close', (code) => resolve(code));
|
|
83
|
-
});
|
|
84
|
-
const stopped = new Promise((resolve) => {
|
|
85
|
-
ffmpegProcess.stdin.on('error', (e) => resolve(`ffmpeg stdin error: ${e.message}`));
|
|
86
|
-
void closed.then((code) => resolve(`ffmpeg exited with code ${code}`));
|
|
87
|
-
});
|
|
88
|
-
return {
|
|
89
|
-
stdin: ffmpegProcess.stdin,
|
|
90
|
-
stopped,
|
|
91
|
-
closed,
|
|
92
|
-
stderrText: () => stderr,
|
|
93
|
-
kill: () => ffmpegProcess.kill(),
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
class OrderedFrameStream {
|
|
97
|
-
encoder;
|
|
98
|
-
pending = new Map();
|
|
99
|
-
nextIndex = 0;
|
|
100
|
-
constructor(encoder) {
|
|
101
|
-
this.encoder = encoder;
|
|
102
|
-
}
|
|
103
|
-
async submit(index, frame) {
|
|
104
|
-
this.pending.set(index, frame);
|
|
105
|
-
await this.flushReady();
|
|
106
|
-
}
|
|
107
|
-
async flushReady() {
|
|
108
|
-
while (this.pending.has(this.nextIndex)) {
|
|
109
|
-
const frame = this.pending.get(this.nextIndex);
|
|
110
|
-
this.pending.delete(this.nextIndex);
|
|
111
|
-
if (!this.encoder.stdin.write(frame)) {
|
|
112
|
-
const woke = await Promise.race([
|
|
113
|
-
once(this.encoder.stdin, 'drain').then(() => 'drain'),
|
|
114
|
-
this.encoder.stopped,
|
|
115
|
-
]);
|
|
116
|
-
if (woke !== 'drain') {
|
|
117
|
-
const stderr = this.encoder.stderrText().trim();
|
|
118
|
-
throw new Error(`${woke}${stderr ? `: ${stderr}` : ''}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
this.nextIndex++;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
end() {
|
|
125
|
-
this.encoder.stdin.end();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function screenshotOptions(capture) {
|
|
129
|
-
return capture === 'jpeg'
|
|
130
|
-
? {
|
|
131
|
-
type: 'jpeg',
|
|
132
|
-
quality: 95,
|
|
133
|
-
animations: 'disabled',
|
|
134
|
-
timeout: SCREENSHOT_TIMEOUT_MS,
|
|
135
|
-
}
|
|
136
|
-
: {
|
|
137
|
-
type: 'png',
|
|
138
|
-
animations: 'disabled',
|
|
139
|
-
timeout: SCREENSHOT_TIMEOUT_MS,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
async function captureFrame(run, loop, page, idx) {
|
|
143
|
-
const evalStart = Date.now();
|
|
144
|
-
await page.evaluate((frame) => globalThis.__setFrame(frame), run.frameStart + idx);
|
|
145
|
-
run.timing.evalMs += Date.now() - evalStart;
|
|
146
|
-
const captureStart = Date.now();
|
|
147
|
-
const buf = await page.screenshot(screenshotOptions(run.capture));
|
|
148
|
-
run.timing.captureMs += Date.now() - captureStart;
|
|
149
|
-
const done = ++loop.capturesDone;
|
|
150
|
-
const emitStart = Date.now();
|
|
151
|
-
await run.stream.submit(idx, buf);
|
|
152
|
-
run.timing.emitMs += Date.now() - emitStart;
|
|
153
|
-
if (done % 100 === 0 || done === run.frames) {
|
|
154
|
-
run.log(`frames: ${done}/${run.frames} captured`);
|
|
155
|
-
run.onCapture?.({ done, total: run.frames });
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async function workerLoop(run, loop, workerId) {
|
|
159
|
-
const page = await run.active.newPage({
|
|
160
|
-
viewport: { width: run.width, height: run.height },
|
|
161
|
-
deviceScaleFactor: 1,
|
|
162
|
-
});
|
|
163
|
-
try {
|
|
164
|
-
await page.goto(run.url, { waitUntil: 'domcontentloaded', timeout: PAGE_LOAD_TIMEOUT_MS });
|
|
165
|
-
await page.waitForFunction('window.__READY === true', null, { timeout: PAGE_LOAD_TIMEOUT_MS });
|
|
166
|
-
for (;;) {
|
|
167
|
-
if (loop.failed)
|
|
168
|
-
return;
|
|
169
|
-
if (run.signal?.aborted)
|
|
170
|
-
throw new Error(ERR_RENDER_CANCELED);
|
|
171
|
-
const idx = loop.cursor++;
|
|
172
|
-
if (idx >= run.frames)
|
|
173
|
-
break;
|
|
174
|
-
await captureFrame(run, loop, page, idx);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
finally {
|
|
178
|
-
await page.close().catch(() => { });
|
|
179
|
-
}
|
|
180
|
-
run.log(`worker ${workerId} done`);
|
|
181
|
-
}
|
|
182
|
-
async function runWorkers(run, workerCount) {
|
|
183
|
-
const loop = { cursor: 0, capturesDone: 0, failed: false };
|
|
184
|
-
const settled = await Promise.allSettled(Array.from({ length: workerCount }, (_, i) => workerLoop(run, loop, i + 1).catch((e) => {
|
|
185
|
-
loop.failed = true;
|
|
186
|
-
throw e;
|
|
187
|
-
})));
|
|
188
|
-
const rejected = settled.find((r) => r.status === 'rejected');
|
|
189
|
-
if (rejected)
|
|
190
|
-
throw rejected.reason;
|
|
191
|
-
}
|
|
192
|
-
async function finishEncode(encoder, stream, log, outPath) {
|
|
193
|
-
await stream.flushReady();
|
|
194
|
-
stream.end();
|
|
195
|
-
const code = await encoder.closed;
|
|
196
|
-
if (code !== 0) {
|
|
197
|
-
throw new Error(`ffmpeg exited with code ${code}: ${encoder.stderrText().trim()}`);
|
|
198
|
-
}
|
|
199
|
-
log(`encoded: ${outPath}`);
|
|
200
|
-
}
|
|
201
|
-
function formatProfile(profile, workerCount) {
|
|
202
|
-
return (`profile: eval=${(profile.evalMs / 1000).toFixed(1)}s capture=${(profile.captureMs / 1000).toFixed(1)}s ` +
|
|
203
|
-
`encode-backpressure=${(profile.emitMs / 1000).toFixed(1)}s (summed over ${workerCount} workers)`);
|
|
204
|
-
}
|
|
205
|
-
async function captureAndEncode(active, env) {
|
|
206
|
-
const { ctx, url, timing, workerCount } = env;
|
|
207
|
-
const { fpsStr, codec, quality, preset, outPath, signal, log, tools } = ctx;
|
|
208
|
-
const encoder = spawnEncoder(tools.ffmpeg, fpsStr, { codec, quality, preset }, outPath);
|
|
209
|
-
const killOnAbort = () => encoder.kill();
|
|
210
|
-
signal?.addEventListener('abort', killOnAbort, { once: true });
|
|
211
|
-
const stream = new OrderedFrameStream(encoder);
|
|
212
|
-
try {
|
|
213
|
-
await runWorkers({ ...ctx, active, url, stream, timing }, workerCount);
|
|
214
|
-
await finishEncode(encoder, stream, log, outPath);
|
|
215
|
-
}
|
|
216
|
-
catch (e) {
|
|
217
|
-
encoder.kill();
|
|
218
|
-
throw e;
|
|
219
|
-
}
|
|
220
|
-
finally {
|
|
221
|
-
signal?.removeEventListener('abort', killOnAbort);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
function reportProfile(env) {
|
|
225
|
-
const { ctx, timing, workerCount } = env;
|
|
226
|
-
const profile = {
|
|
227
|
-
evalMs: Math.round(timing.evalMs),
|
|
228
|
-
captureMs: Math.round(timing.captureMs),
|
|
229
|
-
emitMs: Math.round(timing.emitMs),
|
|
230
|
-
};
|
|
231
|
-
ctx.log(formatProfile(profile, workerCount));
|
|
232
|
-
return { profile };
|
|
233
|
-
}
|
|
234
|
-
export async function renderVideo(opts) {
|
|
235
|
-
const { html, style, tileCache, width, height, frames, fpsStr, workers, outPath, log = () => { }, browserPath = null, tools, capture = 'jpeg', codec = 'h264', quality = 'high', preset = 'medium', frameStart = 0, signal, onCapture, } = opts;
|
|
236
|
-
const workerCount = Math.max(1, Math.min(workers, frames));
|
|
237
|
-
const ctx = {
|
|
238
|
-
width,
|
|
239
|
-
height,
|
|
240
|
-
frames,
|
|
241
|
-
frameStart,
|
|
242
|
-
fpsStr,
|
|
243
|
-
outPath,
|
|
244
|
-
capture,
|
|
245
|
-
codec,
|
|
246
|
-
quality,
|
|
247
|
-
preset,
|
|
248
|
-
signal,
|
|
249
|
-
log,
|
|
250
|
-
onCapture,
|
|
251
|
-
tools,
|
|
252
|
-
};
|
|
253
|
-
if (signal?.aborted)
|
|
254
|
-
throw new Error(ERR_RENDER_CANCELED);
|
|
255
|
-
const timing = { evalMs: 0, captureMs: 0, emitMs: 0 };
|
|
256
|
-
const { server, url } = await startServer({ html, style, tileCache });
|
|
257
|
-
const env = { ctx, url, timing, workerCount };
|
|
258
|
-
let browser = null;
|
|
259
|
-
try {
|
|
260
|
-
browser = await launchBrowser(log, browserPath);
|
|
261
|
-
await captureAndEncode(browser, env);
|
|
262
|
-
}
|
|
263
|
-
finally {
|
|
264
|
-
await browser?.close().catch(() => { });
|
|
265
|
-
server.close();
|
|
266
|
-
}
|
|
267
|
-
return reportProfile(env);
|
|
268
|
-
}
|
package/dist/renderer/boot.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createScene } from './scene.js';
|
|
2
|
-
export function bootScene(host, data, L, opts) {
|
|
3
|
-
const scene = createScene(host, data, { L, hudHost: opts?.hudHost });
|
|
4
|
-
// The pane size may only settle after creation; re-measure post-layout.
|
|
5
|
-
requestAnimationFrame(() => scene.relayout());
|
|
6
|
-
return scene;
|
|
7
|
-
}
|
package/dist/renderer/dom.js
DELETED
|
@@ -1,177 +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 function hudMarkup(hud) {
|
|
116
|
-
const chips = [];
|
|
117
|
-
if (hud.heading) {
|
|
118
|
-
chips.push('<div class="chip" id="chip-heading"><span class="label">HDG</span><span class="chip-arrow">▲</span><span class="num">--</span></div>');
|
|
119
|
-
}
|
|
120
|
-
if (hud.alt) {
|
|
121
|
-
chips.push('<div class="chip" id="chip-alt"><span class="label">ALT</span><span class="num">--</span><span class="unit">m</span></div>');
|
|
122
|
-
}
|
|
123
|
-
if (hud.speed) {
|
|
124
|
-
chips.push('<div class="chip" id="chip-speed"><span class="label">SPD</span><span class="num">--</span><span class="unit">m/s</span></div>');
|
|
125
|
-
}
|
|
126
|
-
return chips.map((chip) => ` ${chip}`).join('\n');
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* The app strip's readout columns (#272): both always render so the strip's
|
|
130
|
-
* shape never depends on settings; a disabled chip keeps its column and shows
|
|
131
|
-
* the dimmed "--" placeholder instead of a value. The ids and .num/.unit spans
|
|
132
|
-
* match the export HUD contract, so the scene's value queries work for both.
|
|
133
|
-
*/
|
|
134
|
-
export function stripReadoutMarkup(hud) {
|
|
135
|
-
const column = (id, label, unit, live) => `<div class="map-readout${live ? '' : ' map-readout-off'}" id="chip-${id}">` +
|
|
136
|
-
`<span class="label">${label}</span>` +
|
|
137
|
-
`<span class="value"><span class="num">--</span><span class="unit">${unit}</span></span>` +
|
|
138
|
-
`</div>`;
|
|
139
|
-
return [
|
|
140
|
-
column('speed', 'Speed', 'm/s', hud.speed),
|
|
141
|
-
column('alt', 'Altitude', 'm', hud.alt),
|
|
142
|
-
]
|
|
143
|
-
.map((col) => ` ${col}`)
|
|
144
|
-
.join('\n');
|
|
145
|
-
}
|
|
146
|
-
/** A null hud keeps the chips out of the map frame: the caller mounts them in
|
|
147
|
-
a strip outside the map image instead. */
|
|
148
|
-
export function mapMarkup(hud, attribution) {
|
|
149
|
-
const hudBlock = hud === null ? '' : `<div id="hud">
|
|
150
|
-
${hudMarkup(hud)}
|
|
151
|
-
</div>
|
|
152
|
-
`;
|
|
153
|
-
return `<div id="map-frame">
|
|
154
|
-
<div id="map"></div>
|
|
155
|
-
<div id="vignette"></div>
|
|
156
|
-
${hudBlock}<div id="attr">${attribution}</div>
|
|
157
|
-
<div id="scalebar"><span id="scaletext"></span><div id="scaleline"></div></div>
|
|
158
|
-
</div>`;
|
|
159
|
-
}
|
|
160
|
-
/** Attribution links are on-screen credits, not controls: keyboard skips them. */
|
|
161
|
-
export function quietAttributionLinks(attr) {
|
|
162
|
-
for (const a of attr.querySelectorAll('a'))
|
|
163
|
-
a.setAttribute('tabindex', '-1');
|
|
164
|
-
}
|
|
165
|
-
export function droneMarkerMarkup(coreColor) {
|
|
166
|
-
return ('<div class="drone-wrap"><div class="drone-arrow" id="drone-arrow">' +
|
|
167
|
-
'<svg viewBox="0 0 24 24"><path d="M12 1.8 L21 22 L12 16.9 L3 22 Z" fill="' +
|
|
168
|
-
coreColor +
|
|
169
|
-
'" stroke="rgba(255,255,255,0.9)" stroke-width="0.9" stroke-linejoin="round"/></svg>' +
|
|
170
|
-
'</div></div>');
|
|
171
|
-
}
|
|
172
|
-
export function el(root, selector) {
|
|
173
|
-
const found = root.querySelector(selector);
|
|
174
|
-
if (!found)
|
|
175
|
-
throw new Error(`renderer element missing: ${selector}`);
|
|
176
|
-
return found;
|
|
177
|
-
}
|
|
@@ -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
|
-
}
|