@vincentt-xr/sdk 2.0.0-alpha.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/GROUNDING.md +537 -0
- package/LICENSE +7 -0
- package/README.md +85 -0
- package/dist/DebuggerUI-CEfdddkZ.cjs +1 -0
- package/dist/DebuggerUI-Dgop6Q6o.js +269 -0
- package/dist/audio/AudioEngine.d.ts +98 -0
- package/dist/audio/index.d.ts +34 -0
- package/dist/components/AspectRatioContainer/index.d.ts +10 -0
- package/dist/components/BodyTracker/index.d.ts +15 -0
- package/dist/components/Debugger/DebuggerProvider.d.ts +22 -0
- package/dist/components/Debugger/DebuggerUI.d.ts +13 -0
- package/dist/components/Debugger/index.d.ts +38 -0
- package/dist/components/Debugger/styles.d.ts +19 -0
- package/dist/components/FaceMesh/FaceMesh.d.ts +26 -0
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +34 -0
- package/dist/components/FaceMesh/canonical/parseCanonicalFaceModel.d.ts +16 -0
- package/dist/components/FaceMesh/canonical/useCanonicalFaceMesh.d.ts +15 -0
- package/dist/components/FaceMesh/deform.d.ts +36 -0
- package/dist/components/FaceMesh/index.d.ts +6 -0
- package/dist/components/FaceMesh/indices.d.ts +1 -0
- package/dist/components/FaceMesh/material/blendModes.d.ts +2 -0
- package/dist/components/FaceMesh/material/defaults.d.ts +3 -0
- package/dist/components/FaceMesh/material/index.d.ts +5 -0
- package/dist/components/FaceMesh/material/options.d.ts +25 -0
- package/dist/components/FaceMesh/material/support.d.ts +3 -0
- package/dist/components/FaceMesh/material/types.d.ts +23 -0
- package/dist/components/FaceMesh/uv.d.ts +1 -0
- package/dist/components/FaceRetouch/Background.d.ts +16 -0
- package/dist/components/FaceRetouch/index.d.ts +6 -0
- package/dist/components/FaceRetouch/landmarkMask.d.ts +23 -0
- package/dist/components/FaceRetouch/retouchRegions.d.ts +23 -0
- package/dist/components/FaceRetouch/useFaceRetouchMask.d.ts +14 -0
- package/dist/components/FaceRetouch/useFaceRetouchRegions.d.ts +12 -0
- package/dist/components/FaceTracker/BoundingBoxOverlay.d.ts +20 -0
- package/dist/components/FaceTracker/index.d.ts +54 -0
- package/dist/components/GestureTracker/index.d.ts +31 -0
- package/dist/components/GestureTrigger/index.d.ts +3 -0
- package/dist/components/HandTracker/index.d.ts +24 -0
- package/dist/components/HeadBinding/index.d.ts +31 -0
- package/dist/components/HeadBindingOccluder/index.d.ts +36 -0
- package/dist/components/HeadOccluder/index.d.ts +13 -0
- package/dist/components/Panel/index.d.ts +71 -0
- package/dist/components/PerspectiveCamera/index.d.ts +14 -0
- package/dist/components/ScreenSpaceUI/ScreenTransform.d.ts +54 -0
- package/dist/components/ScreenSpaceUI/context.d.ts +29 -0
- package/dist/components/ScreenSpaceUI/index.d.ts +40 -0
- package/dist/components/Segmentation/index.d.ts +44 -0
- package/dist/components/SpriteAnimation/index.d.ts +52 -0
- package/dist/components/TextLabel/index.d.ts +62 -0
- package/dist/components/TrackingAnchor/index.d.ts +74 -0
- package/dist/components/VideoBackground/index.d.ts +38 -0
- package/dist/components/XRCompositor/index.d.ts +5 -0
- package/dist/components/XRDebugView/index.d.ts +6 -0
- package/dist/components/XRLayer/index.d.ts +6 -0
- package/dist/components/XRMediaSurface/index.d.ts +27 -0
- package/dist/components/XRProvider/index.d.ts +13 -0
- package/dist/components/XRScene/defaults.d.ts +4 -0
- package/dist/components/XRScene/index.d.ts +15 -0
- package/dist/components/XRViewport/index.d.ts +101 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/config/index.d.ts +8 -0
- package/dist/constants/index.d.ts +25 -0
- package/dist/constants/renderLayers.d.ts +25 -0
- package/dist/entries/all.d.ts +15 -0
- package/dist/entries/core.d.ts +21 -0
- package/dist/entries/face-effects.d.ts +19 -0
- package/dist/entries/internal.d.ts +16 -0
- package/dist/entries/low-level.d.ts +30 -0
- package/dist/entries/tracking.d.ts +15 -0
- package/dist/face-effects.cjs +252 -0
- package/dist/face-effects.js +3542 -0
- package/dist/hasFullUnitUVBounds-BGvcFsQM.js +26 -0
- package/dist/hasFullUnitUVBounds-p1Dl0ejX.cjs +1 -0
- package/dist/hooks/faceResults.d.ts +39 -0
- package/dist/hooks/selectors.d.ts +33 -0
- package/dist/hooks/useCalibrationFaceTracker.d.ts +23 -0
- package/dist/hooks/useDebugger/index.d.ts +25 -0
- package/dist/hooks/useDebugger/types.d.ts +20 -0
- package/dist/hooks/useFaceBoundingBox.d.ts +11 -0
- package/dist/hooks/useFaceResults.d.ts +31 -0
- package/dist/hooks/useGestureEdge.d.ts +53 -0
- package/dist/hooks/useMediaRecorder.d.ts +40 -0
- package/dist/hooks/useTrackerContext.d.ts +35 -0
- package/dist/hooks/useXRModel.d.ts +15 -0
- package/dist/hooks/useXRSession/constants.d.ts +4 -0
- package/dist/hooks/useXRSession/facade.d.ts +39 -0
- package/dist/hooks/useXRSession/fns.d.ts +5 -0
- package/dist/hooks/useXRSession/index.d.ts +4 -0
- package/dist/hooks/useXRSession/registry.d.ts +52 -0
- package/dist/hooks/useXRSession/store.d.ts +40 -0
- package/dist/index-B5J4gzn2.cjs +1 -0
- package/dist/index-BD-JWMjE.js +1991 -0
- package/dist/index-BVBVg96G.cjs +1 -0
- package/dist/index-CYMj26Ej.js +1331 -0
- package/dist/index-DtwHElmG.js +157 -0
- package/dist/index-PtFmD6B8.cjs +1 -0
- package/dist/internal-DH5d1Xnq.cjs +1 -0
- package/dist/internal-KOKJDxCG.js +519 -0
- package/dist/internal.cjs +1 -0
- package/dist/internal.js +14 -0
- package/dist/low-level.cjs +1 -0
- package/dist/low-level.js +941 -0
- package/dist/main.cjs +1 -0
- package/dist/main.js +612 -0
- package/dist/models/Base/index.d.ts +25 -0
- package/dist/models/Body/index.d.ts +22 -0
- package/dist/models/Face/constants.d.ts +2 -0
- package/dist/models/Face/index.d.ts +45 -0
- package/dist/models/Face/landmarksData.d.ts +2 -0
- package/dist/models/Hand/GestureTracking.d.ts +21 -0
- package/dist/models/Hand/HandTracking.d.ts +21 -0
- package/dist/models/Segmentation/index.d.ts +75 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/modules/XRClient/index.d.ts +9 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/selectors-BHO6TnoC.js +59 -0
- package/dist/selectors-Bub0o3qy.cjs +1 -0
- package/dist/services/ApiService.d.ts +12 -0
- package/dist/services/MetricsCollector/CameraFPSTracker.d.ts +25 -0
- package/dist/services/MetricsCollector/MemoryTracker.d.ts +43 -0
- package/dist/services/MetricsCollector/RenderTimeTracker.d.ts +10 -0
- package/dist/services/MetricsCollector/ResolutionTracker.d.ts +26 -0
- package/dist/services/MetricsCollector/index.d.ts +59 -0
- package/dist/services/MetricsCollector/types.d.ts +47 -0
- package/dist/services/MetricsCollector/utils.d.ts +65 -0
- package/dist/texture/computeContainScale.d.ts +25 -0
- package/dist/texture/hasFullUnitUVBounds.d.ts +37 -0
- package/dist/texture/types.d.ts +20 -0
- package/dist/tracking.cjs +1 -0
- package/dist/tracking.js +344 -0
- package/dist/types/body.d.ts +3 -0
- package/dist/types/client.d.ts +3 -0
- package/dist/types/common.d.ts +9 -0
- package/dist/types/compositor.d.ts +23 -0
- package/dist/types/debugger.d.ts +83 -0
- package/dist/types/face.d.ts +67 -0
- package/dist/types/gesture-tracking.d.ts +15 -0
- package/dist/types/hand-tracking.d.ts +5 -0
- package/dist/types/headBinding.d.ts +67 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/logger.d.ts +4 -0
- package/dist/types/model.d.ts +46 -0
- package/dist/types/nodes.d.ts +35 -0
- package/dist/types/segmentation.d.ts +31 -0
- package/dist/types/session.d.ts +102 -0
- package/dist/types/tracking.d.ts +30 -0
- package/dist/types/util-types.d.ts +1 -0
- package/dist/useFaceResults-cpsSmKKc.js +81 -0
- package/dist/useFaceResults-hVUJYSEY.cjs +1 -0
- package/dist/utils/calibrationDebug.d.ts +9 -0
- package/dist/utils/dataURL.d.ts +6 -0
- package/dist/utils/drawMediaCover.d.ts +18 -0
- package/dist/utils/errors.d.ts +3 -0
- package/dist/utils/fns.d.ts +48 -0
- package/dist/utils/headBinding.d.ts +85 -0
- package/dist/utils/integrity.d.ts +43 -0
- package/dist/utils/landmarkBounds.d.ts +11 -0
- package/dist/utils/logger.d.ts +7 -0
- package/package.json +113 -0
|
@@ -0,0 +1,941 @@
|
|
|
1
|
+
import { u as he } from "./index-BD-JWMjE.js";
|
|
2
|
+
import { H as lt, a as ct } from "./index-BD-JWMjE.js";
|
|
3
|
+
import { a as me } from "./selectors-BHO6TnoC.js";
|
|
4
|
+
import { u as ut, c as ht, e as mt, b as ft, d as gt } from "./selectors-BHO6TnoC.js";
|
|
5
|
+
import { useEffect as M, useRef as k, useState as y, useCallback as fe, useContext as ge, useMemo as G, createContext as pe, useLayoutEffect as be, Children as we, isValidElement as ve } from "react";
|
|
6
|
+
import { u as te, c as xe } from "./useFaceResults-cpsSmKKc.js";
|
|
7
|
+
import { u as ye, X as re } from "./index-CYMj26Ej.js";
|
|
8
|
+
import { h as bt } from "./hasFullUnitUVBounds-BGvcFsQM.js";
|
|
9
|
+
import { X as Ce } from "./index-DtwHElmG.js";
|
|
10
|
+
import { c as vt, d as xt, b as yt } from "./index-DtwHElmG.js";
|
|
11
|
+
import { jsx as f, jsxs as z, Fragment as q } from "react/jsx-runtime";
|
|
12
|
+
import { PerspectiveCamera as Re } from "@react-three/drei";
|
|
13
|
+
const Ee = {
|
|
14
|
+
position: "absolute",
|
|
15
|
+
top: -28,
|
|
16
|
+
left: 0,
|
|
17
|
+
background: "rgba(34, 197, 94, 0.9)",
|
|
18
|
+
color: "#04130a",
|
|
19
|
+
fontFamily: "Menlo, Monaco, Consolas, monospace",
|
|
20
|
+
fontSize: 12,
|
|
21
|
+
fontWeight: 700,
|
|
22
|
+
padding: "4px 8px",
|
|
23
|
+
whiteSpace: "nowrap"
|
|
24
|
+
}, Ze = ({
|
|
25
|
+
boundingBox: e,
|
|
26
|
+
label: t = "face bounding box",
|
|
27
|
+
color: n = "#22c55e",
|
|
28
|
+
style: a,
|
|
29
|
+
labelStyle: r
|
|
30
|
+
}) => /* @__PURE__ */ f(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
style: {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
left: `${e.left * 100}%`,
|
|
36
|
+
top: `${e.top * 100}%`,
|
|
37
|
+
width: `${e.width * 100}%`,
|
|
38
|
+
height: `${e.height * 100}%`,
|
|
39
|
+
border: `3px solid ${n}`,
|
|
40
|
+
boxSizing: "border-box",
|
|
41
|
+
pointerEvents: "none",
|
|
42
|
+
zIndex: 20,
|
|
43
|
+
...a
|
|
44
|
+
},
|
|
45
|
+
children: t !== null && /* @__PURE__ */ f("div", { style: { ...Ee, ...r }, children: t })
|
|
46
|
+
}
|
|
47
|
+
), et = (e) => {
|
|
48
|
+
const { makeDefault: t = !0, ...n } = e, a = {
|
|
49
|
+
position: [0, 0, 40],
|
|
50
|
+
fov: 30,
|
|
51
|
+
near: 0.1,
|
|
52
|
+
far: 1e3,
|
|
53
|
+
makeDefault: t,
|
|
54
|
+
...n
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ f(Re, { ...a });
|
|
57
|
+
}, tt = ({
|
|
58
|
+
background: e = "#000",
|
|
59
|
+
children: t,
|
|
60
|
+
style: n
|
|
61
|
+
}) => /* @__PURE__ */ f(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
style: {
|
|
65
|
+
position: "fixed",
|
|
66
|
+
inset: 0,
|
|
67
|
+
overflow: "hidden",
|
|
68
|
+
background: e,
|
|
69
|
+
...n
|
|
70
|
+
},
|
|
71
|
+
children: t
|
|
72
|
+
}
|
|
73
|
+
), $ = ({
|
|
74
|
+
children: e,
|
|
75
|
+
config: t,
|
|
76
|
+
style: n
|
|
77
|
+
}) => /* @__PURE__ */ f(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
"data-render-target": t.name,
|
|
81
|
+
style: {
|
|
82
|
+
position: "absolute",
|
|
83
|
+
inset: 0,
|
|
84
|
+
overflow: "hidden",
|
|
85
|
+
background: t.clearColor,
|
|
86
|
+
pointerEvents: t.pointerEvents ?? "none",
|
|
87
|
+
zIndex: t.zIndex,
|
|
88
|
+
opacity: t.hidden ? 0 : 1,
|
|
89
|
+
...n
|
|
90
|
+
},
|
|
91
|
+
children: e
|
|
92
|
+
}
|
|
93
|
+
), j = ({
|
|
94
|
+
canvas: e,
|
|
95
|
+
layout: t,
|
|
96
|
+
media: n,
|
|
97
|
+
mirrored: a,
|
|
98
|
+
filter: r
|
|
99
|
+
}) => {
|
|
100
|
+
const i = Math.round(t.destination.width), s = Math.round(t.destination.height);
|
|
101
|
+
e.width !== i && (e.width = i), e.height !== s && (e.height = s);
|
|
102
|
+
const o = e.getContext("2d");
|
|
103
|
+
o && (o.setTransform(1, 0, 0, 1, 0, 0), o.clearRect(0, 0, i, s), a && (o.translate(i, 0), o.scale(-1, 1)), r && (o.filter = r), o.drawImage(n, t.offsetX, t.offsetY, t.drawWidth, t.drawHeight), r && (o.filter = "none"), o.setTransform(1, 0, 0, 1, 0, 0));
|
|
104
|
+
}, ne = ({
|
|
105
|
+
canvasRef: e,
|
|
106
|
+
enabled: t = !0,
|
|
107
|
+
fps: n = 30,
|
|
108
|
+
imageRef: a,
|
|
109
|
+
layout: r,
|
|
110
|
+
mirrored: i,
|
|
111
|
+
sourceKind: s,
|
|
112
|
+
videoRef: o
|
|
113
|
+
}) => {
|
|
114
|
+
M(() => {
|
|
115
|
+
if (!t) {
|
|
116
|
+
const p = e.current, c = p == null ? void 0 : p.getContext("2d");
|
|
117
|
+
p && c && c.clearRect(0, 0, p.width, p.height);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let h = 0, m = 0;
|
|
121
|
+
const d = n > 0 ? 1e3 / n : 0, g = (p) => {
|
|
122
|
+
if (h = requestAnimationFrame(g), d > 0 && p - m < d) return;
|
|
123
|
+
m = p;
|
|
124
|
+
const c = e.current;
|
|
125
|
+
if (!c || !r) return;
|
|
126
|
+
if (s === "image") {
|
|
127
|
+
const w = a.current;
|
|
128
|
+
if (!w || !w.complete || w.naturalWidth <= 0 || w.naturalHeight <= 0)
|
|
129
|
+
return;
|
|
130
|
+
j({
|
|
131
|
+
canvas: c,
|
|
132
|
+
layout: r,
|
|
133
|
+
media: w,
|
|
134
|
+
mirrored: i
|
|
135
|
+
});
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const b = o.current;
|
|
139
|
+
!b || b.readyState < 2 || b.videoWidth <= 0 || b.videoHeight <= 0 || j({
|
|
140
|
+
canvas: c,
|
|
141
|
+
layout: r,
|
|
142
|
+
media: b,
|
|
143
|
+
mirrored: i
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
return h = requestAnimationFrame(g), () => {
|
|
147
|
+
cancelAnimationFrame(h);
|
|
148
|
+
};
|
|
149
|
+
}, [e, t, n, a, r, i, s, o]);
|
|
150
|
+
}, Se = ({
|
|
151
|
+
canvasRef: e,
|
|
152
|
+
imageRef: t,
|
|
153
|
+
layer: n,
|
|
154
|
+
layout: a,
|
|
155
|
+
mirrored: r,
|
|
156
|
+
sourceKind: i,
|
|
157
|
+
videoRef: s
|
|
158
|
+
}) => (ne({
|
|
159
|
+
canvasRef: e,
|
|
160
|
+
imageRef: t,
|
|
161
|
+
layout: a,
|
|
162
|
+
mirrored: r,
|
|
163
|
+
sourceKind: i,
|
|
164
|
+
videoRef: s
|
|
165
|
+
}), /* @__PURE__ */ f($, { config: n, children: /* @__PURE__ */ f(
|
|
166
|
+
"canvas",
|
|
167
|
+
{
|
|
168
|
+
ref: e,
|
|
169
|
+
style: {
|
|
170
|
+
position: "absolute",
|
|
171
|
+
inset: 0,
|
|
172
|
+
width: "100%",
|
|
173
|
+
height: "100%",
|
|
174
|
+
display: "block",
|
|
175
|
+
background: "#000"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
) })), rt = ({
|
|
179
|
+
canvasRef: e,
|
|
180
|
+
controlInsetTop: t,
|
|
181
|
+
debugVisible: n,
|
|
182
|
+
fps: a = 15,
|
|
183
|
+
imageRef: r,
|
|
184
|
+
layer: i,
|
|
185
|
+
layout: s,
|
|
186
|
+
mirrored: o,
|
|
187
|
+
sourceKind: h,
|
|
188
|
+
videoRef: m,
|
|
189
|
+
viewportSize: d
|
|
190
|
+
}) => {
|
|
191
|
+
ne({
|
|
192
|
+
canvasRef: e,
|
|
193
|
+
enabled: n,
|
|
194
|
+
fps: a,
|
|
195
|
+
imageRef: r,
|
|
196
|
+
layout: s,
|
|
197
|
+
mirrored: o,
|
|
198
|
+
sourceKind: h,
|
|
199
|
+
videoRef: m
|
|
200
|
+
});
|
|
201
|
+
const g = Math.min(220, Math.max(120, d.width * 0.22)), p = d.width > 0 && d.height > 0 ? d.width / d.height : 1, c = Math.min(d.height - 24, Math.max(t ?? 16, 16));
|
|
202
|
+
return /* @__PURE__ */ f($, { config: i, children: /* @__PURE__ */ f(
|
|
203
|
+
"canvas",
|
|
204
|
+
{
|
|
205
|
+
ref: e,
|
|
206
|
+
style: {
|
|
207
|
+
position: "absolute",
|
|
208
|
+
left: 16,
|
|
209
|
+
top: c,
|
|
210
|
+
width: n ? g : 1,
|
|
211
|
+
height: n ? "auto" : 1,
|
|
212
|
+
aspectRatio: `${p}`,
|
|
213
|
+
opacity: n ? 0.85 : 0,
|
|
214
|
+
borderRadius: 10,
|
|
215
|
+
border: n ? "1px solid rgba(255,255,255,0.16)" : "none",
|
|
216
|
+
pointerEvents: "none",
|
|
217
|
+
objectFit: "contain",
|
|
218
|
+
background: "#000"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
) });
|
|
222
|
+
}, Ie = 5, Fe = 1, Me = (e, t) => t, ke = "brightness(2.2) contrast(1.5) saturate(1.25)", ze = ({
|
|
223
|
+
enabled: e,
|
|
224
|
+
displayMirrored: t,
|
|
225
|
+
imageRef: n,
|
|
226
|
+
layout: a,
|
|
227
|
+
mode: r,
|
|
228
|
+
numFaces: i,
|
|
229
|
+
selectedSource: s,
|
|
230
|
+
sourceStream: o,
|
|
231
|
+
videoRef: h
|
|
232
|
+
}) => {
|
|
233
|
+
const { session: m } = ye(), d = k(null), g = k(!1), p = k(document.createElement("canvas")), {
|
|
234
|
+
ready: c,
|
|
235
|
+
node: b,
|
|
236
|
+
error: w
|
|
237
|
+
} = he(re.FACE_TRACKER, {
|
|
238
|
+
numFaces: i ?? (r === "head-binding" ? Fe : Ie)
|
|
239
|
+
}), [S, v] = y("idle"), [A, I] = y(null), F = e && c && !!b, L = te({
|
|
240
|
+
node: F ? b : null,
|
|
241
|
+
enabled: F,
|
|
242
|
+
selectedSource: s,
|
|
243
|
+
onFrame: fe(() => {
|
|
244
|
+
I(null), v("ready");
|
|
245
|
+
}, [])
|
|
246
|
+
});
|
|
247
|
+
return M(() => {
|
|
248
|
+
if (!e || !a) return;
|
|
249
|
+
const u = () => {
|
|
250
|
+
const x = s === "image" ? n.current : h.current;
|
|
251
|
+
if (x) {
|
|
252
|
+
if (x instanceof HTMLImageElement) {
|
|
253
|
+
if (!x.complete || x.naturalWidth <= 0 || x.naturalHeight <= 0) return;
|
|
254
|
+
} else if (x.readyState < 2 || x.videoWidth <= 0 || x.videoHeight <= 0)
|
|
255
|
+
return;
|
|
256
|
+
j({
|
|
257
|
+
canvas: p.current,
|
|
258
|
+
layout: a,
|
|
259
|
+
media: x,
|
|
260
|
+
mirrored: t,
|
|
261
|
+
filter: s === "webcam" ? ke : void 0
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
if (s === "image") {
|
|
266
|
+
u();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
let l = 0;
|
|
270
|
+
const C = () => {
|
|
271
|
+
l = requestAnimationFrame(C), u();
|
|
272
|
+
};
|
|
273
|
+
return l = requestAnimationFrame(C), () => cancelAnimationFrame(l);
|
|
274
|
+
}, [t, e, n, a, s, h]), M(() => {
|
|
275
|
+
var T;
|
|
276
|
+
if (!e) {
|
|
277
|
+
v("idle"), I(null), g.current = !1, d.current = null;
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!a) {
|
|
281
|
+
v("initializing");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const u = (o == null ? void 0 : o.id) ?? (((T = h.current) == null ? void 0 : T.srcObject) instanceof MediaStream ? h.current.srcObject.id : "none"), C = s === "webcam" ? `webcam:${u}` : s;
|
|
285
|
+
d.current !== C && (g.current = !1, d.current = C);
|
|
286
|
+
let x = !1;
|
|
287
|
+
return (async () => {
|
|
288
|
+
try {
|
|
289
|
+
if (v("initializing"), g.current || (await m.setFrameSource({
|
|
290
|
+
canvas: p.current,
|
|
291
|
+
sourceKind: s
|
|
292
|
+
}), await m.start(), g.current = !0), x) return;
|
|
293
|
+
I(null), v("initializing");
|
|
294
|
+
} catch (E) {
|
|
295
|
+
if (x) return;
|
|
296
|
+
v("error"), I(E instanceof Error ? E.message : "Failed to initialize SDK face tracking");
|
|
297
|
+
}
|
|
298
|
+
})(), () => {
|
|
299
|
+
x = !0;
|
|
300
|
+
};
|
|
301
|
+
}, [e, a, s, m, o, h]), M(() => {
|
|
302
|
+
!F && e && !w && v("initializing");
|
|
303
|
+
}, [F, e, w]), M(() => {
|
|
304
|
+
w && (v("error"), I(w.message));
|
|
305
|
+
}, [w]), M(() => () => {
|
|
306
|
+
g.current = !1, m.stop();
|
|
307
|
+
}, [m]), {
|
|
308
|
+
activeDelegate: "GPU",
|
|
309
|
+
faces: L,
|
|
310
|
+
status: S,
|
|
311
|
+
error: A
|
|
312
|
+
};
|
|
313
|
+
}, ie = pe(null), Te = {
|
|
314
|
+
audio: !1,
|
|
315
|
+
video: {
|
|
316
|
+
facingMode: "user",
|
|
317
|
+
frameRate: { ideal: 30, max: 60 }
|
|
318
|
+
}
|
|
319
|
+
}, Xe = {
|
|
320
|
+
name: "viewport-live",
|
|
321
|
+
clearColor: "#000000",
|
|
322
|
+
pointerEvents: "none",
|
|
323
|
+
zIndex: 0
|
|
324
|
+
}, Ae = {
|
|
325
|
+
name: "viewport-ui",
|
|
326
|
+
clearColor: "transparent",
|
|
327
|
+
pointerEvents: "auto",
|
|
328
|
+
zIndex: 5
|
|
329
|
+
}, Le = {
|
|
330
|
+
name: "viewport-scene",
|
|
331
|
+
clearColor: "transparent",
|
|
332
|
+
pointerEvents: "auto",
|
|
333
|
+
zIndex: 1
|
|
334
|
+
}, X = {
|
|
335
|
+
webcam: { icon: "◉", label: "Webcam" },
|
|
336
|
+
image: { icon: "▣", label: "Images" },
|
|
337
|
+
video: { icon: "▶", label: "Videos" }
|
|
338
|
+
}, K = ({ children: e }) => /* @__PURE__ */ f(q, { children: e });
|
|
339
|
+
K.displayName = "XRViewport.Scene";
|
|
340
|
+
const O = ({ children: e }) => /* @__PURE__ */ f(q, { children: e });
|
|
341
|
+
O.displayName = "XRViewport.Overlay";
|
|
342
|
+
const We = (e) => {
|
|
343
|
+
if (!e)
|
|
344
|
+
return { width: 0, height: 0 };
|
|
345
|
+
const t = e.getBoundingClientRect();
|
|
346
|
+
return {
|
|
347
|
+
width: t.width || e.clientWidth,
|
|
348
|
+
height: t.height || e.clientHeight
|
|
349
|
+
};
|
|
350
|
+
}, Be = (e) => {
|
|
351
|
+
const [t, n] = y({ width: 0, height: 0 });
|
|
352
|
+
return be(() => {
|
|
353
|
+
const a = e.current;
|
|
354
|
+
if (!a) return;
|
|
355
|
+
let r = 0;
|
|
356
|
+
const i = () => {
|
|
357
|
+
const m = We(a);
|
|
358
|
+
n(
|
|
359
|
+
(d) => d.width === m.width && d.height === m.height ? d : m
|
|
360
|
+
);
|
|
361
|
+
};
|
|
362
|
+
i(), r = requestAnimationFrame(i);
|
|
363
|
+
const s = new ResizeObserver(() => {
|
|
364
|
+
i(), r && cancelAnimationFrame(r), r = requestAnimationFrame(i);
|
|
365
|
+
});
|
|
366
|
+
s.observe(a);
|
|
367
|
+
const o = window.visualViewport, h = () => {
|
|
368
|
+
i(), r && cancelAnimationFrame(r), r = requestAnimationFrame(i);
|
|
369
|
+
};
|
|
370
|
+
return window.addEventListener("resize", h), window.addEventListener("orientationchange", h), o == null || o.addEventListener("resize", h), o == null || o.addEventListener("scroll", h), () => {
|
|
371
|
+
r && cancelAnimationFrame(r), s.disconnect(), window.removeEventListener("resize", h), window.removeEventListener("orientationchange", h), o == null || o.removeEventListener("resize", h), o == null || o.removeEventListener("scroll", h);
|
|
372
|
+
};
|
|
373
|
+
}, [e]), t;
|
|
374
|
+
}, J = (e) => {
|
|
375
|
+
e && (e.pause(), e.removeAttribute("src"), e.srcObject = null, e.load());
|
|
376
|
+
}, Q = (e) => {
|
|
377
|
+
e && e.removeAttribute("src");
|
|
378
|
+
}, He = ({
|
|
379
|
+
enabled: e,
|
|
380
|
+
imageAsset: t,
|
|
381
|
+
selectedSource: n,
|
|
382
|
+
videoAsset: a
|
|
383
|
+
}) => {
|
|
384
|
+
const r = k(null), i = k(null), [s, o] = y(null), [h, m] = y({ width: 0, height: 0 }), [d, g] = y("idle"), [p, c] = y(null);
|
|
385
|
+
return M(() => {
|
|
386
|
+
if (!e) {
|
|
387
|
+
J(r.current), Q(i.current), o(null), m({ width: 0, height: 0 }), g("idle"), c(null);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
let b = !1, w = null;
|
|
391
|
+
const S = (u, l) => {
|
|
392
|
+
b || (m({ width: u, height: l }), g("ready"), c(null));
|
|
393
|
+
}, v = () => {
|
|
394
|
+
J(r.current), Q(i.current), w == null || w.getTracks().forEach((u) => u.stop()), w = null, o(null);
|
|
395
|
+
}, A = async () => {
|
|
396
|
+
g("requesting");
|
|
397
|
+
const u = await navigator.mediaDevices.getUserMedia(Te);
|
|
398
|
+
if (b) {
|
|
399
|
+
u.getTracks().forEach((C) => C.stop());
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
w = u, o(u);
|
|
403
|
+
const l = r.current;
|
|
404
|
+
l && (l.srcObject = u, l.muted = !0, l.playsInline = !0, l.autoplay = !0, await l.play(), S(l.videoWidth, l.videoHeight));
|
|
405
|
+
}, I = async (u) => {
|
|
406
|
+
g("requesting"), o(null);
|
|
407
|
+
const l = r.current;
|
|
408
|
+
l && (l.src = u, l.muted = !0, l.loop = !0, l.playsInline = !0, l.autoplay = !0, l.crossOrigin = "anonymous", await l.play(), S(l.videoWidth, l.videoHeight));
|
|
409
|
+
}, F = async (u) => {
|
|
410
|
+
g("requesting"), o(null);
|
|
411
|
+
const l = i.current;
|
|
412
|
+
l && (await new Promise((C, x) => {
|
|
413
|
+
l.onload = () => C(), l.onerror = () => x(new Error("Unable to load image")), l.src = u;
|
|
414
|
+
}), S(l.naturalWidth, l.naturalHeight));
|
|
415
|
+
};
|
|
416
|
+
return v(), (async () => {
|
|
417
|
+
try {
|
|
418
|
+
if (n === "webcam") {
|
|
419
|
+
await A();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (n === "video") {
|
|
423
|
+
if (!(a != null && a.src))
|
|
424
|
+
throw new Error("Missing video source");
|
|
425
|
+
await I(a.src);
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (!(t != null && t.src))
|
|
429
|
+
throw new Error("Missing image source");
|
|
430
|
+
await F(t.src);
|
|
431
|
+
} catch (u) {
|
|
432
|
+
if (b) return;
|
|
433
|
+
g("error"), c(u instanceof Error ? u.message : `Unable to initialize ${n}`);
|
|
434
|
+
}
|
|
435
|
+
})(), () => {
|
|
436
|
+
b = !0, v();
|
|
437
|
+
};
|
|
438
|
+
}, [e, t, n, a]), {
|
|
439
|
+
videoRef: r,
|
|
440
|
+
imageRef: i,
|
|
441
|
+
stream: s,
|
|
442
|
+
mediaSize: h,
|
|
443
|
+
status: d,
|
|
444
|
+
error: p
|
|
445
|
+
};
|
|
446
|
+
}, Ve = (e, t) => e === "auto" ? t === "webcam" ? "cover" : "contain" : e, De = ({
|
|
447
|
+
imageOptions: e,
|
|
448
|
+
initialImageId: t,
|
|
449
|
+
initialSource: n,
|
|
450
|
+
initialVideoId: a,
|
|
451
|
+
source: r,
|
|
452
|
+
videoOptions: i
|
|
453
|
+
}) => {
|
|
454
|
+
var d, g, p, c;
|
|
455
|
+
const s = (r == null ? void 0 : r.kind) ?? n ?? "webcam", o = s === "image" && e.length === 0 || s === "video" && i.length === 0 ? "webcam" : s, h = (r == null ? void 0 : r.kind) === "image" ? r.assetId ?? ((d = e[0]) == null ? void 0 : d.id) ?? "" : t ?? ((g = e[0]) == null ? void 0 : g.id) ?? "", m = (r == null ? void 0 : r.kind) === "video" ? r.assetId ?? ((p = i[0]) == null ? void 0 : p.id) ?? "" : a ?? ((c = i[0]) == null ? void 0 : c.id) ?? "";
|
|
456
|
+
return {
|
|
457
|
+
selectedSource: o,
|
|
458
|
+
selectedImageId: h,
|
|
459
|
+
selectedVideoId: m
|
|
460
|
+
};
|
|
461
|
+
}, _e = (e, t, n) => {
|
|
462
|
+
if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
|
|
463
|
+
return null;
|
|
464
|
+
const a = n === "contain" ? Math.min(t.width / e.width, t.height / e.height) : Math.max(t.width / e.width, t.height / e.height), r = e.width * a, i = e.height * a, s = (t.width - r) * 0.5, o = (t.height - i) * 0.5;
|
|
465
|
+
return {
|
|
466
|
+
source: e,
|
|
467
|
+
destination: t,
|
|
468
|
+
drawWidth: r,
|
|
469
|
+
drawHeight: i,
|
|
470
|
+
offsetX: s,
|
|
471
|
+
offsetY: o,
|
|
472
|
+
scale: a
|
|
473
|
+
};
|
|
474
|
+
}, $e = (e, t) => {
|
|
475
|
+
if (e === "dom")
|
|
476
|
+
return {
|
|
477
|
+
sceneContent: null,
|
|
478
|
+
overlayContent: t
|
|
479
|
+
};
|
|
480
|
+
let n = null, a = null;
|
|
481
|
+
const r = [];
|
|
482
|
+
return we.forEach(t, (i) => {
|
|
483
|
+
var o;
|
|
484
|
+
if (!ve(i)) {
|
|
485
|
+
i != null && r.push(i);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const s = (o = i.type) == null ? void 0 : o.displayName;
|
|
489
|
+
if (s === K.displayName) {
|
|
490
|
+
n = i.props.children;
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (s === O.displayName) {
|
|
494
|
+
a = i.props.children;
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
r.push(i);
|
|
498
|
+
}), !a && r.length > 0 && (a = r), {
|
|
499
|
+
sceneContent: n,
|
|
500
|
+
overlayContent: a
|
|
501
|
+
};
|
|
502
|
+
}, Z = (e, t) => typeof e == "function" ? e(t) : e, nt = () => ge(ie), qe = ({
|
|
503
|
+
imageRef: e,
|
|
504
|
+
selectedSource: t,
|
|
505
|
+
videoRef: n
|
|
506
|
+
}) => /* @__PURE__ */ z(q, { children: [
|
|
507
|
+
/* @__PURE__ */ f(
|
|
508
|
+
"video",
|
|
509
|
+
{
|
|
510
|
+
ref: n,
|
|
511
|
+
style: {
|
|
512
|
+
position: "absolute",
|
|
513
|
+
width: 1,
|
|
514
|
+
height: 1,
|
|
515
|
+
opacity: t === "image" ? 0 : 1e-3,
|
|
516
|
+
pointerEvents: "none"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
/* @__PURE__ */ f(
|
|
521
|
+
"img",
|
|
522
|
+
{
|
|
523
|
+
ref: e,
|
|
524
|
+
alt: "",
|
|
525
|
+
style: {
|
|
526
|
+
position: "absolute",
|
|
527
|
+
width: 1,
|
|
528
|
+
height: 1,
|
|
529
|
+
opacity: t === "image" ? 1e-3 : 0,
|
|
530
|
+
pointerEvents: "none"
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
)
|
|
534
|
+
] }), ee = ({
|
|
535
|
+
dock: e,
|
|
536
|
+
label: t,
|
|
537
|
+
onChange: n,
|
|
538
|
+
options: a,
|
|
539
|
+
value: r
|
|
540
|
+
}) => /* @__PURE__ */ f(
|
|
541
|
+
"div",
|
|
542
|
+
{
|
|
543
|
+
style: {
|
|
544
|
+
position: "absolute",
|
|
545
|
+
top: e === "top-left" ? 74 : void 0,
|
|
546
|
+
bottom: e === "bottom-left" ? 74 : void 0,
|
|
547
|
+
left: 16,
|
|
548
|
+
zIndex: 5,
|
|
549
|
+
maxWidth: "calc(100vw - 32px)",
|
|
550
|
+
padding: 10,
|
|
551
|
+
borderRadius: 14,
|
|
552
|
+
background: "rgba(15, 23, 42, 0.72)",
|
|
553
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
554
|
+
boxShadow: "0 12px 30px rgba(0,0,0,0.18)",
|
|
555
|
+
backdropFilter: "blur(10px)"
|
|
556
|
+
},
|
|
557
|
+
children: /* @__PURE__ */ z(
|
|
558
|
+
"label",
|
|
559
|
+
{
|
|
560
|
+
style: {
|
|
561
|
+
display: "grid",
|
|
562
|
+
gap: 6,
|
|
563
|
+
color: "#e5eefb",
|
|
564
|
+
fontSize: 12,
|
|
565
|
+
fontWeight: 700
|
|
566
|
+
},
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ f("span", { children: t }),
|
|
569
|
+
/* @__PURE__ */ f(
|
|
570
|
+
"select",
|
|
571
|
+
{
|
|
572
|
+
value: r,
|
|
573
|
+
onChange: (i) => n(i.target.value),
|
|
574
|
+
style: {
|
|
575
|
+
minWidth: 180,
|
|
576
|
+
maxWidth: "calc(100vw - 52px)",
|
|
577
|
+
height: 36,
|
|
578
|
+
borderRadius: 10,
|
|
579
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
580
|
+
background: "rgba(255,255,255,0.06)",
|
|
581
|
+
color: "#e5eefb",
|
|
582
|
+
padding: "0 10px"
|
|
583
|
+
},
|
|
584
|
+
children: a.map((i) => /* @__PURE__ */ f("option", { value: i.id, style: { color: "#111827" }, children: i.label }, i.id))
|
|
585
|
+
}
|
|
586
|
+
)
|
|
587
|
+
]
|
|
588
|
+
}
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
), Ne = ({
|
|
592
|
+
dock: e,
|
|
593
|
+
imageOptions: t,
|
|
594
|
+
selectedImageId: n,
|
|
595
|
+
selectedSource: a,
|
|
596
|
+
selectedVideoId: r,
|
|
597
|
+
setSelectedImageId: i,
|
|
598
|
+
setSelectedSource: s,
|
|
599
|
+
setSelectedVideoId: o,
|
|
600
|
+
showMediaControls: h,
|
|
601
|
+
videoOptions: m
|
|
602
|
+
}) => {
|
|
603
|
+
const [d, g] = y(!1), p = ["webcam", "image", "video"].filter((c) => c === "image" ? t.length > 0 : c === "video" ? m.length > 0 : !0);
|
|
604
|
+
return h ? d ? /* @__PURE__ */ f(
|
|
605
|
+
"button",
|
|
606
|
+
{
|
|
607
|
+
type: "button",
|
|
608
|
+
onClick: () => g(!1),
|
|
609
|
+
"aria-label": "Open media controls",
|
|
610
|
+
title: "Open media controls",
|
|
611
|
+
style: {
|
|
612
|
+
position: "absolute",
|
|
613
|
+
top: e === "top-left" ? 16 : void 0,
|
|
614
|
+
bottom: e === "bottom-left" ? 16 : void 0,
|
|
615
|
+
left: 16,
|
|
616
|
+
zIndex: 5,
|
|
617
|
+
width: 40,
|
|
618
|
+
height: 40,
|
|
619
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
620
|
+
borderRadius: 999,
|
|
621
|
+
background: "rgba(15, 23, 42, 0.72)",
|
|
622
|
+
color: "#e5eefb",
|
|
623
|
+
boxShadow: "0 12px 30px rgba(0,0,0,0.18)",
|
|
624
|
+
backdropFilter: "blur(10px)",
|
|
625
|
+
cursor: "pointer"
|
|
626
|
+
},
|
|
627
|
+
children: "≡"
|
|
628
|
+
}
|
|
629
|
+
) : /* @__PURE__ */ z(q, { children: [
|
|
630
|
+
/* @__PURE__ */ z(
|
|
631
|
+
"div",
|
|
632
|
+
{
|
|
633
|
+
style: {
|
|
634
|
+
position: "absolute",
|
|
635
|
+
top: e === "top-left" ? 16 : void 0,
|
|
636
|
+
bottom: e === "bottom-left" ? 16 : void 0,
|
|
637
|
+
left: 16,
|
|
638
|
+
zIndex: 5,
|
|
639
|
+
display: "inline-flex",
|
|
640
|
+
alignItems: "center",
|
|
641
|
+
gap: 8,
|
|
642
|
+
maxWidth: "calc(100vw - 32px)"
|
|
643
|
+
},
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ f(
|
|
646
|
+
"div",
|
|
647
|
+
{
|
|
648
|
+
style: {
|
|
649
|
+
display: "inline-flex",
|
|
650
|
+
alignItems: "center",
|
|
651
|
+
gap: 8,
|
|
652
|
+
padding: 8,
|
|
653
|
+
borderRadius: 999,
|
|
654
|
+
background: "rgba(15, 23, 42, 0.72)",
|
|
655
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
656
|
+
boxShadow: "0 12px 30px rgba(0,0,0,0.18)",
|
|
657
|
+
backdropFilter: "blur(10px)",
|
|
658
|
+
overflowX: "auto"
|
|
659
|
+
},
|
|
660
|
+
children: p.map((c) => {
|
|
661
|
+
const b = c === a;
|
|
662
|
+
return /* @__PURE__ */ z(
|
|
663
|
+
"button",
|
|
664
|
+
{
|
|
665
|
+
type: "button",
|
|
666
|
+
onClick: () => s(c),
|
|
667
|
+
"aria-pressed": b,
|
|
668
|
+
title: X[c].label,
|
|
669
|
+
style: {
|
|
670
|
+
border: "none",
|
|
671
|
+
borderRadius: 999,
|
|
672
|
+
minWidth: 42,
|
|
673
|
+
height: 42,
|
|
674
|
+
padding: "0 12px",
|
|
675
|
+
display: "inline-flex",
|
|
676
|
+
alignItems: "center",
|
|
677
|
+
justifyContent: "center",
|
|
678
|
+
gap: 8,
|
|
679
|
+
background: b ? "rgba(56, 189, 248, 0.18)" : "rgba(255,255,255,0.04)",
|
|
680
|
+
color: b ? "#e0f2fe" : "rgba(229,238,251,0.82)",
|
|
681
|
+
cursor: "pointer",
|
|
682
|
+
flex: "0 0 auto"
|
|
683
|
+
},
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ f("span", { style: { fontSize: 14, lineHeight: 1 }, children: X[c].icon }),
|
|
686
|
+
/* @__PURE__ */ f("span", { style: { fontSize: 12, fontWeight: 700, letterSpacing: "0.01em" }, children: X[c].label })
|
|
687
|
+
]
|
|
688
|
+
},
|
|
689
|
+
c
|
|
690
|
+
);
|
|
691
|
+
})
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
/* @__PURE__ */ f(
|
|
695
|
+
"button",
|
|
696
|
+
{
|
|
697
|
+
type: "button",
|
|
698
|
+
onClick: () => g(!0),
|
|
699
|
+
"aria-label": "Close media controls",
|
|
700
|
+
title: "Close media controls",
|
|
701
|
+
style: {
|
|
702
|
+
width: 40,
|
|
703
|
+
height: 40,
|
|
704
|
+
border: "1px solid rgba(255,255,255,0.12)",
|
|
705
|
+
borderRadius: 999,
|
|
706
|
+
background: "rgba(15, 23, 42, 0.72)",
|
|
707
|
+
color: "#e5eefb",
|
|
708
|
+
boxShadow: "0 12px 30px rgba(0,0,0,0.18)",
|
|
709
|
+
backdropFilter: "blur(10px)",
|
|
710
|
+
cursor: "pointer",
|
|
711
|
+
flex: "0 0 auto"
|
|
712
|
+
},
|
|
713
|
+
children: "×"
|
|
714
|
+
}
|
|
715
|
+
)
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
),
|
|
719
|
+
a === "image" && t.length > 0 && /* @__PURE__ */ f(
|
|
720
|
+
ee,
|
|
721
|
+
{
|
|
722
|
+
dock: e,
|
|
723
|
+
label: "Image Asset",
|
|
724
|
+
options: t,
|
|
725
|
+
value: n,
|
|
726
|
+
onChange: i
|
|
727
|
+
}
|
|
728
|
+
),
|
|
729
|
+
a === "video" && m.length > 0 && /* @__PURE__ */ f(
|
|
730
|
+
ee,
|
|
731
|
+
{
|
|
732
|
+
dock: e,
|
|
733
|
+
label: "Video Asset",
|
|
734
|
+
options: m,
|
|
735
|
+
value: r,
|
|
736
|
+
onChange: o
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
] }) : null;
|
|
740
|
+
}, Pe = ({
|
|
741
|
+
enabled: e,
|
|
742
|
+
selectedSource: t
|
|
743
|
+
}) => {
|
|
744
|
+
const n = me(re.FACE_TRACKER);
|
|
745
|
+
return {
|
|
746
|
+
faces: te({ node: n, enabled: e, selectedSource: t }),
|
|
747
|
+
trackerStatus: n ? "ready" : "idle"
|
|
748
|
+
};
|
|
749
|
+
}, oe = ({
|
|
750
|
+
children: e,
|
|
751
|
+
fitMode: t = "auto",
|
|
752
|
+
imageOptions: n = [],
|
|
753
|
+
initialImageId: a,
|
|
754
|
+
initialMirrored: r = !0,
|
|
755
|
+
initialSource: i = "webcam",
|
|
756
|
+
initialVideoId: s,
|
|
757
|
+
mediaStrategy: o = "internal",
|
|
758
|
+
mediaDock: h = "bottom-left",
|
|
759
|
+
mode: m = "dom",
|
|
760
|
+
showMediaControlsByDefault: d = !0,
|
|
761
|
+
source: g,
|
|
762
|
+
style: p,
|
|
763
|
+
videoOptions: c = []
|
|
764
|
+
}) => {
|
|
765
|
+
const b = k(null), w = k(null), S = Be(b), v = G(
|
|
766
|
+
() => De({
|
|
767
|
+
imageOptions: n,
|
|
768
|
+
initialImageId: a,
|
|
769
|
+
initialSource: i,
|
|
770
|
+
initialVideoId: s,
|
|
771
|
+
source: g,
|
|
772
|
+
videoOptions: c
|
|
773
|
+
}),
|
|
774
|
+
[n, a, i, s, g, c]
|
|
775
|
+
), [A, I] = y(r), [F, L] = y(d), [u, l] = y(
|
|
776
|
+
v.selectedSource
|
|
777
|
+
), [C, x] = y(v.selectedImageId), [W, T] = y(v.selectedVideoId), E = o === "internal";
|
|
778
|
+
M(() => {
|
|
779
|
+
g && (l(v.selectedSource), x(v.selectedImageId), T(v.selectedVideoId));
|
|
780
|
+
}, [v, g]);
|
|
781
|
+
const B = n.find((U) => U.id === C) ?? n[0], H = c.find((U) => U.id === W) ?? c[0], R = He({
|
|
782
|
+
enabled: E,
|
|
783
|
+
imageAsset: B,
|
|
784
|
+
selectedSource: u,
|
|
785
|
+
videoAsset: H
|
|
786
|
+
}), N = Ve(t, u), V = G(
|
|
787
|
+
() => _e(R.mediaSize, S, N),
|
|
788
|
+
[R.mediaSize, N, S]
|
|
789
|
+
), P = Me(u, A), D = ze({
|
|
790
|
+
displayMirrored: P,
|
|
791
|
+
enabled: E && R.status === "ready" && V !== null,
|
|
792
|
+
imageRef: R.imageRef,
|
|
793
|
+
layout: V,
|
|
794
|
+
selectedSource: u,
|
|
795
|
+
sourceStream: R.stream,
|
|
796
|
+
videoRef: R.videoRef
|
|
797
|
+
}), Y = Pe({
|
|
798
|
+
enabled: !E,
|
|
799
|
+
selectedSource: u
|
|
800
|
+
}), ae = u === "image" ? `${X.image.label}: ${(B == null ? void 0 : B.label) ?? ""}` : u === "video" ? `${X.video.label}: ${(H == null ? void 0 : H.label) ?? ""}` : X.webcam.label, _ = {
|
|
801
|
+
activeDelegate: E ? D.activeDelegate : null,
|
|
802
|
+
faces: E ? D.faces : Y.faces,
|
|
803
|
+
imageOptions: n,
|
|
804
|
+
layout: V,
|
|
805
|
+
mediaError: R.error,
|
|
806
|
+
mediaFitMode: N,
|
|
807
|
+
mediaLabel: ae,
|
|
808
|
+
mediaStatus: R.status,
|
|
809
|
+
mirrored: P,
|
|
810
|
+
selectedImageId: C,
|
|
811
|
+
selectedSource: u,
|
|
812
|
+
selectedVideoId: W,
|
|
813
|
+
setMirrored: I,
|
|
814
|
+
setSelectedImageId: x,
|
|
815
|
+
setSelectedSource: l,
|
|
816
|
+
setSelectedVideoId: T,
|
|
817
|
+
setShowMediaControls: L,
|
|
818
|
+
showMediaControls: F,
|
|
819
|
+
trackerError: E ? D.error : null,
|
|
820
|
+
trackerStatus: E ? D.status : Y.trackerStatus,
|
|
821
|
+
videoOptions: c,
|
|
822
|
+
viewportSize: S,
|
|
823
|
+
mediaSize: R.mediaSize
|
|
824
|
+
}, se = typeof e == "function" ? e(_) : e, { sceneContent: le, overlayContent: ce } = $e(m, se), de = Z(
|
|
825
|
+
le,
|
|
826
|
+
_
|
|
827
|
+
), ue = Z(
|
|
828
|
+
ce,
|
|
829
|
+
_
|
|
830
|
+
);
|
|
831
|
+
return /* @__PURE__ */ f(ie.Provider, { value: _, children: /* @__PURE__ */ z(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
ref: b,
|
|
835
|
+
style: {
|
|
836
|
+
position: "fixed",
|
|
837
|
+
inset: 0,
|
|
838
|
+
overflow: "hidden",
|
|
839
|
+
background: "#000",
|
|
840
|
+
...p
|
|
841
|
+
},
|
|
842
|
+
children: [
|
|
843
|
+
/* @__PURE__ */ f(
|
|
844
|
+
qe,
|
|
845
|
+
{
|
|
846
|
+
imageRef: R.imageRef,
|
|
847
|
+
selectedSource: u,
|
|
848
|
+
videoRef: R.videoRef
|
|
849
|
+
}
|
|
850
|
+
),
|
|
851
|
+
m === "dom" && E && /* @__PURE__ */ f(
|
|
852
|
+
Se,
|
|
853
|
+
{
|
|
854
|
+
canvasRef: w,
|
|
855
|
+
imageRef: R.imageRef,
|
|
856
|
+
videoRef: R.videoRef,
|
|
857
|
+
layer: Xe,
|
|
858
|
+
layout: V,
|
|
859
|
+
mirrored: P,
|
|
860
|
+
sourceKind: u === "image" ? "image" : "video"
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
(m === "r3f" || m === "hybrid") && /* @__PURE__ */ f($, { config: Le, children: /* @__PURE__ */ f(Ce, { renderTargetSize: S, style: { width: "100%", height: "100%" }, children: de }) }),
|
|
864
|
+
/* @__PURE__ */ z($, { config: Ae, children: [
|
|
865
|
+
E && /* @__PURE__ */ f(
|
|
866
|
+
Ne,
|
|
867
|
+
{
|
|
868
|
+
dock: h,
|
|
869
|
+
imageOptions: n,
|
|
870
|
+
selectedImageId: C,
|
|
871
|
+
selectedSource: u,
|
|
872
|
+
selectedVideoId: W,
|
|
873
|
+
setSelectedImageId: x,
|
|
874
|
+
setSelectedSource: l,
|
|
875
|
+
setSelectedVideoId: T,
|
|
876
|
+
showMediaControls: F,
|
|
877
|
+
videoOptions: c
|
|
878
|
+
}
|
|
879
|
+
),
|
|
880
|
+
ue
|
|
881
|
+
] })
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
) });
|
|
885
|
+
};
|
|
886
|
+
oe.Scene = K;
|
|
887
|
+
oe.Overlay = O;
|
|
888
|
+
const it = (e) => {
|
|
889
|
+
const [t, n] = y(null);
|
|
890
|
+
return M(() => {
|
|
891
|
+
let a = 0;
|
|
892
|
+
const r = () => {
|
|
893
|
+
var h, m;
|
|
894
|
+
a = requestAnimationFrame(r);
|
|
895
|
+
const i = (m = (h = e == null ? void 0 : e.detectionResults) == null ? void 0 : h.faceLandmarks) == null ? void 0 : m[0];
|
|
896
|
+
if (!i || i.length === 0) {
|
|
897
|
+
n(null);
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
const s = xe(i), o = {
|
|
901
|
+
left: s.minX,
|
|
902
|
+
top: s.minY,
|
|
903
|
+
width: s.width,
|
|
904
|
+
height: s.height
|
|
905
|
+
};
|
|
906
|
+
n((d) => d && d.left === o.left && d.top === o.top && d.width === o.width && d.height === o.height ? d : o);
|
|
907
|
+
};
|
|
908
|
+
return r(), () => {
|
|
909
|
+
cancelAnimationFrame(a);
|
|
910
|
+
};
|
|
911
|
+
}, [e]), t;
|
|
912
|
+
}, ot = ["fill", "contain"];
|
|
913
|
+
export {
|
|
914
|
+
Ze as BoundingBoxOverlay,
|
|
915
|
+
lt as HeadTracker,
|
|
916
|
+
et as PerspectiveCamera,
|
|
917
|
+
vt as ScreenRectAspectContext,
|
|
918
|
+
ot as TEXTURE_FITS,
|
|
919
|
+
tt as XRCompositor,
|
|
920
|
+
$ as XRLayer,
|
|
921
|
+
Se as XRMediaSurface,
|
|
922
|
+
rt as XRTrackingOverlay,
|
|
923
|
+
oe as XRViewport,
|
|
924
|
+
xe as computeLandmarkBounds,
|
|
925
|
+
xt as computeScreenTransform,
|
|
926
|
+
bt as hasFullUnitUVBounds,
|
|
927
|
+
Me as resolveCalibrationFaceDisplayMirrored,
|
|
928
|
+
ze as useCalibrationFaceTracker,
|
|
929
|
+
it as useFaceBoundingBox,
|
|
930
|
+
yt as useScreenSpace,
|
|
931
|
+
ct as useTrackerContext,
|
|
932
|
+
ut as useXRCameraTexture,
|
|
933
|
+
ye as useXRContext,
|
|
934
|
+
ht as useXRError,
|
|
935
|
+
he as useXRModel,
|
|
936
|
+
me as useXRModelNode,
|
|
937
|
+
mt as useXRPipelineSnapshot,
|
|
938
|
+
ft as useXRReady,
|
|
939
|
+
gt as useXRRenderSize,
|
|
940
|
+
nt as useXRViewportState
|
|
941
|
+
};
|