gps-plus-slam-app-framework 1.0.0 → 1.0.6

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 (131) hide show
  1. package/dist/{app-selectors-DyMzxCEC.d.ts → app-selectors-CHt7DLuq.d.ts} +9 -8
  2. package/dist/ar/depth-sampler.js +1 -1
  3. package/dist/ar/tracking-state.js +1 -1
  4. package/dist/ar/webxr-session.js +1 -1
  5. package/dist/combined-root-state-B3SvPNjU.d.ts +6 -0
  6. package/dist/core/index.d.ts +2 -0
  7. package/dist/core/index.js +2 -0
  8. package/dist/create-slam-app-store-DBm7g2Zd.d.ts +85 -0
  9. package/dist/file-system-DD5TczSO.d.ts +84 -0
  10. package/dist/geo/h3-proximity.d.ts +2 -0
  11. package/dist/{ref-points/h3-ref-point.js → geo/h3-proximity.js} +16 -12
  12. package/dist/geo/index.d.ts +2 -0
  13. package/dist/geo/index.js +2 -0
  14. package/dist/gps-anchored-mesh-manager-CovAFK4g.d.ts +56 -0
  15. package/dist/gps-ar-pose-sampler-D_Zso40V.d.ts +43 -0
  16. package/dist/{recording-coordinator-DzflP07_.d.ts → gps-event-coordinator-fwvmVfku.d.ts} +6 -5
  17. package/dist/{h3-ref-point-CFhayNSZ.d.ts → h3-proximity-GwesPTFT.d.ts} +16 -12
  18. package/dist/index.d.ts +31 -34
  19. package/dist/index.js +14 -19
  20. package/dist/{leaflet-map-overlay-CvfQXTye.d.ts → leaflet-map-overlay-CQZcnxbc.d.ts} +10 -6
  21. package/dist/licensing/index.d.ts +1 -1
  22. package/dist/licensing/index.js +1 -1
  23. package/dist/{null-storage-backend-CsWvQwN8.d.ts → null-storage-backend-C0TiwwzQ.d.ts} +4 -2
  24. package/dist/{opfs-storage-ChOzF_Wp.d.ts → opfs-storage-Dlq1I_Gb.d.ts} +54 -51
  25. package/dist/opfs-storage-backend-Gt3rd76D.d.ts +13 -0
  26. package/dist/{persistence-middleware-DrptY02i.d.ts → persistence-middleware-z-75iisb.d.ts} +4 -4
  27. package/dist/{recording-replayer-oOzPITrd.d.ts → recording-replayer-BFhFs7Mc.d.ts} +2 -2
  28. package/dist/recording-slice-BiktUIWF.d.ts +28 -0
  29. package/dist/{replay-engine-DuX316ae.d.ts → replay-engine-B88Va62x.d.ts} +4 -1
  30. package/dist/sensors/gps-error-handler.d.ts +1 -1
  31. package/dist/sensors/gps.d.ts +1 -1
  32. package/dist/sensors/index.d.ts +3 -3
  33. package/dist/sensors/index.js +1 -1
  34. package/dist/sensors/permission-checker.d.ts +1 -1
  35. package/dist/state/app-selectors.d.ts +1 -1
  36. package/dist/state/create-slam-app-store.d.ts +2 -0
  37. package/dist/state/create-slam-app-store.js +61 -0
  38. package/dist/state/gps-ar-pose-sampler.d.ts +4 -0
  39. package/dist/state/gps-ar-pose-sampler.js +19 -0
  40. package/dist/state/{recording-coordinator.d.ts → gps-event-coordinator.d.ts} +1 -1
  41. package/dist/state/{recording-coordinator.js → gps-event-coordinator.js} +3 -4
  42. package/dist/state/index.d.ts +15 -16
  43. package/dist/state/index.js +7 -7
  44. package/dist/state/persistence-middleware.d.ts +1 -1
  45. package/dist/state/persistence-middleware.js +8 -8
  46. package/dist/state/recording-replayer.d.ts +3 -2
  47. package/dist/state/recording-replayer.js +2 -2
  48. package/dist/state/recording-slice.d.ts +2 -0
  49. package/dist/state/{recorder-slice.js → recording-slice.js} +7 -15
  50. package/dist/state/replay-engine.d.ts +1 -1
  51. package/dist/state/replay-engine.js +3 -3
  52. package/dist/state/store-subscribers.d.ts +2 -2
  53. package/dist/state/store-subscribers.js +1 -9
  54. package/dist/state/subscribe-to-selector.d.ts +1 -1
  55. package/dist/storage/file-system-utils.d.ts +1 -1
  56. package/dist/storage/file-system.d.ts +2 -2
  57. package/dist/storage/file-system.js +103 -94
  58. package/dist/storage/index.d.ts +9 -11
  59. package/dist/storage/index.js +5 -7
  60. package/dist/storage/null-storage-backend.d.ts +1 -1
  61. package/dist/storage/null-storage-backend.js +7 -0
  62. package/dist/storage/opfs-storage-backend.d.ts +1 -1
  63. package/dist/storage/opfs-storage-backend.js +7 -1
  64. package/dist/storage/opfs-storage.d.ts +2 -2
  65. package/dist/storage/opfs-storage.js +69 -85
  66. package/dist/storage/storage-backend.d.ts +2 -2
  67. package/dist/storage/zip-export.d.ts +2 -2
  68. package/dist/storage/zip-export.js +55 -62
  69. package/dist/storage/zip-reader.d.ts +2 -2
  70. package/dist/storage/zip-reader.js +24 -1
  71. package/dist/storage-backend-yVnuWGTr.d.ts +28 -0
  72. package/dist/{store-subscribers-CuoIzB5T.d.ts → store-subscribers-DKKHld49.d.ts} +1 -2
  73. package/dist/{subscribe-to-selector-UTZ0KkAc.d.ts → subscribe-to-selector-ghDKYtap.d.ts} +1 -1
  74. package/dist/test-utils/zip-round-trip-helpers.d.ts +1 -1
  75. package/dist/test-utils/zip-round-trip-helpers.js +4 -4
  76. package/dist/visualization/gps-anchored-mesh-manager.d.ts +2 -0
  77. package/dist/visualization/gps-anchored-mesh-manager.js +128 -0
  78. package/dist/visualization/gps-compass-cubes.d.ts +1 -1
  79. package/dist/visualization/gps-event-markers.d.ts +1 -1
  80. package/dist/visualization/index.d.ts +9 -9
  81. package/dist/visualization/index.js +2 -2
  82. package/dist/visualization/leaflet-map-overlay.d.ts +1 -1
  83. package/dist/visualization/leaflet-map-overlay.js +23 -19
  84. package/dist/visualization/lerp-utils.d.ts +1 -1
  85. package/dist/visualization/map-overlay.d.ts +1 -1
  86. package/dist/visualization/three-dispose.d.ts +1 -1
  87. package/dist/visualization/vis-colors.d.ts +1 -1
  88. package/dist/{zip-export-Rtpi75JJ.d.ts → zip-export-BjrQPv0X.d.ts} +58 -7
  89. package/dist/{zip-reader-D7pkpX8K.d.ts → zip-reader-KgJEXbca.d.ts} +33 -1
  90. package/package.json +15 -4
  91. package/dist/community-license-key-ChZLCJyO.d.ts +0 -21
  92. package/dist/file-system-BsQgYCU3.d.ts +0 -128
  93. package/dist/licensing/community-license-key.d.ts +0 -2
  94. package/dist/licensing/community-license-key.js +0 -21
  95. package/dist/opfs-storage-backend-CVcmfJHN.d.ts +0 -11
  96. package/dist/recorder-slice-fcwAXrsh.d.ts +0 -35
  97. package/dist/ref-point-importer-B_wn5ABk.d.ts +0 -62
  98. package/dist/ref-point-loader-Pt1smgHS.d.ts +0 -117
  99. package/dist/ref-points/h3-ref-point.d.ts +0 -2
  100. package/dist/ref-points/index.d.ts +0 -2
  101. package/dist/ref-points/index.js +0 -2
  102. package/dist/ref-points-slice-tC-Wd6XJ.d.ts +0 -48
  103. package/dist/reference-points-CFWy8_wj.d.ts +0 -68
  104. package/dist/routing-slice-BlHTM8eh.d.ts +0 -23
  105. package/dist/state/recorder-slice.d.ts +0 -2
  106. package/dist/state/ref-points-slice.d.ts +0 -2
  107. package/dist/state/ref-points-slice.js +0 -44
  108. package/dist/state/routing-slice.d.ts +0 -2
  109. package/dist/state/routing-slice.js +0 -13
  110. package/dist/state/store.d.ts +0 -9
  111. package/dist/state/store.js +0 -71
  112. package/dist/storage/ref-point-importer.d.ts +0 -2
  113. package/dist/storage/ref-point-importer.js +0 -163
  114. package/dist/storage/ref-point-loader.d.ts +0 -2
  115. package/dist/storage/ref-point-loader.js +0 -248
  116. package/dist/storage/ref-point-recovery.d.ts +0 -28
  117. package/dist/storage/ref-point-recovery.js +0 -159
  118. package/dist/storage-backend-BcEItnFr.d.ts +0 -20
  119. package/dist/store-C7PKOj8S.d.ts +0 -96
  120. package/dist/visualization/reference-points.d.ts +0 -2
  121. package/dist/visualization/reference-points.js +0 -160
  122. /package/dist/{file-system-utils-5cWO8Xyv.d.ts → file-system-utils-BH8FdyIu.d.ts} +0 -0
  123. /package/dist/{gps-Ddzr2KlX.d.ts → gps-GKc6_Cly.d.ts} +0 -0
  124. /package/dist/{gps-compass-cubes-C-6JEnpR.d.ts → gps-compass-cubes-jRIJMOuh.d.ts} +0 -0
  125. /package/dist/{gps-error-handler-VPuNOuf8.d.ts → gps-error-handler-CH1S528z.d.ts} +0 -0
  126. /package/dist/{gps-event-markers-DpEy2qRd.d.ts → gps-event-markers-sVyO9utS.d.ts} +0 -0
  127. /package/dist/{lerp-utils-87NWjUOD.d.ts → lerp-utils-CZgQlrmu.d.ts} +0 -0
  128. /package/dist/{map-overlay-DuiZuCTx.d.ts → map-overlay-C9ifl_4-.d.ts} +0 -0
  129. /package/dist/{permission-checker-jO2ziCWC.d.ts → permission-checker-Cu3nbH1S.d.ts} +0 -0
  130. /package/dist/{three-dispose-CCBHjE_a.d.ts → three-dispose-qt_r5wR1.d.ts} +0 -0
  131. /package/dist/{vis-colors-Qi2vlRGt.d.ts → vis-colors-BKkdTIKb.d.ts} +0 -0
