@omnidotdev/rdk 0.9.0 → 0.9.1
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/build/fiducial-CqsG94R9.js +163 -0
- package/build/fiducial-dapuWTXg.cjs +1 -0
- package/build/fiducial.cjs +1 -1
- package/build/fiducial.js +3 -7
- package/build/geolocation/GeoLine.d.ts.map +1 -1
- package/build/geolocation/GeolocationAnchor.d.ts.map +1 -1
- package/build/geolocation/geolocationBackend.d.ts.map +1 -1
- package/build/geolocation-U_vaIjuk.js +288 -0
- package/build/geolocation-uko8RwgK.cjs +1 -0
- package/build/geolocation.cjs +1 -1
- package/build/geolocation.js +3 -9
- package/build/immersive/ImmersiveSession.d.ts.map +1 -1
- package/build/immersive-8m33PLug.cjs +1 -0
- package/build/immersive-Dp2-ZCRC.js +23 -0
- package/build/immersive.cjs +1 -1
- package/build/immersive.js +3 -4
- package/build/index.cjs +1 -1
- package/build/index.js +14 -33
- package/build/magic-DAQdGGEO.js +148 -0
- package/build/magic-DznuBYgG.cjs +1 -0
- package/build/magic.cjs +1 -1
- package/build/magic.js +3 -6
- package/build/useXRStore-7Gy83DEg.cjs +1 -0
- package/build/useXRStore-B3-MaaCu.js +131 -0
- package/package.json +14 -11
- package/build/ImmersiveSession-BiX-Du0K.cjs +0 -1
- package/build/ImmersiveSession-CJRYdHjb.js +0 -21
- package/build/WorldAnchor-gszXX9H2.cjs +0 -1
- package/build/WorldAnchor-ur1RjMrN.js +0 -167
- package/build/fiducialBackend-Cr8mdwro.cjs +0 -1
- package/build/fiducialBackend-Vj5N1epW.js +0 -180
- package/build/geolocationBackend-BkS2-zqx.cjs +0 -1
- package/build/geolocationBackend-BxwE8Vcl.js +0 -338
- package/build/useXRStore-eThHhTNv.js +0 -149
- package/build/useXRStore-emhiLtDT.cjs +0 -1
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
-
import { ArMarkerControls as w, ArToolkitSource as v, ArToolkitContext as h } from "@ar-js-org/ar.js/three.js/build/ar-threex";
|
|
3
|
-
import { useFrame as z, useThree as R } from "@react-three/fiber";
|
|
4
|
-
import { useRef as m, useEffect as y } from "react";
|
|
5
|
-
import { u as C, B as E } from "./useXRStore-eThHhTNv.js";
|
|
6
|
-
const T = {
|
|
7
|
-
isPending: !0,
|
|
8
|
-
isSuccess: !1,
|
|
9
|
-
arSource: null,
|
|
10
|
-
arContext: null
|
|
11
|
-
}, b = () => {
|
|
12
|
-
const e = C((t) => t.backends).get(E.FIDUCIAL);
|
|
13
|
-
return e ? {
|
|
14
|
-
...e.getInternal(),
|
|
15
|
-
isPending: !1,
|
|
16
|
-
isSuccess: !0
|
|
17
|
-
} : T;
|
|
18
|
-
}, j = ({
|
|
19
|
-
patternUrl: o,
|
|
20
|
-
barcodeValue: e,
|
|
21
|
-
params: t,
|
|
22
|
-
onMarkerFound: u,
|
|
23
|
-
onMarkerLost: d,
|
|
24
|
-
children: i
|
|
25
|
-
}) => {
|
|
26
|
-
const c = m(null), A = b(), a = m(!1), s = m(!1), l = m(null);
|
|
27
|
-
return y(() => {
|
|
28
|
-
if (!A.isSuccess) return;
|
|
29
|
-
let n = !1;
|
|
30
|
-
return (() => {
|
|
31
|
-
try {
|
|
32
|
-
const { arContext: f } = A, p = c.current;
|
|
33
|
-
if (!f || !p || n) return;
|
|
34
|
-
if (p.visible = !1, s.current = !1, !f.arController) {
|
|
35
|
-
requestAnimationFrame(() => {
|
|
36
|
-
if (!c.current || n || !A.arContext?.arController)
|
|
37
|
-
return;
|
|
38
|
-
const x = new w(
|
|
39
|
-
A.arContext,
|
|
40
|
-
c.current,
|
|
41
|
-
{
|
|
42
|
-
type: o ? "pattern" : e ? "barcode" : "unknown",
|
|
43
|
-
patternUrl: o,
|
|
44
|
-
barcodeValue: e,
|
|
45
|
-
...t
|
|
46
|
-
}
|
|
47
|
-
);
|
|
48
|
-
l.current = x, s.current = !0;
|
|
49
|
-
});
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const g = new w(f, p, {
|
|
53
|
-
type: o ? "pattern" : e ? "barcode" : "unknown",
|
|
54
|
-
patternUrl: o,
|
|
55
|
-
barcodeValue: e,
|
|
56
|
-
...t
|
|
57
|
-
});
|
|
58
|
-
l.current = g, s.current = !0;
|
|
59
|
-
} catch (f) {
|
|
60
|
-
console.error("Failed to initialize fiducial anchor:", f);
|
|
61
|
-
}
|
|
62
|
-
})(), () => {
|
|
63
|
-
n = !0;
|
|
64
|
-
const f = l.current;
|
|
65
|
-
typeof f?.dispose == "function" && f.dispose(), s.current = !1;
|
|
66
|
-
};
|
|
67
|
-
}, [
|
|
68
|
-
A.isSuccess,
|
|
69
|
-
A.arContext,
|
|
70
|
-
o,
|
|
71
|
-
e,
|
|
72
|
-
t,
|
|
73
|
-
A
|
|
74
|
-
]), z(() => {
|
|
75
|
-
const n = c.current;
|
|
76
|
-
if (!n || !s.current) {
|
|
77
|
-
n && (n.visible = !1);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const r = n.visible;
|
|
81
|
-
r && !a.current ? (a.current = !0, u?.()) : !r && a.current && (a.current = !1, d?.());
|
|
82
|
-
}), /* @__PURE__ */ S(
|
|
83
|
-
"group",
|
|
84
|
-
{
|
|
85
|
-
ref: c,
|
|
86
|
-
visible: !1,
|
|
87
|
-
children: i
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
}, B = ({ options: o = {}, children: e }) => {
|
|
91
|
-
const { scene: t, camera: u, gl: d } = R(), { registerBackend: i, unregisterBackend: c } = C(), A = m(null), a = m(o);
|
|
92
|
-
return a.current = o, y(() => {
|
|
93
|
-
if (A.current) return;
|
|
94
|
-
let s = !1;
|
|
95
|
-
return (async () => {
|
|
96
|
-
try {
|
|
97
|
-
const n = k(a.current);
|
|
98
|
-
if (s) return;
|
|
99
|
-
await i(n, { scene: t, camera: u, renderer: d }), A.current = n;
|
|
100
|
-
} catch (n) {
|
|
101
|
-
console.error("[FiducialSession] Failed to initialize:", n);
|
|
102
|
-
}
|
|
103
|
-
})(), () => {
|
|
104
|
-
s = !0, A.current && (c(A.current), A.current = null);
|
|
105
|
-
};
|
|
106
|
-
}, [t, u, d, i, c]), e;
|
|
107
|
-
}, k = (o) => {
|
|
108
|
-
let e = null, t = null, u = null, d;
|
|
109
|
-
return {
|
|
110
|
-
type: E.FIDUCIAL,
|
|
111
|
-
async init({ camera: i, renderer: c }) {
|
|
112
|
-
e = new v({
|
|
113
|
-
sourceType: o?.sourceType ?? "webcam"
|
|
114
|
-
}), await new Promise((s, l) => {
|
|
115
|
-
const n = setTimeout(() => {
|
|
116
|
-
l(new Error("AR source initialization timeout"));
|
|
117
|
-
}, 1e4);
|
|
118
|
-
e?.init(() => {
|
|
119
|
-
clearTimeout(n);
|
|
120
|
-
const r = e?.domElement;
|
|
121
|
-
r && (r.style.position = "fixed", r.style.top = "0", r.style.left = "0", r.style.width = "100vw", r.style.height = "100vh", r.style.objectFit = "cover", r.style.zIndex = "-1", r.style.pointerEvents = "none"), s();
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
const A = {
|
|
125
|
-
cameraParametersUrl: o?.cameraParametersUrl ?? // default to internal camera parameters
|
|
126
|
-
new URL("data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=", import.meta.url).toString(),
|
|
127
|
-
detectionMode: o?.detectionMode ?? "mono",
|
|
128
|
-
patternRatio: o?.patternRatio ?? 0.5,
|
|
129
|
-
matrixCodeType: o?.matrixCodeType ?? "3x3"
|
|
130
|
-
};
|
|
131
|
-
t = new h(A), u = i;
|
|
132
|
-
const a = () => {
|
|
133
|
-
e?.onResizeElement();
|
|
134
|
-
const s = window.innerWidth, l = window.innerHeight;
|
|
135
|
-
c.setSize(s, l, !1), e?.copyElementSizeTo(c.domElement), t?.arController && e?.copyElementSizeTo(t.arController.canvas);
|
|
136
|
-
};
|
|
137
|
-
await new Promise((s, l) => {
|
|
138
|
-
const n = setTimeout(() => {
|
|
139
|
-
l(new Error("AR context initialization timeout"));
|
|
140
|
-
}, 1e4);
|
|
141
|
-
t?.init(() => {
|
|
142
|
-
clearTimeout(n);
|
|
143
|
-
try {
|
|
144
|
-
const r = t?.getProjectionMatrix();
|
|
145
|
-
r && i.projectionMatrix.copy(r), a(), s();
|
|
146
|
-
} catch (r) {
|
|
147
|
-
l(r);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}), window.addEventListener("resize", a), d = a;
|
|
151
|
-
},
|
|
152
|
-
update() {
|
|
153
|
-
if (!(!e || !t) && !(!e.ready || !e.domElement))
|
|
154
|
-
try {
|
|
155
|
-
t.update(e.domElement);
|
|
156
|
-
const i = t.getProjectionMatrix?.();
|
|
157
|
-
u && i && u.projectionMatrix.copy(i);
|
|
158
|
-
} catch (i) {
|
|
159
|
-
console.warn("AR.js update error:", i);
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
dispose() {
|
|
163
|
-
if (d && (window.removeEventListener("resize", d), d = void 0), t && typeof t.dispose == "function" && t.dispose(), e?.domElement) {
|
|
164
|
-
const i = e.domElement.parentNode;
|
|
165
|
-
i && i.removeChild(e.domElement);
|
|
166
|
-
}
|
|
167
|
-
e = null, t = null, u = null;
|
|
168
|
-
},
|
|
169
|
-
getInternal: () => ({
|
|
170
|
-
arSource: e,
|
|
171
|
-
arContext: t
|
|
172
|
-
})
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
export {
|
|
176
|
-
j as F,
|
|
177
|
-
B as a,
|
|
178
|
-
k as c,
|
|
179
|
-
b as u
|
|
180
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const P=require("react/jsx-runtime"),T=require("@react-three/fiber"),h=require("react"),L=require("three"),_=require("three/addons/lines/Line2.js"),H=require("three/addons/lines/LineGeometry.js"),K=require("three/addons/lines/LineMaterial.js"),B=require("./useXRStore-emhiLtDT.cjs"),z=require("locar"),Z={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>{}},C=()=>{const e=B.useXRStore(a=>a.backends).get(B.BACKEND_TYPES.GEOLOCATION);return e?{...e.getInternal(),isPending:!1,isSuccess:!0}:Z},J=({coordinates:o,color:e="#ff0000",isDashed:a=!1,dashSize:l=3,gapSize:f=1,lineWidth:d=1})=>{const r=C(),[t]=h.useState(()=>new L.Group),u=h.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,g]=h.useState(null);return h.useEffect(()=>{if(!r.isSuccess||o.length<2)return;const[p,n,c=0]=o[0],G=A=>{const[E,k,i=0]=o[0],[w,y]=A.lonLatToWorldCoords(E,k),S=o.map(([j,m,v=0])=>{const[R,x]=A.lonLatToWorldCoords(j,m);return new L.Vector3(R-w,v-i,x-y)}),b=new H.LineGeometry().setFromPoints(S),M=new K.LineMaterial({color:e,dashSize:l,gapSize:f,dashed:a,worldUnits:!0,linewidth:d}),O=new _.Line2(b,M);a&&O.computeLineDistances(),g(O)};return r.registerAnchor(u,{anchor:t,isAttached:!1,latitude:n,longitude:p,altitude:c,onAttach:G}),()=>{r.unregisterAnchor(u)}},[r.isSuccess,r.registerAnchor,r.unregisterAnchor,u,t,o,e,a,l,f,d]),T.createPortal(P.jsx("group",{children:s&&P.jsx("primitive",{object:s})}),t)},Y=({latitude:o,longitude:e,altitude:a=0,isBillboard:l=!0,onAttach:f,onGpsUpdate:d,children:r})=>{const t=C(),{camera:u}=T.useThree(),[s]=h.useState(()=>new L.Group),g=h.useMemo(()=>Math.random().toString(36).slice(2,11),[]),p=h.useCallback(()=>{f?.()},[f]),n=h.useCallback((c,G)=>{d?.(c,G)},[d]);return h.useEffect(()=>{if(t.isSuccess)return t.registerAnchor(g,{anchor:s,isAttached:!1,latitude:o,longitude:e,altitude:a,onAttach:p,onGpsUpdate:n}),()=>{t.unregisterAnchor(g)}},[t.isSuccess,t.registerAnchor,t.unregisterAnchor,s,g,o,e,a,p,n]),T.useFrame(()=>{!l||!u||!t.isSuccess||!t.getAnchor(g)?.isAttached||s.lookAt(u.position)}),T.createPortal(P.jsx("group",{children:r}),s)},$=({options:o={},children:e})=>{const{scene:a,camera:l,gl:f}=T.useThree(),{registerBackend:d,unregisterBackend:r}=B.useXRStore(),t=h.useRef(null),u=h.useRef(o);return u.current=o,h.useEffect(()=>{if(t.current)return;let s=!1;return(async()=>{try{const p=D(u.current);if(s)return;await d(p,{scene:a,camera:l,renderer:f}),t.current=p}catch(p){console.error("[GeolocationSession] Failed to initialize:",p)}})(),()=>{s=!0,t.current&&(r(t.current),t.current=null)}},[a,l,f,d,r]),e},V={front:L.FrontSide,back:L.BackSide,double:L.DoubleSide},Q=({coordinates:o,holes:e,color:a="#ff0000",opacity:l=1,isWireframe:f=!1,side:d="double"})=>{const r=C(),[t]=h.useState(()=>new L.Group),u=h.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,g]=h.useState(null);return h.useEffect(()=>{if(!r.isSuccess||o.length<3)return;const[p,n,c=0]=o[0],G=A=>{const[E,k,i=0]=o[0],[w,y]=A.lonLatToWorldCoords(E,k),S=[];for(const[m,v,R=0]of o){const[x,I]=A.lonLatToWorldCoords(m,v);S.push({x:x-w,z:I-y,elev:R-i})}const b=new L.Shape;b.moveTo(S[0].x,S[0].z);for(let m=1;m<S.length;m++)b.lineTo(S[m].x,S[m].z);if(b.closePath(),e&&e.length>0)for(const m of e){if(m.length<3)continue;const v=new L.Path,[R,x]=m[0],[I,N]=A.lonLatToWorldCoords(R,x);v.moveTo(I-w,N-y);for(let q=1;q<m.length;q++){const[F,W]=m[q],[X,U]=A.lonLatToWorldCoords(F,W);v.lineTo(X-w,U-y)}v.closePath(),b.holes.push(v)}const M=new L.ShapeGeometry(b),j=S.reduce((m,v)=>m+v.elev,0)/S.length;M.rotateX(-Math.PI/2),g({geometry:M,avgElevation:j})};return r.registerAnchor(u,{anchor:t,isAttached:!1,latitude:n,longitude:p,altitude:c,onAttach:G}),()=>{r.unregisterAnchor(u)}},[r.isSuccess,r.registerAnchor,r.unregisterAnchor,u,t,o,e]),T.createPortal(P.jsx("group",{children:s&&P.jsx("group",{position:[0,s.avgElevation,0],children:P.jsx("mesh",{geometry:s.geometry,children:P.jsx("meshBasicMaterial",{color:a,opacity:l,transparent:l<1,wireframe:f,side:V[d]})})})}),t)},D=o=>{let e=null,a=null,l=null,f,d=null,r=null,t=null,u=null;const s=new Map;let g=null;const p=n=>{if(!(!e||n.isAttached))try{e.add(n.anchor,n.longitude,n.latitude,n.altitude),n.isAttached=!0,n.onAttach?.(e)}catch(c){console.error("❌ Failed to attach anchor:",c)}};return{type:B.BACKEND_TYPES.GEOLOCATION,async init(n){const{camera:c,renderer:G,scene:A}=n;if(!A)throw new Error("[geolocationBackend] A THREE.Scene is required for location-based AR");r=c,t=G,u=A,e=new z.LocationBased(A,c),a=new z.Webcam(o?.webcamConstraints??{video:{facingMode:"environment"}}),d=i=>{g=i.position;for(const w of s.values())w.isAttached||p(w),w.onGpsUpdate?.(i.position,i.distMoved);o?.onGpsUpdate?.(i.position,i.distMoved)},e.on("gpsupdate",d),a.on("webcamstarted",i=>{A.background=i.texture}),a.on("webcamerror",i=>{console.error("[geolocationBackend] webcam error:",i)}),l=new z.DeviceOrientationControls(c),l.on("deviceorientationgranted",i=>{i.target?.connect?.()}),l.on("deviceorientationerror",i=>{console.error("[geolocationBackend] Device orientation error:",i)}),l.init?.(),e.on("gpserror",i=>{console.error("[geolocationBackend] gps error:",i)}),e.startGps(),typeof o?.fakeLat=="number"&&typeof o?.fakeLon=="number"&&e.fakeGps(o.fakeLon,o.fakeLat);const E=e.getLastKnownLocation();E!==null&&(g={coords:{longitude:E.longitude,latitude:E.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>E},timestamp:Date.now(),toJSON:()=>E});const k=()=>{if(!t||!r)return;const i=window.innerWidth,w=window.innerHeight;t.setSize(i,w,!1),r.aspect=i/w,r.updateProjectionMatrix?.()};k(),window.addEventListener("resize",k),f=k},update(){l?.update?.()},dispose(){e&&d&&e.off("gpsupdate",d),e?.stopGps?.(),a?.stop?.(),l?.dispose?.(),f&&(window.removeEventListener("resize",f),f=void 0);for(const n of s.values())if(n.isAttached)try{n.anchor.removeFromParent()}catch(c){console.error("⚠️ Error removing anchor:",c)}s.clear(),e=null,a=null,l=null,r=null,t=null,u=null,d=null,g=null},getInternal:()=>({locar:e,webcam:a,deviceOrientation:l,scene:u,camera:r,lastPosition:g,registerAnchor:(n,c)=>{s.set(n,c),g!==null&&!c.isAttached&&(p(c),c.onGpsUpdate?.(g,0))},unregisterAnchor:n=>{const c=s.get(n);if(c?.isAttached)try{c.anchor.removeFromParent()}catch(G){console.error(`⚠️ Error removing anchor ${n}:`,G)}s.delete(n)},getAnchor:n=>s.get(n)})}};exports.GeoLine=J;exports.GeoPolygon=Q;exports.GeolocationAnchor=Y;exports.GeolocationSession=$;exports.createGeolocationBackend=D;exports.useGeolocationBackend=C;
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { jsx as G } from "react/jsx-runtime";
|
|
2
|
-
import { createPortal as x, useThree as U, useFrame as q } from "@react-three/fiber";
|
|
3
|
-
import { useState as y, useMemo as z, useEffect as B, useCallback as F, useRef as W } from "react";
|
|
4
|
-
import { Group as D, Vector3 as V, DoubleSide as Y, BackSide as $, FrontSide as Q, Shape as ee, Path as te, ShapeGeometry as ne } from "three";
|
|
5
|
-
import { Line2 as oe } from "three/addons/lines/Line2.js";
|
|
6
|
-
import { LineGeometry as re } from "three/addons/lines/LineGeometry.js";
|
|
7
|
-
import { LineMaterial as se } from "three/addons/lines/LineMaterial.js";
|
|
8
|
-
import { u as X, B as j } from "./useXRStore-eThHhTNv.js";
|
|
9
|
-
import { LocationBased as ce, Webcam as ie, DeviceOrientationControls as ae } from "locar";
|
|
10
|
-
const le = {
|
|
11
|
-
isPending: !0,
|
|
12
|
-
isSuccess: !1,
|
|
13
|
-
locar: null,
|
|
14
|
-
webcam: null,
|
|
15
|
-
deviceOrientation: null,
|
|
16
|
-
scene: null,
|
|
17
|
-
camera: null,
|
|
18
|
-
lastPosition: null,
|
|
19
|
-
registerAnchor: () => {
|
|
20
|
-
},
|
|
21
|
-
unregisterAnchor: () => {
|
|
22
|
-
},
|
|
23
|
-
getAnchor: () => {
|
|
24
|
-
}
|
|
25
|
-
}, N = () => {
|
|
26
|
-
const e = X((a) => a.backends).get(j.GEOLOCATION);
|
|
27
|
-
return e ? {
|
|
28
|
-
...e.getInternal(),
|
|
29
|
-
isPending: !1,
|
|
30
|
-
isSuccess: !0
|
|
31
|
-
} : le;
|
|
32
|
-
}, Se = ({
|
|
33
|
-
coordinates: o,
|
|
34
|
-
color: e = "#ff0000",
|
|
35
|
-
isDashed: a = !1,
|
|
36
|
-
dashSize: l = 3,
|
|
37
|
-
gapSize: h = 1,
|
|
38
|
-
lineWidth: d = 1
|
|
39
|
-
}) => {
|
|
40
|
-
const r = N(), [t] = y(() => new D()), u = z(() => Math.random().toString(36).slice(2, 11), []), [s, g] = y(null);
|
|
41
|
-
return B(() => {
|
|
42
|
-
if (!r.isSuccess || o.length < 2) return;
|
|
43
|
-
const [m, n, c = 0] = o[0], L = (p) => {
|
|
44
|
-
const [S, b, i = 0] = o[0], [A, E] = p.lonLatToWorldCoords(
|
|
45
|
-
S,
|
|
46
|
-
b
|
|
47
|
-
), w = o.map(([M, f, v = 0]) => {
|
|
48
|
-
const [P, T] = p.lonLatToWorldCoords(M, f);
|
|
49
|
-
return new V(P - A, v - i, T - E);
|
|
50
|
-
}), k = new re().setFromPoints(w), O = new se({
|
|
51
|
-
color: e,
|
|
52
|
-
dashSize: l,
|
|
53
|
-
gapSize: h,
|
|
54
|
-
dashed: a,
|
|
55
|
-
worldUnits: !0,
|
|
56
|
-
linewidth: d
|
|
57
|
-
}), C = new oe(k, O);
|
|
58
|
-
a && C.computeLineDistances(), g(C);
|
|
59
|
-
};
|
|
60
|
-
return r.registerAnchor(u, {
|
|
61
|
-
anchor: t,
|
|
62
|
-
isAttached: !1,
|
|
63
|
-
latitude: n,
|
|
64
|
-
longitude: m,
|
|
65
|
-
altitude: c,
|
|
66
|
-
onAttach: L
|
|
67
|
-
}), () => {
|
|
68
|
-
r.unregisterAnchor(u);
|
|
69
|
-
};
|
|
70
|
-
}, [
|
|
71
|
-
r.isSuccess,
|
|
72
|
-
r.registerAnchor,
|
|
73
|
-
r.unregisterAnchor,
|
|
74
|
-
u,
|
|
75
|
-
t,
|
|
76
|
-
o,
|
|
77
|
-
e,
|
|
78
|
-
a,
|
|
79
|
-
l,
|
|
80
|
-
h,
|
|
81
|
-
d
|
|
82
|
-
]), x(
|
|
83
|
-
/* @__PURE__ */ G("group", { children: s && /* @__PURE__ */ G("primitive", { object: s }) }),
|
|
84
|
-
t
|
|
85
|
-
);
|
|
86
|
-
}, be = ({
|
|
87
|
-
latitude: o,
|
|
88
|
-
longitude: e,
|
|
89
|
-
altitude: a = 0,
|
|
90
|
-
isBillboard: l = !0,
|
|
91
|
-
onAttach: h,
|
|
92
|
-
onGpsUpdate: d,
|
|
93
|
-
children: r
|
|
94
|
-
}) => {
|
|
95
|
-
const t = N(), { camera: u } = U(), [s] = y(() => new D()), g = z(() => Math.random().toString(36).slice(2, 11), []), m = F(() => {
|
|
96
|
-
h?.();
|
|
97
|
-
}, [h]), n = F(
|
|
98
|
-
(c, L) => {
|
|
99
|
-
d?.(c, L);
|
|
100
|
-
},
|
|
101
|
-
[d]
|
|
102
|
-
);
|
|
103
|
-
return B(() => {
|
|
104
|
-
if (t.isSuccess)
|
|
105
|
-
return t.registerAnchor(g, {
|
|
106
|
-
anchor: s,
|
|
107
|
-
isAttached: !1,
|
|
108
|
-
latitude: o,
|
|
109
|
-
longitude: e,
|
|
110
|
-
altitude: a,
|
|
111
|
-
onAttach: m,
|
|
112
|
-
onGpsUpdate: n
|
|
113
|
-
}), () => {
|
|
114
|
-
t.unregisterAnchor(g);
|
|
115
|
-
};
|
|
116
|
-
}, [
|
|
117
|
-
t.isSuccess,
|
|
118
|
-
t.registerAnchor,
|
|
119
|
-
t.unregisterAnchor,
|
|
120
|
-
s,
|
|
121
|
-
g,
|
|
122
|
-
o,
|
|
123
|
-
e,
|
|
124
|
-
a,
|
|
125
|
-
m,
|
|
126
|
-
n
|
|
127
|
-
]), q(() => {
|
|
128
|
-
!l || !u || !t.isSuccess || !t.getAnchor(g)?.isAttached || s.lookAt(u.position);
|
|
129
|
-
}), x(/* @__PURE__ */ G("group", { children: r }), s);
|
|
130
|
-
}, ke = ({
|
|
131
|
-
options: o = {},
|
|
132
|
-
children: e
|
|
133
|
-
}) => {
|
|
134
|
-
const { scene: a, camera: l, gl: h } = U(), { registerBackend: d, unregisterBackend: r } = X(), t = W(null), u = W(o);
|
|
135
|
-
return u.current = o, B(() => {
|
|
136
|
-
if (t.current) return;
|
|
137
|
-
let s = !1;
|
|
138
|
-
return (async () => {
|
|
139
|
-
try {
|
|
140
|
-
const m = de(u.current);
|
|
141
|
-
if (s) return;
|
|
142
|
-
await d(m, { scene: a, camera: l, renderer: h }), t.current = m;
|
|
143
|
-
} catch (m) {
|
|
144
|
-
console.error("[GeolocationSession] Failed to initialize:", m);
|
|
145
|
-
}
|
|
146
|
-
})(), () => {
|
|
147
|
-
s = !0, t.current && (r(t.current), t.current = null);
|
|
148
|
-
};
|
|
149
|
-
}, [a, l, h, d, r]), e;
|
|
150
|
-
}, ue = {
|
|
151
|
-
front: Q,
|
|
152
|
-
back: $,
|
|
153
|
-
double: Y
|
|
154
|
-
}, Ge = ({
|
|
155
|
-
coordinates: o,
|
|
156
|
-
holes: e,
|
|
157
|
-
color: a = "#ff0000",
|
|
158
|
-
opacity: l = 1,
|
|
159
|
-
isWireframe: h = !1,
|
|
160
|
-
side: d = "double"
|
|
161
|
-
}) => {
|
|
162
|
-
const r = N(), [t] = y(() => new D()), u = z(() => Math.random().toString(36).slice(2, 11), []), [s, g] = y(null);
|
|
163
|
-
return B(() => {
|
|
164
|
-
if (!r.isSuccess || o.length < 3) return;
|
|
165
|
-
const [m, n, c = 0] = o[0], L = (p) => {
|
|
166
|
-
const [S, b, i = 0] = o[0], [A, E] = p.lonLatToWorldCoords(
|
|
167
|
-
S,
|
|
168
|
-
b
|
|
169
|
-
), w = [];
|
|
170
|
-
for (const [f, v, P = 0] of o) {
|
|
171
|
-
const [T, I] = p.lonLatToWorldCoords(f, v);
|
|
172
|
-
w.push({
|
|
173
|
-
x: T - A,
|
|
174
|
-
z: I - E,
|
|
175
|
-
elev: P - i
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const k = new ee();
|
|
179
|
-
k.moveTo(w[0].x, w[0].z);
|
|
180
|
-
for (let f = 1; f < w.length; f++)
|
|
181
|
-
k.lineTo(w[f].x, w[f].z);
|
|
182
|
-
if (k.closePath(), e && e.length > 0)
|
|
183
|
-
for (const f of e) {
|
|
184
|
-
if (f.length < 3) continue;
|
|
185
|
-
const v = new te(), [P, T] = f[0], [I, H] = p.lonLatToWorldCoords(
|
|
186
|
-
P,
|
|
187
|
-
T
|
|
188
|
-
);
|
|
189
|
-
v.moveTo(I - A, H - E);
|
|
190
|
-
for (let R = 1; R < f.length; R++) {
|
|
191
|
-
const [Z, J] = f[R], [K, _] = p.lonLatToWorldCoords(Z, J);
|
|
192
|
-
v.lineTo(K - A, _ - E);
|
|
193
|
-
}
|
|
194
|
-
v.closePath(), k.holes.push(v);
|
|
195
|
-
}
|
|
196
|
-
const O = new ne(k), M = w.reduce((f, v) => f + v.elev, 0) / w.length;
|
|
197
|
-
O.rotateX(-Math.PI / 2), g({ geometry: O, avgElevation: M });
|
|
198
|
-
};
|
|
199
|
-
return r.registerAnchor(u, {
|
|
200
|
-
anchor: t,
|
|
201
|
-
isAttached: !1,
|
|
202
|
-
latitude: n,
|
|
203
|
-
longitude: m,
|
|
204
|
-
altitude: c,
|
|
205
|
-
onAttach: L
|
|
206
|
-
}), () => {
|
|
207
|
-
r.unregisterAnchor(u);
|
|
208
|
-
};
|
|
209
|
-
}, [
|
|
210
|
-
r.isSuccess,
|
|
211
|
-
r.registerAnchor,
|
|
212
|
-
r.unregisterAnchor,
|
|
213
|
-
u,
|
|
214
|
-
t,
|
|
215
|
-
o,
|
|
216
|
-
e
|
|
217
|
-
]), x(
|
|
218
|
-
/* @__PURE__ */ G("group", { children: s && /* @__PURE__ */ G("group", { position: [0, s.avgElevation, 0], children: /* @__PURE__ */ G("mesh", { geometry: s.geometry, children: /* @__PURE__ */ G(
|
|
219
|
-
"meshBasicMaterial",
|
|
220
|
-
{
|
|
221
|
-
color: a,
|
|
222
|
-
opacity: l,
|
|
223
|
-
transparent: l < 1,
|
|
224
|
-
wireframe: h,
|
|
225
|
-
side: ue[d]
|
|
226
|
-
}
|
|
227
|
-
) }) }) }),
|
|
228
|
-
t
|
|
229
|
-
);
|
|
230
|
-
}, de = (o) => {
|
|
231
|
-
let e = null, a = null, l = null, h, d = null, r = null, t = null, u = null;
|
|
232
|
-
const s = /* @__PURE__ */ new Map();
|
|
233
|
-
let g = null;
|
|
234
|
-
const m = (n) => {
|
|
235
|
-
if (!(!e || n.isAttached))
|
|
236
|
-
try {
|
|
237
|
-
e.add(n.anchor, n.longitude, n.latitude, n.altitude), n.isAttached = !0, n.onAttach?.(e);
|
|
238
|
-
} catch (c) {
|
|
239
|
-
console.error("❌ Failed to attach anchor:", c);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
return {
|
|
243
|
-
type: j.GEOLOCATION,
|
|
244
|
-
async init(n) {
|
|
245
|
-
const { camera: c, renderer: L, scene: p } = n;
|
|
246
|
-
if (!p)
|
|
247
|
-
throw new Error(
|
|
248
|
-
"[geolocationBackend] A THREE.Scene is required for location-based AR"
|
|
249
|
-
);
|
|
250
|
-
r = c, t = L, u = p, e = new ce(p, c), a = new ie(
|
|
251
|
-
o?.webcamConstraints ?? {
|
|
252
|
-
video: { facingMode: "environment" }
|
|
253
|
-
// TODO remove `as any` once fixed upstream (LocAR.js)
|
|
254
|
-
}
|
|
255
|
-
), d = (i) => {
|
|
256
|
-
g = i.position;
|
|
257
|
-
for (const A of s.values())
|
|
258
|
-
A.isAttached || m(A), A.onGpsUpdate?.(i.position, i.distMoved);
|
|
259
|
-
o?.onGpsUpdate?.(i.position, i.distMoved);
|
|
260
|
-
}, e.on("gpsupdate", d), a.on("webcamstarted", (i) => {
|
|
261
|
-
p.background = i.texture;
|
|
262
|
-
}), a.on("webcamerror", (i) => {
|
|
263
|
-
console.error("[geolocationBackend] webcam error:", i);
|
|
264
|
-
}), l = new ae(c), l.on("deviceorientationgranted", (i) => {
|
|
265
|
-
i.target?.connect?.();
|
|
266
|
-
}), l.on("deviceorientationerror", (i) => {
|
|
267
|
-
console.error("[geolocationBackend] Device orientation error:", i);
|
|
268
|
-
}), l.init?.(), e.on("gpserror", (i) => {
|
|
269
|
-
console.error("[geolocationBackend] gps error:", i);
|
|
270
|
-
}), e.startGps(), typeof o?.fakeLat == "number" && typeof o?.fakeLon == "number" && e.fakeGps(o.fakeLon, o.fakeLat);
|
|
271
|
-
const S = e.getLastKnownLocation();
|
|
272
|
-
S !== null && (g = {
|
|
273
|
-
coords: {
|
|
274
|
-
longitude: S.longitude,
|
|
275
|
-
latitude: S.latitude,
|
|
276
|
-
accuracy: 0,
|
|
277
|
-
altitude: null,
|
|
278
|
-
altitudeAccuracy: null,
|
|
279
|
-
heading: null,
|
|
280
|
-
speed: null,
|
|
281
|
-
toJSON: () => S
|
|
282
|
-
},
|
|
283
|
-
timestamp: Date.now(),
|
|
284
|
-
toJSON: () => S
|
|
285
|
-
});
|
|
286
|
-
const b = () => {
|
|
287
|
-
if (!t || !r) return;
|
|
288
|
-
const i = window.innerWidth, A = window.innerHeight;
|
|
289
|
-
t.setSize(i, A, !1), r.aspect = i / A, r.updateProjectionMatrix?.();
|
|
290
|
-
};
|
|
291
|
-
b(), window.addEventListener("resize", b), h = b;
|
|
292
|
-
},
|
|
293
|
-
update() {
|
|
294
|
-
l?.update?.();
|
|
295
|
-
},
|
|
296
|
-
dispose() {
|
|
297
|
-
e && d && e.off("gpsupdate", d), e?.stopGps?.(), a?.stop?.(), l?.dispose?.(), h && (window.removeEventListener("resize", h), h = void 0);
|
|
298
|
-
for (const n of s.values())
|
|
299
|
-
if (n.isAttached)
|
|
300
|
-
try {
|
|
301
|
-
n.anchor.removeFromParent();
|
|
302
|
-
} catch (c) {
|
|
303
|
-
console.error("⚠️ Error removing anchor:", c);
|
|
304
|
-
}
|
|
305
|
-
s.clear(), e = null, a = null, l = null, r = null, t = null, u = null, d = null, g = null;
|
|
306
|
-
},
|
|
307
|
-
getInternal: () => ({
|
|
308
|
-
locar: e,
|
|
309
|
-
webcam: a,
|
|
310
|
-
deviceOrientation: l,
|
|
311
|
-
scene: u,
|
|
312
|
-
camera: r,
|
|
313
|
-
lastPosition: g,
|
|
314
|
-
registerAnchor: (n, c) => {
|
|
315
|
-
s.set(n, c), g !== null && !c.isAttached && (m(c), c.onGpsUpdate?.(g, 0));
|
|
316
|
-
},
|
|
317
|
-
unregisterAnchor: (n) => {
|
|
318
|
-
const c = s.get(n);
|
|
319
|
-
if (c?.isAttached)
|
|
320
|
-
try {
|
|
321
|
-
c.anchor.removeFromParent();
|
|
322
|
-
} catch (L) {
|
|
323
|
-
console.error(`⚠️ Error removing anchor ${n}:`, L);
|
|
324
|
-
}
|
|
325
|
-
s.delete(n);
|
|
326
|
-
},
|
|
327
|
-
getAnchor: (n) => s.get(n)
|
|
328
|
-
})
|
|
329
|
-
};
|
|
330
|
-
};
|
|
331
|
-
export {
|
|
332
|
-
Se as G,
|
|
333
|
-
be as a,
|
|
334
|
-
ke as b,
|
|
335
|
-
Ge as c,
|
|
336
|
-
de as d,
|
|
337
|
-
N as u
|
|
338
|
-
};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import b from "react";
|
|
2
|
-
const S = {
|
|
3
|
-
FIDUCIAL: "fiducial",
|
|
4
|
-
GEOLOCATION: "geolocation",
|
|
5
|
-
IMMERSIVE: "immersive",
|
|
6
|
-
MAGIC: "magic"
|
|
7
|
-
}, y = (e) => {
|
|
8
|
-
let t;
|
|
9
|
-
const n = /* @__PURE__ */ new Set(), r = (c, d) => {
|
|
10
|
-
const a = typeof c == "function" ? c(t) : c;
|
|
11
|
-
if (!Object.is(a, t)) {
|
|
12
|
-
const m = t;
|
|
13
|
-
t = d ?? (typeof a != "object" || a === null) ? a : Object.assign({}, t, a), n.forEach((f) => f(t, m));
|
|
14
|
-
}
|
|
15
|
-
}, s = () => t, u = { setState: r, getState: s, getInitialState: () => i, subscribe: (c) => (n.add(c), () => n.delete(c)) }, i = t = e(r, s, u);
|
|
16
|
-
return u;
|
|
17
|
-
}, h = ((e) => e ? y(e) : y), w = (e) => e;
|
|
18
|
-
function E(e, t = w) {
|
|
19
|
-
const n = b.useSyncExternalStore(
|
|
20
|
-
e.subscribe,
|
|
21
|
-
b.useCallback(() => t(e.getState()), [e, t]),
|
|
22
|
-
b.useCallback(() => t(e.getInitialState()), [e, t])
|
|
23
|
-
);
|
|
24
|
-
return b.useDebugValue(n), n;
|
|
25
|
-
}
|
|
26
|
-
const j = (e) => {
|
|
27
|
-
const t = h(e), n = (r) => E(t, r);
|
|
28
|
-
return Object.assign(n, t), n;
|
|
29
|
-
}, M = ((e) => j), x = (e) => (t, n, r) => {
|
|
30
|
-
const s = r.subscribe;
|
|
31
|
-
return r.subscribe = ((l, u, i) => {
|
|
32
|
-
let c = l;
|
|
33
|
-
if (u) {
|
|
34
|
-
const d = i?.equalityFn || Object.is;
|
|
35
|
-
let a = l(r.getState());
|
|
36
|
-
c = (m) => {
|
|
37
|
-
const f = l(m);
|
|
38
|
-
if (!d(a, f)) {
|
|
39
|
-
const k = a;
|
|
40
|
-
u(a = f, k);
|
|
41
|
-
}
|
|
42
|
-
}, i?.fireImmediately && u(a, a);
|
|
43
|
-
}
|
|
44
|
-
return s(c);
|
|
45
|
-
}), e(t, n, r);
|
|
46
|
-
}, R = x, p = (e) => Symbol.iterator in e, g = (e) => (
|
|
47
|
-
// HACK: avoid checking entries type
|
|
48
|
-
"entries" in e
|
|
49
|
-
), O = (e, t) => {
|
|
50
|
-
const n = e instanceof Map ? e : new Map(e.entries()), r = t instanceof Map ? t : new Map(t.entries());
|
|
51
|
-
if (n.size !== r.size)
|
|
52
|
-
return !1;
|
|
53
|
-
for (const [s, o] of n)
|
|
54
|
-
if (!r.has(s) || !Object.is(o, r.get(s)))
|
|
55
|
-
return !1;
|
|
56
|
-
return !0;
|
|
57
|
-
}, C = (e, t) => {
|
|
58
|
-
const n = e[Symbol.iterator](), r = t[Symbol.iterator]();
|
|
59
|
-
let s = n.next(), o = r.next();
|
|
60
|
-
for (; !s.done && !o.done; ) {
|
|
61
|
-
if (!Object.is(s.value, o.value))
|
|
62
|
-
return !1;
|
|
63
|
-
s = n.next(), o = r.next();
|
|
64
|
-
}
|
|
65
|
-
return !!s.done && !!o.done;
|
|
66
|
-
};
|
|
67
|
-
function F(e, t) {
|
|
68
|
-
return Object.is(e, t) ? !0 : typeof e != "object" || e === null || typeof t != "object" || t === null || Object.getPrototypeOf(e) !== Object.getPrototypeOf(t) ? !1 : p(e) && p(t) ? g(e) && g(t) ? O(e, t) : C(e, t) : O(
|
|
69
|
-
{ entries: () => Object.entries(e) },
|
|
70
|
-
{ entries: () => Object.entries(t) }
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
function T(e) {
|
|
74
|
-
const t = b.useRef(void 0);
|
|
75
|
-
return (n) => {
|
|
76
|
-
const r = e(n);
|
|
77
|
-
return F(t.current, r) ? t.current : t.current = r;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
const I = M()(
|
|
81
|
-
R((e, t) => ({
|
|
82
|
-
// initial state
|
|
83
|
-
video: null,
|
|
84
|
-
backends: /* @__PURE__ */ new Map(),
|
|
85
|
-
immersiveStore: null,
|
|
86
|
-
// actions
|
|
87
|
-
registerBackend: async (n, r) => {
|
|
88
|
-
try {
|
|
89
|
-
const s = t(), o = new Set(s.backends.keys()), l = o.has(S.FIDUCIAL) || n.type === S.FIDUCIAL, u = o.has(S.GEOLOCATION) || n.type === S.GEOLOCATION;
|
|
90
|
-
if (l && u) {
|
|
91
|
-
const i = "❌ [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.";
|
|
92
|
-
throw console.error(i), new Error(i);
|
|
93
|
-
}
|
|
94
|
-
await n.init({
|
|
95
|
-
scene: r.scene,
|
|
96
|
-
camera: r.camera,
|
|
97
|
-
renderer: r.renderer
|
|
98
|
-
}), e((i) => {
|
|
99
|
-
const c = new Map(i.backends);
|
|
100
|
-
return c.set(n.type, n), { backends: c };
|
|
101
|
-
});
|
|
102
|
-
} catch (s) {
|
|
103
|
-
throw console.error("[XRStore] Failed to register backend:", s), s;
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
unregisterBackend: (n) => {
|
|
107
|
-
e((r) => {
|
|
108
|
-
const s = new Map(r.backends);
|
|
109
|
-
s.delete(n.type);
|
|
110
|
-
try {
|
|
111
|
-
n.dispose?.();
|
|
112
|
-
} catch (o) {
|
|
113
|
-
console.error("[XRStore] Error disposing backend:", o);
|
|
114
|
-
}
|
|
115
|
-
return { backends: s };
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
setVideo: (n) => {
|
|
119
|
-
e({ video: n });
|
|
120
|
-
},
|
|
121
|
-
updateBackends: (n) => {
|
|
122
|
-
const { backends: r } = t();
|
|
123
|
-
for (const s of r.values())
|
|
124
|
-
try {
|
|
125
|
-
s.update?.(n);
|
|
126
|
-
} catch (o) {
|
|
127
|
-
console.error("[XRStore] Backend update error:", o);
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
setImmersiveStore: (n) => {
|
|
131
|
-
e({ immersiveStore: n });
|
|
132
|
-
}
|
|
133
|
-
}))
|
|
134
|
-
), D = () => I.getState(), L = I.subscribe, N = (e) => I(
|
|
135
|
-
T((n) => {
|
|
136
|
-
const r = {
|
|
137
|
-
...n,
|
|
138
|
-
isImmersive: n.backends.has(S.IMMERSIVE),
|
|
139
|
-
immersive: n.immersiveStore || null
|
|
140
|
-
};
|
|
141
|
-
return e ? e(r) : r;
|
|
142
|
-
})
|
|
143
|
-
);
|
|
144
|
-
export {
|
|
145
|
-
S as B,
|
|
146
|
-
D as g,
|
|
147
|
-
L as s,
|
|
148
|
-
N as u
|
|
149
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("react"),b={FIDUCIAL:"fiducial",GEOLOCATION:"geolocation",IMMERSIVE:"immersive",MAGIC:"magic"},y=e=>{let t;const r=new Set,n=(c,d)=>{const a=typeof c=="function"?c(t):c;if(!Object.is(a,t)){const m=t;t=d??(typeof a!="object"||a===null)?a:Object.assign({},t,a),r.forEach(f=>f(t,m))}},s=()=>t,u={setState:n,getState:s,getInitialState:()=>i,subscribe:c=>(r.add(c),()=>r.delete(c))},i=t=e(n,s,u);return u},E=(e=>e?y(e):y),h=e=>e;function w(e,t=h){const r=l.useSyncExternalStore(e.subscribe,l.useCallback(()=>t(e.getState()),[e,t]),l.useCallback(()=>t(e.getInitialState()),[e,t]));return l.useDebugValue(r),r}const j=e=>{const t=E(e),r=n=>w(t,n);return Object.assign(r,t),r},R=(e=>j),M=e=>(t,r,n)=>{const s=n.subscribe;return n.subscribe=((S,u,i)=>{let c=S;if(u){const d=i?.equalityFn||Object.is;let a=S(n.getState());c=m=>{const f=S(m);if(!d(a,f)){const k=a;u(a=f,k)}},i?.fireImmediately&&u(a,a)}return s(c)}),e(t,r,n)},C=M,g=e=>Symbol.iterator in e,p=e=>"entries"in e,O=(e,t)=>{const r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(const[s,o]of r)if(!n.has(s)||!Object.is(o,n.get(s)))return!1;return!0},x=(e,t)=>{const r=e[Symbol.iterator](),n=t[Symbol.iterator]();let s=r.next(),o=n.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=r.next(),o=n.next()}return!!s.done&&!!o.done};function X(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:g(e)&&g(t)?p(e)&&p(t)?O(e,t):x(e,t):O({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function T(e){const t=l.useRef(void 0);return r=>{const n=e(r);return X(t.current,n)?t.current:t.current=n}}const I=R()(C((e,t)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(r,n)=>{try{const s=t(),o=new Set(s.backends.keys()),S=o.has(b.FIDUCIAL)||r.type===b.FIDUCIAL,u=o.has(b.GEOLOCATION)||r.type===b.GEOLOCATION;if(S&&u){const i="❌ [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(i),new Error(i)}await r.init({scene:n.scene,camera:n.camera,renderer:n.renderer}),e(i=>{const c=new Map(i.backends);return c.set(r.type,r),{backends:c}})}catch(s){throw console.error("[XRStore] Failed to register backend:",s),s}},unregisterBackend:r=>{e(n=>{const s=new Map(n.backends);s.delete(r.type);try{r.dispose?.()}catch(o){console.error("[XRStore] Error disposing backend:",o)}return{backends:s}})},setVideo:r=>{e({video:r})},updateBackends:r=>{const{backends:n}=t();for(const s of n.values())try{s.update?.(r)}catch(o){console.error("[XRStore] Backend update error:",o)}},setImmersiveStore:r=>{e({immersiveStore:r})}}))),D=()=>I.getState(),F=I.subscribe,N=e=>I(T(r=>{const n={...r,isImmersive:r.backends.has(b.IMMERSIVE),immersive:r.immersiveStore||null};return e?e(n):n}));exports.BACKEND_TYPES=b;exports.getXRStore=D;exports.subscribeToXRStore=F;exports.useXRStore=N;
|