drone-path-engine 1.2.1 → 2.0.0
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 +3 -1
- package/dist/config.d.ts +11 -12
- package/dist/config.js +14 -35
- package/dist/paths.d.ts +1 -2
- package/dist/paths.js +1 -7
- package/dist/pipeline.d.ts +1 -5
- package/dist/pipeline.js +14 -35
- package/dist/plan.d.ts +0 -9
- package/dist/plan.js +0 -12
- package/dist/render-page.d.ts +1 -8
- package/dist/render-page.js +3 -8
- package/dist/render.d.ts +0 -1
- package/dist/render.js +2 -3
- package/dist/renderer/framemath.d.ts +0 -1
- package/dist/renderer/framemath.js +0 -11
- package/dist/renderer/scene.d.ts +0 -2
- package/dist/renderer/scene.js +56 -25
- package/dist/renderer/theme.d.ts +1 -0
- package/dist/renderer/theme.js +1 -1
- package/dist/renderer/trail.d.ts +2 -0
- package/dist/renderer/trail.js +41 -11
- package/dist/restyle.js +0 -1
- package/dist/tiles.js +29 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -15,7 +15,9 @@ import { DEFAULT_CONFIG } from 'drone-path-engine/config';
|
|
|
15
15
|
import { runBatch } from 'drone-path-engine/pipeline';
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Each module ships TypeScript declarations.
|
|
18
|
+
Each module ships TypeScript declarations. If you construct a `RenderConfig`,
|
|
19
|
+
remove the retired `introSec` and `outroSec` fields. Renders use the selected
|
|
20
|
+
camera mode for the entire recording.
|
|
19
21
|
|
|
20
22
|
Install `@types/node` for your Node.js major version. In TypeScript 6, list
|
|
21
23
|
`node` in `compilerOptions.types` to load the Node declarations.
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { FfmpegToolOverrides } from 'drone-path-core/ffmpeg-tools';
|
|
2
|
-
import type { FrameRange } from 'drone-path-core/frame-range';
|
|
3
2
|
export declare const MAP_STYLE_VALUES: readonly ["satellite", "topo"];
|
|
4
3
|
export type MapStyle = (typeof MAP_STYLE_VALUES)[number];
|
|
5
4
|
declare const VIEW_MODE_VALUES: readonly ["follow", "overview"];
|
|
@@ -26,8 +25,6 @@ export interface RenderConfig extends FfmpegToolOverrides {
|
|
|
26
25
|
view: ViewMode;
|
|
27
26
|
zoom: number;
|
|
28
27
|
zoomOut: number;
|
|
29
|
-
introSec: number;
|
|
30
|
-
outroSec: number;
|
|
31
28
|
trailColor: string | null;
|
|
32
29
|
hud: HudLayout;
|
|
33
30
|
workers: number;
|
|
@@ -95,12 +92,6 @@ export declare const OVERRIDE_NORMALIZERS: {
|
|
|
95
92
|
zoomOut: (v: unknown, name: string) => {
|
|
96
93
|
zoomOut: number;
|
|
97
94
|
};
|
|
98
|
-
introSec: (v: unknown, name: string) => {
|
|
99
|
-
introSec: number;
|
|
100
|
-
};
|
|
101
|
-
outroSec: (v: unknown, name: string) => {
|
|
102
|
-
outroSec: number;
|
|
103
|
-
};
|
|
104
95
|
trailColor: (v: unknown, name: string) => {
|
|
105
96
|
trailColor: string | null;
|
|
106
97
|
};
|
|
@@ -176,11 +167,20 @@ export declare function assertOneTrackOutSpelling(entries: readonly {
|
|
|
176
167
|
}[]): void;
|
|
177
168
|
export declare function cliDefaultOf(key: keyof RenderConfig): string | boolean;
|
|
178
169
|
export declare const DEFAULT_CONFIG: RenderConfig;
|
|
170
|
+
export declare const RETIRED_ZOOM_OPTIONS: readonly [{
|
|
171
|
+
readonly key: "introSec";
|
|
172
|
+
readonly flags: "--intro-sec <s>";
|
|
173
|
+
}, {
|
|
174
|
+
readonly key: "outroSec";
|
|
175
|
+
readonly flags: "--outro-sec <s>";
|
|
176
|
+
}];
|
|
177
|
+
export declare const RETIRED_ZOOM_HELP = "Deprecated and ignored. Remove this option from your settings.";
|
|
178
|
+
export declare function retiredZoomWarning(option: string): string;
|
|
179
179
|
export declare function normalizeOverrides(raw: Record<string, unknown>, origin: string, onDeprecated?: (message: string) => void): ConfigOverrides;
|
|
180
180
|
export declare function effectiveZoomOut(config: Pick<RenderConfig, 'zoom' | 'zoomOut'>): number;
|
|
181
|
-
declare const LOOK_SETTINGS_KEYS: readonly ["style", "view", "zoom", "zoomOut", "hud", "
|
|
181
|
+
declare const LOOK_SETTINGS_KEYS: readonly ["style", "view", "zoom", "zoomOut", "hud", "trailColor"];
|
|
182
182
|
declare const ENCODE_SETTINGS_KEYS: readonly ["codec", "quality", "preset"];
|
|
183
|
-
export declare const SETTINGS_KEYS: readonly ["style", "view", "zoom", "zoomOut", "hud", "
|
|
183
|
+
export declare const SETTINGS_KEYS: readonly ["style", "view", "zoom", "zoomOut", "hud", "trailColor", "codec", "quality", "preset"];
|
|
184
184
|
export type AppearanceSettings = Pick<RenderConfig, (typeof LOOK_SETTINGS_KEYS)[number]>;
|
|
185
185
|
export type EncodeSettings = Pick<RenderConfig, (typeof ENCODE_SETTINGS_KEYS)[number]>;
|
|
186
186
|
export type SettingsPatch = Pick<RenderConfig, (typeof SETTINGS_KEYS)[number]>;
|
|
@@ -202,7 +202,6 @@ export declare function finalizeRenderConfig(config: RenderConfig): RenderConfig
|
|
|
202
202
|
export interface ExportRequest {
|
|
203
203
|
outPath: string;
|
|
204
204
|
config: RenderConfig;
|
|
205
|
-
range: FrameRange | null;
|
|
206
205
|
}
|
|
207
206
|
export declare function parseExportRequest(raw: unknown, base: RenderConfig): ExportRequest;
|
|
208
207
|
export {};
|
package/dist/config.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { parseFrameRange } from 'drone-path-core/frame-range';
|
|
3
2
|
import { asRecord, isRecord, numberValue, parseValue, strictShape } from 'drone-path-core/validation';
|
|
4
3
|
export const MAP_STYLE_VALUES = ['satellite', 'topo'];
|
|
5
4
|
const VIEW_MODE_VALUES = ['follow', 'overview'];
|
|
@@ -113,8 +112,6 @@ export const OVERRIDE_NORMALIZERS = {
|
|
|
113
112
|
view: (v, name) => ({ view: parseValue(enumValue(name, VIEW_MODE_VALUES), v) }),
|
|
114
113
|
zoom: (v, name) => ({ zoom: parseValue(numberValue(name), v) }),
|
|
115
114
|
zoomOut: (v, name) => ({ zoomOut: parseValue(numberValue(name), v) }),
|
|
116
|
-
introSec: (v, name) => ({ introSec: parseValue(numberValue(name), v) }),
|
|
117
|
-
outroSec: (v, name) => ({ outroSec: parseValue(numberValue(name), v) }),
|
|
118
115
|
trailColor: (v, name) => ({ trailColor: asTrailColor(v, name) }),
|
|
119
116
|
hud: (v, name) => ({ hud: parseHud(parseValue(stringValue(name), v)) }),
|
|
120
117
|
workers: (v, name) => ({ workers: parseValue(numberValue(name), v) }),
|
|
@@ -185,18 +182,6 @@ export const CONFIG_OPTIONS = [
|
|
|
185
182
|
default: 1,
|
|
186
183
|
normalize: OVERRIDE_NORMALIZERS.zoomOut,
|
|
187
184
|
},
|
|
188
|
-
{
|
|
189
|
-
key: 'introSec',
|
|
190
|
-
cli: { flags: '--intro-sec <s>', help: 'intro: zoom in from one level out over s seconds', parse: cliNumber },
|
|
191
|
-
default: 2,
|
|
192
|
-
normalize: OVERRIDE_NORMALIZERS.introSec,
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
key: 'outroSec',
|
|
196
|
-
cli: { flags: '--outro-sec <s>', help: 'outro: zoom back out over s seconds', parse: cliNumber },
|
|
197
|
-
default: 2,
|
|
198
|
-
normalize: OVERRIDE_NORMALIZERS.outroSec,
|
|
199
|
-
},
|
|
200
185
|
{
|
|
201
186
|
key: 'trailColor',
|
|
202
187
|
cli: {
|
|
@@ -361,11 +346,20 @@ export function cliDefaultOf(key) {
|
|
|
361
346
|
}
|
|
362
347
|
export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
|
|
363
348
|
Object.freeze(DEFAULT_CONFIG.hud);
|
|
349
|
+
export const RETIRED_ZOOM_OPTIONS = [
|
|
350
|
+
{ key: 'introSec', flags: '--intro-sec <s>' },
|
|
351
|
+
{ key: 'outroSec', flags: '--outro-sec <s>' },
|
|
352
|
+
];
|
|
353
|
+
export const RETIRED_ZOOM_HELP = 'Deprecated and ignored. Remove this option from your settings.';
|
|
354
|
+
export function retiredZoomWarning(option) {
|
|
355
|
+
return `deprecated option ${option} is ignored: automatic opening and closing zoom has been removed`;
|
|
356
|
+
}
|
|
364
357
|
const OVERRIDE_SHAPE = {
|
|
365
358
|
...Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, z.unknown().optional()])),
|
|
366
359
|
// The deprecated alias is accepted as an input spelling only; it never
|
|
367
360
|
// becomes its own config key.
|
|
368
361
|
[TELEMETRY_JSON_ALIAS.inputKey]: z.unknown().optional(),
|
|
362
|
+
...Object.fromEntries(RETIRED_ZOOM_OPTIONS.map(({ key }) => [key, z.unknown().optional()])),
|
|
369
363
|
};
|
|
370
364
|
export function normalizeOverrides(raw, origin, onDeprecated) {
|
|
371
365
|
parseValue(strictShape(OVERRIDE_SHAPE, {
|
|
@@ -376,6 +370,10 @@ export function normalizeOverrides(raw, origin, onDeprecated) {
|
|
|
376
370
|
for (const key of Object.keys(raw)) {
|
|
377
371
|
if (key === TELEMETRY_JSON_ALIAS.inputKey)
|
|
378
372
|
continue;
|
|
373
|
+
if (RETIRED_ZOOM_OPTIONS.some((option) => option.key === key)) {
|
|
374
|
+
onDeprecated?.(retiredZoomWarning(key));
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
379
377
|
const normalize = OVERRIDE_NORMALIZERS[key];
|
|
380
378
|
const value = raw[key];
|
|
381
379
|
if (value === undefined)
|
|
@@ -400,8 +398,6 @@ const LOOK_SETTINGS_KEYS = [
|
|
|
400
398
|
'zoom',
|
|
401
399
|
'zoomOut',
|
|
402
400
|
'hud',
|
|
403
|
-
'introSec',
|
|
404
|
-
'outroSec',
|
|
405
401
|
'trailColor',
|
|
406
402
|
];
|
|
407
403
|
const ENCODE_SETTINGS_KEYS = ['codec', 'quality', 'preset'];
|
|
@@ -415,8 +411,6 @@ export function appearanceOf(config) {
|
|
|
415
411
|
zoom: config.zoom,
|
|
416
412
|
zoomOut: config.zoomOut,
|
|
417
413
|
hud: { ...config.hud },
|
|
418
|
-
introSec: config.introSec,
|
|
419
|
-
outroSec: config.outroSec,
|
|
420
414
|
trailColor: config.trailColor,
|
|
421
415
|
};
|
|
422
416
|
}
|
|
@@ -464,10 +458,6 @@ export function parseAppearanceSettings(raw) {
|
|
|
464
458
|
const zoomOut = parseValue(numberValue('zoom-out'), look.zoomOut);
|
|
465
459
|
requireNonNegative(zoom, 'zoom must be >= 0 (0 = auto-fit)');
|
|
466
460
|
requireNonNegative(zoomOut, 'zoom-out must be >= 0');
|
|
467
|
-
const introSec = parseValue(numberValue('intro'), look.introSec);
|
|
468
|
-
const outroSec = parseValue(numberValue('outro'), look.outroSec);
|
|
469
|
-
requireNonNegative(introSec, 'intro must be 0 or more');
|
|
470
|
-
requireNonNegative(outroSec, 'outro must be 0 or more');
|
|
471
461
|
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
472
462
|
const chips = asRecord(hud);
|
|
473
463
|
return {
|
|
@@ -476,8 +466,6 @@ export function parseAppearanceSettings(raw) {
|
|
|
476
466
|
zoom,
|
|
477
467
|
zoomOut,
|
|
478
468
|
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
479
|
-
introSec,
|
|
480
|
-
outroSec,
|
|
481
469
|
trailColor,
|
|
482
470
|
};
|
|
483
471
|
}
|
|
@@ -514,8 +502,6 @@ export function isValidRenderConfig(config) {
|
|
|
514
502
|
isValidWorkerCount(config.workers) &&
|
|
515
503
|
isNonNegative(config.zoom) &&
|
|
516
504
|
isNonNegative(config.zoomOut) &&
|
|
517
|
-
isNonNegative(config.introSec) &&
|
|
518
|
-
isNonNegative(config.outroSec) &&
|
|
519
505
|
config.outSuffix !== '');
|
|
520
506
|
}
|
|
521
507
|
export function validateRenderConfig(config) {
|
|
@@ -525,9 +511,6 @@ export function validateRenderConfig(config) {
|
|
|
525
511
|
}
|
|
526
512
|
requireNonNegative(config.zoom, 'zoom must be >= 0 (0 = auto-fit)');
|
|
527
513
|
requireNonNegative(config.zoomOut, 'zoom-out must be >= 0');
|
|
528
|
-
if (!isNonNegative(config.introSec) || !isNonNegative(config.outroSec)) {
|
|
529
|
-
throw new Error('intro-sec and outro-sec must be >= 0');
|
|
530
|
-
}
|
|
531
514
|
if (!config.outSuffix)
|
|
532
515
|
throw new Error('out-suffix must not be empty');
|
|
533
516
|
}
|
|
@@ -559,7 +542,6 @@ function parseRequestConfig(raw, base) {
|
|
|
559
542
|
const EXPORT_REQUEST_SCHEMA = z.preprocess(keyedObjectInput, strictShape({
|
|
560
543
|
outPath: z.unknown().optional(),
|
|
561
544
|
config: z.unknown().optional(),
|
|
562
|
-
range: z.unknown().optional(),
|
|
563
545
|
}, {
|
|
564
546
|
invalid: 'invalid export request',
|
|
565
547
|
unknownKey: (key) => `unknown export request key ${key}`,
|
|
@@ -570,8 +552,5 @@ export function parseExportRequest(raw, base) {
|
|
|
570
552
|
if (!outPath.toLowerCase().endsWith('.mp4')) {
|
|
571
553
|
throw new Error(`export request: outPath must be an .mp4 file: ${outPath}`);
|
|
572
554
|
}
|
|
573
|
-
|
|
574
|
-
? null
|
|
575
|
-
: parseFrameRange(request.range);
|
|
576
|
-
return { outPath, config: parseRequestConfig(request.config, base), range };
|
|
555
|
+
return { outPath, config: parseRequestConfig(request.config, base) };
|
|
577
556
|
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function samePath(a: string, b: string, platform?: NodeJS.Platform): boolean;
|
|
1
|
+
export { pathKey, samePath } from 'drone-path-core/paths';
|
|
3
2
|
export declare function uniquePath(dir: string, stem: string, ext: string, isTaken: (candidate: string) => boolean): string;
|
|
4
3
|
export declare function userDataDir(): string;
|
package/dist/paths.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
export
|
|
4
|
-
const resolved = platform === 'win32' ? path.win32.resolve(p) : path.posix.resolve(p);
|
|
5
|
-
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
6
|
-
}
|
|
7
|
-
export function samePath(a, b, platform = process.platform) {
|
|
8
|
-
return pathKey(a, platform) === pathKey(b, platform);
|
|
9
|
-
}
|
|
3
|
+
export { pathKey, samePath } from 'drone-path-core/paths';
|
|
10
4
|
export function uniquePath(dir, stem, ext, isTaken) {
|
|
11
5
|
for (let n = 1;; n++) {
|
|
12
6
|
const name = n === 1 ? `${stem}${ext}` : `${stem}-${n}${ext}`;
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -10,12 +10,11 @@ import type { TelemetryDocumentInput, TelemetryFrameInput } from 'drone-path-cor
|
|
|
10
10
|
import type { TrackRecord, TrackStream } from 'drone-path-core/track';
|
|
11
11
|
import { prefetchTiles } from './tiles.js';
|
|
12
12
|
import { INITIAL_PREPARE_PROGRESS } from './plan.js';
|
|
13
|
-
import type {
|
|
13
|
+
import type { OverviewPlan, PrepareProgress, PrepareStage } from './plan.js';
|
|
14
14
|
import type { RenderPageOpts } from './render-page.js';
|
|
15
15
|
import { renderVideo } from './render.js';
|
|
16
16
|
import type { CaptureProgress } from './render.js';
|
|
17
17
|
import type { HudLayout, RenderConfig } from './config.js';
|
|
18
|
-
import type { FrameRange } from 'drone-path-core/frame-range';
|
|
19
18
|
import type { TelemetrySummary } from 'drone-path-core/telemetry-summary';
|
|
20
19
|
import type { LogFn } from './logging.js';
|
|
21
20
|
export { INITIAL_PREPARE_PROGRESS };
|
|
@@ -31,7 +30,6 @@ export interface RecordingSummary extends Partial<Pick<TelemetrySummary, 'source
|
|
|
31
30
|
hud?: HudLayout;
|
|
32
31
|
frames?: number;
|
|
33
32
|
fps?: string;
|
|
34
|
-
frameRange?: FrameRange;
|
|
35
33
|
bbox?: Bbox;
|
|
36
34
|
zoomFixed?: boolean;
|
|
37
35
|
tilesDownloaded?: number;
|
|
@@ -63,7 +61,6 @@ export interface PipelineDeps {
|
|
|
63
61
|
interface PipelineOptions {
|
|
64
62
|
deps?: Partial<PipelineDeps>;
|
|
65
63
|
tools?: FfmpegToolPaths;
|
|
66
|
-
range?: FrameRange;
|
|
67
64
|
signal?: AbortSignal;
|
|
68
65
|
onProgress?: PrepareProgressFn;
|
|
69
66
|
onCapture?: (progress: CaptureProgress) => void;
|
|
@@ -78,7 +75,6 @@ interface PreparedRecording {
|
|
|
78
75
|
protoFile: string | null;
|
|
79
76
|
gimbalDevice: GimbalDeviceConstants | null;
|
|
80
77
|
hud: HudLayout;
|
|
81
|
-
introOutro: IntroOutroFrames;
|
|
82
78
|
overview: OverviewPlan;
|
|
83
79
|
frames: FrameChannels;
|
|
84
80
|
}
|
package/dist/pipeline.js
CHANGED
|
@@ -10,11 +10,10 @@ import { pathKey, uniquePath } from './paths.js';
|
|
|
10
10
|
import { loadTelemetry } from 'drone-path-core/telemetry';
|
|
11
11
|
import { writeTrackFile } from 'drone-path-core/track-write';
|
|
12
12
|
import { prefetchTiles } from './tiles.js';
|
|
13
|
-
import { INITIAL_PREPARE_PROGRESS, PREPARE_STAGE_ORDER,
|
|
13
|
+
import { INITIAL_PREPARE_PROGRESS, PREPARE_STAGE_ORDER, planView, } from './plan.js';
|
|
14
14
|
import { buildPageHtml, planPageOpts } from './render-page.js';
|
|
15
15
|
import { renderVideo } from './render.js';
|
|
16
16
|
import { effectiveZoomOut, hasAltitude, resolveHudLayout } from './config.js';
|
|
17
|
-
import { resolveFrameRange } from 'drone-path-core/frame-range';
|
|
18
17
|
import { fixCountLabel, noLockCountLabel, telemetrySummary, trackDistanceLabel, } from 'drone-path-core/telemetry-summary';
|
|
19
18
|
export { INITIAL_PREPARE_PROGRESS };
|
|
20
19
|
export function outputPathFor(videoPath, config) {
|
|
@@ -131,18 +130,11 @@ function createPrepareReporter(onProgress = () => { }) {
|
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
async function probeStage(env) {
|
|
134
|
-
const { videoPath,
|
|
133
|
+
const { videoPath, log, deps, tools, report } = env;
|
|
135
134
|
report('probe');
|
|
136
135
|
const probe = await deps.probeVideo(tools, videoPath, log);
|
|
137
136
|
log(`source: ${path.basename(videoPath)} ${probe.width}x${probe.height} @ ${probe.fps.str} fps, ${probe.frames} frames`);
|
|
138
|
-
|
|
139
|
-
fps: probe.fps.value,
|
|
140
|
-
frames: probe.frames,
|
|
141
|
-
});
|
|
142
|
-
if (introOutro.clamped) {
|
|
143
|
-
log(`intro/outro shortened to ${introOutro.introN}/${introOutro.outroN} frames for this clip`);
|
|
144
|
-
}
|
|
145
|
-
return { probe, introOutro };
|
|
137
|
+
return probe;
|
|
146
138
|
}
|
|
147
139
|
async function telemetryStage(env, probe) {
|
|
148
140
|
const { videoPath, config, log, deps, tools, report } = env;
|
|
@@ -202,7 +194,7 @@ async function tileWarmStage(deps, config, overview, log, signal) {
|
|
|
202
194
|
}
|
|
203
195
|
async function prepareWithEnv(env) {
|
|
204
196
|
const { width, height } = env.config;
|
|
205
|
-
const
|
|
197
|
+
const probe = await probeStage(env);
|
|
206
198
|
const { tel, frameValues, trackValues, protoFile, gimbalDevice, hud } = await telemetryStage(env, probe);
|
|
207
199
|
const overview = await viewPlanStage(env, tel);
|
|
208
200
|
const frames = frameChannelsOf(tel);
|
|
@@ -216,7 +208,6 @@ async function prepareWithEnv(env) {
|
|
|
216
208
|
protoFile,
|
|
217
209
|
gimbalDevice,
|
|
218
210
|
hud,
|
|
219
|
-
introOutro,
|
|
220
211
|
overview,
|
|
221
212
|
frames,
|
|
222
213
|
};
|
|
@@ -237,17 +228,15 @@ export function recordingPageOpts(prep, config) {
|
|
|
237
228
|
width: prep.width,
|
|
238
229
|
height: prep.height,
|
|
239
230
|
config,
|
|
240
|
-
source: { fps: prep.probe.fps.value, frames: prep.probe.frames },
|
|
241
231
|
frames: prep.frames,
|
|
242
232
|
planned: {
|
|
243
233
|
overview: prep.overview,
|
|
244
|
-
introOutro: prep.introOutro,
|
|
245
234
|
hud: prep.hud,
|
|
246
235
|
},
|
|
247
236
|
});
|
|
248
237
|
}
|
|
249
238
|
function buildOkSummary(ctx, elapsedSec) {
|
|
250
|
-
const { config, probe, tel, hud,
|
|
239
|
+
const { config, probe, tel, hud, overview, tileStats } = ctx;
|
|
251
240
|
const telemetry = telemetrySummary(tel);
|
|
252
241
|
return {
|
|
253
242
|
video: ctx.videoPath,
|
|
@@ -257,8 +246,8 @@ function buildOkSummary(ctx, elapsedSec) {
|
|
|
257
246
|
height: ctx.height,
|
|
258
247
|
style: config.style,
|
|
259
248
|
view: config.view,
|
|
260
|
-
introFrames:
|
|
261
|
-
outroFrames:
|
|
249
|
+
introFrames: 0,
|
|
250
|
+
outroFrames: 0,
|
|
262
251
|
hud,
|
|
263
252
|
// Field by field, not a spread: a TelemetrySummary rename must land here visibly, not silently drop a --json key.
|
|
264
253
|
source: telemetry.source,
|
|
@@ -267,9 +256,8 @@ function buildOkSummary(ctx, elapsedSec) {
|
|
|
267
256
|
fixes: telemetry.fixCount,
|
|
268
257
|
noLock: telemetry.noLock,
|
|
269
258
|
trackDistanceM: telemetry.trackDistanceM,
|
|
270
|
-
frames:
|
|
259
|
+
frames: probe.frames,
|
|
271
260
|
fps: probe.fps.str,
|
|
272
|
-
frameRange: ctx.frameRange ?? undefined,
|
|
273
261
|
bbox: tel.bbox,
|
|
274
262
|
zoom: overview.zoom,
|
|
275
263
|
zoomFixed: config.zoom > 0,
|
|
@@ -281,22 +269,20 @@ function buildOkSummary(ctx, elapsedSec) {
|
|
|
281
269
|
}
|
|
282
270
|
async function verifyRenderedOutput(env) {
|
|
283
271
|
const { ctx, deps, tools } = env;
|
|
284
|
-
const verify = await deps.verifyOutput(tools, ctx.outPath, ctx.
|
|
272
|
+
const verify = await deps.verifyOutput(tools, ctx.outPath, ctx.probe.frames, ctx.probe.fps.value);
|
|
285
273
|
if (!verify.ok) {
|
|
286
274
|
throw codedError(`${ERR_OUTPUT_VERIFICATION}got ${verify.frames} frames @ ${verify.fps ?? 'unknown'}, ` +
|
|
287
|
-
`expected ${ctx.
|
|
275
|
+
`expected ${ctx.probe.frames} @ ${ctx.probe.fps.str}`, {
|
|
288
276
|
code: 'OUTPUT_VERIFICATION',
|
|
289
277
|
params: {
|
|
290
278
|
frames: verify.frames,
|
|
291
279
|
fps: verify.fps ?? 'unknown',
|
|
292
|
-
expectedFrames: ctx.
|
|
280
|
+
expectedFrames: ctx.probe.frames,
|
|
293
281
|
expectedFps: ctx.probe.fps.str,
|
|
294
282
|
},
|
|
295
283
|
});
|
|
296
284
|
}
|
|
297
|
-
ctx.log(
|
|
298
|
-
? 'verified: frame count and frame rate are 1:1 within the exported range'
|
|
299
|
-
: 'verified: frame count and frame rate match the source');
|
|
285
|
+
ctx.log('verified: frame count and frame rate match the source');
|
|
300
286
|
}
|
|
301
287
|
async function renderToOutput(env) {
|
|
302
288
|
const { ctx, deps, tools, options } = env;
|
|
@@ -314,8 +300,7 @@ async function renderToOutput(env) {
|
|
|
314
300
|
tools,
|
|
315
301
|
width: ctx.width,
|
|
316
302
|
height: ctx.height,
|
|
317
|
-
frames: ctx.
|
|
318
|
-
frameStart: ctx.frameRange?.start ?? 0,
|
|
303
|
+
frames: ctx.probe.frames,
|
|
319
304
|
fpsStr: ctx.probe.fps.str,
|
|
320
305
|
workers: ctx.config.workers,
|
|
321
306
|
outPath: ctx.outPath,
|
|
@@ -349,9 +334,7 @@ export function trackExportStream(prep) {
|
|
|
349
334
|
};
|
|
350
335
|
}
|
|
351
336
|
function writeTrackExport(file, prep, log) {
|
|
352
|
-
|
|
353
|
-
// limits the render, never this export.
|
|
354
|
-
writeTrackFile(file, { document: telemetryExportInput(prep), track: trackExportStream(prep) }, null);
|
|
337
|
+
writeTrackFile(file, { document: telemetryExportInput(prep), track: trackExportStream(prep) });
|
|
355
338
|
log(`track: wrote ${file}`);
|
|
356
339
|
}
|
|
357
340
|
export async function processRecording(videoPath, config, log, outPath = outputPathFor(videoPath, config), options = {}) {
|
|
@@ -374,16 +357,12 @@ export async function processRecording(videoPath, config, log, outPath = outputP
|
|
|
374
357
|
writeTrackExport(config.trackOut, prep, log);
|
|
375
358
|
}
|
|
376
359
|
const tileStats = await tileWarmStage(deps, config, prep.overview, log, options.signal);
|
|
377
|
-
const range = resolveFrameRange(options.range, prep.probe.frames);
|
|
378
|
-
const outFrames = range ? range.end - range.start + 1 : prep.probe.frames;
|
|
379
360
|
const ctx = {
|
|
380
361
|
...prep,
|
|
381
362
|
videoPath,
|
|
382
363
|
outPath,
|
|
383
364
|
config,
|
|
384
365
|
log,
|
|
385
|
-
outFrames,
|
|
386
|
-
frameRange: range,
|
|
387
366
|
tileStats,
|
|
388
367
|
};
|
|
389
368
|
await renderToOutput({ ctx, deps, tools, options });
|
package/dist/plan.d.ts
CHANGED
|
@@ -26,16 +26,7 @@ export declare function zoomLimits(style: MapStyle): {
|
|
|
26
26
|
max: number;
|
|
27
27
|
};
|
|
28
28
|
export declare function computeOverview({ bbox, width, height, maxZoom, zoomOut, follow, maxNativeZoom, zoomOverride, }: OverviewPlanOptions): OverviewPlan;
|
|
29
|
-
export interface IntroOutroFrames {
|
|
30
|
-
introN: number;
|
|
31
|
-
outroN: number;
|
|
32
|
-
clamped: boolean;
|
|
33
|
-
}
|
|
34
29
|
export declare function planView(bbox: Bbox, width: number, height: number, config: Pick<RenderConfig, 'style' | 'view' | 'zoom' | 'zoomOut'>): OverviewPlan;
|
|
35
|
-
export declare function planIntroOutroFrames(config: Pick<RenderConfig, 'introSec' | 'outroSec'>, source: {
|
|
36
|
-
fps: number;
|
|
37
|
-
frames: number;
|
|
38
|
-
}): IntroOutroFrames;
|
|
39
30
|
export declare const PREPARE_STAGE_ORDER: readonly ["probe", "telemetry", "plan"];
|
|
40
31
|
export type PrepareStage = (typeof PREPARE_STAGE_ORDER)[number];
|
|
41
32
|
export interface PrepareProgress {
|
package/dist/plan.js
CHANGED
|
@@ -93,18 +93,6 @@ export function planView(bbox, width, height, config) {
|
|
|
93
93
|
follow: config.view === 'follow',
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
-
export function planIntroOutroFrames(config, source) {
|
|
97
|
-
let introN = Math.max(0, Math.round(config.introSec * source.fps));
|
|
98
|
-
let outroN = Math.max(0, Math.round(config.outroSec * source.fps));
|
|
99
|
-
const budget = Math.max(2, Math.floor(source.frames / 2));
|
|
100
|
-
const clamped = introN + outroN > budget;
|
|
101
|
-
if (clamped) {
|
|
102
|
-
const scale = budget / (introN + outroN);
|
|
103
|
-
introN = Math.floor(introN * scale);
|
|
104
|
-
outroN = Math.floor(outroN * scale);
|
|
105
|
-
}
|
|
106
|
-
return { introN, outroN, clamped };
|
|
107
|
-
}
|
|
108
96
|
export const PREPARE_STAGE_ORDER = ['probe', 'telemetry', 'plan'];
|
|
109
97
|
export const INITIAL_PREPARE_PROGRESS = {
|
|
110
98
|
stage: PREPARE_STAGE_ORDER[0],
|
package/dist/render-page.d.ts
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
1
|
import type { AppearanceSettings, HudLayout, RenderConfig } from './config.js';
|
|
2
2
|
import type { DecimatedTrack } from './decimate.js';
|
|
3
3
|
import type { Bbox, LatLon } from 'drone-path-core/geo';
|
|
4
|
-
import type {
|
|
4
|
+
import type { OverviewPlan } from './plan.js';
|
|
5
5
|
import type { SceneData } from './renderer/scene.js';
|
|
6
6
|
import type { FrameChannels } from 'drone-path-core/telemetry-math';
|
|
7
7
|
export interface RenderPageOpts extends FrameChannels, Pick<RenderConfig, 'width' | 'height'>, Pick<AppearanceSettings, 'style' | 'view' | 'zoom' | 'trailColor' | 'hud'> {
|
|
8
8
|
center: LatLon;
|
|
9
9
|
attribution: string;
|
|
10
10
|
decimated: DecimatedTrack;
|
|
11
|
-
introN?: number;
|
|
12
|
-
outroN?: number;
|
|
13
11
|
}
|
|
14
12
|
export declare function planPageOpts(opts: {
|
|
15
13
|
bbox: Bbox;
|
|
16
14
|
width: number;
|
|
17
15
|
height: number;
|
|
18
16
|
config: AppearanceSettings;
|
|
19
|
-
source: {
|
|
20
|
-
fps: number;
|
|
21
|
-
frames: number;
|
|
22
|
-
};
|
|
23
17
|
frames: FrameChannels;
|
|
24
18
|
planned?: {
|
|
25
19
|
overview: OverviewPlan;
|
|
26
|
-
introOutro: IntroOutroFrames;
|
|
27
20
|
hud: HudLayout;
|
|
28
21
|
};
|
|
29
22
|
previous?: {
|
package/dist/render-page.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { hasAltitude, resolveHudLayout } from './config.js';
|
|
2
2
|
import { decimateTrack } from './decimate.js';
|
|
3
3
|
import { unproject } from 'drone-path-core/geo';
|
|
4
|
-
import {
|
|
4
|
+
import { planView } from './plan.js';
|
|
5
5
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
6
6
|
export function planPageOpts(opts) {
|
|
7
|
-
const { bbox, width, height, config,
|
|
7
|
+
const { bbox, width, height, config, frames, planned, previous } = opts;
|
|
8
8
|
const overview = planned?.overview ?? planView(bbox, width, height, config);
|
|
9
|
-
const introOutro = planned?.introOutro ?? planIntroOutroFrames(config, source);
|
|
10
9
|
const hud = planned?.hud ?? resolveHudLayout(config.hud, hasAltitude(frames.alt));
|
|
11
10
|
const decimated = previous && previous.zoom === overview.zoom
|
|
12
11
|
? previous.decimated
|
|
@@ -20,8 +19,6 @@ export function planPageOpts(opts) {
|
|
|
20
19
|
center: unproject(overview.centerPx.x, overview.centerPx.y, overview.zoom),
|
|
21
20
|
zoom: overview.zoom,
|
|
22
21
|
attribution: TILE_SOURCES[config.style].attribution,
|
|
23
|
-
introN: introOutro.introN,
|
|
24
|
-
outroN: introOutro.outroN,
|
|
25
22
|
lat: frames.lat,
|
|
26
23
|
lon: frames.lon,
|
|
27
24
|
alt: frames.alt,
|
|
@@ -32,7 +29,7 @@ export function planPageOpts(opts) {
|
|
|
32
29
|
};
|
|
33
30
|
}
|
|
34
31
|
export function buildSceneData(opts, tileBase) {
|
|
35
|
-
const { width, height, style, trailColor, view, center, zoom, attribution, lat, lon, alt, speed, headingDeg, hud, decimated,
|
|
32
|
+
const { width, height, style, trailColor, view, center, zoom, attribution, lat, lon, alt, speed, headingDeg, hud, decimated, } = opts;
|
|
36
33
|
return {
|
|
37
34
|
style,
|
|
38
35
|
trailColor,
|
|
@@ -43,8 +40,6 @@ export function buildSceneData(opts, tileBase) {
|
|
|
43
40
|
zoom,
|
|
44
41
|
center: { lat: center.lat, lon: center.lon },
|
|
45
42
|
attribution,
|
|
46
|
-
introN,
|
|
47
|
-
outroN,
|
|
48
43
|
lat, lon, alt, speed, headingDeg,
|
|
49
44
|
hud,
|
|
50
45
|
trailLat: decimated.lat,
|
package/dist/render.d.ts
CHANGED
|
@@ -37,7 +37,6 @@ export interface CaptureProgress {
|
|
|
37
37
|
export interface RenderJobOptions extends Pick<RenderConfig, 'style' | 'tileCache' | 'width' | 'height' | 'workers' | 'capture' | 'codec' | 'quality' | 'preset'> {
|
|
38
38
|
html: string;
|
|
39
39
|
frames: number;
|
|
40
|
-
frameStart?: number;
|
|
41
40
|
fpsStr: string;
|
|
42
41
|
outPath: string;
|
|
43
42
|
log?: LogFn;
|
package/dist/render.js
CHANGED
|
@@ -254,7 +254,7 @@ function screenshotOptions(capture) {
|
|
|
254
254
|
}
|
|
255
255
|
async function captureFrame(run, loop, page, idx) {
|
|
256
256
|
const evalStart = Date.now();
|
|
257
|
-
await page.evaluate((frame) => globalThis.__setFrame(frame),
|
|
257
|
+
await page.evaluate((frame) => globalThis.__setFrame(frame), idx);
|
|
258
258
|
run.timing.evalMs += Date.now() - evalStart;
|
|
259
259
|
const captureStart = Date.now();
|
|
260
260
|
const buf = await page.screenshot(screenshotOptions(run.capture));
|
|
@@ -361,13 +361,12 @@ function reportProfile(env) {
|
|
|
361
361
|
return { profile };
|
|
362
362
|
}
|
|
363
363
|
export async function renderVideo(opts) {
|
|
364
|
-
const { html, style, tileCache, width, height, frames, fpsStr, workers, outPath, log = () => { }, browserPath = null, tools, capture = 'jpeg', codec = 'h264', quality = 'high', preset = 'medium',
|
|
364
|
+
const { html, style, tileCache, width, height, frames, fpsStr, workers, outPath, log = () => { }, browserPath = null, tools, capture = 'jpeg', codec = 'h264', quality = 'high', preset = 'medium', signal, onCapture, } = opts;
|
|
365
365
|
const workerCount = Math.max(1, Math.min(workers, frames));
|
|
366
366
|
const ctx = {
|
|
367
367
|
width,
|
|
368
368
|
height,
|
|
369
369
|
frames,
|
|
370
|
-
frameStart,
|
|
371
370
|
fpsStr,
|
|
372
371
|
outPath,
|
|
373
372
|
capture,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function computeScale(width: number, height: number): number;
|
|
2
2
|
export declare function smoothstep(t: number): number;
|
|
3
|
-
export declare function introOutroScale(i: number, introN: number, outroN: number, totalN: number): number;
|
|
4
3
|
export declare function metersPerPixel(lat: number, zoom: number): number;
|
|
5
4
|
export declare function scaleBarMeters(mPerPx: number, maxPx: number): number;
|
|
@@ -5,17 +5,6 @@ export function smoothstep(t) {
|
|
|
5
5
|
const clamped = Math.max(0, Math.min(1, t));
|
|
6
6
|
return clamped * clamped * (3 - 2 * clamped);
|
|
7
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
8
|
export function metersPerPixel(lat, zoom) {
|
|
20
9
|
return (156543.033928 * Math.cos((lat * Math.PI) / 180)) / Math.pow(2, zoom);
|
|
21
10
|
}
|
package/dist/renderer/scene.d.ts
CHANGED
|
@@ -14,8 +14,6 @@ export interface SceneData extends FrameChannels {
|
|
|
14
14
|
zoom: number;
|
|
15
15
|
center: LatLon;
|
|
16
16
|
attribution: string;
|
|
17
|
-
introN: number;
|
|
18
|
-
outroN: number;
|
|
19
17
|
hud: HudLayout;
|
|
20
18
|
/** Whether this viewer draws the in-frame HUD pills; a caller that overlays
|
|
21
19
|
its own toggles (the Map appearance preview) sets this to false. */
|
package/dist/renderer/scene.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { TILE_SOURCES } from './tilesources.js';
|
|
2
2
|
import { droneMarkerMarkup, el, hudMarkup, mapMarkup, quietAttributionLinks, sceneCss, stripReadoutMarkup } from './dom.js';
|
|
3
|
-
import { computeScale,
|
|
3
|
+
import { computeScale, metersPerPixel, scaleBarMeters } from './framemath.js';
|
|
4
4
|
import { themeFor } from './theme.js';
|
|
5
5
|
import { createTrailController } from './trail.js';
|
|
6
6
|
function hudEq(a, b) {
|
|
7
7
|
return (a.heading === b.heading && a.alt === b.alt && a.speed === b.speed);
|
|
8
8
|
}
|
|
9
|
+
function trailLayerFor(L, line) {
|
|
10
|
+
return {
|
|
11
|
+
setLatLngs(points) {
|
|
12
|
+
line.setLatLngs(points);
|
|
13
|
+
},
|
|
14
|
+
// Mutating the live array and calling redraw() is Leaflet's documented
|
|
15
|
+
// way to skip reconverting the whole prefix; bounds are extended as
|
|
16
|
+
// addLatLng does so a line that started empty still projects.
|
|
17
|
+
spliceTail(drop, points) {
|
|
18
|
+
const latlngs = line.getLatLngs();
|
|
19
|
+
latlngs.length -= drop;
|
|
20
|
+
const bounds = line.getBounds();
|
|
21
|
+
for (const [lat, lon] of points) {
|
|
22
|
+
const ll = L.latLng(lat, lon);
|
|
23
|
+
latlngs.push(ll);
|
|
24
|
+
bounds.extend(ll);
|
|
25
|
+
}
|
|
26
|
+
line.redraw();
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
9
30
|
/** A missing value renders exactly like a disabled chip: the dimmed "--". */
|
|
10
31
|
function isMissing(value) {
|
|
11
32
|
return value === null || value === undefined;
|
|
@@ -53,10 +74,13 @@ class SceneState {
|
|
|
53
74
|
this.styleEl = document.createElement('style');
|
|
54
75
|
document.head.appendChild(this.styleEl);
|
|
55
76
|
// One definedness rule for both: a caller either supplies the external
|
|
56
|
-
// strip host or gets the in-frame export HUD
|
|
77
|
+
// strip host or gets the in-frame export HUD (unless hudPills is false),
|
|
78
|
+
// never a mix of the two.
|
|
57
79
|
const externalHud = hudHost !== undefined;
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
const suppressHud = externalHud || firstData.hudPills === false;
|
|
81
|
+
host.innerHTML = mapMarkup(suppressHud ? null : firstData.hud, firstData.attribution);
|
|
82
|
+
this.frameEl = el(host, '#map-frame');
|
|
83
|
+
this.hudRoot = hudHost ?? host.querySelector('#hud');
|
|
60
84
|
this.externalHud = externalHud;
|
|
61
85
|
this.attrEl = el(host, '#attr');
|
|
62
86
|
this.applyChrome();
|
|
@@ -80,7 +104,6 @@ class SceneState {
|
|
|
80
104
|
this.tiles.addTo(this.map);
|
|
81
105
|
this.latlngs = this.latlngsOf(firstData);
|
|
82
106
|
this.bb = L.latLngBounds(this.latlngs);
|
|
83
|
-
this.frameEl = el(host, '#map-frame');
|
|
84
107
|
this.scalelineEl = el(host, '#scaleline');
|
|
85
108
|
this.scaletextEl = el(host, '#scaletext');
|
|
86
109
|
// Leaflet only creates marker DOM once the map has a view: layoutMap() must precede buildDecor() so the arrow/wrap elements exist.
|
|
@@ -104,7 +127,7 @@ class SceneState {
|
|
|
104
127
|
makeTileLayer(tileUrl, style) {
|
|
105
128
|
return this.L.tileLayer(tileUrl, {
|
|
106
129
|
maxZoom: TILE_SOURCES[style].maxZoom,
|
|
107
|
-
maxNativeZoom: TILE_SOURCES[style].maxNativeZoom
|
|
130
|
+
maxNativeZoom: TILE_SOURCES[style].maxNativeZoom,
|
|
108
131
|
});
|
|
109
132
|
}
|
|
110
133
|
latlngsOf(data) {
|
|
@@ -244,9 +267,8 @@ class SceneState {
|
|
|
244
267
|
lat: this.data.trailLat,
|
|
245
268
|
lon: this.data.trailLon,
|
|
246
269
|
frame: this.data.trailFrame,
|
|
247
|
-
}, { lat: this.data.lat, lon: this.data.lon }, trailLayers),
|
|
270
|
+
}, { lat: this.data.lat, lon: this.data.lon }, trailLayers.map((line) => trailLayerFor(this.L, line))),
|
|
248
271
|
arrowEl: this.host.querySelector('#drone-arrow'),
|
|
249
|
-
wrapEl: this.host.querySelector('.drone-wrap'),
|
|
250
272
|
};
|
|
251
273
|
if (!this.data.hud.heading && decor.arrowEl)
|
|
252
274
|
decor.arrowEl.style.display = 'none';
|
|
@@ -261,19 +283,32 @@ class SceneState {
|
|
|
261
283
|
// Scoped to the chip container so an external strip and a second scene
|
|
262
284
|
// (the export preview) can never cross-write. A scene whose caller
|
|
263
285
|
// overlays its own pills draws none of its own (#283).
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
286
|
+
if (this.externalHud) {
|
|
287
|
+
if (this.hudRoot) {
|
|
288
|
+
this.hudRoot.innerHTML = stripReadoutMarkup(this.data.hud, this.data.stripLabels);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if (this.data.hudPills === false) {
|
|
292
|
+
this.hudRoot?.remove();
|
|
293
|
+
this.hudRoot = null;
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
if (!this.hudRoot) {
|
|
297
|
+
const hud = document.createElement('div');
|
|
298
|
+
hud.id = 'hud';
|
|
299
|
+
this.frameEl.insertBefore(hud, this.attrEl);
|
|
300
|
+
this.hudRoot = hud;
|
|
301
|
+
}
|
|
302
|
+
this.hudRoot.innerHTML = hudMarkup(this.data.hud);
|
|
303
|
+
}
|
|
304
|
+
this.headingChip = this.hudRoot?.querySelector('#chip-heading') ?? null;
|
|
305
|
+
this.altChip = this.hudRoot?.querySelector('#chip-alt') ?? null;
|
|
306
|
+
this.speedChip = this.hudRoot?.querySelector('#chip-speed') ?? null;
|
|
272
307
|
if (this.decor.arrowEl) {
|
|
273
308
|
this.decor.arrowEl.style.display = this.data.hud.heading ? '' : 'none';
|
|
274
309
|
}
|
|
275
310
|
}
|
|
276
|
-
updateTransform(i
|
|
311
|
+
updateTransform(i) {
|
|
277
312
|
const { data, layout, decor, mapEl } = this;
|
|
278
313
|
let dx = 0;
|
|
279
314
|
let dy = 0;
|
|
@@ -283,12 +318,9 @@ class SceneState {
|
|
|
283
318
|
dy = p.y - layout.c0.y;
|
|
284
319
|
}
|
|
285
320
|
mapEl.style.transform =
|
|
286
|
-
'translate(' + (layout.vw / 2 - layout.bigW / 2 -
|
|
287
|
-
(layout.vh / 2 - layout.bigH / 2 -
|
|
288
|
-
|
|
289
|
-
decor.wrapEl.style.transform = k === 1 ? '' : 'scale(' + 1 / k + ')';
|
|
290
|
-
}
|
|
291
|
-
this.scalelineEl.style.width = Math.round((layout.bestM / layout.mPerPx) * k) + 'px';
|
|
321
|
+
'translate(' + (layout.vw / 2 - layout.bigW / 2 - dx) + 'px,' +
|
|
322
|
+
(layout.vh / 2 - layout.bigH / 2 - dy) + 'px)';
|
|
323
|
+
this.scalelineEl.style.width = Math.round(layout.bestM / layout.mPerPx) + 'px';
|
|
292
324
|
if (data.hud.heading && decor.arrowEl) {
|
|
293
325
|
decor.arrowEl.style.transform = 'rotate(' + data.headingDeg[i] + 'deg)';
|
|
294
326
|
}
|
|
@@ -327,8 +359,7 @@ class SceneState {
|
|
|
327
359
|
this.curIdx = i;
|
|
328
360
|
this.decor.trailCtl.setFrame(i);
|
|
329
361
|
this.decor.drone.setLatLng(this.latlngs[i]);
|
|
330
|
-
|
|
331
|
-
this.updateTransform(i, k);
|
|
362
|
+
this.updateTransform(i);
|
|
332
363
|
this.updateHud(i);
|
|
333
364
|
// Canvas painting is deferred to requestAnimationFrame
|
|
334
365
|
return new Promise((resolve) => {
|
package/dist/renderer/theme.d.ts
CHANGED
package/dist/renderer/theme.js
CHANGED
package/dist/renderer/trail.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { LatLngTuple } from 'leaflet';
|
|
2
2
|
export interface TrailLayer {
|
|
3
3
|
setLatLngs(points: LatLngTuple[]): void;
|
|
4
|
+
/** Drops the last `drop` points, appends `points`, and redraws once. */
|
|
5
|
+
spliceTail(drop: number, points: LatLngTuple[]): void;
|
|
4
6
|
}
|
|
5
7
|
export interface TrailController {
|
|
6
8
|
setFrame(i: number): void;
|
package/dist/renderer/trail.js
CHANGED
|
@@ -16,27 +16,57 @@ export function lastIndexAtOrBefore(trailFrame, i) {
|
|
|
16
16
|
}
|
|
17
17
|
export function createTrailController(trail, frames, layers) {
|
|
18
18
|
let lastFrame = null;
|
|
19
|
+
// Last kept trail index on screen; null until the first full draw.
|
|
20
|
+
let drawnEnd = null;
|
|
21
|
+
let drawnTip = false;
|
|
19
22
|
let drawn = false;
|
|
23
|
+
const keptPoints = (from, to) => {
|
|
24
|
+
const points = [];
|
|
25
|
+
for (let j = from; j <= to; j++)
|
|
26
|
+
points.push([trail.lat[j], trail.lon[j]]);
|
|
27
|
+
return points;
|
|
28
|
+
};
|
|
29
|
+
const drawFull = (end, tip) => {
|
|
30
|
+
const points = keptPoints(0, end);
|
|
31
|
+
if (tip !== null)
|
|
32
|
+
points.push(tip);
|
|
33
|
+
if (points.length === 0 && !drawn)
|
|
34
|
+
return;
|
|
35
|
+
drawnEnd = end;
|
|
36
|
+
drawnTip = tip !== null;
|
|
37
|
+
drawn = points.length > 0;
|
|
38
|
+
for (const layer of layers)
|
|
39
|
+
layer.setLatLngs(points);
|
|
40
|
+
};
|
|
41
|
+
// While the kept prefix only grows, swapping the old tip for the new points
|
|
42
|
+
// yields the same polyline as a full rebuild at O(new points) cost.
|
|
43
|
+
const drawTail = (prevEnd, end, tip) => {
|
|
44
|
+
const drop = drawnTip ? 1 : 0;
|
|
45
|
+
const points = keptPoints(prevEnd + 1, end);
|
|
46
|
+
if (tip !== null)
|
|
47
|
+
points.push(tip);
|
|
48
|
+
drawnEnd = end;
|
|
49
|
+
drawnTip = tip !== null;
|
|
50
|
+
drawn = end >= 0 || drawnTip;
|
|
51
|
+
if (drop === 0 && points.length === 0)
|
|
52
|
+
return;
|
|
53
|
+
for (const layer of layers)
|
|
54
|
+
layer.spliceTail(drop, points);
|
|
55
|
+
};
|
|
20
56
|
return {
|
|
21
57
|
setFrame(i) {
|
|
22
58
|
if (i === lastFrame)
|
|
23
59
|
return;
|
|
60
|
+
lastFrame = i;
|
|
24
61
|
const tip = i >= 0 && i < frames.lat.length ? [frames.lat[i], frames.lon[i]] : null;
|
|
25
62
|
// A kept point at exactly frame i would duplicate the tip's position.
|
|
26
63
|
let end = lastIndexAtOrBefore(trail.frame, i);
|
|
27
64
|
if (tip !== null && trail.frame[end] === i)
|
|
28
65
|
end -= 1;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
points.push(tip);
|
|
34
|
-
lastFrame = i;
|
|
35
|
-
if (points.length === 0 && !drawn)
|
|
36
|
-
return;
|
|
37
|
-
drawn = points.length > 0;
|
|
38
|
-
for (const layer of layers)
|
|
39
|
-
layer.setLatLngs(points);
|
|
66
|
+
if (drawnEnd === null || end < drawnEnd)
|
|
67
|
+
drawFull(end, tip);
|
|
68
|
+
else
|
|
69
|
+
drawTail(drawnEnd, end, tip);
|
|
40
70
|
},
|
|
41
71
|
};
|
|
42
72
|
}
|
package/dist/restyle.js
CHANGED
package/dist/tiles.js
CHANGED
|
@@ -26,6 +26,7 @@ const DOWNLOAD_WORKERS = 2;
|
|
|
26
26
|
const REQUEST_INTERVAL_MS = 500;
|
|
27
27
|
const RETRY_DELAY_MS = 500;
|
|
28
28
|
const FETCH_TIMEOUT_MS = 20000;
|
|
29
|
+
const MAX_TILE_BYTES = 2 * 1024 * 1024;
|
|
29
30
|
// p-queue starts higher priorities first, so 'now' jumps the queued pre-warm.
|
|
30
31
|
const TASK_PRIORITY = { now: 1, background: 0 };
|
|
31
32
|
function tileUrl(style, tile) {
|
|
@@ -42,14 +43,41 @@ function tileUrl(style, tile) {
|
|
|
42
43
|
function canceledError(signal) {
|
|
43
44
|
return new Error('tile download canceled', { cause: signal.reason });
|
|
44
45
|
}
|
|
46
|
+
async function readCappedBody(res) {
|
|
47
|
+
const reader = res.body?.getReader();
|
|
48
|
+
if (!reader)
|
|
49
|
+
return Buffer.alloc(0);
|
|
50
|
+
const chunks = [];
|
|
51
|
+
let size = 0;
|
|
52
|
+
try {
|
|
53
|
+
while (true) {
|
|
54
|
+
const next = await reader.read();
|
|
55
|
+
if (next.done)
|
|
56
|
+
return Buffer.concat(chunks, size);
|
|
57
|
+
size += next.value.byteLength;
|
|
58
|
+
if (size > MAX_TILE_BYTES)
|
|
59
|
+
throw new Error('tile response too large');
|
|
60
|
+
chunks.push(next.value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
void reader.cancel().catch(() => { });
|
|
65
|
+
reader.releaseLock();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
45
68
|
async function fetchBody(url, userAgent, signal) {
|
|
46
69
|
const res = await fetch(url, {
|
|
47
70
|
headers: { 'User-Agent': userAgent },
|
|
71
|
+
redirect: 'error',
|
|
48
72
|
signal: signal
|
|
49
73
|
? AbortSignal.any([AbortSignal.timeout(FETCH_TIMEOUT_MS), signal])
|
|
50
74
|
: AbortSignal.timeout(FETCH_TIMEOUT_MS),
|
|
51
75
|
});
|
|
52
|
-
|
|
76
|
+
if (!res.ok || Number(res.headers.get('content-length')) > MAX_TILE_BYTES) {
|
|
77
|
+
void res.body?.cancel().catch(() => { });
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return readCappedBody(res);
|
|
53
81
|
}
|
|
54
82
|
async function downloadTile(ctx, url, priority, signal) {
|
|
55
83
|
for (let attempt = 0; attempt < DOWNLOAD_ATTEMPTS; attempt++) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drone-path-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Plan and render flight-path map overlays from drone telemetry.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"author": "Manuel Warum",
|
|
25
25
|
"license": "MIT",
|
|
26
|
-
"homepage": "https://
|
|
26
|
+
"homepage": "https://dronepath.dev",
|
|
27
27
|
"keywords": [
|
|
28
28
|
"dji",
|
|
29
29
|
"drone",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"directory": "packages/engine"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@types/leaflet": "
|
|
44
|
-
"drone-path-core": "
|
|
45
|
-
"leaflet": "
|
|
46
|
-
"p-queue": "
|
|
47
|
-
"playwright-core": "
|
|
48
|
-
"zod": "
|
|
43
|
+
"@types/leaflet": "^1.9.23",
|
|
44
|
+
"drone-path-core": "^2.0.0",
|
|
45
|
+
"leaflet": "^1.9.4",
|
|
46
|
+
"p-queue": "^10.0.0",
|
|
47
|
+
"playwright-core": "^1.65.0",
|
|
48
|
+
"zod": "^4.6.7"
|
|
49
49
|
}
|
|
50
50
|
}
|