react-native-image-stitcher 0.18.0 → 0.20.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/CHANGELOG.md +62 -0
- package/android/src/main/java/io/imagestitcher/rn/ARFrameContext.kt +89 -0
- package/android/src/main/java/io/imagestitcher/rn/ARFramePlugin.kt +57 -0
- package/android/src/main/java/io/imagestitcher/rn/AROverlayRenderer.kt +406 -0
- package/android/src/main/java/io/imagestitcher/rn/AROverlayStore.kt +441 -0
- package/android/src/main/java/io/imagestitcher/rn/RNSARCameraView.kt +472 -13
- package/android/src/main/java/io/imagestitcher/rn/RNSARCameraViewManager.kt +30 -5
- package/android/src/main/java/io/imagestitcher/rn/RNSARPluginRegistry.kt +177 -0
- package/android/src/main/java/io/imagestitcher/rn/RNSARSession.kt +127 -0
- package/dist/camera/ARCameraView.d.ts +55 -2
- package/dist/camera/ARCameraView.js +68 -2
- package/dist/camera/Camera.d.ts +65 -2
- package/dist/camera/Camera.js +24 -6
- package/dist/camera/arOverlayController.d.ts +52 -0
- package/dist/camera/arOverlayController.js +132 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -2
- package/dist/stitching/ARFrameMeta.d.ts +49 -0
- package/dist/stitching/AROverlay.d.ts +97 -0
- package/dist/stitching/AROverlay.js +4 -0
- package/ios/Sources/RNImageStitcher/ARCameraViewManager.m +15 -8
- package/ios/Sources/RNImageStitcher/ARCameraViewManager.swift +22 -0
- package/ios/Sources/RNImageStitcher/ARSessionBridge.m +14 -0
- package/ios/Sources/RNImageStitcher/ARSessionBridge.swift +117 -1
- package/ios/Sources/RNImageStitcher/CameraFrameHostObject.h +25 -0
- package/ios/Sources/RNImageStitcher/CameraFrameHostObject.mm +66 -54
- package/ios/Sources/RNImageStitcher/RNISARFramePlugin.swift +284 -0
- package/ios/Sources/RNImageStitcher/RNISAROverlay.swift +409 -0
- package/ios/Sources/RNImageStitcher/RNSARCameraView.swift +281 -3
- package/ios/Sources/RNImageStitcher/RNSARSession.swift +127 -1
- package/package.json +1 -1
- package/src/camera/ARCameraView.tsx +139 -3
- package/src/camera/Camera.tsx +94 -3
- package/src/camera/arOverlayController.ts +184 -0
- package/src/index.ts +21 -1
- package/src/stitching/ARFrameMeta.ts +50 -0
- package/src/stitching/AROverlay.ts +105 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* v0.20.0 — the AR OVERLAY / ANNOTATION renderer's data model.
|
|
5
|
+
*
|
|
6
|
+
* An {@link AROverlay} describes a 2D shape (a billboard marker/box or a
|
|
7
|
+
* world-anchored quad) that the native overlay layer draws ON TOP of the AR
|
|
8
|
+
* camera preview (`RNSARCameraView`). Each overlay is anchored to WORLD
|
|
9
|
+
* positions and REPROJECTED to screen on EVERY AR frame from the current
|
|
10
|
+
* camera pose + intrinsics — so it tracks the scene at display rate with no
|
|
11
|
+
* 3D-engine dependency.
|
|
12
|
+
*
|
|
13
|
+
* ## Two ways to anchor an overlay
|
|
14
|
+
*
|
|
15
|
+
* 1. **A single world point** (`worldPosition`) — drawn as a billboard
|
|
16
|
+
* marker/box facing the camera, sized by `sizeMeters` (default a small
|
|
17
|
+
* marker). Use this for a pin on a detected plane anchor, a label on a
|
|
18
|
+
* point of interest, etc.
|
|
19
|
+
* 2. **Explicit world corners** (`worldQuad`, 3–4 points) — drawn as the
|
|
20
|
+
* outline/box connecting the projected corners. Use this for a detected
|
|
21
|
+
* quad (a shelf face, a packet, a door) whose real-world shape you
|
|
22
|
+
* already know.
|
|
23
|
+
*
|
|
24
|
+
* Provide ONE of the two anchor forms. If both are present `worldQuad` wins
|
|
25
|
+
* (it's the more specific description); the native renderers read `worldQuad`
|
|
26
|
+
* first and fall back to `worldPosition` + `sizeMeters`.
|
|
27
|
+
*
|
|
28
|
+
* ## Rendering / reprojection (native)
|
|
29
|
+
*
|
|
30
|
+
* The native side reprojects each overlay's world point(s) to screen with the
|
|
31
|
+
* AR framework's BUILT-IN, correct projection — iOS
|
|
32
|
+
* `ARFrame.camera.projectPoint(_:orientation:viewportSize:)`, Android
|
|
33
|
+
* `viewMatrix · projectionMatrix` → clip → NDC → screen. Points behind the
|
|
34
|
+
* camera or off-screen are hidden. The layer redraws every frame so the
|
|
35
|
+
* outline/box + label stay pinned to the world as the camera moves.
|
|
36
|
+
*
|
|
37
|
+
* ## Where overlays come from
|
|
38
|
+
*
|
|
39
|
+
* Overlays reach the native renderer through two INDEPENDENT, merged sets:
|
|
40
|
+
*
|
|
41
|
+
* - **JS-set** — the declarative `overlays` prop or the imperative ref
|
|
42
|
+
* methods (`setOverlays` / `addOverlay` / `updateOverlay` / `removeOverlay`
|
|
43
|
+
* / `clearOverlays`) on `<Camera>` and `<ARCameraView>`.
|
|
44
|
+
* - **Native-plugin-set** — a registered AR plugin places overlays directly
|
|
45
|
+
* via the 0.19 registry (`RNISARPluginRegistry.setOverlays(...)` on iOS /
|
|
46
|
+
* `RNSARPluginRegistry.setOverlays(...)` on Android), with zero JS latency.
|
|
47
|
+
*
|
|
48
|
+
* The native renderer draws the UNION of both sets; the plugin set is
|
|
49
|
+
* namespaced so a JS `setOverlays(...)` never clobbers plugin overlays.
|
|
50
|
+
*/
|
|
51
|
+
export interface AROverlay {
|
|
52
|
+
/**
|
|
53
|
+
* Stable identifier. The declarative `overlays` prop diffs the incoming
|
|
54
|
+
* array against the current set BY `id` (add / update / remove); the
|
|
55
|
+
* imperative `updateOverlay` / `removeOverlay` methods key off it too. Must
|
|
56
|
+
* be unique within a set.
|
|
57
|
+
*/
|
|
58
|
+
id: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Anchor form 1 — a single world point in METRES (world space `[x, y, z]`).
|
|
62
|
+
* Drawn as a billboard marker/box of `sizeMeters` extent facing the camera.
|
|
63
|
+
* Ignored when `worldQuad` is provided.
|
|
64
|
+
*/
|
|
65
|
+
worldPosition?: [number, number, number];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Box extent in METRES `[width, height]` at `worldPosition`. Only meaningful
|
|
69
|
+
* with `worldPosition`. Defaults to a small marker on the native side when
|
|
70
|
+
* omitted.
|
|
71
|
+
*/
|
|
72
|
+
sizeMeters?: [number, number];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Anchor form 2 — 3 or 4 explicit world corners in METRES (e.g. a detected
|
|
76
|
+
* quad). Each corner is `[x, y, z]` in world space. Drawn as the
|
|
77
|
+
* outline/box connecting the projected corners. Takes precedence over
|
|
78
|
+
* `worldPosition` + `sizeMeters` when both are present.
|
|
79
|
+
*/
|
|
80
|
+
worldQuad?: Array<[number, number, number]>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Draw style. Default `'outline'` (stroked edges). `'box'` is a filled /
|
|
84
|
+
* boxed marker. Both render in 2D this release.
|
|
85
|
+
*/
|
|
86
|
+
shape?: 'box' | 'outline';
|
|
87
|
+
|
|
88
|
+
/** Optional text label drawn at the overlay's anchor point. */
|
|
89
|
+
label?: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Stroke / fill colour as a hex string (e.g. `'#00E5FF'`). Defaults to a
|
|
93
|
+
* theme colour on the native side when omitted.
|
|
94
|
+
*/
|
|
95
|
+
color?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Render mode. Default `'2d'` — a flat shape reprojected to screen.
|
|
99
|
+
* `'3d'` is SCAFFOLD ONLY this release: the data-model field exists and the
|
|
100
|
+
* native renderers leave a marked hook for a future SceneKit (iOS) / Android
|
|
101
|
+
* 3D renderer, but v1 treats `'3d'` as `'2d'` (with a one-time native log
|
|
102
|
+
* warning). Document-only forward compatibility.
|
|
103
|
+
*/
|
|
104
|
+
mode?: '2d' | '3d';
|
|
105
|
+
}
|