gps-plus-slam-app-framework 1.0.6 → 1.1.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/LICENSE +4 -4
- package/README.md +310 -115
- package/dist/accuracy-circles-DEKr0Hoh.d.ts +43 -0
- package/dist/{app-selectors-CHt7DLuq.d.ts → app-selectors-CR9OWodf.d.ts} +8 -10
- package/dist/ar/camera-blit-capture.d.ts +1 -1
- package/dist/ar/capability-checker.d.ts +2 -0
- package/dist/ar/capability-checker.js +25 -0
- package/dist/ar/capture-failure-tracker.d.ts +1 -1
- package/dist/ar/chromium-camera-access-workaround.d.ts +2 -2
- package/dist/ar/chromium-camera-access-workaround.js +197 -8
- package/dist/ar/depth-sampler.d.ts +2 -2
- package/dist/ar/enable-gps-ar.d.ts +2 -0
- package/dist/ar/enable-gps-ar.js +137 -0
- package/dist/ar/frame-loop.d.ts +2 -0
- package/dist/ar/frame-loop.js +63 -0
- package/dist/ar/image-capture.d.ts +1 -1
- package/dist/ar/image-capture.js +1 -1
- package/dist/ar/index.d.ts +16 -12
- package/dist/ar/index.js +8 -4
- package/dist/ar/replay-scene.d.ts +1 -1
- package/dist/ar/scene-node-names.d.ts +1 -1
- package/dist/ar/webxr-session.d.ts +4 -4
- package/dist/ar/webxr-session.js +173 -93
- package/dist/ar/xr-camera-texture.d.ts +1 -1
- package/dist/ar/xr-error-handler.d.ts +1 -1
- package/dist/ar/xr-frame-loop.d.ts +2 -0
- package/dist/ar/xr-frame-loop.js +69 -0
- package/dist/ar-world-group-alignment-Dn4rQk_c.d.ts +43 -0
- package/dist/capability-checker-BTCmZRL4.d.ts +43 -0
- package/dist/chromium-camera-access-workaround-MifIwK9x.d.ts +137 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/create-slam-app-store-B76AGaI0.d.ts +371 -0
- package/dist/{depth-sampler-BNCtnEoP.d.ts → depth-sampler-CqrkRr2N.d.ts} +1 -1
- package/dist/enable-gps-ar-DNbO0zbg.d.ts +95 -0
- package/dist/{file-system-DD5TczSO.d.ts → file-system-TIsDfamK.d.ts} +32 -2
- package/dist/frame-conversions-D2EYjeNa.d.ts +54 -0
- package/dist/frame-loop-BTeRpDm4.d.ts +47 -0
- package/dist/frustum-visibility-DGnJqls0.d.ts +58 -0
- package/dist/{fused-path-DtqCSqJh.d.ts → fused-path-BdVHmDW9.d.ts} +1 -1
- package/dist/geo/h3-proximity.d.ts +1 -1
- package/dist/geo/index.d.ts +1 -1
- package/dist/{geo-types-Xx-LVcnw.d.ts → geo-types-clgzl8b5.d.ts} +16 -1
- package/dist/{gps-GKc6_Cly.d.ts → gps-B7AlMPz5.d.ts} +1 -1
- package/dist/gps-anchor-CISLPQIb.d.ts +59 -0
- package/dist/{gps-ar-pose-sampler-D_Zso40V.d.ts → gps-ar-pose-sampler-BypXZUqC.d.ts} +1 -1
- package/dist/{gps-event-coordinator-fwvmVfku.d.ts → gps-event-coordinator-BKVZbS1M.d.ts} +3 -3
- package/dist/gps-event-markers-BlHq3jYV.d.ts +103 -0
- package/dist/hit-test-reticle-BGXOxrUh.d.ts +45 -0
- package/dist/{image-capture-2pKjYUS6.d.ts → image-capture-BXZUmj7j.d.ts} +1 -1
- package/dist/index--ldLph4V.d.ts +2 -0
- package/dist/index-22v8MXJX.d.ts +23 -0
- package/dist/index-BB2KEWbN2.d.ts +37 -0
- package/dist/index.d.ts +64 -52
- package/dist/index.js +21 -8
- package/dist/{leaflet-map-overlay-CQZcnxbc.d.ts → leaflet-map-overlay-jNt-kcUr.d.ts} +22 -11
- package/dist/{logger-B81iwxx0.d.ts → logger-BZ44Dhd3.d.ts} +7 -1
- package/dist/map-data-BGIBM5rv.d.ts +49 -0
- package/dist/map-overlay-draw-DcGs9UV3.d.ts +42 -0
- package/dist/{null-storage-backend-C0TiwwzQ.d.ts → null-storage-backend-BPQJSaMw.d.ts} +2 -2
- package/dist/{opfs-storage-backend-Gt3rd76D.d.ts → opfs-storage-backend-u4QKvgvP.d.ts} +2 -2
- package/dist/{permission-checker-Cu3nbH1S.d.ts → permission-checker-CfV7INCa.d.ts} +41 -1
- package/dist/persistence-middleware-xB5sTllJ.d.ts +55 -0
- package/dist/{recording-options-BYUFX8iU.d.ts → recording-options-BSFpBSZH.d.ts} +10 -4
- package/dist/{recording-replayer-BFhFs7Mc.d.ts → recording-replayer-CTL2cUE0.d.ts} +2 -2
- package/dist/{recording-slice-BiktUIWF.d.ts → recording-slice-Cb888P6d.d.ts} +2 -2
- package/dist/{replay-engine-B88Va62x.d.ts → replay-engine-B-5GIZtc.d.ts} +1 -1
- package/dist/{replay-scene-DtUm6bsr.d.ts → replay-scene-DkNfldPh.d.ts} +3 -3
- package/dist/sensors/gps-error-handler.d.ts +1 -1
- package/dist/sensors/gps.d.ts +1 -1
- package/dist/sensors/gps.js +2 -2
- package/dist/sensors/index.d.ts +3 -3
- package/dist/sensors/index.js +1 -1
- package/dist/sensors/permission-checker.d.ts +2 -2
- package/dist/sensors/permission-checker.js +79 -1
- package/dist/session-disposers-M-oashRH.js +57 -0
- package/dist/state/app-selectors.d.ts +2 -2
- package/dist/state/app-selectors.js +33 -3
- package/dist/state/combined-root-state.d.ts +2 -0
- package/dist/state/combined-root-state.js +1 -0
- package/dist/state/create-slam-app-store.d.ts +1 -1
- package/dist/state/create-slam-app-store.js +27 -13
- package/dist/state/gps-ar-pose-sampler.d.ts +3 -3
- package/dist/state/gps-event-coordinator.d.ts +1 -1
- package/dist/state/index.d.ts +17 -16
- package/dist/state/index.js +6 -4
- package/dist/state/persistence-middleware.d.ts +2 -2
- package/dist/state/persistence-middleware.js +43 -9
- package/dist/state/recording-options.d.ts +1 -1
- package/dist/state/recording-replayer.d.ts +2 -2
- package/dist/state/recording-slice.d.ts +1 -1
- package/dist/state/replay-engine.d.ts +1 -1
- package/dist/state/store-subscribers.d.ts +2 -2
- package/dist/state/store-subscribers.js +38 -12
- package/dist/state/subscribe-to-selector.d.ts +1 -1
- package/dist/state/tracking-quality.d.ts +2 -0
- package/dist/state/tracking-quality.js +723 -0
- package/dist/state/tracking-slice.d.ts +2 -0
- package/dist/state/tracking-slice.js +147 -0
- package/dist/state-BkIfpiyA.js +87 -0
- package/dist/storage/file-system-utils.d.ts +1 -1
- package/dist/storage/file-system.d.ts +2 -2
- package/dist/storage/file-system.js +52 -1
- package/dist/storage/index.d.ts +8 -8
- package/dist/storage/null-storage-backend.d.ts +1 -1
- package/dist/storage/opfs-storage-backend.d.ts +1 -1
- package/dist/storage/opfs-storage.d.ts +1 -1
- package/dist/storage/storage-backend.d.ts +1 -1
- package/dist/storage/zip-export.d.ts +1 -1
- package/dist/storage/zip-reader.d.ts +1 -1
- package/dist/storage/zip-reader.js +8 -4
- package/dist/{storage-backend-yVnuWGTr.d.ts → storage-backend-yDSKafAQ.d.ts} +1 -1
- package/dist/{store-subscribers-DKKHld49.d.ts → store-subscribers-swlbtg_z.d.ts} +31 -6
- package/dist/{subscribe-to-selector-ghDKYtap.d.ts → subscribe-to-selector--KQpgLXG.d.ts} +1 -1
- package/dist/test-utils/browser-mocks.d.ts +1 -1
- package/dist/test-utils/zip-round-trip-helpers.d.ts +7 -1
- package/dist/test-utils/zip-round-trip-helpers.js +2 -1
- package/dist/tracking-slice-CDREeoZ_.d.ts +86 -0
- package/dist/types/ar-types.d.ts +1 -1
- package/dist/types/geo-types.d.ts +2 -2
- package/dist/types/index.d.ts +3 -3
- package/dist/utils/concurrency.d.ts +1 -1
- package/dist/utils/failure-tracker.d.ts +1 -1
- package/dist/utils/format-file-size.d.ts +1 -1
- package/dist/utils/fused-path.d.ts +1 -1
- package/dist/utils/index.d.ts +6 -6
- package/dist/utils/list-formatter.d.ts +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.js +68 -8
- package/dist/visualization/accuracy-circles.d.ts +2 -0
- package/dist/visualization/accuracy-circles.js +57 -0
- package/dist/visualization/alignment-lerper.d.ts +1 -1
- package/dist/visualization/ar-world-group-alignment.d.ts +2 -0
- package/dist/visualization/ar-world-group-alignment.js +51 -0
- package/dist/visualization/camera-follower.d.ts +1 -1
- package/dist/visualization/css3d-renderer-manager.d.ts +1 -1
- package/dist/visualization/frame-conversions.d.ts +2 -0
- package/dist/visualization/frame-conversions.js +88 -0
- package/dist/visualization/frustum-visibility.d.ts +2 -0
- package/dist/visualization/frustum-visibility.js +139 -0
- package/dist/visualization/gps-anchor.d.ts +2 -0
- package/dist/visualization/gps-anchor.js +217 -0
- package/dist/visualization/gps-compass-cubes.d.ts +1 -1
- package/dist/visualization/gps-event-markers.d.ts +2 -2
- package/dist/visualization/gps-event-markers.js +69 -2
- package/dist/visualization/hit-test-reticle.d.ts +2 -0
- package/dist/visualization/hit-test-reticle.js +81 -0
- package/dist/visualization/index.d.ts +19 -12
- package/dist/visualization/index.js +9 -2
- package/dist/visualization/leaflet-map-overlay.d.ts +1 -1
- package/dist/visualization/leaflet-map-overlay.js +33 -79
- package/dist/visualization/lerp-utils.d.ts +1 -1
- package/dist/visualization/map-data.d.ts +2 -0
- package/dist/visualization/map-data.js +33 -0
- package/dist/visualization/map-overlay-draw.d.ts +2 -0
- package/dist/visualization/map-overlay-draw.js +107 -0
- package/dist/visualization/map-overlay.d.ts +1 -1
- package/dist/visualization/three-dispose.d.ts +1 -1
- package/dist/visualization/vis-colors.d.ts +1 -1
- package/dist/webxr-nue-basis-BbdqhqY6.js +54 -0
- package/dist/{webxr-session-COlSrXdL.d.ts → webxr-session-BnArFCew.d.ts} +76 -14
- package/dist/xr-frame-loop-BKckC7xC.d.ts +70 -0
- package/dist/{zip-reader-KgJEXbca.d.ts → zip-reader-B2lzN8F5.d.ts} +5 -0
- package/package.json +16 -16
- package/dist/ar/tracking-state.d.ts +0 -2
- package/dist/ar/tracking-state.js +0 -164
- package/dist/chromium-camera-access-workaround-CU5zSKNr.d.ts +0 -61
- package/dist/combined-root-state-B3SvPNjU.d.ts +0 -6
- package/dist/create-slam-app-store-DBm7g2Zd.d.ts +0 -85
- package/dist/gps-anchored-mesh-manager-CovAFK4g.d.ts +0 -56
- package/dist/gps-event-markers-sVyO9utS.d.ts +0 -67
- package/dist/persistence-middleware-z-75iisb.d.ts +0 -31
- package/dist/tracking-state-B9QfuZCg.d.ts +0 -101
- package/dist/visualization/gps-anchored-mesh-manager.d.ts +0 -2
- package/dist/visualization/gps-anchored-mesh-manager.js +0 -128
- /package/dist/{alignment-lerper-D9BeDwZX.d.ts → alignment-lerper-CCZJf-Xb.d.ts} +0 -0
- /package/dist/{ar-types-B-ORgk6Z.d.ts → ar-types-isPsQptb.d.ts} +0 -0
- /package/dist/{camera-blit-capture-DHuyrrxr.d.ts → camera-blit-capture-75WWa9Xb.d.ts} +0 -0
- /package/dist/{camera-follower-BMqPddxx.d.ts → camera-follower-B-nS1sr6.d.ts} +0 -0
- /package/dist/{capture-failure-tracker-2Q6oI2uQ.d.ts → capture-failure-tracker-D4HYJNOj.d.ts} +0 -0
- /package/dist/{concurrency-p6gB30fT.d.ts → concurrency-Bsmv53qw.d.ts} +0 -0
- /package/dist/{css3d-renderer-manager-rgLMVAvd.d.ts → css3d-renderer-manager-EDED3nvg.d.ts} +0 -0
- /package/dist/{failure-tracker-1sQ_Cgyw.d.ts → failure-tracker-D7ELffm0.d.ts} +0 -0
- /package/dist/{file-system-utils-BH8FdyIu.d.ts → file-system-utils-BH6uIs2i.d.ts} +0 -0
- /package/dist/{format-file-size-onGq0k1Q.d.ts → format-file-size-B7gJb3Md.d.ts} +0 -0
- /package/dist/{gps-compass-cubes-jRIJMOuh.d.ts → gps-compass-cubes-Ys6Hf1nc.d.ts} +0 -0
- /package/dist/{gps-error-handler-CH1S528z.d.ts → gps-error-handler-BLDhUlw5.d.ts} +0 -0
- /package/dist/{h3-proximity-GwesPTFT.d.ts → h3-proximity-DJnghtir.d.ts} +0 -0
- /package/dist/{lerp-utils-CZgQlrmu.d.ts → lerp-utils-DNcSmKVX.d.ts} +0 -0
- /package/dist/{list-formatter-DKQQVLcl.d.ts → list-formatter-CsqcU4v5.d.ts} +0 -0
- /package/dist/{map-overlay-C9ifl_4-.d.ts → map-overlay-yrFsUtGv.d.ts} +0 -0
- /package/dist/{opfs-storage-Dlq1I_Gb.d.ts → opfs-storage-LsLY6VZV.d.ts} +0 -0
- /package/dist/{scene-node-names-DPsaE2z3.d.ts → scene-node-names-IHW7HR4S.d.ts} +0 -0
- /package/dist/{three-dispose-qt_r5wR1.d.ts → three-dispose-WTBAfaWU.d.ts} +0 -0
- /package/dist/{vis-colors-BKkdTIKb.d.ts → vis-colors-Djnyg_UH.d.ts} +0 -0
- /package/dist/{xr-camera-texture-BbukNE79.d.ts → xr-camera-texture-BU5YvKAM.d.ts} +0 -0
- /package/dist/{xr-error-handler-DTHfmvrl.d.ts → xr-error-handler-DcUFshNF.d.ts} +0 -0
- /package/dist/{zip-export-BjrQPv0X.d.ts → zip-export-C0_ErAqT.d.ts} +0 -0
package/LICENSE
CHANGED
|
@@ -181,10 +181,10 @@ APPENDIX: How to apply the Apache License to your work.
|
|
|
181
181
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
182
|
replaced with your own identifying information. (Don't include
|
|
183
183
|
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
188
|
|
|
189
189
|
Copyright 2026 cs-util-com
|
|
190
190
|
|
package/README.md
CHANGED
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
# GPS+SLAM App Framework
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/gps-plus-slam-app-framework)
|
|
4
|
+
[](https://www.npmjs.com/package/gps-plus-slam-app-framework)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Reusable building blocks for AR+GPS web apps, built on top of the closed-source [gps-plus-slam-js](https://www.npmjs.com/package/gps-plus-slam-js) alignment core.
|
|
9
|
+
|
|
10
|
+
It is part toolkit, part fusion engine: the toolkit covers the AR + GPS plumbing every app needs anyway, and the fusion engine lifts location accuracy to the point where ideas that previously sat on the "someday, on native" shelf become reachable in a browser:
|
|
11
|
+
|
|
12
|
+
- A **WebXR + Three.js scene** with image and depth capture, replay rendering, and tracking-state monitoring.
|
|
13
|
+
- **GPS, orientation, and permission wiring** ready to plug into the store.
|
|
14
|
+
- **OPFS + ZIP record & replay** with a `StorageBackend` interface you can swap.
|
|
15
|
+
- A **composable Redux store factory** (`createSlamAppStore`) that combines the core library's reducers with your own slices.
|
|
16
|
+
|
|
17
|
+
## Why use GPS+SLAM? (Visual Stability Beyond Raw GPS)
|
|
18
|
+
|
|
19
|
+
Raw GPS is useful for getting near a place, but it still jitters by meters and altitude is usually the hardest channel to trust. Most location-based AR apps work around that with broad proximity zones, floating beacons, or oversized highlights — fine as a fallback, but limiting if you want content that sits exactly on a path, a wall, or a specific spot on the ground.
|
|
20
|
+
|
|
21
|
+
GPS+SLAM fuses GPS observations with the device's AR odometry, so as the user moves the alignment between the AR world and real-world coordinates gets more stable. On top of that, the framework gives you placement helpers for objects that should stay tied to a real location:
|
|
22
|
+
|
|
23
|
+
- **Alignment improves with motion:** Once the user has walked for roughly 15 seconds in representative outdoor conditions, the solver has enough baseline that visible drift drops well below raw GPS. How stable it actually feels still depends on the device, the environment, and how clean the GPS track is — but in our own outdoor tests it consistently held up well enough for content that needs to sit on a specific spot.
|
|
24
|
+
- **VPS-like benefits without a VPS dependency:** Cloud visual-positioning systems can work well, but they usually require network access and a provider-maintained scan of the place where the user stands. GPS+SLAM localizes from the device's own GPS, camera tracking, motion, and orientation sensors, so the same alignment approach works in rural areas, woods, mountains, and private sites that no VPS provider has pre-scanned.
|
|
25
|
+
- **Just a URL, no app install:** The whole experience runs in the mobile browser through WebXR, so end users open a link and are in AR within seconds. There is no app-store gate, no native build per platform, and authors can iterate on the live URL while users keep using the same link.
|
|
26
|
+
- **Heading does not depend only on the compass:** Phone compass data can be noisy, biased, or temporarily wrong enough to make a naive AR overlay rotate in the wrong direction. GPS+SLAM can infer the world heading from how the user actually moves through space, so after the user has walked a few meters the overlay no longer has to trust the device-orientation readings.
|
|
27
|
+
- **Session-local objects stay fixed:** Objects created directly in the AR scene can stay at the same 3D position for the current session, independent of later GPS alignment updates. This is ideal for content the user creates live, such as a 3D trail of the path they walked, temporary markers, or objects they place by hand in the world.
|
|
28
|
+
- **Anchors make placed content shareable:** When an object should also be tied to a GPS coordinate for replay, persistence, or sharing with other users, `createGpsAnchor` bootstraps from median GPS samples, keeps the Three.js object positioned from its GPS target inside `arWorldGroup`, and can defer small corrections until the object is off-screen. Large alignment jumps still force a correction so content does not remain in a stale location.
|
|
29
|
+
- **Use exact paths and POIs, not only blobs:** Proximity zones remain a good UX for letting users enter an experience from any direction, but they do not have to be the only interaction model. The framework is designed for route-following cues, authored POI objects, precise areas of interest, and other content that benefits from being visibly tied to a real-world path or location.
|
|
30
|
+
|
|
31
|
+
Don't take any of this on trust. Because everything runs in the browser, the fastest review is to open one of the example URLs on your own phone, step outside, drop an object, walk around it, and judge for yourself whether the stability holds up for your use case.
|
|
6
32
|
|
|
7
33
|
## Architecture
|
|
8
34
|
|
|
9
35
|
```
|
|
10
36
|
┌──────────────────────────────────────────────────┐
|
|
11
37
|
│ Your App │
|
|
12
|
-
│ (UI, screen flow, app-specific
|
|
38
|
+
│ (UI, screen flow, app-specific reducers) │
|
|
13
39
|
├──────────────────────────────────────────────────┤
|
|
14
40
|
│ gps-plus-slam-app-framework ← this package │
|
|
15
|
-
│ (WebXR, Three.js, sensors, storage, replay
|
|
41
|
+
│ (WebXR, Three.js, sensors, storage, replay, │
|
|
42
|
+
│ composable store factory) │
|
|
16
43
|
├──────────────────────────────────────────────────┤
|
|
17
44
|
│ gps-plus-slam-js (core algorithms) │
|
|
18
45
|
│ (GPS/AR alignment, outlier rejection, GPS math) │
|
|
@@ -24,175 +51,340 @@ The framework never imports from your app. Your app imports from the framework a
|
|
|
24
51
|
## Installation
|
|
25
52
|
|
|
26
53
|
```bash
|
|
27
|
-
|
|
54
|
+
pnpm add gps-plus-slam-app-framework gps-plus-slam-js
|
|
28
55
|
```
|
|
29
56
|
|
|
57
|
+
### Runtime Dependencies
|
|
58
|
+
|
|
59
|
+
These are pulled in automatically — you do not need to install them yourself:
|
|
60
|
+
|
|
61
|
+
- `@reduxjs/toolkit`
|
|
62
|
+
- `gl-matrix`
|
|
63
|
+
- `gps-plus-slam-js`
|
|
64
|
+
|
|
30
65
|
### Peer Dependencies
|
|
31
66
|
|
|
32
|
-
Required:
|
|
67
|
+
Required (install in your app):
|
|
33
68
|
|
|
34
69
|
- `three` (>= 0.170.0)
|
|
35
70
|
- `@zip.js/zip.js` (>= 2.7.0)
|
|
36
71
|
- `h3-js` (>= 4.0.0)
|
|
37
|
-
- `@reduxjs/toolkit` (>= 2.9.0)
|
|
38
72
|
|
|
39
73
|
Optional:
|
|
40
74
|
|
|
41
|
-
- `leaflet` (>= 1.9.0) — only needed if
|
|
42
|
-
- `@sentry/browser` (>= 10.0.0) — only needed
|
|
75
|
+
- `leaflet` (>= 1.9.0) — only needed if you use `LeafletMapOverlay`
|
|
76
|
+
- `@sentry/browser` (>= 10.0.0) — only needed if you wire Sentry error reporting
|
|
43
77
|
|
|
44
78
|
## Quick Start
|
|
45
79
|
|
|
46
80
|
```typescript
|
|
47
|
-
import {
|
|
81
|
+
import { createSlamAppStore } from 'gps-plus-slam-app-framework/state';
|
|
48
82
|
import { initAR } from 'gps-plus-slam-app-framework/ar';
|
|
49
83
|
import { startGpsWatch } from 'gps-plus-slam-app-framework/sensors';
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
84
|
+
import { NullStorageBackend } from 'gps-plus-slam-app-framework/storage';
|
|
85
|
+
import { recordGpsEvent } from 'gps-plus-slam-app-framework/state';
|
|
86
|
+
|
|
87
|
+
// 1. Compose the store. NullStorageBackend keeps everything in memory; swap
|
|
88
|
+
// to OpfsStorageBackend when you want durable recording.
|
|
89
|
+
const store = createSlamAppStore({
|
|
90
|
+
storageBackend: new NullStorageBackend(),
|
|
91
|
+
});
|
|
52
92
|
|
|
53
|
-
//
|
|
54
|
-
|
|
93
|
+
// 2. Start the WebXR AR session.
|
|
94
|
+
await initAR(document.getElementById('app')!);
|
|
55
95
|
|
|
56
|
-
//
|
|
96
|
+
// 3. Wire GPS into the store.
|
|
57
97
|
startGpsWatch(
|
|
58
98
|
(pos) => {
|
|
59
|
-
|
|
99
|
+
store.dispatch(
|
|
100
|
+
recordGpsEvent({
|
|
101
|
+
/* build the payload from `pos` */
|
|
102
|
+
})
|
|
103
|
+
);
|
|
60
104
|
},
|
|
61
105
|
(err) => {
|
|
62
|
-
|
|
106
|
+
console.error('GPS error', err);
|
|
63
107
|
}
|
|
64
108
|
);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See [`GpsPlusSlamJs_MinimalExample`](../GpsPlusSlamJs_MinimalExample/) for a complete, runnable smallest-possible consumer (Three.js scene + status panel, no AR, no recording). For the next rung up — a readable AR + GPS + persistence demo (a single GPS anchor that survives a page reload) — see [`GpsPlusSlamJs_AnchorStarter`](../GpsPlusSlamJs_AnchorStarter/). The example ladder is **trivial** (MinimalExample) → **starter** (AnchorStarter) → **full** (RecorderApp).
|
|
112
|
+
|
|
113
|
+
> **Imports.** Prefer subpath imports (`gps-plus-slam-app-framework/ar`, `…/state`, `…/sensors`, `…/storage`, `…/geo`, `…/visualization`, `…/utils`, `…/types`, `…/licensing`). The root barrel re-exports conflict-free names for convenience.
|
|
65
114
|
|
|
66
|
-
|
|
67
|
-
const container = document.getElementById('app')!;
|
|
68
|
-
await initAR(container);
|
|
115
|
+
## Composing With Your Own Slices
|
|
69
116
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
117
|
+
`createSlamAppStore` is the headline composability seam. Your app plugs in its own reducers, middleware, and storage backend without forking the factory:
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { createSlamAppStore } from 'gps-plus-slam-app-framework/state';
|
|
121
|
+
import { OpfsStorageBackend } from 'gps-plus-slam-app-framework/storage';
|
|
122
|
+
import { myUiReducer } from './state/ui-slice';
|
|
123
|
+
import { myAnalyticsMiddleware } from './state/analytics-middleware';
|
|
124
|
+
|
|
125
|
+
const store = createSlamAppStore({
|
|
126
|
+
storageBackend: new OpfsStorageBackend(),
|
|
127
|
+
extraReducers: { ui: myUiReducer },
|
|
128
|
+
extraMiddleware: [myAnalyticsMiddleware],
|
|
129
|
+
onWriteFailure: (err) => myErrorReporter(err),
|
|
130
|
+
enableDevChecks: import.meta.env.DEV,
|
|
131
|
+
// licenseKey: 'paid-key-here' // omit to use the bundled community key
|
|
73
132
|
});
|
|
74
133
|
```
|
|
75
134
|
|
|
76
|
-
|
|
135
|
+
| Option | Purpose |
|
|
136
|
+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
137
|
+
| `storageBackend` | **Required.** Bridge from Redux actions to durable storage. Use `NullStorageBackend` for tests/replay, `OpfsStorageBackend` for browser recording. |
|
|
138
|
+
| `extraReducers` | Caller-supplied reducers added alongside the framework's built-ins (`gpsData`, `gpsElements`, `arElements`, `recording`). |
|
|
139
|
+
| `extraMiddleware` | Caller-supplied middlewares appended after RTK defaults and the persistence middleware. |
|
|
140
|
+
| `onWriteFailure` | Invoked when the persistence middleware fails to durably write an action. |
|
|
141
|
+
| `enableDevChecks` | Toggle RTK's expensive dev-only Serializable / Immutable checks. Default `true`; set `false` for high-throughput replay. |
|
|
142
|
+
| `licenseKey` | Override the bundled community key with a paid license. Validation always runs. |
|
|
77
143
|
|
|
78
|
-
##
|
|
144
|
+
## Recording & Replay
|
|
79
145
|
|
|
80
|
-
|
|
146
|
+
Out of the box the framework lays out durable storage like this when you use `OpfsStorageBackend`:
|
|
81
147
|
|
|
82
|
-
|
|
148
|
+
```
|
|
149
|
+
/gps-plus-slam/
|
|
150
|
+
└── sessions/
|
|
151
|
+
└── recording-{timestamp}/
|
|
152
|
+
├── actions/ (one JSON file per recorded Redux action)
|
|
153
|
+
├── frames/ (captured camera/depth frames)
|
|
154
|
+
└── session.json
|
|
155
|
+
```
|
|
83
156
|
|
|
84
|
-
|
|
85
|
-
| -------------------------------------------- | ------------------------------------------------ |
|
|
86
|
-
| `initAR(container)` | Start a WebXR AR session with Three.js rendering |
|
|
87
|
-
| `endARSession()` | End the active XR session |
|
|
88
|
-
| `startImageCapture()` / `stopImageCapture()` | Toggle camera frame capture |
|
|
89
|
-
| `startDepthCapture()` / `stopDepthCapture()` | Toggle depth sampling |
|
|
90
|
-
| `initReplayScene(container)` | Create a 3D replay scene with orbit/FPS controls |
|
|
91
|
-
| `ImageCaptureManager` | Configurable camera frame capture pipeline |
|
|
92
|
-
| `DepthSampler` | Depth buffer sampling with configurable grids |
|
|
93
|
-
| `CameraBlitCapture` | GPU blit-based camera capture |
|
|
94
|
-
| `TrackingStateManager` | AR tracking state monitoring |
|
|
157
|
+
Key APIs:
|
|
95
158
|
|
|
96
|
-
|
|
159
|
+
- `exportSessionAsZip(sessionHandle, { contributors? })` — bundle a recorded session into a ZIP blob.
|
|
160
|
+
- `replayRecording(store, blob)` — feed a ZIP recording back into a store.
|
|
161
|
+
- `loadActionsFromZip(blob)` / `loadEntriesFromSubdir(blob, subdir)` — read recorded actions or any contributor-defined ZIP subdirectory.
|
|
97
162
|
|
|
98
|
-
|
|
163
|
+
### Adding Your Own ZIP Sections (`ZipExportContributor`)
|
|
99
164
|
|
|
100
|
-
|
|
101
|
-
| ----------------------------- | --------------------------------- |
|
|
102
|
-
| `startGpsWatch(onPos, onErr)` | Start watching GPS position |
|
|
103
|
-
| `stopGpsWatch()` | Stop GPS watch |
|
|
104
|
-
| `startOrientationWatch(cb)` | Start device orientation events |
|
|
105
|
-
| `checkAllPermissions()` | Probe camera, GPS, XR permissions |
|
|
106
|
-
| `requestAllPermissions()` | Request all needed permissions |
|
|
107
|
-
| `getGpsErrorMessage(code)` | Human-readable GPS error messages |
|
|
165
|
+
Apps that need to ship extra data alongside the standard recording (e.g., the recorder app stores `refPoints/` this way) implement a `ZipExportContributor`:
|
|
108
166
|
|
|
109
|
-
|
|
167
|
+
```typescript
|
|
168
|
+
import {
|
|
169
|
+
exportSessionAsZip,
|
|
170
|
+
type ZipExportContributor,
|
|
171
|
+
} from 'gps-plus-slam-app-framework/storage';
|
|
172
|
+
|
|
173
|
+
const refPointsContributor: ZipExportContributor = {
|
|
174
|
+
subdir: 'refPoints',
|
|
175
|
+
contribute: async (addFile) => {
|
|
176
|
+
addFile('points.json', JSON.stringify(myRefPoints));
|
|
177
|
+
},
|
|
178
|
+
};
|
|
110
179
|
|
|
111
|
-
|
|
180
|
+
const blob = await exportSessionAsZip(sessionHandle, {
|
|
181
|
+
contributors: [refPointsContributor],
|
|
182
|
+
});
|
|
183
|
+
```
|
|
112
184
|
|
|
113
|
-
|
|
114
|
-
| ----------------------------------- | --------------------------------------------- |
|
|
115
|
-
| `createRecorderStore(options?)` | Create a combined store (core + app slices) |
|
|
116
|
-
| `startSession()` / `endSession()` | Session lifecycle actions |
|
|
117
|
-
| `recordGpsEvent(payload)` | Record a paired AR+GPS observation |
|
|
118
|
-
| `createGpsPositionHandler(config)` | Factory for GPS→store wiring |
|
|
119
|
-
| `ReplayEngine` | Timed action playback with pause/resume/speed |
|
|
120
|
-
| `replayRecording(store, blob)` | Replay a ZIP recording into a store |
|
|
121
|
-
| `wireStoreSubscribers(store, deps)` | Bridge store state → visualization updates |
|
|
122
|
-
| `loadRecordingOptions()` | Load persisted recording settings |
|
|
123
|
-
| `refPointsReducer` | Reference point state reducer |
|
|
185
|
+
## Scene-Graph Convention
|
|
124
186
|
|
|
125
|
-
|
|
187
|
+
The framework's WebXR scene is laid out so that the **scene root is GPS-aligned (NUE) space**:
|
|
126
188
|
|
|
127
|
-
|
|
189
|
+
```
|
|
190
|
+
scene ← GPS-aligned (NUE) space, the scene root
|
|
191
|
+
├── arWorldGroup ← carries the alignment matrix (GPS → AR)
|
|
192
|
+
│ ├── camera ← WebXR XRViewerPose (raw AR pose)
|
|
193
|
+
│ └── ar-content ← anything fixed in AR space
|
|
194
|
+
│ (planes, point clouds, hit-test reticles, …)
|
|
195
|
+
└── ..objects with gps coords.. ← anything anchored to GPS coordinates
|
|
196
|
+
(waypoints, POIs, navigation arrows, …)
|
|
197
|
+
```
|
|
128
198
|
|
|
129
|
-
|
|
130
|
-
| -------------------------------------- | ----------------------------------------------- |
|
|
131
|
-
| `StorageBackend` | Abstract storage interface (implement your own) |
|
|
132
|
-
| `OpfsStorageBackend` | OPFS-based `StorageBackend` implementation |
|
|
133
|
-
| `NullStorageBackend` | No-op backend for testing |
|
|
134
|
-
| `initOpfsStorage()` | Initialize OPFS directory structure |
|
|
135
|
-
| `initStorage(backend)` | Initialize the file-system layer |
|
|
136
|
-
| `exportSessionAsZip(handle)` | Export a recording session as a ZIP blob |
|
|
137
|
-
| `loadActionsFromZip(blob)` | Parse recorded actions from a ZIP file |
|
|
138
|
-
| `importRefPointsFromFolder(handle)` | Import reference points from prior sessions |
|
|
139
|
-
| `saveRefPointObservation(handle, obs)` | Persist a reference point observation |
|
|
199
|
+
When the alignment solver produces a new matrix, the framework writes it to `arWorldGroup.matrix` (smoothly lerped — see `enableArWorldGroupAlignment` below). The camera moves with `arWorldGroup`; objects parented directly to `scene` do not.
|
|
140
200
|
|
|
141
|
-
|
|
201
|
+
> **Apply alignment to `arWorldGroup` — the framework default.** Call
|
|
202
|
+
> [`enableArWorldGroupAlignment({ store, arWorldGroup })`](src/visualization/ar-world-group-alignment.ts.md)
|
|
203
|
+
> once after AR starts. It subscribes to the store's alignment matrix, lerps it
|
|
204
|
+
> onto `arWorldGroup.matrix` each frame, and thereby **GPS-registers the view**:
|
|
205
|
+
> the camera and every object parented under `arWorldGroup` (including GPS
|
|
206
|
+
> anchors) shift together as alignment refines, so anchors stay stable in the AR
|
|
207
|
+
> overlay and only ever correct a small residual. The recorder wires its own
|
|
208
|
+
> lerper; the simpler apps use this helper. Forgetting it leaves the camera
|
|
209
|
+
> pure-VIO and forces each anchor to absorb the full alignment delta on every
|
|
210
|
+
> re-registration.
|
|
211
|
+
|
|
212
|
+
**Three options for placing your own `Object3D`:**
|
|
213
|
+
|
|
214
|
+
1. **Add it to `scene`** (with NUE-meter coordinates from `calcRelativeCoordsInMeters(zeroRef, …)`). The object's world pose stays at the correct latitude/longitude/altitude forever, but every time the alignment matrix is corrected the camera shifts inside `arWorldGroup`, so from the user's AR view the object visually "floats". Cheap and correct, but ugly during corrections — fine for small markers (e.g. ref-point spheres), not great for richer GPS-anchored content.
|
|
215
|
+
2. **Add it to `arWorldGroup`** with a fixed local transform. The object is frozen relative to AR-tracked content and stays visually fixed at the same 3D position for this session. This is a good fit for user-created local content such as a walked path, a temporary marker, a hit-test reticle, or an object the user placed by hand. The tradeoff is that its world / GPS pose drifts every time alignment is corrected, so this mode is not enough when the object must be replayed or shared by GPS coordinate.
|
|
216
|
+
3. **Use `createGpsAnchor` for objects that should stay visually stable at a GPS target.** The anchor owns a single `Object3D` **inside `arWorldGroup`** (the factory throws if `object3D` is not a descendant of the `arWorldGroup` you pass — placing an anchor under the scene root defeats AR stability), bootstraps from median samples unless `skipBootstrap` is set, and re-derives the object's local pose from the current GPS target and alignment state each tick. Because the object rides the (lerped) `arWorldGroup` alignment, its motion relative to the camera between re-registrations is small. In the default `snap-when-offscreen` mode an accepted correction is committed **instantly** while the object is outside the camera frustum, making the (now small, residual) correction hard to notice; larger alignment jumps bypass that gate so the object does not stay in a stale location. Use `snap-every-tick` when correctness is more important than hiding visible position changes. Smoothing is **not** per-anchor: it lives once in the lerped `arWorldGroup.matrix` (`enableArWorldGroupAlignment`), so the whole AR world eases together. This is how the MinimalExample and AnchorStarter get the smooth alignment feel.
|
|
217
|
+
|
|
218
|
+
A pure-function `syncGpsAnchoredMeshes` reconciler (option 1, bulk markers) is shipped by the RecorderApp. Use `createGpsAnchor` when a single visible object, route cue, or POI needs the more careful bootstrap and correction policy.
|
|
142
219
|
|
|
143
|
-
|
|
220
|
+
> **Worked example.** The [`GpsPlusSlamJs_MinimalExample`](../GpsPlusSlamJs_MinimalExample/) ports the stock three.js `webxr_ar_hittest` example onto this convention and ends in a deliberate side-by-side **contrast demo**: a tap co-spawns an option-1 floater under `scene` and an option-3 `createGpsAnchor` marker under `arWorldGroup` at the same world pose, so the drift difference is visible. It is the canonical reference for options 1–3 and for the `registerXrFrameUpdate` + Enable-GPS-AR seams below.
|
|
144
221
|
|
|
145
|
-
|
|
146
|
-
| ------------------------------ | --------------------------------------------------- |
|
|
147
|
-
| `LeafletMapOverlay` | 2D Leaflet map integrated via CSS3D into a 3D scene |
|
|
148
|
-
| `MapOverlay` | Tile-based 3D map overlay (no Leaflet dependency) |
|
|
149
|
-
| `GpsEventVisualizer` | Three.js spheres for GPS event positions |
|
|
150
|
-
| `RefPointVisualizer` | Three.js spheres for reference points |
|
|
151
|
-
| `createAlignmentLerper()` | Smooth alignment matrix interpolation |
|
|
152
|
-
| `createCameraFollower()` | Camera that tracks a moving target |
|
|
153
|
-
| `createCss3dRendererManager()` | CSS3D renderer for HTML-in-3D overlays |
|
|
154
|
-
| `createGpsCompassCubes()` | Cardinal direction indicator cubes |
|
|
155
|
-
| `VIS_COLORS` | Consistent color palette for visualizations |
|
|
156
|
-
| `disposeObject3D(obj)` | Safe Three.js object disposal |
|
|
222
|
+
## DOM-Overlay / HUD stacking convention
|
|
157
223
|
|
|
158
|
-
|
|
224
|
+
`initAR(container)` requests the WebXR **`dom-overlay`** feature with
|
|
225
|
+
`domOverlay.root = container` — the **same element you pass in**. During an
|
|
226
|
+
`immersive-ar` session the browser composites **only that element's subtree**
|
|
227
|
+
over the camera feed; everything else on the page is hidden until the session
|
|
228
|
+
ends.
|
|
159
229
|
|
|
160
|
-
|
|
230
|
+
> **The rule:** every HUD / overlay / button you want visible **in AR** must be
|
|
231
|
+
> a **DOM descendant of the element you pass to `initAR`**. A sibling overlay
|
|
232
|
+
> works in the 2D pre-AR layout but silently disappears the moment AR starts —
|
|
233
|
+
> a failure that only shows up on real AR hardware, never in a headless test.
|
|
234
|
+
|
|
235
|
+
This is **not** a `z-index` problem; `z-index`/`pointer-events` only govern the
|
|
236
|
+
2D (pre-AR) layout. Nesting is what determines in-AR visibility.
|
|
237
|
+
|
|
238
|
+
```html
|
|
239
|
+
<!-- ✅ Correct: HUD is inside the initAR container -->
|
|
240
|
+
<div id="app">
|
|
241
|
+
<!-- three.js canvas is injected here by initAR -->
|
|
242
|
+
<div id="hud">…</div>
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<!-- ❌ Wrong: HUD is a sibling — it vanishes once AR starts -->
|
|
246
|
+
<div id="app"></div>
|
|
247
|
+
<div id="hud">…</div>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```js
|
|
251
|
+
await initAR(document.getElementById('app')!); // #app's subtree = the overlay root
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
A repo-meta guard (`tests/repo-config/hud-overlay-nesting.test.js`) asserts this
|
|
255
|
+
structurally for every app's `index.html`, so a new app that authors its overlay
|
|
256
|
+
as a sibling fails CI instead of failing silently in the field. Add new apps to
|
|
257
|
+
that guard's `APP_OVERLAY_CONTRACTS` list.
|
|
258
|
+
|
|
259
|
+
## Modules
|
|
260
|
+
|
|
261
|
+
### `ar/` — WebXR & 3D Scene
|
|
161
262
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
|
165
|
-
|
|
|
166
|
-
| `
|
|
263
|
+
WebXR session lifecycle, Three.js renderer setup, image/depth capture, replay scene management.
|
|
264
|
+
|
|
265
|
+
| Export | Description |
|
|
266
|
+
| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
267
|
+
| `initAR(container, isolation?, features?)` | Start a WebXR AR session with Three.js rendering. `features.requestHitTest` opts the session into the WebXR `hit-test` feature |
|
|
268
|
+
| `endARSession()` | End the active XR session |
|
|
269
|
+
| `createEnableGpsArController()` | Headless "Enable GPS AR" orchestration (support check + permission bundling + sensor watches + `initAR`) with observable state; the app renders its own button over it |
|
|
270
|
+
| `registerXrFrameUpdate(cb)` | Per-frame access to the live `XRFrame` + reference space + session (valid only synchronously inside the callback). Enables app-side hit-test / other WebXR features |
|
|
271
|
+
| `isFullySupported(s)` / `capabilityMessage(s)` | WebXR + geolocation capability gating + a user-facing message |
|
|
272
|
+
| `startImageCapture()` / `stopImageCapture()` | Toggle camera frame capture |
|
|
273
|
+
| `ImageCaptureManager` | Configurable camera frame capture pipeline |
|
|
274
|
+
| `DepthSampler` | Depth buffer sampling with configurable grids |
|
|
275
|
+
| `CameraBlitCapture` | GPU blit-based camera capture |
|
|
276
|
+
| `initReplayScene(container)` | Create a 3D replay scene with orbit/FPS controls |
|
|
277
|
+
| `applyChromiumProjectionLayerWorkaround` | Chromium camera-access tab-crash workaround. Always deletes projection-layer hooks (forces `XRWebGLLayer`; required on every affected build incl. Chrome 150) and additionally persists `baseLayer` only on the affected Chrome window (148.0.7778.12 up to 149.0.7821) |
|
|
278
|
+
|
|
279
|
+
### `sensors/` — GPS & Permissions
|
|
280
|
+
|
|
281
|
+
| Export | Description |
|
|
282
|
+
| ----------------------------------- | ----------------------------------------- |
|
|
283
|
+
| `startGpsWatch(onPos, onErr)` | Start watching GPS position |
|
|
284
|
+
| `stopGpsWatch()` | Stop GPS watch |
|
|
285
|
+
| `startOrientationWatch(cb)` | Start device orientation events |
|
|
286
|
+
| `checkAllPermissions()` | Probe camera, GPS, XR permissions |
|
|
287
|
+
| `requestAllPermissions()` | Request all needed permissions |
|
|
288
|
+
| `getGpsErrorMessage(code)` | Human-readable GPS error messages |
|
|
289
|
+
| `createGpsErrorHandler()` | GPS error callback with deduplicated logs |
|
|
290
|
+
| `requestWebXRWithDepthPermission()` | Combined XR + depth permission prompt |
|
|
291
|
+
|
|
292
|
+
### `state/` — Store & Recording
|
|
293
|
+
|
|
294
|
+
| Export | Description |
|
|
295
|
+
| --------------------------------------------------- | -------------------------------------------------------------- |
|
|
296
|
+
| `createSlamAppStore(options)` | Composable store factory (see options table above). |
|
|
297
|
+
| `recordingReducer` | Recording lifecycle slice (built into the factory). |
|
|
298
|
+
| `startSession()` / `endSession()` | Recording lifecycle actions. |
|
|
299
|
+
| `recordGpsEvent(payload)` | Record a paired AR+GPS observation. |
|
|
300
|
+
| `createGpsPositionHandler(config)` | Factory that adapts `GeolocationPosition` to a store dispatch. |
|
|
301
|
+
| `captureGpsAnchorSample(options)` | Sample a paired AR pose + GPS point for anchoring. |
|
|
302
|
+
| `loadRecordingOptions()` / `saveRecordingOptions()` | Persist user-controlled recording settings. |
|
|
303
|
+
| `replayRecording(store, blob)` | Replay a ZIP recording into a store. |
|
|
304
|
+
| `ReplayEngine` | Lower-level timed action playback with pause/resume/speed. |
|
|
305
|
+
| `createPersistenceMiddleware(options)` | Middleware factory used internally by `createSlamAppStore`. |
|
|
306
|
+
| `wireStoreSubscribers(store, deps)` | Bridge store state → visualization updates. |
|
|
307
|
+
|
|
308
|
+
### `storage/` — OPFS, ZIP, File System
|
|
309
|
+
|
|
310
|
+
| Export | Description |
|
|
311
|
+
| ---------------------------------------------- | ------------------------------------------------------- |
|
|
312
|
+
| `StorageBackend` | Abstract storage interface (implement your own). |
|
|
313
|
+
| `OpfsStorageBackend` | OPFS-based `StorageBackend`. |
|
|
314
|
+
| `NullStorageBackend` | No-op backend for tests and replay. |
|
|
315
|
+
| `initOpfsStorage()` / `initStorage(backend)` | Initialize the file-system layer. |
|
|
316
|
+
| `createSession()` / `listSessions()` | Session lifecycle on disk. |
|
|
317
|
+
| `exportSessionAsZip(handle, { contributors })` | Export a recording session as a ZIP blob. |
|
|
318
|
+
| `ZipExportContributor` | Hook for adding your own ZIP subdirectories on export. |
|
|
319
|
+
| `loadActionsFromZip(blob)` | Parse recorded actions from a ZIP file. |
|
|
320
|
+
| `loadEntriesFromSubdir(blob, subdir)` | Read entries written by a contributor on import/replay. |
|
|
321
|
+
| `loadSessionMetadataFromBlob(blob)` | Read `session.json` from a ZIP. |
|
|
322
|
+
| `loadGpsPathFromBlob(blob)` | Read the recorded GPS path. |
|
|
323
|
+
| `checkStorageQuota()` | Check OPFS quota usage. |
|
|
324
|
+
|
|
325
|
+
### `geo/` — H3 Spatial Indexing
|
|
326
|
+
|
|
327
|
+
H3-based proximity matching for GPS-anchored points (renamed from `ref-points/` in the boundary migration).
|
|
328
|
+
|
|
329
|
+
| Export | Description |
|
|
330
|
+
| -------------------------------- | ------------------------------------------------------------- |
|
|
331
|
+
| `gpsToH3(lat, lon)` | Convert GPS coordinates to an H3 cell index. |
|
|
332
|
+
| `findNearbyGeoAnchor(h3, known)` | Find a known geo-anchored point near an H3 cell. |
|
|
333
|
+
| `h3CellsMatch(a, b)` | Compare two H3 indices. |
|
|
334
|
+
| `approxDistanceMetres(a, b)` | Approximate distance between two `LatLong`s. |
|
|
335
|
+
| `isH3Index(value)` | Type guard for H3 index strings. |
|
|
336
|
+
| `H3_RESOLUTION` | The H3 resolution used (default: 12, ~10 m cells). |
|
|
337
|
+
| `KnownGeoAnchor` (type) | Shape of a known anchor with H3 index, lat/lon, and metadata. |
|
|
338
|
+
|
|
339
|
+
### `visualization/` — Three.js & Maps
|
|
340
|
+
|
|
341
|
+
| Export | Description |
|
|
342
|
+
| ------------------------------ | ------------------------------------------------------ |
|
|
343
|
+
| `LeafletMapOverlay` | 2D Leaflet map integrated via CSS3D into a 3D scene. |
|
|
344
|
+
| `MapOverlay` | Tile-based 3D map overlay (no Leaflet dependency). |
|
|
345
|
+
| `GpsEventVisualizer` | Three.js spheres for GPS event positions. |
|
|
346
|
+
| `createAlignmentLerper()` | Smooth alignment matrix interpolation. |
|
|
347
|
+
| `createCameraFollower()` | Camera that tracks a moving target. |
|
|
348
|
+
| `createCss3dRendererManager()` | CSS3D renderer for HTML-in-3D overlays. |
|
|
349
|
+
| `createGpsCompassCubes()` | Cardinal direction indicator cubes. |
|
|
350
|
+
| `createGpsAnchor()` | GPS-anchored placement helper for one Three.js object. |
|
|
351
|
+
| `VIS_COLORS` | Consistent color palette for visualizations. |
|
|
352
|
+
| `disposeObject3D(obj)` | Safe Three.js object disposal. |
|
|
167
353
|
|
|
168
354
|
### `utils/` — Logging & Helpers
|
|
169
355
|
|
|
170
|
-
| Export | Description
|
|
171
|
-
| ------------------------------------------- |
|
|
172
|
-
| `createLogger(channel)` |
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
356
|
+
| Export | Description |
|
|
357
|
+
| ------------------------------------------- | ------------------------------------------------- |
|
|
358
|
+
| `createLogger(channel)` | Channeled logger with level control. |
|
|
359
|
+
| `getLogBuffer()` / `subscribeToLogs()` | Inspect or subscribe to the in-memory log ring. |
|
|
360
|
+
| `computeFusedPath(inputs)` | Compute a fused GPS+odometry path. |
|
|
361
|
+
| `createFailureTracker(config)` | Track failure rates with configurable thresholds. |
|
|
362
|
+
| `mapWithConcurrencyLimit(items, fn, limit)` | Async map with bounded concurrency. |
|
|
363
|
+
| `formatFileSize(bytes)` | Human-readable file sizes. |
|
|
364
|
+
| `listFormatter(items)` | Human-friendly comma/and list formatting. |
|
|
177
365
|
|
|
178
366
|
### `types/` — Shared Type Definitions
|
|
179
367
|
|
|
180
|
-
AR and
|
|
368
|
+
AR and geo type definitions (`DepthPoint`, `DepthSample`, `LatLong`, `KnownGeoAnchor`, …) used across modules.
|
|
369
|
+
|
|
370
|
+
### `licensing/` — Bundled Community Key
|
|
371
|
+
|
|
372
|
+
Re-exports `COMMUNITY_LICENSE_KEY` from the core library so that consumers can pass it explicitly if they need to. `createSlamAppStore` already uses it as the default.
|
|
181
373
|
|
|
182
374
|
## Design Principles
|
|
183
375
|
|
|
184
376
|
1. **No global singletons.** Everything is created via factories and passed explicitly.
|
|
185
|
-
2. **Store is the integration point.**
|
|
377
|
+
2. **Store is the integration point.** Modules communicate through Redux state.
|
|
186
378
|
3. **Modules are optional.** Use `initAR` without `LeafletMapOverlay`. No forced coupling.
|
|
187
|
-
4. **Swappable implementations.** The `StorageBackend` interface lets you replace OPFS with IndexedDB or
|
|
379
|
+
4. **Swappable implementations.** The `StorageBackend` interface lets you replace OPFS with IndexedDB or anything else.
|
|
188
380
|
|
|
189
381
|
## Development
|
|
190
382
|
|
|
191
383
|
```bash
|
|
192
384
|
cd GpsPlusSlamJs_AppFramework
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
385
|
+
pnpm install
|
|
386
|
+
pnpm test # format + lint + typecheck + unit tests
|
|
387
|
+
pnpm run build # build with tsdown
|
|
196
388
|
```
|
|
197
389
|
|
|
198
390
|
### Project Structure
|
|
@@ -201,12 +393,13 @@ npm run build # build with tsdown
|
|
|
201
393
|
src/
|
|
202
394
|
├── ar/ # WebXR session, capture, replay scene
|
|
203
395
|
├── sensors/ # GPS, orientation, permissions
|
|
204
|
-
├── state/ #
|
|
205
|
-
├── storage/ # OPFS, ZIP
|
|
206
|
-
├──
|
|
396
|
+
├── state/ # createSlamAppStore, recording, replay, persistence middleware
|
|
397
|
+
├── storage/ # OPFS, ZIP export/import, StorageBackend
|
|
398
|
+
├── geo/ # H3 spatial indexing
|
|
207
399
|
├── visualization/ # Three.js markers, maps, camera helpers
|
|
208
|
-
├── utils/ # Logger, concurrency, formatters
|
|
400
|
+
├── utils/ # Logger, fused-path, concurrency, formatters
|
|
209
401
|
├── types/ # Shared type definitions
|
|
402
|
+
├── licensing/ # Bundled community license key
|
|
210
403
|
└── test-utils/ # Test helpers (browser mocks, ZIP helpers)
|
|
211
404
|
```
|
|
212
405
|
|
|
@@ -214,9 +407,11 @@ src/
|
|
|
214
407
|
|
|
215
408
|
This framework is licensed under **Apache 2.0** — see [LICENSE](LICENSE).
|
|
216
409
|
|
|
217
|
-
> **Note:** This package depends on [gps-plus-slam-js](https://www.npmjs.com/package/gps-plus-slam-js), which is a **closed-source, proprietary** library distributed via npm under a separate license. A community license key is
|
|
410
|
+
> **Note:** This package depends on [gps-plus-slam-js](https://www.npmjs.com/package/gps-plus-slam-js), which is a **closed-source, proprietary** library distributed via npm under a separate license. A free community license key is bundled with the framework so you can start building right away — no signup or API key required. See the core library's EULA for the full terms.
|
|
218
411
|
|
|
219
412
|
## See Also
|
|
220
413
|
|
|
221
|
-
- [gps-plus-slam-js](https://www.npmjs.com/package/gps-plus-slam-js) — Core alignment algorithms (closed-source
|
|
222
|
-
- [
|
|
414
|
+
- [gps-plus-slam-js](https://www.npmjs.com/package/gps-plus-slam-js) — Core alignment algorithms (closed-source)
|
|
415
|
+
- [`GpsPlusSlamJs_MinimalExample`](../GpsPlusSlamJs_MinimalExample/) — Smallest possible consumer of this framework (trivial rung)
|
|
416
|
+
- [`GpsPlusSlamJs_AnchorStarter`](../GpsPlusSlamJs_AnchorStarter/) — Meaningful-minimal starter: a persistent GPS anchor across reload (starter rung)
|
|
417
|
+
- [`GpsPlusSlamJs_RecorderApp`](../GpsPlusSlamJs_RecorderApp/) — Full-featured recording app built on this framework
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import L from "leaflet";
|
|
2
|
+
|
|
3
|
+
//#region ../src/visualization/accuracy-circles.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Style for per-event GPS accuracy circles. Radius comes from the GPS event's
|
|
6
|
+
* horizontal accuracy in meters; larger circles mean lower-quality fixes.
|
|
7
|
+
* Filled and stroked with a highly transparent variant of the path color so
|
|
8
|
+
* overlapping circles remain legible without obscuring the basemap or the
|
|
9
|
+
* polyline drawn on top.
|
|
10
|
+
*/
|
|
11
|
+
declare const ACCURACY_CIRCLE_FILL_OPACITY = 0.12;
|
|
12
|
+
declare const ACCURACY_CIRCLE_STROKE_OPACITY = 0.5;
|
|
13
|
+
declare const ACCURACY_CIRCLE_WEIGHT = 1;
|
|
14
|
+
/**
|
|
15
|
+
* Minimal shape required to render an accuracy circle. Intentionally narrower
|
|
16
|
+
* than `RawGpsSample` so any caller with `lat`/`lng` and an optional
|
|
17
|
+
* `accuracy` (meters) can use this helper without coupling to a specific
|
|
18
|
+
* GPS-sample type.
|
|
19
|
+
*/
|
|
20
|
+
interface AccuracyCircleSample {
|
|
21
|
+
readonly lat: number;
|
|
22
|
+
readonly lng: number;
|
|
23
|
+
readonly accuracy?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Draw one transparent circle per sample whose `accuracy` is a finite
|
|
27
|
+
* positive number. Samples without a usable accuracy value are skipped so
|
|
28
|
+
* pre-accuracy recordings still render their polyline.
|
|
29
|
+
*
|
|
30
|
+
* Circles are added to `map` immediately. The caller is responsible for
|
|
31
|
+
* draw-order: invoke this BEFORE adding the polyline so the line stays
|
|
32
|
+
* visually on top of the circles.
|
|
33
|
+
*
|
|
34
|
+
* @param map - The Leaflet map to add circles to.
|
|
35
|
+
* @param samples - GPS samples to consider; non-positive / non-finite
|
|
36
|
+
* `accuracy` values are silently skipped.
|
|
37
|
+
* @param color - CSS color string used for both stroke and fill.
|
|
38
|
+
* @returns The created `L.Circle` instances, in the order they were added.
|
|
39
|
+
* Callers that track layers for cleanup can append these to their list.
|
|
40
|
+
*/
|
|
41
|
+
declare function addAccuracyCircles(map: L.Map, samples: readonly AccuracyCircleSample[], color: string): L.Circle[];
|
|
42
|
+
//#endregion
|
|
43
|
+
export { addAccuracyCircles as a, AccuracyCircleSample as i, ACCURACY_CIRCLE_STROKE_OPACITY as n, ACCURACY_CIRCLE_WEIGHT as r, ACCURACY_CIRCLE_FILL_OPACITY as t };
|