@omnidotdev/rdk 0.14.0 → 0.15.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.
Files changed (63) hide show
  1. package/build/assets/onnxWorker-3jptKfHs.js +1 -0
  2. package/build/engine-B_SO7XR5.cjs +1 -0
  3. package/build/{engine-NEJZ-OgD.js → engine-DeBLXgW-.js} +2 -3
  4. package/build/engine.cjs +1 -1
  5. package/build/engine.js +2 -2
  6. package/build/fiducial/FiducialAnchor.d.ts +1 -1
  7. package/build/fiducial/FiducialAnchor.d.ts.map +1 -1
  8. package/build/{fiducial-7pF-ErgE.js → fiducial-DUn6sFBT.js} +17 -13
  9. package/build/fiducial-IzVogwhD.cjs +1 -0
  10. package/build/fiducial.cjs +1 -1
  11. package/build/fiducial.js +1 -2
  12. package/build/geolocation/GeoLine.d.ts +3 -15
  13. package/build/geolocation/GeoLine.d.ts.map +1 -1
  14. package/build/geolocation/GeoPolygon.d.ts +3 -15
  15. package/build/geolocation/GeoPolygon.d.ts.map +1 -1
  16. package/build/geolocation/GeolocationAnchor.d.ts +1 -1
  17. package/build/geolocation/geolocationBackend.d.ts.map +1 -1
  18. package/build/geolocation/useMaterialStore.d.ts +20 -0
  19. package/build/geolocation/useMaterialStore.d.ts.map +1 -0
  20. package/build/geolocation-BK0FDlmT.cjs +1 -0
  21. package/build/geolocation-DmJvz9om.js +376 -0
  22. package/build/geolocation.cjs +1 -1
  23. package/build/geolocation.js +1 -2
  24. package/build/immersive/ImmersiveSession.d.ts +1 -1
  25. package/build/immersive/ImmersiveSession.d.ts.map +1 -1
  26. package/build/{immersive-CoSRZ58s.js → immersive-BNYjOBFO.js} +2 -3
  27. package/build/{immersive-DMYGUy_v.cjs → immersive-C76xlUbB.cjs} +1 -1
  28. package/build/immersive.cjs +1 -1
  29. package/build/immersive.js +1 -2
  30. package/build/index.cjs +1 -1
  31. package/build/index.js +7 -7
  32. package/build/magic/WorldAnchor.d.ts +1 -1
  33. package/build/magic/WorldAnchor.d.ts.map +1 -1
  34. package/build/magic-BbyHQVOH.cjs +1 -0
  35. package/build/{magic-CjnX9lWp.js → magic-COfaC4at.js} +10 -9
  36. package/build/magic.cjs +1 -1
  37. package/build/magic.js +1 -2
  38. package/build/{useXRStore-BTnI1ZM2.js → useXRStore-CrglOU9_.js} +5 -8
  39. package/build/useXRStore-DfyQv43d.cjs +1 -0
  40. package/build/vision/HandTracker.d.ts +1 -1
  41. package/build/vision/HandTracker.d.ts.map +1 -1
  42. package/build/vision/VisionAnchor.d.ts +1 -1
  43. package/build/vision/VisionAnchor.d.ts.map +1 -1
  44. package/build/vision/VisionSession.d.ts.map +1 -1
  45. package/build/vision/providers/mediapipeProvider.d.ts +6 -0
  46. package/build/vision/providers/mediapipeProvider.d.ts.map +1 -1
  47. package/build/vision/types.d.ts +12 -0
  48. package/build/vision/types.d.ts.map +1 -1
  49. package/build/vision/visionBackend.d.ts +1 -1
  50. package/build/vision/visionBackend.d.ts.map +1 -1
  51. package/build/{vision-Vp2iuVNJ.js → vision-1_qdyG-O.js} +60 -49
  52. package/build/vision-B9EQHClV.cjs +1 -0
  53. package/build/vision.cjs +1 -1
  54. package/build/vision.js +1 -2
  55. package/package.json +5 -5
  56. package/build/assets/onnxWorker-BNjoneWr.js +0 -1
  57. package/build/engine-EvzyijbY.cjs +0 -1
  58. package/build/fiducial-Tris7XAY.cjs +0 -1
  59. package/build/geolocation-C_n3zwq4.js +0 -353
  60. package/build/geolocation-D0RxA8Tv.cjs +0 -1
  61. package/build/magic-B9pQnRYJ.cjs +0 -1
  62. package/build/useXRStore-Cf_XL0aI.cjs +0 -1
  63. package/build/vision-BLWMU9Ys.cjs +0 -1