@@ -1,28 +0,0 @@
1
- import { t as RefPointDefinition } from "../ref-point-loader-Pt1smgHS.js";
2
-
3
- //#region ../src/storage/ref-point-recovery.d.ts
4
- /**
5
- * Result of recovering ref point definitions from ZIP files.
6
- */
7
- interface RefPointRecoveryResult {
8
- /** Merged, deduplicated RefPointDefinition objects from all ZIPs */
9
- readonly definitions: RefPointDefinition[];
10
- /** Number of ZIP files successfully scanned */
11
- readonly zipFilesScanned: number;
12
- /** Error messages from failed ZIPs or malformed ref points */
13
- readonly errors: string[];
14
- }
15
- /**
16
- * Extract full RefPointDefinition objects from all ZIPs in a folder,
17
- * merge observations by ref point ID, and return the merged definitions.
18
- *
19
- * Unlike importRefPointsFromFolder() which returns simplified ImportedRefPoint[],
20
- * this preserves full observation data (AR poses, GPS, timestamps) needed for
21
- * 3D display and OPFS recovery.
22
- *
23
- * @param folderHandle - Read-only directory handle from showDirectoryPicker
24
- * @returns Result containing merged definitions, scan count, and errors
25
- */
26
- declare function recoverRefPointDefinitionsFromZips(folderHandle: FileSystemDirectoryHandle): Promise<RefPointRecoveryResult>;
27
- //#endregion
28
- export { RefPointRecoveryResult, recoverRefPointDefinitionsFromZips };
@@ -1,159 +0,0 @@
1
- import { createLogger } from "../utils/logger.js";
2
- import { BlobReader, TextWriter, ZipReader } from "@zip.js/zip.js";
3
- //#region ../src/storage/ref-point-recovery.ts
4
- /**
5
- * Reference Point Recovery Module
6
- *
7
- * Extracts full RefPointDefinition objects from ZIP files in a folder and
8
- * merges observations by ref point ID. Unlike ref-point-importer.ts (which
9
- * returns simplified ImportedRefPoint with only lat/lon), this module
10
- * preserves complete observation data (AR poses, GPS, timestamps) needed
11
- * for 3D display and OPFS restoration after browser data loss.
12
- *
13
- * Used by the recovery flow: when OPFS is empty after browser data clear,
14
- * this module reconstructs the full scenario-level ref point state from
15
- * session ZIPs so the user can continue recording with prior ref points visible.
16
- *
17
- * Uses @zip.js/zip.js for ZIP reading (same library as zip-export.ts
18
- * and ref-point-importer.ts).
19
- */
20
- const log = createLogger("RefPointRecovery");
21
- function isZipFileName(name) {
22
- return name.toLowerCase().endsWith(".zip");
23
- }
24
- function isRefPointEntry(entryPath) {
25
- return entryPath.startsWith("refPoints/") && entryPath.endsWith(".json") && entryPath !== "refPoints/";
26
- }
27
- /**
28
- * Validate parsed JSON matches RefPointDefinition shape.
29
- * Looser than ref-point-loader's validator: accepts empty observations
30
- * (schema-valid, preserves identity) and doesn't require arPose/gpsPoint
31
- * validation on every observation (the importer's validator already checks
32
- * first obs structure).
33
- */
34
- function isValidRefPointDefinition(value) {
35
- if (typeof value !== "object" || value === null) return false;
36
- const obj = value;
37
- if (typeof obj.id !== "string" || typeof obj.name !== "string" || typeof obj.createdAt !== "number" || !Array.isArray(obj.observations)) return false;
38
- return true;
39
- }
40
- /**
41
- * Extract full RefPointDefinition objects from a single ZIP file.
42
- */
43
- async function extractDefinitionsFromZip(zipBlob, zipFileName) {
44
- const definitions = [];
45
- const errors = [];
46
- const zipReader = new ZipReader(new BlobReader(zipBlob));
47
- try {
48
- const entries = await zipReader.getEntries();
49
- for (const entry of entries) {
50
- if (entry.directory) continue;
51
- if (!isRefPointEntry(entry.filename)) continue;
52
- try {
53
- const textWriter = new TextWriter();
54
- const jsonText = await entry.getData(textWriter);
55
- let parsed;
56
- try {
57
- parsed = JSON.parse(jsonText);
58
- } catch (parseErr) {
59
- errors.push(`${zipFileName}/${entry.filename}: Invalid JSON - ${parseErr.message}`);
60
- continue;
61
- }
62
- if (!isValidRefPointDefinition(parsed)) {
63
- errors.push(`${zipFileName}/${entry.filename}: Invalid ref point schema`);
64
- continue;
65
- }
66
- definitions.push(parsed);
67
- } catch (entryErr) {
68
- errors.push(`${zipFileName}/${entry.filename}: ${entryErr.message}`);
69
- }
70
- }
71
- } finally {
72
- await zipReader.close();
73
- }
74
- return {
75
- definitions,
76
- errors
77
- };
78
- }
79
- /**
80
- * Merge observations from multiple RefPointDefinitions with the same ID.
81
- * Deduplicates observations by sessionId + timestamp.
82
- * Uses earliest createdAt and first-encountered name.
83
- */
84
- function mergeDefinitions(allDefs) {
85
- const byId = /* @__PURE__ */ new Map();
86
- for (const def of allDefs) {
87
- let entry = byId.get(def.id);
88
- if (!entry) {
89
- entry = {
90
- def: {
91
- id: def.id,
92
- name: def.name,
93
- createdAt: def.createdAt,
94
- observations: []
95
- },
96
- seen: /* @__PURE__ */ new Set()
97
- };
98
- byId.set(def.id, entry);
99
- } else if (def.createdAt < entry.def.createdAt) entry.def.createdAt = def.createdAt;
100
- for (const obs of def.observations) {
101
- const key = `${obs.sessionId}:${obs.timestamp}`;
102
- if (!entry.seen.has(key)) {
103
- entry.seen.add(key);
104
- entry.def.observations.push(obs);
105
- }
106
- }
107
- }
108
- return Array.from(byId.values()).map((e) => e.def).sort((a, b) => a.createdAt - b.createdAt);
109
- }
110
- /**
111
- * Extract full RefPointDefinition objects from all ZIPs in a folder,
112
- * merge observations by ref point ID, and return the merged definitions.
113
- *
114
- * Unlike importRefPointsFromFolder() which returns simplified ImportedRefPoint[],
115
- * this preserves full observation data (AR poses, GPS, timestamps) needed for
116
- * 3D display and OPFS recovery.
117
- *
118
- * @param folderHandle - Read-only directory handle from showDirectoryPicker
119
- * @returns Result containing merged definitions, scan count, and errors
120
- */
121
- async function recoverRefPointDefinitionsFromZips(folderHandle) {
122
- const allDefinitions = [];
123
- const allErrors = [];
124
- let zipFilesScanned = 0;
125
- log.info(`Recovery scan: ${folderHandle.name}`);
126
- try {
127
- for await (const entry of folderHandle.values()) {
128
- if (entry.kind !== "file" || !isZipFileName(entry.name)) continue;
129
- log.debug(`Processing ZIP: ${entry.name}`);
130
- try {
131
- const { definitions, errors } = await extractDefinitionsFromZip(await entry.getFile(), entry.name);
132
- zipFilesScanned++;
133
- allErrors.push(...errors);
134
- allDefinitions.push(...definitions);
135
- } catch (zipErr) {
136
- const errorMsg = `Failed to process ${entry.name}: ${zipErr.message}`;
137
- log.warn(errorMsg);
138
- allErrors.push(errorMsg);
139
- }
140
- }
141
- const merged = mergeDefinitions(allDefinitions);
142
- log.info(`Recovered ${merged.length} ref points from ${zipFilesScanned} ZIP files`);
143
- return {
144
- definitions: merged,
145
- zipFilesScanned,
146
- errors: allErrors
147
- };
148
- } catch (err) {
149
- const errorMsg = `Failed to scan folder: ${err.message}`;
150
- log.error(errorMsg);
151
- return {
152
- definitions: mergeDefinitions(allDefinitions),
153
- zipFilesScanned,
154
- errors: [...allErrors, errorMsg]
155
- };
156
- }
157
- }
158
- //#endregion
159
- export { recoverRefPointDefinitionsFromZips };
@@ -1,20 +0,0 @@
1
- import { n as SessionMetadata } from "./opfs-storage-ChOzF_Wp.js";
2
-
3
- //#region ../src/storage/storage-backend.d.ts
4
- /**
5
- * Contract for persisting recording data during a session.
6
- *
7
- * Implementations:
8
- * - OpfsStorageBackend: production — delegates to OPFS via file-system.ts
9
- * - NullStorageBackend: tests/replay — silent no-ops
10
- */
11
- interface StorageBackend {
12
- /** Persist a Redux action as a numbered JSON file. */
13
- writeAction(action: unknown, index: number): Promise<void>;
14
- /** Persist a captured camera frame as a numbered JPEG. */
15
- writeFrame(blob: Blob, index: number): Promise<void>;
16
- /** Persist session metadata (session.json). */
17
- writeSessionMetadata(metadata: SessionMetadata): Promise<void>;
18
- }
19
- //#endregion
20
- export { StorageBackend as t };
@@ -1,96 +0,0 @@
1
- import { n as SessionMetadata } from "./opfs-storage-ChOzF_Wp.js";
2
- import { t as StorageBackend } from "./storage-backend-BcEItnFr.js";
3
- import { t as RecorderState } from "./recorder-slice-fcwAXrsh.js";
4
- import { t as RefPointsState } from "./ref-points-slice-tC-Wd6XJ.js";
5
- import { n as RoutingState } from "./routing-slice-BlHTM8eh.js";
6
- import { configureStore } from "@reduxjs/toolkit";
7
- import { GpsPoint as GpsPoint$1, LatLong as LatLong$1, MarkReferencePointPayload, RawDeviceOrientation, RawGpsPoint as RawGpsPoint$1, RecordGpsEventPayload, RootState, add2dImage, calcRelativeCoordsInMeters as calcRelativeCoordsInMeters$1, markReferencePoint, recordGpsEvent, setZeroPos } from "gps-plus-slam-js";
8
-
9
- //#region ../src/state/store.d.ts
10
- /**
11
- * Combined root state: library state + app-level state.
12
- * All 6 reducers (3 library + 3 app) are managed by a single configureStore.
13
- */
14
- interface CombinedRootState extends RootState {
15
- recorder: RecorderState;
16
- refPoints: RefPointsState;
17
- routing: RoutingState;
18
- }
19
- /**
20
- * Store interface for the recorder app.
21
- *
22
- * Wraps the Redux Toolkit store and adds storage delegation methods
23
- * (writeFrame, writeSessionMetadata) that route through the injected
24
- * StorageBackend abstraction.
25
- */
26
- interface RecorderStore {
27
- /** Get combined state (library + app) */
28
- getState: () => CombinedRootState;
29
- /** Dispatch actions to the unified store */
30
- dispatch: ReturnType<typeof configureStore>['dispatch'];
31
- /** Subscribe to state changes */
32
- subscribe: (listener: () => void) => () => void;
33
- /**
34
- * Persist a captured camera frame via the StorageBackend.
35
- * A1 fix: routes through the abstraction so NullStorageBackend suppresses
36
- * writes during replay/testing.
37
- */
38
- writeFrame: (blob: Blob, index: number) => Promise<void>;
39
- /**
40
- * Persist session metadata (session.json) via the StorageBackend.
41
- * A1 fix: routes through the abstraction so NullStorageBackend suppresses
42
- * writes during replay/testing.
43
- */
44
- writeSessionMetadata: (metadata: SessionMetadata) => Promise<void>;
45
- }
46
- /**
47
- * Options for creating the recorder store.
48
- */
49
- interface RecorderStoreOptions {
50
- /**
51
- * Callback invoked when a write operation fails during persistence.
52
- * User Feedback Issue #1 Part B: Used to show toast notifications.
53
- */
54
- onWriteFailure?: (error: Error) => void;
55
- /**
56
- * StorageBackend to use for action persistence.
57
- * Defaults to OpfsStorageBackend (production OPFS).
58
- * Pass NullStorageBackend for tests or replay mode.
59
- *
60
- * Finding F2: Decouples the store from the concrete OPFS dependency.
61
- */
62
- storageBackend?: StorageBackend;
63
- /**
64
- * When false, disables expensive Redux dev-only middleware
65
- * (SerializableStateInvariantMiddleware, ImmutableStateInvariantMiddleware).
66
- * Set to false in high-throughput replay scenarios such as investigation tests
67
- * to avoid excessive per-dispatch overhead.
68
- * Default: true (dev checks enabled).
69
- */
70
- enableDevChecks?: boolean;
71
- /**
72
- * License key for the core library.
73
- * Validated via Ed25519 signature verification and expiry check.
74
- *
75
- * Defaults to the bundled `COMMUNITY_LICENSE_KEY` so example apps work out
76
- * of the box. Pass a paid license to override. The library is never usable
77
- * without a valid key — invalid, empty, or expired keys throw.
78
- *
79
- * @see EULA.md §3 — License Key
80
- */
81
- licenseKey?: string;
82
- }
83
- /**
84
- * Create the recorder store using Redux Toolkit's configureStore.
85
- *
86
- * Combines all 6 reducers (3 library: gpsData, gpsElements, arElements;
87
- * 3 app: recorder, refPoints, routing) into a single store with the
88
- * persistence middleware for action recording.
89
- *
90
- * @param options - Optional configuration including callbacks
91
- */
92
- declare function createRecorderStore(options?: RecorderStoreOptions): RecorderStore;
93
- type RootState$1 = CombinedRootState;
94
- type AppDispatch = RecorderStore['dispatch'];
95
- //#endregion
96
- export { setZeroPos as _, MarkReferencePointPayload as a, RecordGpsEventPayload as c, RootState$1 as d, add2dImage as f, recordGpsEvent as g, markReferencePoint as h, LatLong$1 as i, RecorderStore as l, createRecorderStore as m, CombinedRootState as n, RawDeviceOrientation as o, calcRelativeCoordsInMeters$1 as p, GpsPoint$1 as r, RawGpsPoint$1 as s, AppDispatch as t, RecorderStoreOptions as u };
@@ -1,2 +0,0 @@
1
- import { n as refPointVisualizer, t as RefPointVisualizer } from "../reference-points-CFWy8_wj.js";
2
- export { RefPointVisualizer, refPointVisualizer };
@@ -1,160 +0,0 @@
1
- import { createLogger } from "../utils/logger.js";
2
- import { disposeMeshArray } from "./three-dispose.js";
3
- import { getScene } from "../ar/webxr-session.js";
4
- import { VIS_COLORS } from "./vis-colors.js";
5
- import * as THREE from "three";
6
- import { calcRelativeCoordsInMeters } from "gps-plus-slam-js";
7
- //#region ../src/visualization/reference-points.ts
8
- /**
9
- * Reference Point Visualizer
10
- *
11
- * Creates and manages Three.js meshes for visualizing reference points
12
- * in GPS-aligned 3D space.
13
- *
14
- * ARCHITECTURE NOTE:
15
- * - Prior reference points (green) are added to scene root (GPS world space)
16
- * - Current session points (red) are also in GPS world space
17
- * - Spheres stay in GPS coordinates, independent of alignment matrix
18
- */
19
- const log = createLogger("RefPointVisualizer");
20
- /** Sphere radius in meters (10cm) */
21
- const REF_POINT_RADIUS = .1;
22
- /**
23
- * Manager for reference point visualization
24
- */
25
- var RefPointVisualizer = class {
26
- priorRefMeshes = [];
27
- currentRefMeshes = [];
28
- zeroRef = null;
29
- /** Shared geometry for prior-session ref point meshes (lazy-created) */
30
- priorRefGeometry = null;
31
- /** Shared material for prior-session ref point meshes (lazy-created) */
32
- priorRefMaterial = null;
33
- /** Shared geometry for current-session ref point meshes (lazy-created) */
34
- currentRefGeometry = null;
35
- /**
36
- * Set the GPS zero reference (origin for coordinate conversion).
37
- * Must be called before displaying reference points.
38
- *
39
- * @param zero - GPS coordinates of the origin
40
- */
41
- setZeroRef(zero) {
42
- this.zeroRef = zero;
43
- }
44
- /**
45
- * Get the current zero reference
46
- */
47
- getZeroRef() {
48
- return this.zeroRef;
49
- }
50
- /**
51
- * Display reference points from prior sessions.
52
- * Clears any existing prior ref points first.
53
- *
54
- * @param refPoints - Array of reference point marks to visualize
55
- */
56
- displayPriorRefPoints(refPoints) {
57
- if (!this.zeroRef) {
58
- log.warn("No zero reference set");
59
- return;
60
- }
61
- const scene = getScene();
62
- if (!scene) {
63
- log.warn("Scene not available");
64
- return;
65
- }
66
- this.clearPriorRefPoints();
67
- const geometry = this.priorRefGeometry ??= new THREE.SphereGeometry(REF_POINT_RADIUS, 16, 16);
68
- const material = this.priorRefMaterial ??= new THREE.MeshBasicMaterial({ color: VIS_COLORS.PRIOR_REF_POINT.hex });
69
- let visibleCount = 0;
70
- for (const refPoint of refPoints) {
71
- if (!refPoint.gpsPosition) continue;
72
- const coords = calcRelativeCoordsInMeters(this.zeroRef, {
73
- lat: refPoint.gpsPosition.lat,
74
- lon: refPoint.gpsPosition.lon
75
- }, refPoint.gpsPosition.altitude ?? 0, 0);
76
- const mesh = new THREE.Mesh(geometry, material);
77
- mesh.position.set(coords[0], coords[1], coords[2]);
78
- mesh.name = `prior-ref-${refPoint.id}`;
79
- scene.add(mesh);
80
- this.priorRefMeshes.push(mesh);
81
- visibleCount++;
82
- }
83
- log.info(`Displayed ${visibleCount}/${refPoints.length} prior reference points`);
84
- }
85
- /**
86
- * Add a reference point from the current session.
87
- *
88
- * @param refPoint - Reference point mark to visualize
89
- */
90
- addCurrentRefPoint(refPoint) {
91
- if (!this.zeroRef || !refPoint.gpsPosition) {
92
- log.warn("Cannot add current ref point - missing zero ref or GPS position");
93
- return;
94
- }
95
- const scene = getScene();
96
- if (!scene) {
97
- log.warn("Scene not available");
98
- return;
99
- }
100
- const coords = calcRelativeCoordsInMeters(this.zeroRef, {
101
- lat: refPoint.gpsPosition.lat,
102
- lon: refPoint.gpsPosition.lon
103
- }, refPoint.gpsPosition.altitude ?? 0, 0);
104
- const geometry = this.currentRefGeometry ??= new THREE.SphereGeometry(REF_POINT_RADIUS, 16, 16);
105
- const material = new THREE.MeshBasicMaterial({ color: VIS_COLORS.CURRENT_REF_POINT.hex });
106
- const mesh = new THREE.Mesh(geometry, material);
107
- mesh.position.set(coords[0], coords[1], coords[2]);
108
- mesh.name = `current-ref-${refPoint.id}`;
109
- scene.add(mesh);
110
- this.currentRefMeshes.push(mesh);
111
- log.info(`Added current ref point: ${refPoint.id}`);
112
- }
113
- /**
114
- * Clear all prior reference point meshes from the scene.
115
- */
116
- clearPriorRefPoints() {
117
- const scene = getScene();
118
- disposeMeshArray(this.priorRefMeshes, scene, {
119
- skipGeometry: true,
120
- skipMaterial: true
121
- });
122
- this.priorRefGeometry?.dispose();
123
- this.priorRefGeometry = null;
124
- this.priorRefMaterial?.dispose();
125
- this.priorRefMaterial = null;
126
- }
127
- /**
128
- * Clear current session reference point meshes from the scene.
129
- */
130
- clearCurrentRefPoints() {
131
- const scene = getScene();
132
- disposeMeshArray(this.currentRefMeshes, scene, { skipGeometry: true });
133
- this.currentRefGeometry?.dispose();
134
- this.currentRefGeometry = null;
135
- }
136
- /**
137
- * Clear all visualizations and reset state.
138
- */
139
- clearAll() {
140
- this.clearPriorRefPoints();
141
- this.clearCurrentRefPoints();
142
- this.zeroRef = null;
143
- }
144
- /**
145
- * Get count of visible reference points.
146
- */
147
- getCounts() {
148
- return {
149
- prior: this.priorRefMeshes.length,
150
- current: this.currentRefMeshes.length
151
- };
152
- }
153
- };
154
- /**
155
- * Singleton instance for global use.
156
- * Import this to visualize reference points.
157
- */
158
- const refPointVisualizer = new RefPointVisualizer();
159
- //#endregion
160
- export { RefPointVisualizer, refPointVisualizer };
File without changes