@@ -1,353 +0,0 @@
1
- import { i as e, r as t } from "./useXRStore-BTnI1ZM2.js";
2
- import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
3
- import { createPortal as s, useFrame as c, useThree as l } from "@react-three/fiber";
4
- import { jsx as u } from "react/jsx-runtime";
5
- import { BackSide as d, BufferAttribute as f, BufferGeometry as p, DoubleSide as m, FrontSide as h, Group as g, Mesh as _, MeshBasicMaterial as v, Path as y, Shape as b, ShapeGeometry as x, Vector3 as S } from "three";
6
- import { Line2 as C } from "three/addons/lines/Line2.js";
7
- import { LineGeometry as w } from "three/addons/lines/LineGeometry.js";
8
- import { LineMaterial as T } from "three/addons/lines/LineMaterial.js";
9
- import { App as E, LocAR as D } from "locar";
10
- //#region src/geolocation/useGeolocationBackend.ts
11
- var O = {
12
- isPending: !0,
13
- isSuccess: !1,
14
- locar: null,
15
- webcam: null,
16
- deviceOrientation: null,
17
- scene: null,
18
- camera: null,
19
- lastPosition: null,
20
- registerAnchor: () => {},
21
- unregisterAnchor: () => {},
22
- getAnchor: () => void 0
23
- }, k = () => {
24
- let n = t((e) => e.backends).get(e.GEOLOCATION);
25
- return n ? {
26
- ...n.getInternal(),
27
- isPending: !1,
28
- isSuccess: !0
29
- } : O;
30
- }, A = (e, t) => {
31
- let n = e.length - 1, r = [], i = 0, a = 0;
32
- for (let o = 0; o < n; o++) {
33
- let n = e[o + 1].x - e[o].x, s = e[o + 1].y - e[o].y, c = e[o + 1].z - e[o].z, l = Math.sqrt(n * n + s * s + c * c), u = t / 2, d = -(c * u) / l, f = n * u / l, p = o > 0 ? (d + i) / 2 : d, m = o > 0 ? (f + a) / 2 : f;
34
- r.push(e[o].x - p, e[o].y, e[o].z - m, e[o].x + p, e[o].y, e[o].z + m), i = d, a = f;
35
- }
36
- r.push(e[n].x - i, e[n].y, e[n].z - a, e[n].x + i, e[n].y, e[n].z + a);
37
- let o = [];
38
- for (let e = 0; e < n; e++) o.push(e * 2, e * 2 + 1, e * 2 + 2), o.push(e * 2 + 1, e * 2 + 3, e * 2 + 2);
39
- let s = new p();
40
- return s.setIndex(o), s.setAttribute("position", new f(new Float32Array(r), 3)), s.computeBoundingBox(), s;
41
- }, j = ({ coordinates: e, color: t = "#ff0000", isDashed: n = !1, dashSize: c = 3, gapSize: l = 1, lineWidth: d = 1, onClick: f, onPointerOut: p, onPointerOver: h, opacity: y = 1 }) => {
42
- let b = k(), x = a(b);
43
- x.current = b;
44
- let [E] = o(() => new g()), D = i(() => Math.random().toString(36).slice(2, 11), []), [O, j] = o(null);
45
- return r(() => {
46
- if (!b.isSuccess || e.length < 2) return;
47
- let [r, i, a = 0] = e[0];
48
- return x.current.registerAnchor(D, {
49
- anchor: E,
50
- isAttached: !1,
51
- latitude: i,
52
- longitude: r,
53
- altitude: a,
54
- onAttach: (r) => {
55
- let [i, a, o = 0] = e[0], [s, u] = r.lonLatToWorldCoords(i, a), f = e.map(([e, t, n = 0]) => {
56
- let [i, a] = r.lonLatToWorldCoords(e, t);
57
- return new S(i - s, n - o, a - u);
58
- });
59
- if (n) {
60
- let e = new C(new w().setFromPoints(f), new T({
61
- color: t,
62
- dashSize: c,
63
- gapSize: l,
64
- dashed: !0,
65
- worldUnits: !0,
66
- linewidth: d,
67
- transparent: y < 1,
68
- opacity: y
69
- }));
70
- e.computeLineDistances(), j(e);
71
- } else j(new _(A(f, d), new v({
72
- color: t,
73
- transparent: y < 1,
74
- opacity: y,
75
- side: m
76
- })));
77
- }
78
- }), () => {
79
- x.current.unregisterAnchor(D), j((e) => (e && (e.geometry.dispose(), e.material.dispose()), null));
80
- };
81
- }, [
82
- D,
83
- E,
84
- e,
85
- t,
86
- n,
87
- c,
88
- l,
89
- d,
90
- y,
91
- b.isSuccess
92
- ]), s(/* @__PURE__ */ u("group", {
93
- onClick: f,
94
- onPointerOut: p,
95
- onPointerOver: h,
96
- children: O && /* @__PURE__ */ u("primitive", { object: O })
97
- }), E);
98
- }, M = ({ latitude: e, longitude: t, altitude: d = 0, isBillboard: f = !0, onAttach: p, onGpsUpdate: m, children: h }) => {
99
- let _ = k(), v = a(_);
100
- v.current = _;
101
- let { camera: y } = l(), [b] = o(() => new g()), x = i(() => Math.random().toString(36).slice(2, 11), []), S = n(() => {
102
- p?.();
103
- }, [p]), C = n((e, t) => {
104
- m?.(e, t);
105
- }, [m]);
106
- return r(() => {
107
- if (_.isSuccess) return v.current.registerAnchor(x, {
108
- anchor: b,
109
- isAttached: !1,
110
- latitude: e,
111
- longitude: t,
112
- altitude: d,
113
- onAttach: S,
114
- onGpsUpdate: C
115
- }), () => {
116
- v.current.unregisterAnchor(x);
117
- };
118
- }, [
119
- b,
120
- x,
121
- e,
122
- t,
123
- d,
124
- S,
125
- C,
126
- _.isSuccess
127
- ]), c(() => {
128
- !f || !y || !_.isSuccess || _.getAnchor(x)?.isAttached && b.lookAt(y.position);
129
- }), s(/* @__PURE__ */ u("group", { children: h }), b);
130
- }, N = ({ options: e = {}, children: n }) => {
131
- let { scene: i, camera: o, gl: s, size: c } = l(), { registerBackend: u, unregisterBackend: d } = t(), f = a(null), p = a(e);
132
- return p.current = e, r(() => {
133
- if (f.current) return;
134
- let e = !1;
135
- return (async () => {
136
- try {
137
- let t = I(p.current);
138
- if (e) return;
139
- await u(t, {
140
- scene: i,
141
- camera: o,
142
- renderer: s,
143
- size: c
144
- }), f.current = t;
145
- } catch (e) {
146
- console.error("[GeolocationSession] Failed to initialize:", e);
147
- }
148
- })(), () => {
149
- e = !0, f.current &&= (d(f.current), null);
150
- };
151
- }, [
152
- i,
153
- o,
154
- s,
155
- u,
156
- d
157
- ]), r(() => {
158
- f.current?.setSize(c);
159
- }, [c]), n;
160
- }, P = {
161
- front: h,
162
- back: d,
163
- double: m
164
- }, F = ({ coordinates: e, holes: t, color: n = "#ff0000", opacity: c = 1, isWireframe: l = !1, onClick: d, onPointerOut: f, onPointerOver: p, side: m = "double" }) => {
165
- let h = k(), _ = a(h);
166
- _.current = h;
167
- let [v] = o(() => new g()), S = i(() => Math.random().toString(36).slice(2, 11), []), [C, w] = o(null);
168
- return r(() => {
169
- if (!h.isSuccess || e.length < 3) return;
170
- let [n, r, i = 0] = e[0];
171
- return _.current.registerAnchor(S, {
172
- anchor: v,
173
- isAttached: !1,
174
- latitude: r,
175
- longitude: n,
176
- altitude: i,
177
- onAttach: (n) => {
178
- let [r, i, a = 0] = e[0], [o, s] = n.lonLatToWorldCoords(r, i), c = [];
179
- for (let [t, r, i = 0] of e) {
180
- let [e, l] = n.lonLatToWorldCoords(t, r);
181
- c.push({
182
- x: e - o,
183
- z: l - s,
184
- elev: i - a
185
- });
186
- }
187
- let l = new b();
188
- l.moveTo(c[0].x, c[0].z);
189
- for (let e = 1; e < c.length; e++) l.lineTo(c[e].x, c[e].z);
190
- if (l.closePath(), t && t.length > 0) for (let e of t) {
191
- if (e.length < 3) continue;
192
- let t = new y(), [r, i] = e[0], [a, c] = n.lonLatToWorldCoords(r, i);
193
- t.moveTo(a - o, c - s);
194
- for (let r = 1; r < e.length; r++) {
195
- let [i, a] = e[r], [c, l] = n.lonLatToWorldCoords(i, a);
196
- t.lineTo(c - o, l - s);
197
- }
198
- t.closePath(), l.holes.push(t);
199
- }
200
- let u = new x(l), d = c.reduce((e, t) => e + t.elev, 0) / c.length;
201
- u.rotateX(-Math.PI / 2), w({
202
- geometry: u,
203
- avgElevation: d
204
- });
205
- }
206
- }), () => {
207
- _.current.unregisterAnchor(S), w((e) => (e && e.geometry.dispose(), null));
208
- };
209
- }, [
210
- S,
211
- v,
212
- e,
213
- t,
214
- h.isSuccess
215
- ]), s(/* @__PURE__ */ u("group", { children: C && /* @__PURE__ */ u("group", {
216
- position: [
217
- 0,
218
- C.avgElevation,
219
- 0
220
- ],
221
- children: /* @__PURE__ */ u("mesh", {
222
- geometry: C.geometry,
223
- onClick: d,
224
- onPointerOut: f,
225
- onPointerOver: p,
226
- children: /* @__PURE__ */ u("meshBasicMaterial", {
227
- color: n,
228
- opacity: c,
229
- transparent: c < 1,
230
- wireframe: l,
231
- side: P[m]
232
- })
233
- })
234
- }) }), v);
235
- }, I = (t) => {
236
- let n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = {
237
- width: 0,
238
- height: 0
239
- }, u = /* @__PURE__ */ new Map(), d = null, f = (e) => {
240
- if (!(!r || e.isAttached)) try {
241
- r.add(e.anchor, e.longitude, e.latitude, e.altitude), e.isAttached = !0, e.onAttach?.(r);
242
- } catch (e) {
243
- console.error("❌ Failed to attach anchor:", e);
244
- }
245
- }, p = (e, t) => {
246
- u.set(e, t), d !== null && !t.isAttached && (f(t), t.onGpsUpdate?.(d, 0));
247
- }, m = (e) => {
248
- let t = u.get(e);
249
- if (t?.isAttached) try {
250
- t.anchor.removeFromParent();
251
- } catch (t) {
252
- console.error(`⚠️ Error removing anchor ${e}:`, t);
253
- }
254
- u.delete(e);
255
- }, h = (e) => u.get(e);
256
- return {
257
- type: e.GEOLOCATION,
258
- async init(e) {
259
- let { camera: l, renderer: p, scene: m, size: h } = e;
260
- if (!m) throw Error("[geolocationBackend] A THREE.Scene is required for location-based AR");
261
- a = l, o = p, s = m, c = h;
262
- let g = a, _ = t?.hFov ?? 80;
263
- g.fov = D.htov(_, h.width / h.height), g.updateProjectionMatrix(), n = new E({
264
- threeObjects: {
265
- camera: l,
266
- renderer: p,
267
- scene: m
268
- },
269
- videoConstraints: t?.webcamConstraints ?? { video: { facingMode: "environment" } },
270
- deviceOrientationOptions: { enabled: !0 },
271
- dimensionsProvider: () => c ? {
272
- width: c.width,
273
- height: c.height
274
- } : {
275
- width: 0,
276
- height: 0
277
- }
278
- }), p.setClearAlpha?.(0), i = (e) => {
279
- d = e.position;
280
- for (let t of u.values()) t.isAttached || f(t), t.onGpsUpdate?.(e.position, e.distMoved);
281
- t?.onGpsUpdate?.(e.position, e.distMoved);
282
- }, r = await n.start();
283
- let v = n.deviceOrientationControls;
284
- if (v && v.orientationChangeEventName !== "deviceorientation") try {
285
- v.disconnect(), v.orientationChangeEventName = "deviceorientation", v.connect();
286
- } catch (e) {
287
- console.error("[geolocationBackend] failed to rebind device orientation event:", e);
288
- }
289
- r.on("gpsupdate", i), n.webcam?.on?.("webcamerror", (e) => {
290
- console.error("[geolocationBackend] webcam error:", e);
291
- }), n.deviceOrientationControls?.on?.("deviceorientationerror", (e) => {
292
- console.error("[geolocationBackend] Device orientation error:", e);
293
- }), r.on("gpserror", (e) => {
294
- console.error("[geolocationBackend] gps error:", e);
295
- }), typeof t?.fakeLat == "number" && typeof t?.fakeLon == "number" ? r.fakeGps(t.fakeLon, t.fakeLat) : r.startGps();
296
- let y = r.getLastKnownLocation();
297
- y !== null && (d = {
298
- coords: {
299
- longitude: y.longitude,
300
- latitude: y.latitude,
301
- accuracy: 0,
302
- altitude: null,
303
- altitudeAccuracy: null,
304
- heading: null,
305
- speed: null,
306
- toJSON: () => y
307
- },
308
- timestamp: Date.now(),
309
- toJSON: () => y
310
- });
311
- },
312
- update() {
313
- if (n?.deviceOrientationControls?.update?.(), c !== null && (c.width !== l.width || c.height !== l.height)) {
314
- l = {
315
- width: c.width,
316
- height: c.height
317
- };
318
- let e = c.width / c.height, t = a;
319
- t.aspect = e, t.updateProjectionMatrix(), n?.syncFovWithWebcam(e);
320
- }
321
- },
322
- dispose() {
323
- r && i && r.off("gpsupdate", i), r?.stopGps?.(), n?.webcam?.dispose?.(), o?.setClearAlpha?.(1), n?.deviceOrientationControls?.dispose?.();
324
- for (let e of u.values()) if (e.isAttached) try {
325
- e.anchor.removeFromParent();
326
- } catch (e) {
327
- console.error("⚠️ Error removing anchor:", e);
328
- }
329
- u.clear(), n = null, r = null, a = null, o = null, s = null, i = null, d = null;
330
- },
331
- setSize(e) {
332
- c = {
333
- width: e.width,
334
- height: e.height,
335
- top: 0,
336
- left: 0
337
- };
338
- },
339
- getInternal: () => ({
340
- locar: r,
341
- webcam: n?.webcam ?? null,
342
- deviceOrientation: n?.deviceOrientationControls ?? null,
343
- scene: s,
344
- camera: a,
345
- lastPosition: d,
346
- registerAnchor: p,
347
- unregisterAnchor: m,
348
- getAnchor: h
349
- })
350
- };
351
- };
352
- //#endregion
353
- export { j as a, M as i, F as n, k as o, N as r, I as t };
@@ -1 +0,0 @@
1
- const e=require(`./useXRStore-Cf_XL0aI.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`react/jsx-runtime`),i=require(`three`),a=require(`three/addons/lines/Line2.js`),o=require(`three/addons/lines/LineGeometry.js`),s=require(`three/addons/lines/LineMaterial.js`),c=require(`locar`);var l={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>void 0},u=()=>{let t=e.r(e=>e.backends).get(e.i.GEOLOCATION);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:l},d=(e,t)=>{let n=e.length-1,r=[],a=0,o=0;for(let i=0;i<n;i++){let n=e[i+1].x-e[i].x,s=e[i+1].y-e[i].y,c=e[i+1].z-e[i].z,l=Math.sqrt(n*n+s*s+c*c),u=t/2,d=-(c*u)/l,f=n*u/l,p=i>0?(d+a)/2:d,m=i>0?(f+o)/2:f;r.push(e[i].x-p,e[i].y,e[i].z-m,e[i].x+p,e[i].y,e[i].z+m),a=d,o=f}r.push(e[n].x-a,e[n].y,e[n].z-o,e[n].x+a,e[n].y,e[n].z+o);let s=[];for(let e=0;e<n;e++)s.push(e*2,e*2+1,e*2+2),s.push(e*2+1,e*2+3,e*2+2);let c=new i.BufferGeometry;return c.setIndex(s),c.setAttribute(`position`,new i.BufferAttribute(new Float32Array(r),3)),c.computeBoundingBox(),c},f=({coordinates:e,color:c=`#ff0000`,isDashed:l=!1,dashSize:f=3,gapSize:p=1,lineWidth:m=1,onClick:h,onPointerOut:g,onPointerOver:_,opacity:v=1})=>{let y=u(),b=(0,t.useRef)(y);b.current=y;let[x]=(0,t.useState)(()=>new i.Group),S=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[C,w]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!y.isSuccess||e.length<2)return;let[t,n,r=0]=e[0];return b.current.registerAnchor(S,{anchor:x,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,u=0]=e[0],[h,g]=t.lonLatToWorldCoords(n,r),_=e.map(([e,n,r=0])=>{let[a,o]=t.lonLatToWorldCoords(e,n);return new i.Vector3(a-h,r-u,o-g)});if(l){let e=new a.Line2(new o.LineGeometry().setFromPoints(_),new s.LineMaterial({color:c,dashSize:f,gapSize:p,dashed:!0,worldUnits:!0,linewidth:m,transparent:v<1,opacity:v}));e.computeLineDistances(),w(e)}else w(new i.Mesh(d(_,m),new i.MeshBasicMaterial({color:c,transparent:v<1,opacity:v,side:i.DoubleSide})))}}),()=>{b.current.unregisterAnchor(S),w(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[S,x,e,c,l,f,p,m,v,y.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{onClick:h,onPointerOut:g,onPointerOver:_,children:C&&(0,r.jsx)(`primitive`,{object:C})}),x)},p=({latitude:e,longitude:a,altitude:o=0,isBillboard:s=!0,onAttach:c,onGpsUpdate:l,children:d})=>{let f=u(),p=(0,t.useRef)(f);p.current=f;let{camera:m}=(0,n.useThree)(),[h]=(0,t.useState)(()=>new i.Group),g=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),_=(0,t.useCallback)(()=>{c?.()},[c]),v=(0,t.useCallback)((e,t)=>{l?.(e,t)},[l]);return(0,t.useEffect)(()=>{if(f.isSuccess)return p.current.registerAnchor(g,{anchor:h,isAttached:!1,latitude:e,longitude:a,altitude:o,onAttach:_,onGpsUpdate:v}),()=>{p.current.unregisterAnchor(g)}},[h,g,e,a,o,_,v,f.isSuccess]),(0,n.useFrame)(()=>{!s||!m||!f.isSuccess||f.getAnchor(g)?.isAttached&&h.lookAt(m.position)}),(0,n.createPortal)((0,r.jsx)(`group`,{children:d}),h)},m=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s,size:c}=(0,n.useThree)(),{registerBackend:l,unregisterBackend:u}=e.r(),d=(0,t.useRef)(null),f=(0,t.useRef)(r);return f.current=r,(0,t.useEffect)(()=>{if(d.current)return;let e=!1;return(async()=>{try{let t=_(f.current);if(e)return;await l(t,{scene:a,camera:o,renderer:s,size:c}),d.current=t}catch(e){console.error(`[GeolocationSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,s,l,u]),(0,t.useEffect)(()=>{d.current?.setSize(c)},[c]),i},h={front:i.FrontSide,back:i.BackSide,double:i.DoubleSide},g=({coordinates:e,holes:a,color:o=`#ff0000`,opacity:s=1,isWireframe:c=!1,onClick:l,onPointerOut:d,onPointerOver:f,side:p=`double`})=>{let m=u(),g=(0,t.useRef)(m);g.current=m;let[_]=(0,t.useState)(()=>new i.Group),v=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[y,b]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!m.isSuccess||e.length<3)return;let[t,n,r=0]=e[0];return g.current.registerAnchor(v,{anchor:_,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,o=0]=e[0],[s,c]=t.lonLatToWorldCoords(n,r),l=[];for(let[n,r,i=0]of e){let[e,a]=t.lonLatToWorldCoords(n,r);l.push({x:e-s,z:a-c,elev:i-o})}let u=new i.Shape;u.moveTo(l[0].x,l[0].z);for(let e=1;e<l.length;e++)u.lineTo(l[e].x,l[e].z);if(u.closePath(),a&&a.length>0)for(let e of a){if(e.length<3)continue;let n=new i.Path,[r,a]=e[0],[o,l]=t.lonLatToWorldCoords(r,a);n.moveTo(o-s,l-c);for(let r=1;r<e.length;r++){let[i,a]=e[r],[o,l]=t.lonLatToWorldCoords(i,a);n.lineTo(o-s,l-c)}n.closePath(),u.holes.push(n)}let d=new i.ShapeGeometry(u),f=l.reduce((e,t)=>e+t.elev,0)/l.length;d.rotateX(-Math.PI/2),b({geometry:d,avgElevation:f})}}),()=>{g.current.unregisterAnchor(v),b(e=>(e&&e.geometry.dispose(),null))}},[v,_,e,a,m.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:y&&(0,r.jsx)(`group`,{position:[0,y.avgElevation,0],children:(0,r.jsx)(`mesh`,{geometry:y.geometry,onClick:l,onPointerOut:d,onPointerOver:f,children:(0,r.jsx)(`meshBasicMaterial`,{color:o,opacity:s,transparent:s<1,wireframe:c,side:h[p]})})})}),_)},_=t=>{let n=null,r=null,i=null,a=null,o=null,s=null,l=null,u={width:0,height:0},d=new Map,f=null,p=e=>{if(!(!r||e.isAttached))try{r.add(e.anchor,e.longitude,e.latitude,e.altitude),e.isAttached=!0,e.onAttach?.(r)}catch(e){console.error(`❌ Failed to attach anchor:`,e)}},m=(e,t)=>{d.set(e,t),f!==null&&!t.isAttached&&(p(t),t.onGpsUpdate?.(f,0))},h=e=>{let t=d.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}d.delete(e)},g=e=>d.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:u,renderer:m,scene:h,size:g}=e;if(!h)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);a=u,o=m,s=h,l=g;let _=a,v=t?.hFov??80;_.fov=c.LocAR.htov(v,g.width/g.height),_.updateProjectionMatrix(),n=new c.App({threeObjects:{camera:u,renderer:m,scene:h},videoConstraints:t?.webcamConstraints??{video:{facingMode:`environment`}},deviceOrientationOptions:{enabled:!0},dimensionsProvider:()=>l?{width:l.width,height:l.height}:{width:0,height:0}}),m.setClearAlpha?.(0),i=e=>{f=e.position;for(let t of d.values())t.isAttached||p(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},r=await n.start();let y=n.deviceOrientationControls;if(y&&y.orientationChangeEventName!==`deviceorientation`)try{y.disconnect(),y.orientationChangeEventName=`deviceorientation`,y.connect()}catch(e){console.error(`[geolocationBackend] failed to rebind device orientation event:`,e)}r.on(`gpsupdate`,i),n.webcam?.on?.(`webcamerror`,e=>{console.error(`[geolocationBackend] webcam error:`,e)}),n.deviceOrientationControls?.on?.(`deviceorientationerror`,e=>{console.error(`[geolocationBackend] Device orientation error:`,e)}),r.on(`gpserror`,e=>{console.error(`[geolocationBackend] gps error:`,e)}),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`?r.fakeGps(t.fakeLon,t.fakeLat):r.startGps();let b=r.getLastKnownLocation();b!==null&&(f={coords:{longitude:b.longitude,latitude:b.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>b},timestamp:Date.now(),toJSON:()=>b})},update(){if(n?.deviceOrientationControls?.update?.(),l!==null&&(l.width!==u.width||l.height!==u.height)){u={width:l.width,height:l.height};let e=l.width/l.height,t=a;t.aspect=e,t.updateProjectionMatrix(),n?.syncFovWithWebcam(e)}},dispose(){r&&i&&r.off(`gpsupdate`,i),r?.stopGps?.(),n?.webcam?.dispose?.(),o?.setClearAlpha?.(1),n?.deviceOrientationControls?.dispose?.();for(let e of d.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}d.clear(),n=null,r=null,a=null,o=null,s=null,i=null,f=null},setSize(e){l={width:e.width,height:e.height,top:0,left:0}},getInternal:()=>({locar:r,webcam:n?.webcam??null,deviceOrientation:n?.deviceOrientationControls??null,scene:s,camera:a,lastPosition:f,registerAnchor:m,unregisterAnchor:h,getAnchor:g})}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
@@ -1 +0,0 @@
1
- const e=require(`./useXRStore-Cf_XL0aI.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`react/jsx-runtime`),i=require(`three`);i=e.a(i);var a=.15,o=.5,s=t=>{let n=null,r=null,s=null,c=t?.enableOrientation??!0,l=!1,u=t?.enableWorldAnchoring??!0,d=null,f=null,p=t?.smoothingFactor??a,m=t?.deadZone??o,h={alpha:0,beta:0,gamma:0},g={alpha:0,beta:0,gamma:0},_={alpha:0,beta:0,gamma:0},v=!1,y=null,b=null,x=new i.Quaternion,S=new i.Quaternion,C=new i.Euler,w=new i.Quaternion,T=new i.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),E=new i.Vector3(0,0,1),D=new i.Quaternion,O=new i.Quaternion,k=(e,t,n,r)=>{let i=(screen.orientation?.angle??0)*Math.PI/180;C.set(n,t,-r,`YXZ`),e.setFromEuler(C),e.multiply(T),e.multiply(w.setFromAxisAngle(E,-i))},A=(e,t)=>{let n=(t-e)%360+360;return n=(n+180)%360-180,n},j=(e,t,n=!1)=>Math.abs(n?A(e,t):t-e)<m?e:t,M=(e,t,n)=>e+(t-e)*n,N=(e,t,n)=>((e+A(e,t)*n)%360+360)%360,P=async()=>{let e=DeviceOrientationEvent;if(typeof e.requestPermission==`function`)try{return await e.requestPermission()===`granted`?(l=!0,!0):(console.warn(`[MagicBackend] Device orientation permission denied`),!1)}catch(e){return console.error(`[MagicBackend] Error requesting orientation permission:`,e),!1}return l=!0,!0},F=()=>{d=e=>{if(h.alpha=e.alpha??0,h.beta=e.beta??0,h.gamma=e.gamma??0,!v&&(h.alpha!==0||h.beta!==0||h.gamma!==0)){_.alpha=h.alpha,_.beta=h.beta,_.gamma=h.gamma;let{degToRad:e}=i.MathUtils;k(D,e(h.alpha),e(h.beta),e(h.gamma)),O.copy(D).invert(),v=!0}},window.addEventListener(`deviceorientation`,d,!0)},I=async(e,a)=>{let o=t?.webcamConstraints??{video:{facingMode:`environment`}};try{s=await navigator.mediaDevices.getUserMedia(o)}catch(e){throw console.error(`[MagicBackend] Failed to access camera:`,e),e}n=document.createElement(`video`),n.srcObject=s,n.setAttribute(`playsinline`,``),n.setAttribute(`autoplay`,``),n.muted=!0,n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.width=`100vw`,n.style.height=`100vh`,n.style.objectFit=`cover`,n.style.zIndex=`-1`,n.style.pointerEvents=`none`,document.body.appendChild(n),await n.play(),r=new i.VideoTexture(n),r.minFilter=i.LinearFilter,r.magFilter=i.LinearFilter,r.colorSpace=i.SRGBColorSpace,e.background=r,a.setClearColor(0,0)};return{type:e.i.MAGIC,async init({scene:e,camera:t,renderer:n}){if(y=t,b=e,await I(e,n),c)if(await P())F();else{let e=async()=>{document.removeEventListener(`click`,e),document.removeEventListener(`touchend`,e),f=null,await P()&&F()};f=e,document.addEventListener(`click`,e),document.addEventListener(`touchend`,e)}},update(){if(!c||!l)return;let e=j(g.alpha,h.alpha,!0),t=j(g.beta,h.beta),n=j(g.gamma,h.gamma);if(g.alpha=N(g.alpha,e,p),g.beta=M(g.beta,t,p),g.gamma=M(g.gamma,n,p),u&&y&&v){let{degToRad:e}=i.MathUtils;k(x,e(h.alpha),e(h.beta),e(h.gamma)),S.copy(O).multiply(x),y.quaternion.slerp(S,p)}r&&(r.needsUpdate=!0)},dispose(){if(d&&=(window.removeEventListener(`deviceorientation`,d),null),f&&=(document.removeEventListener(`click`,f),document.removeEventListener(`touchend`,f),null),s){for(let e of s.getTracks())e.stop();s=null}n&&=(n.pause(),n.srcObject=null,n.parentNode?.removeChild(n),null),r&&=(r.dispose(),null),b&&(b.background=null),y=null,b=null,c=!1,l=!1,u=!1,v=!1,g.alpha=0,g.beta=0,g.gamma=0,h.alpha=0,h.beta=0,h.gamma=0,_.alpha=0,_.beta=0,_.gamma=0,D.identity(),O.identity()},getInternal:()=>({videoElement:n,videoTexture:r,stream:s,orientationEnabled:c,orientationPermissionGranted:l,worldAnchoringEnabled:u,currentOrientation:{...g},initialOrientation:{..._},hasInitialOrientation:v,requestOrientationPermission:async()=>{let e=await P();return e&&!d&&F(),e}})}},c=({options:r={},children:i})=>{let{scene:a,camera:o,gl:c,size:l}=(0,n.useThree)(),{registerBackend:u,unregisterBackend:d}=e.r(),f=(0,t.useRef)(null),p=(0,t.useRef)(r);return p.current=r,(0,t.useEffect)(()=>{if(f.current)return;let e=!1;return(async()=>{try{let t=s(p.current);if(e)return;await u(t,{scene:a,camera:o,renderer:c,size:l}),f.current=t}catch(e){console.error(`[MagicSession] Failed to initialize:`,e)}})(),()=>{e=!0,f.current&&=(d(f.current),null)}},[a,o,c,u,d]),i},l=({position:i=[0,0,-2],rotation:a=[0,0,0],scale:o=1,isBillboard:s=!1,children:c})=>{let l=(0,t.useRef)(null),u=e.r(e=>e.backends);return(0,n.useFrame)(({camera:t})=>{let n=l.current;if(!n)return;let r=u.get(e.i.MAGIC);r&&r.getInternal().hasInitialOrientation&&(n.position.set(i[0],i[1],i[2]),n.rotation.set(a[0],a[1],a[2]),typeof o==`number`?n.scale.setScalar(o):n.scale.set(o[0],o[1],o[2]),s&&n.lookAt(t.position))}),(0,r.jsx)(`group`,{ref:l,children:c})};Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);var l=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},u=(e=>e?l(e):l),d=e=>e;function f(e,t=d){let n=c.default.useSyncExternalStore(e.subscribe,c.default.useCallback(()=>t(e.getState()),[e,t]),c.default.useCallback(()=>t(e.getInitialState()),[e,t]));return c.default.useDebugValue(n),n}var p=e=>{let t=u(e),n=e=>f(t,e);return Object.assign(n,t),n},m=(e=>e?p(e):p),h=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)},g=e=>Symbol.iterator in e,_=e=>`entries`in e,v=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},y=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function b(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:g(e)&&g(t)?_(e)&&_(t)?v(e,t):y(e,t):v({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function x(e){let t=c.default.useRef(void 0);return n=>{let r=e(n);return b(t.current,r)?t.current:t.current=r}}var S={FIDUCIAL:`fiducial`,GEOLOCATION:`geolocation`,IMMERSIVE:`immersive`,MAGIC:`magic`,VISION:`vision`},C=m()(h((e,t)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(n,r)=>{try{let i=t(),a=new Set(i.backends.keys()),o=a.has(S.FIDUCIAL)||n.type===S.FIDUCIAL,s=a.has(S.GEOLOCATION)||n.type===S.GEOLOCATION;if(o&&s){let e=`❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.`;throw console.error(e),Error(e)}await n.init({scene:r.scene,camera:r.camera,renderer:r.renderer,size:r.size}),e(e=>{let t=new Map(e.backends);return t.set(n.type,n),{backends:t}})}catch(e){throw console.error(`[XRStore] Failed to register backend:`,e),e}},unregisterBackend:t=>{e(e=>{let n=new Map(e.backends);n.delete(t.type);try{t.dispose?.()}catch(e){console.error(`[XRStore] Error disposing backend:`,e)}return{backends:n}})},setVideo:t=>{e({video:t})},updateBackends:e=>{let{backends:n}=t();for(let t of n.values())try{t.update?.(e)}catch(e){console.error(`[XRStore] Backend update error:`,e)}},setImmersiveStore:t=>{e({immersiveStore:t})}}))),w=()=>C.getState(),T=C.subscribe,E=e=>C(x(t=>{let n={...t,isImmersive:t.backends.has(S.IMMERSIVE),immersive:t.immersiveStore||null};return e?e(n):n}));Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return w}});
@@ -1 +0,0 @@
1
- const e=require(`./useXRStore-Cf_XL0aI.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`react/jsx-runtime`),i=require(`three`);var a=({constraints:e,onReady:n,onError:i,mirrored:a=!0})=>{let o=(0,t.useRef)(null),[s,c]=(0,t.useState)(!1),l=(0,t.useRef)(n);l.current=n;let u=(0,t.useRef)(i);return u.current=i,(0,t.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await navigator.mediaDevices.getUserMedia({video:e||{width:{ideal:1280},height:{ideal:720},facingMode:`user`}});if(t||!o.current){for(let e of n.getTracks())e.stop();return}if(o.current.srcObject=n,await new Promise((e,t)=>{let n=o.current;if(!n){t(Error(`Video ref lost`));return}let r=()=>{n.removeEventListener(`canplay`,r),n.removeEventListener(`error`,i),e()},i=()=>{n.removeEventListener(`canplay`,r),n.removeEventListener(`error`,i),t(Error(`Video failed to load`))};n.addEventListener(`canplay`,r,{once:!0}),n.addEventListener(`error`,i,{once:!0})}),t)return;await o.current.play(),c(!0),l.current?.(o.current)}catch(e){if(t)return;let n=e instanceof Error?e:Error(`Failed to access camera`);console.error(`Camera error:`,n),u.current?.(n)}})(),()=>{if(t=!0,o.current?.srcObject){let e=o.current.srcObject;for(let t of e.getTracks())t.stop()}}},[e]),(0,r.jsx)(`video`,{ref:o,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,objectFit:`cover`,transform:a?`scaleX(-1)`:void 0,opacity:s?1:0,transition:`opacity 0.5s ease`},autoPlay:!0,playsInline:!0,muted:!0})},o=(e,t)=>e.y<t.y,s=e=>[Math.abs(e[4].x-e[9].x)>Math.abs(e[3].x-e[9].x),o(e[8],e[6]),o(e[12],e[10]),o(e[16],e[14]),o(e[20],e[18])],c=e=>{if(e.length<21)return null;let t=s(e);return t[0]&&!t[1]&&!t[2]&&!t[3]&&!t[4]?{gesture:`thumbs_up`,confidence:.9}:null},l=e=>{if(e.length<21)return null;let t=s(e);return!t[0]&&t[1]&&t[2]&&!t[3]&&!t[4]?{gesture:`peace`,confidence:.8}:null},u=e=>{if(e.length<21)return null;let t=s(e);return Math.sqrt((e[4].x-e[8].x)**2+(e[4].y-e[8].y)**2)<.05&&t[2]&&t[3]&&t[4]?{gesture:`ok`,confidence:.8}:null},d=e=>e.length<21?null:s(e).filter(Boolean).length===5?{gesture:`open_hand`,confidence:.7}:null,f=e=>e.length<21?null:s(e).filter(Boolean).length<=1?{gesture:`fist`,confidence:.7}:null,p=[c,l,u,d,f],m={gesture:`none`,confidence:0},h=(e,t=p)=>{let n=m;for(let r of t){let t=r(e);t&&t.confidence>n.confidence&&(n=t)}return n},g=(e,t,n,r=!0)=>{let i=t.width/t.height,a=n.width/n.height,o=a>i?a/i:1,s=a>i?1:i/a,c=.5+(e.x-.5)*o,l=.5+(e.y-.5)*s;return[(r?.5-c:c-.5)*t.width,(.5-l)*t.height,0]},_=e=>{let t=e.length||1,n=0,r=0,i=0;for(let t of e)n+=t.x,r+=t.y,i+=t.z??0;return{x:n/t,y:r/t,z:i/t}},v={isPending:!0,isSuccess:!1,provider:null,videoElement:null,onDetection:()=>()=>{}},y=()=>{let t=e.r(e=>e.backends).get(e.i.VISION);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:v},b=({onHandMove:e,onGesture:a,landmarkIndex:o=9,mirror:s=!0,children:c})=>{let{onDetection:l,isSuccess:u}=y(),{viewport:d}=(0,n.useThree)(),f=(0,t.useRef)(null),p=(0,t.useRef)(new i.Vector3),m=(0,t.useRef)(``);return(0,t.useEffect)(()=>{if(u)return l(e=>{f.current=e})},[u,l]),(0,n.useFrame)(()=>{let t=f.current;if(!t)return;let n=t.hands[0];if(!n||n.landmarks.length===0)return;let[r,i,c]=g(n.landmarks[o]??n.landmarks[0],d,t.frameSize,s);p.current.set(r,i,c),e?.(p.current);let l=h(n.landmarks);l.gesture!==m.current&&(m.current=l.gesture,a?.(l.gesture,l.confidence))}),(0,r.jsx)(`group`,{children:c})},x=`person.bicycle.car.motorcycle.airplane.bus.train.truck.boat.traffic light.fire hydrant.stop sign.parking meter.bench.bird.cat.dog.horse.sheep.cow.elephant.bear.zebra.giraffe.backpack.umbrella.handbag.tie.suitcase.frisbee.skis.snowboard.sports ball.kite.baseball bat.baseball glove.skateboard.surfboard.tennis racket.bottle.wine glass.cup.fork.knife.spoon.bowl.banana.apple.sandwich.orange.broccoli.carrot.hot dog.pizza.donut.cake.chair.couch.potted plant.bed.dining table.toilet.tv.laptop.mouse.remote.keyboard.cell phone.microwave.oven.toaster.sink.refrigerator.book.clock.vase.scissors.teddy bear.hair drier.toothbrush`.split(`.`),S=(e,t={})=>({name:`yolo`,inputSize:640,labels:[...x],...t,path:e,decoder:`yolo`}),C=(e,t={})=>({name:`rf-detr`,inputSize:560,labels:[...x],...t,path:e,decoder:`rfdetr`}),w=(e,t={})=>({name:`yolo-seg`,inputSize:640,labels:[...x],...t,path:e,decoder:`yoloseg`}),T=e=>{let{isSuccess:n,onDetection:r}=y(),[i,a]=(0,t.useState)(null),o=e?.throttle??16,s=(0,t.useRef)(0);return(0,t.useEffect)(()=>{if(!n){a(null);return}return r(e=>{let t=performance.now();t-s.current<o||(s.current=t,a(e))})},[n,r,o]),i},E=478,D=(e,t)=>t===`faces`?e.faces:t===`poses`?e.poses:e.hands,O=({task:e,index:a=0,debug:o=!1,mirror:s=!0,smoothing:c=.4,children:l})=>{let{onDetection:u,isSuccess:d}=y(),{viewport:f}=(0,n.useThree)(),p=(0,t.useRef)(null),m=(0,t.useRef)(null),h=(0,t.useRef)(null),v=(0,t.useMemo)(()=>new i.Object3D,[]),b=(0,t.useMemo)(()=>new i.Vector3,[]);return(0,t.useEffect)(()=>{m.current&&(m.current.visible=!1),h.current&&(h.current.count=0)},[]),(0,t.useEffect)(()=>{if(d)return u(e=>{p.current=e})},[d,u]),(0,n.useFrame)(()=>{let t=p.current,n=m.current;if(!t||!n)return;let r=D(t,e)[a],i=h.current;if(!r||r.landmarks.length===0){n.visible=!1,i&&(i.count=0);return}let l=n.visible;n.visible=!0;let[u,d,y]=g(_(r.landmarks),f,t.frameSize,s);if(b.set(u,d,y),!l||c>=1?n.position.copy(b):n.position.lerp(b,c),o&&i){let e=n.position,a=Math.min(r.landmarks.length,E);for(let n=0;n<a;n++){let[a,o,c]=g(r.landmarks[n],f,t.frameSize,s);v.position.set(a-e.x,o-e.y,c-e.z),v.updateMatrix(),i.setMatrixAt(n,v.matrix)}i.count=a,i.instanceMatrix.needsUpdate=!0}}),(0,r.jsxs)(`group`,{ref:m,children:[l,o&&(0,r.jsxs)(`instancedMesh`,{ref:h,args:[void 0,void 0,E],children:[(0,r.jsx)(`sphereGeometry`,{args:[.02,6,6]}),(0,r.jsx)(`meshBasicMaterial`,{color:`#00ff88`})]})]})},k=({tasks:e,width:t=320,height:n=240,style:i})=>{let a=T({throttle:50});return(0,r.jsxs)(`div`,{style:{background:`rgba(0, 0, 0, 0.8)`,color:`#00ff88`,padding:`8px`,borderRadius:`8px`,fontFamily:`monospace`,fontSize:`0.75rem`,width:t,height:n,overflow:`auto`,...i},children:[(0,r.jsxs)(`div`,{children:[`Frame: `,a?`active`:`none`]}),a&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(`div`,{children:[`Size: `,a.frameSize.width,`x`,a.frameSize.height]}),e.includes(`hands`)&&(0,r.jsxs)(`div`,{children:[`Hands: `,a.hands.length]}),e.includes(`faces`)&&(0,r.jsxs)(`div`,{children:[`Faces: `,a.faces.length]}),e.includes(`poses`)&&(0,r.jsxs)(`div`,{children:[`Poses: `,a.poses.length]}),e.includes(`objects`)&&(0,r.jsxs)(`div`,{children:[`Objects: `,a.objects.length]})]})]})},A=class{type=`mediapipe`;models={};isInitialized=!1;isProcessing=!1;isDisposed=!1;videoElement=null;animationId=null;lastProcessTime=0;callbacks=[];options;constructor(e){this.options=e}async initialize(e){this.videoElement=e;let{FilesetResolver:t,HandLandmarker:n,FaceLandmarker:r,PoseLandmarker:i}=await import(`@mediapipe/tasks-vision`),a=await t.forVisionTasks(`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10/wasm`),o=this.options.useGpu??!0?`GPU`:`CPU`,s=async e=>{if(o===`CPU`)return e(`CPU`);try{return await e(`GPU`)}catch{return console.warn(`MediaPipe GPU delegate failed, falling back to CPU`),e(`CPU`)}},c=new Set(this.options.tasks??[`hands`,`faces`,`poses`]),l=[`hands`,`faces`,`poses`].filter(e=>c.has(e)),u=0;c.has(`hands`)&&(this.options.onProgress?.({step:++u,total:l.length,label:`hand landmarker`}),this.models.handLandmarker=await s(e=>n.createFromOptions(a,{baseOptions:{modelAssetPath:`https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task`,delegate:e},runningMode:`VIDEO`,numHands:2,minHandDetectionConfidence:.7,minHandPresenceConfidence:.5,minTrackingConfidence:.5}))),c.has(`faces`)&&(this.options.onProgress?.({step:++u,total:l.length,label:`face landmarker`}),this.models.faceLandmarker=await s(e=>r.createFromOptions(a,{baseOptions:{modelAssetPath:`https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task`,delegate:e},runningMode:`VIDEO`,numFaces:1,minFaceDetectionConfidence:.7,minFacePresenceConfidence:.5,minTrackingConfidence:.5,outputFaceBlendshapes:!1,outputFacialTransformationMatrixes:!1}))),c.has(`poses`)&&(this.options.onProgress?.({step:++u,total:l.length,label:`pose landmarker`}),this.models.poseLandmarker=await s(e=>i.createFromOptions(a,{baseOptions:{modelAssetPath:`https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task`,delegate:e},runningMode:`VIDEO`,numPoses:1,minPoseDetectionConfidence:.7,minPosePresenceConfidence:.5,minTrackingConfidence:.5,outputSegmentationMasks:this.options.segmentation??!1}))),this.isInitialized=!0,this.options.onProgress?.(null)}startDetection(){!this.isInitialized||!this.videoElement||this.isProcessing||(this.isProcessing=!0,this.processFrame())}stopDetection(){this.isProcessing=!1,this.animationId&&=(cancelAnimationFrame(this.animationId),null)}onDetection(e){return this.callbacks.push(e),()=>{let t=this.callbacks.indexOf(e);t>-1&&this.callbacks.splice(t,1)}}dispose(){this.isDisposed=!0,this.stopDetection(),this.models.handLandmarker&&this.models.handLandmarker.close(),this.models.faceLandmarker&&this.models.faceLandmarker.close(),this.models.poseLandmarker&&this.models.poseLandmarker.close(),this.models={},this.videoElement=null,this.callbacks=[],this.isInitialized=!1,this.isProcessing=!1}processFrame=()=>{if(!this.isProcessing||!this.videoElement||this.isDisposed)return;let e=performance.now(),t=this.options.throttle??16;if(e-this.lastProcessTime<t){this.animationId=requestAnimationFrame(this.processFrame);return}let{videoWidth:n,videoHeight:r}=this.videoElement;if(n===0||r===0){this.animationId=requestAnimationFrame(this.processFrame);return}this.lastProcessTime=e;let i=e;try{let e={hands:[],faces:[],poses:[],objects:[],timestamp:i,frameSize:{width:n,height:r}};if(this.models.handLandmarker){let t=this.models.handLandmarker.detectForVideo(this.videoElement,i);e.hands=t.landmarks.map((e,n)=>({landmarks:e.map(e=>({x:e.x,y:e.y,z:e.z||0})),confidence:t.handednesses?.[n]?.[0]?.score||.5}))}if(this.models.faceLandmarker&&(e.faces=this.models.faceLandmarker.detectForVideo(this.videoElement,i).faceLandmarks.map(e=>{let t=e.map(e=>e.x),n=e.map(e=>e.y),r=(Math.max(...t)-Math.min(...t))*(Math.max(...n)-Math.min(...n)),i=Math.min(.95,Math.max(.6,r*4));return{landmarks:e.map(e=>({x:e.x,y:e.y,z:e.z||0})),confidence:i}})),this.models.poseLandmarker){let t=this.models.poseLandmarker.detectForVideo(this.videoElement,i);e.poses=t.landmarks.map(e=>{let t=0,n=0;for(let r of e)typeof r.visibility==`number`&&(t+=r.visibility,n++);let r=n>0?t/n:.5;return{landmarks:e.map(e=>({x:e.x,y:e.y,z:e.z||0})),confidence:r}});let n=t.segmentationMasks?.[0];if(n){let t=new OffscreenCanvas(n.width,n.height).getContext(`2d`),r=n.getAsFloat32Array(),i=t.createImageData(n.width,n.height);for(let e=0;e<r.length;e++){let t=r[e]*255;i.data[e*4]=t,i.data[e*4+1]=t,i.data[e*4+2]=t,i.data[e*4+3]=255}e.segmentationMask=i}}this.handleResult(e)}catch(e){console.error(`Vision processing error:`,e)}this.animationId=requestAnimationFrame(this.processFrame)};handleResult(e){let t=this.options.minConfidence??.7,n=this.options.maxResults??2,r={...e,hands:e.hands.filter(e=>e.confidence>=t).slice(0,n),faces:e.faces.filter(e=>e.confidence>=t).slice(0,n),poses:e.poses.filter(e=>e.confidence>=t).slice(0,n),objects:[]};for(let e of this.callbacks)try{e(r)}catch(e){console.error(`Error in vision callback:`,e)}}},j=5e3,M=class{type=`onnx`;worker=null;isInitialized=!1;isDisposed=!1;isProcessing=!1;videoElement=null;animationId=null;loadedModels=new Map;lastProcessTime=0;processingStartTime=0;callbacks=[];options;messageHandler=null;pendingModelCallbacks=new Map;constructor(e){this.options=e}post(e,t){t?this.worker?.postMessage(e,t):this.worker?.postMessage(e)}async initialize(e){this.videoElement=e,this.worker=new Worker(new URL(`/assets/onnxWorker-BNjoneWr.js`,``+{}.url),{type:`module`}),await new Promise((e,t)=>{let n=setTimeout(()=>{t(Error(`ONNX worker initialization timeout`))},1e4);this.messageHandler=r=>{let i=r.data;switch(i.type){case`initialized`:clearTimeout(n),this.isInitialized=!0,e();break;case`result`:this.isProcessing=!1,this.handleResult(i.result);break;case`modelLoaded`:{let e=this.pendingModelCallbacks.get(i.modelName);e&&(this.pendingModelCallbacks.delete(i.modelName),e.resolve());break}case`modelError`:{let e=this.pendingModelCallbacks.get(i.modelName);e&&(this.pendingModelCallbacks.delete(i.modelName),e.reject(Error(i.error)));break}case`error`:this.isProcessing=!1,this.isInitialized?console.error(`ONNX worker error:`,i.error):(clearTimeout(n),t(Error(i.error)));break}},this.worker?.addEventListener(`message`,this.messageHandler),this.post({type:`init`})});let t=this.options.onnx?.models??[];for(let e of t)await this.loadModel(e)}startDetection(){if(!this.isInitialized||!this.videoElement){console.warn(`ONNX provider not initialized`);return}let e=()=>{if(!this.videoElement||!this.isInitialized)return;let t=Date.now(),n=this.options.throttle??100;if(t-this.lastProcessTime<n){this.animationId=requestAnimationFrame(e);return}this.isProcessing&&this.processingStartTime>0&&t-this.processingStartTime>j&&(console.warn(`ONNX processing stall detected, resetting`),this.isProcessing=!1),this.isProcessing||this.processCurrentFrame(),this.animationId=requestAnimationFrame(e)};e()}stopDetection(){this.animationId&&=(cancelAnimationFrame(this.animationId),null),this.isProcessing=!1}onDetection(e){return this.callbacks.push(e),()=>{let t=this.callbacks.indexOf(e);t>-1&&this.callbacks.splice(t,1)}}dispose(){this.isDisposed=!0,this.stopDetection(),this.worker&&=(this.messageHandler&&=(this.worker.removeEventListener(`message`,this.messageHandler),null),this.post({type:`dispose`}),this.worker.terminate(),null),this.videoElement=null,this.callbacks.length=0,this.loadedModels.clear(),this.pendingModelCallbacks.clear(),this.isInitialized=!1}async loadModel(e){if(!this.worker)throw Error(`Worker not initialized`);let t=new Promise((t,n)=>{this.pendingModelCallbacks.set(e.name,{resolve:t,reject:n})});this.post({type:`loadModel`,model:e}),await t,this.loadedModels.set(e.name,e)}processCurrentFrame(){if(!this.videoElement||!this.worker||this.isProcessing)return;let e=Date.now();this.isProcessing=!0,this.lastProcessTime=e,this.processingStartTime=e;let{videoWidth:t,videoHeight:n}=this.videoElement;createImageBitmap(this.videoElement).then(e=>{if(this.isDisposed){e.close();return}this.post({type:`process`,imageBitmap:e,sourceWidth:t,sourceHeight:n,options:{minConfidence:this.options.minConfidence??.5,maxResults:this.options.maxResults??100}},[e])},e=>{this.isProcessing=!1,console.error(`Error creating ImageBitmap:`,e)})}handleResult(e){let t=this.options.minConfidence??.5,n=this.options.maxResults??100,r={hands:[],faces:[],poses:[],objects:e.detections.filter(e=>e.confidence>=t).sort((e,t)=>t.confidence-e.confidence).slice(0,n),masks:e.masks.length>0?e.masks:void 0,timestamp:e.timestamp,frameSize:e.frameSize,processingTime:e.processingTime};for(let e of this.callbacks)try{e(r)}catch(e){console.error(`Error in ONNX detection callback:`,e)}}},N=e=>e.provider===`onnx`?new M(e):new A(e),P=async e=>{let t=document.createElement(`video`);t.style.display=`none`,document.body.appendChild(t);try{return t.srcObject=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280,min:640},height:{ideal:720,min:480},facingMode:e.provider===`onnx`?`environment`:`user`,frameRate:{ideal:30,min:15}}}),t.playsInline=!0,t.muted=!0,await new Promise((e,n)=>{t.onloadedmetadata=()=>{t.play().then(e).catch(n)},t.onerror=n}),t}catch(e){throw document.body.removeChild(t),e}},F=e=>{if(!e)return;let t=e.srcObject;if(t)for(let e of t.getTracks())e.stop();e.parentNode&&e.parentNode.removeChild(e)},I=t=>{let n=null,r=null,i=!1,a=null,o=[],s=e=>(o.push(e),()=>{let t=o.indexOf(e);t>-1&&o.splice(t,1)});return{type:e.i.VISION,async init(e){t.videoElement?(r=t.videoElement,i=!1):(r=await P(t),i=!0),n=N(t),await n.initialize(r),a=n.onDetection(e=>{for(let t of o)try{t(e)}catch(e){console.error(`Error in vision detection callback:`,e)}}),n.startDetection()},update(e){},dispose(){a?.(),a=null,n?.dispose(),i&&F(r),r=null,n=null,o.length=0},getInternal:()=>({provider:n,videoElement:r,onDetection:s})}},L=({options:i,children:a,onError:o})=>{let{scene:s,camera:c,gl:l,size:u}=(0,n.useThree)(),{registerBackend:d,unregisterBackend:f}=e.r(),p=(0,t.useRef)(null),m=(0,t.useRef)(i);m.current=i;let h=(0,t.useRef)(o);return h.current=o,(0,t.useEffect)(()=>{if(p.current)return;let e=!1;return(async()=>{try{let t=I(m.current);if(e)return;if(await d(t,{scene:s,camera:c,renderer:l,size:u}),e){f(t);return}p.current=t}catch(e){let t=e instanceof Error?e:Error(String(e));console.error(`[VisionSession] Failed to initialize:`,t),h.current?.(t)}})(),()=>{e=!0,p.current&&=(f(p.current),null)}},[s,c,l,d,f]),(0,r.jsx)(r.Fragment,{children:a})},R=({tasks:e,progress:t,showDebug:n,onToggleDebug:i})=>{let a=T({throttle:100}),o=e=>{if(!a)return!1;switch(e){case`hands`:return a.hands.length>0;case`faces`:return a.faces.length>0;case`poses`:return a.poses.length>0;case`objects`:return a.objects.length>0;default:return!1}},s=e.some(o),c=a!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(`div`,{style:{position:`fixed`,top:`20px`,left:`20px`,background:`rgba(0, 0, 0, 0.7)`,color:`white`,padding:`12px`,borderRadius:`8px`,fontFamily:`system-ui, sans-serif`,fontSize:`0.9rem`,zIndex:1e3},children:[(0,r.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,marginBottom:`8px`},children:[(0,r.jsx)(`div`,{style:{width:`8px`,height:`8px`,borderRadius:`50%`,background:c?`#00ff88`:`#ffaa00`}}),(0,r.jsx)(`span`,{children:s?`Active`:c?`Ready`:t?`Loading models (${t.step}/${t.total}) ${t.label}...`:`Starting...`})]}),e.map(e=>(0,r.jsxs)(`div`,{style:{fontSize:`0.8rem`,opacity:.8,display:`flex`,justifyContent:`space-between`,gap:`12px`},children:[(0,r.jsx)(`span`,{children:e}),(0,r.jsx)(`span`,{children:o(e)?`active`:c?`idle`:`...`})]},e))]}),(0,r.jsxs)(`button`,{onClick:i,type:`button`,style:{position:`fixed`,top:`20px`,right:`20px`,background:`rgba(0, 0, 0, 0.7)`,color:`white`,border:`1px solid #333`,padding:`8px 12px`,borderRadius:`6px`,cursor:`pointer`,fontFamily:`system-ui, sans-serif`,fontSize:`0.8rem`,zIndex:1e3},children:[n?`Hide`:`Show`,` Debug`]})]})},z={},B=({tasks:e=[`hands`],options:i,children:o,showDebug:s=!1,cameraConstraints:c,canvasStyle:l=z,onReady:u,onError:d})=>{let[f,p]=(0,t.useState)(s),[m,h]=(0,t.useState)(null),[g,_]=(0,t.useState)(null),v=(0,t.useRef)(u);v.current=u;let y=(0,t.useRef)(_);y.current=_;let b=(0,t.useCallback)(e=>y.current(e),[]),x=(0,t.useCallback)(e=>{h(e),v.current?.()},[]),S=(0,t.useMemo)(()=>({tasks:e,minConfidence:.6,maxResults:2,useGpu:!0,...i,videoElement:m??void 0,onProgress:b}),[e,i,m,b]);return(0,r.jsxs)(`div`,{style:{position:`relative`,width:`100%`,height:`100%`},children:[(0,r.jsx)(a,{constraints:c,onReady:x,onError:d}),m&&(0,r.jsx)(n.Canvas,{style:{position:`absolute`,inset:0,pointerEvents:`none`,...l},camera:{position:[0,0,5],fov:75},gl:{alpha:!0,premultipliedAlpha:!1},children:(0,r.jsx)(V,{options:S,onError:d,children:o})}),(0,r.jsx)(R,{tasks:e,progress:g,showDebug:f,onToggleDebug:()=>p(e=>!e)}),f&&(0,r.jsx)(k,{tasks:e,width:320,height:240,style:{position:`fixed`,bottom:`80px`,right:`20px`,maxWidth:`calc(100vw - 40px)`,overflow:`hidden`}})]})},V=({options:e,onError:t,children:n})=>(0,r.jsxs)(L,{options:e,onError:t,children:[(0,r.jsx)(`ambientLight`,{intensity:.6}),(0,r.jsx)(`directionalLight`,{position:[10,10,10],intensity:.8}),n]});Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return u}});