@omnidotdev/rdk 0.8.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.
Files changed (41) hide show
  1. package/build/fiducial-CqsG94R9.js +163 -0
  2. package/build/fiducial-dapuWTXg.cjs +1 -0
  3. package/build/fiducial.cjs +1 -0
  4. package/build/fiducial.d.ts +2 -0
  5. package/build/fiducial.js +3 -0
  6. package/build/geolocation/GeoLine.d.ts.map +1 -1
  7. package/build/geolocation/GeolocationAnchor.d.ts.map +1 -1
  8. package/build/geolocation/geolocationBackend.d.ts.map +1 -1
  9. package/build/geolocation-U_vaIjuk.js +288 -0
  10. package/build/geolocation-uko8RwgK.cjs +1 -0
  11. package/build/geolocation.cjs +1 -0
  12. package/build/geolocation.d.ts +2 -0
  13. package/build/geolocation.js +3 -0
  14. package/build/immersive/ImmersiveSession.d.ts.map +1 -1
  15. package/build/immersive-8m33PLug.cjs +1 -0
  16. package/build/immersive-Dp2-ZCRC.js +23 -0
  17. package/build/immersive.cjs +1 -0
  18. package/build/immersive.d.ts +2 -0
  19. package/build/immersive.js +3 -0
  20. package/build/index.cjs +1 -1
  21. package/build/index.d.ts +1 -0
  22. package/build/index.d.ts.map +1 -1
  23. package/build/index.js +14 -674
  24. package/build/lib/types/engine/backend/Backend.interface.d.ts +1 -0
  25. package/build/lib/types/engine/backend/Backend.interface.d.ts.map +1 -1
  26. package/build/magic/MagicSession.d.ts +14 -0
  27. package/build/magic/MagicSession.d.ts.map +1 -0
  28. package/build/magic/WorldAnchor.d.ts +21 -0
  29. package/build/magic/WorldAnchor.d.ts.map +1 -0
  30. package/build/magic/index.d.ts +7 -0
  31. package/build/magic/index.d.ts.map +1 -0
  32. package/build/magic/magicBackend.d.ts +57 -0
  33. package/build/magic/magicBackend.d.ts.map +1 -0
  34. package/build/magic-DAQdGGEO.js +148 -0
  35. package/build/magic-DznuBYgG.cjs +1 -0
  36. package/build/magic.cjs +1 -0
  37. package/build/magic.d.ts +2 -0
  38. package/build/magic.js +3 -0
  39. package/build/useXRStore-7Gy83DEg.cjs +1 -0
  40. package/build/useXRStore-B3-MaaCu.js +131 -0
  41. package/package.json +31 -8
@@ -0,0 +1,163 @@
1
+ import { i as e, r as t } from "./useXRStore-B3-MaaCu.js";
2
+ import { useEffect as n, useRef as r } from "react";
3
+ import { useFrame as i, useThree as a } from "@react-three/fiber";
4
+ import { ArMarkerControls as o, ArToolkitContext as s, ArToolkitSource as c } from "@ar-js-org/ar.js/three.js/build/ar-threex";
5
+ import { jsx as l } from "react/jsx-runtime";
6
+ //#region src/fiducial/useFiducialBackend.ts
7
+ var u = {
8
+ isPending: !0,
9
+ isSuccess: !1,
10
+ arSource: null,
11
+ arContext: null
12
+ }, d = () => {
13
+ let n = t((e) => e.backends).get(e.FIDUCIAL);
14
+ return n ? {
15
+ ...n.getInternal(),
16
+ isPending: !1,
17
+ isSuccess: !0
18
+ } : u;
19
+ }, f = ({ patternUrl: e, barcodeValue: t, params: a, onMarkerFound: s, onMarkerLost: c, children: u }) => {
20
+ let f = r(null), p = d(), m = r(!1), h = r(!1), g = r(null);
21
+ return n(() => {
22
+ if (!p.isSuccess) return;
23
+ let n = !1;
24
+ return (() => {
25
+ try {
26
+ let { arContext: r } = p, i = f.current;
27
+ if (!r || !i || n) return;
28
+ if (i.visible = !1, h.current = !1, !r.arController) {
29
+ requestAnimationFrame(() => {
30
+ !f.current || n || !p.arContext?.arController || (g.current = new o(p.arContext, f.current, {
31
+ type: e ? "pattern" : t ? "barcode" : "unknown",
32
+ patternUrl: e,
33
+ barcodeValue: t,
34
+ ...a
35
+ }), h.current = !0);
36
+ });
37
+ return;
38
+ }
39
+ g.current = new o(r, i, {
40
+ type: e ? "pattern" : t ? "barcode" : "unknown",
41
+ patternUrl: e,
42
+ barcodeValue: t,
43
+ ...a
44
+ }), h.current = !0;
45
+ } catch (e) {
46
+ console.error("Failed to initialize fiducial anchor:", e);
47
+ }
48
+ })(), () => {
49
+ n = !0;
50
+ let e = g.current;
51
+ typeof e?.dispose == "function" && e.dispose(), h.current = !1;
52
+ };
53
+ }, [
54
+ p.isSuccess,
55
+ p.arContext,
56
+ e,
57
+ t,
58
+ a,
59
+ p
60
+ ]), i(() => {
61
+ let e = f.current;
62
+ if (!e || !h.current) {
63
+ e && (e.visible = !1);
64
+ return;
65
+ }
66
+ let t = e.visible;
67
+ t && !m.current ? (m.current = !0, s?.()) : !t && m.current && (m.current = !1, c?.());
68
+ }), /* @__PURE__ */ l("group", {
69
+ ref: f,
70
+ visible: !1,
71
+ children: u
72
+ });
73
+ }, p = ({ options: e = {}, children: i }) => {
74
+ let { scene: o, camera: s, gl: c } = a(), { registerBackend: l, unregisterBackend: u } = t(), d = r(null), f = r(e);
75
+ return f.current = e, n(() => {
76
+ if (d.current) return;
77
+ let e = !1;
78
+ return (async () => {
79
+ try {
80
+ let t = m(f.current);
81
+ if (e) return;
82
+ await l(t, {
83
+ scene: o,
84
+ camera: s,
85
+ renderer: c
86
+ }), d.current = t;
87
+ } catch (e) {
88
+ console.error("[FiducialSession] Failed to initialize:", e);
89
+ }
90
+ })(), () => {
91
+ e = !0, d.current &&= (u(d.current), null);
92
+ };
93
+ }, [
94
+ o,
95
+ s,
96
+ c,
97
+ l,
98
+ u
99
+ ]), i;
100
+ }, m = (t) => {
101
+ let n = null, r = null, i = null, a;
102
+ return {
103
+ type: e.FIDUCIAL,
104
+ async init({ camera: e, renderer: o }) {
105
+ n = new c({ sourceType: t?.sourceType ?? "webcam" }), await new Promise((e, t) => {
106
+ let r = setTimeout(() => {
107
+ t(/* @__PURE__ */ Error("AR source initialization timeout"));
108
+ }, 1e4);
109
+ n?.init(() => {
110
+ clearTimeout(r);
111
+ let t = n?.domElement;
112
+ t && (t.style.position = "fixed", t.style.top = "0", t.style.left = "0", t.style.width = "100vw", t.style.height = "100vh", t.style.objectFit = "cover", t.style.zIndex = "-1", t.style.pointerEvents = "none"), e();
113
+ });
114
+ }), r = new s({
115
+ cameraParametersUrl: t?.cameraParametersUrl ?? new URL("data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=", "" + import.meta.url).toString(),
116
+ detectionMode: t?.detectionMode ?? "mono",
117
+ patternRatio: t?.patternRatio ?? .5,
118
+ matrixCodeType: t?.matrixCodeType ?? "3x3"
119
+ }), i = e;
120
+ let l = () => {
121
+ n?.onResizeElement();
122
+ let e = window.innerWidth, t = window.innerHeight;
123
+ o.setSize(e, t, !1), n?.copyElementSizeTo(o.domElement), r?.arController && n?.copyElementSizeTo(r.arController.canvas);
124
+ };
125
+ await new Promise((t, n) => {
126
+ let i = setTimeout(() => {
127
+ n(/* @__PURE__ */ Error("AR context initialization timeout"));
128
+ }, 1e4);
129
+ r?.init(() => {
130
+ clearTimeout(i);
131
+ try {
132
+ let n = r?.getProjectionMatrix();
133
+ n && e.projectionMatrix.copy(n), l(), t();
134
+ } catch (e) {
135
+ n(e);
136
+ }
137
+ });
138
+ }), window.addEventListener("resize", l), a = l;
139
+ },
140
+ update() {
141
+ if (!(!n || !r) && !(!n.ready || !n.domElement)) try {
142
+ r.update(n.domElement);
143
+ let e = r.getProjectionMatrix?.();
144
+ i && e && i.projectionMatrix.copy(e);
145
+ } catch (e) {
146
+ console.warn("AR.js update error:", e);
147
+ }
148
+ },
149
+ dispose() {
150
+ if (a &&= (window.removeEventListener("resize", a), void 0), r && typeof r.dispose == "function" && r.dispose(), n?.domElement) {
151
+ let e = n.domElement.parentNode;
152
+ e && e.removeChild(n.domElement);
153
+ }
154
+ n = null, r = null, i = null;
155
+ },
156
+ getInternal: () => ({
157
+ arSource: n,
158
+ arContext: r
159
+ })
160
+ };
161
+ };
162
+ //#endregion
163
+ export { d as i, p as n, f as r, m as t };
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-7Gy83DEg.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`@ar-js-org/ar.js/three.js/build/ar-threex`),i=require(`react/jsx-runtime`);var a={isPending:!0,isSuccess:!1,arSource:null,arContext:null},o=()=>{let t=e.r(e=>e.backends).get(e.i.FIDUCIAL);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:a},s=({patternUrl:e,barcodeValue:a,params:s,onMarkerFound:c,onMarkerLost:l,children:u})=>{let d=(0,t.useRef)(null),f=o(),p=(0,t.useRef)(!1),m=(0,t.useRef)(!1),h=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!f.isSuccess)return;let t=!1;return(()=>{try{let{arContext:n}=f,i=d.current;if(!n||!i||t)return;if(i.visible=!1,m.current=!1,!n.arController){requestAnimationFrame(()=>{!d.current||t||!f.arContext?.arController||(h.current=new r.ArMarkerControls(f.arContext,d.current,{type:e?`pattern`:a?`barcode`:`unknown`,patternUrl:e,barcodeValue:a,...s}),m.current=!0)});return}h.current=new r.ArMarkerControls(n,i,{type:e?`pattern`:a?`barcode`:`unknown`,patternUrl:e,barcodeValue:a,...s}),m.current=!0}catch(e){console.error(`Failed to initialize fiducial anchor:`,e)}})(),()=>{t=!0;let e=h.current;typeof e?.dispose==`function`&&e.dispose(),m.current=!1}},[f.isSuccess,f.arContext,e,a,s,f]),(0,n.useFrame)(()=>{let e=d.current;if(!e||!m.current){e&&(e.visible=!1);return}let t=e.visible;t&&!p.current?(p.current=!0,c?.()):!t&&p.current&&(p.current=!1,l?.())}),(0,i.jsx)(`group`,{ref:d,visible:!1,children:u})},c=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s}=(0,n.useThree)(),{registerBackend:c,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=l(f.current);if(e)return;await c(t,{scene:a,camera:o,renderer:s}),d.current=t}catch(e){console.error(`[FiducialSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,s,c,u]),i},l=t=>{let n=null,i=null,a=null,o;return{type:e.i.FIDUCIAL,async init({camera:e,renderer:s}){n=new r.ArToolkitSource({sourceType:t?.sourceType??`webcam`}),await new Promise((e,t)=>{let r=setTimeout(()=>{t(Error(`AR source initialization timeout`))},1e4);n?.init(()=>{clearTimeout(r);let t=n?.domElement;t&&(t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.width=`100vw`,t.style.height=`100vh`,t.style.objectFit=`cover`,t.style.zIndex=`-1`,t.style.pointerEvents=`none`),e()})}),i=new r.ArToolkitContext({cameraParametersUrl:t?.cameraParametersUrl??new URL(`data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=`,``+{}.url).toString(),detectionMode:t?.detectionMode??`mono`,patternRatio:t?.patternRatio??.5,matrixCodeType:t?.matrixCodeType??`3x3`}),a=e;let c=()=>{n?.onResizeElement();let e=window.innerWidth,t=window.innerHeight;s.setSize(e,t,!1),n?.copyElementSizeTo(s.domElement),i?.arController&&n?.copyElementSizeTo(i.arController.canvas)};await new Promise((t,n)=>{let r=setTimeout(()=>{n(Error(`AR context initialization timeout`))},1e4);i?.init(()=>{clearTimeout(r);try{let n=i?.getProjectionMatrix();n&&e.projectionMatrix.copy(n),c(),t()}catch(e){n(e)}})}),window.addEventListener(`resize`,c),o=c},update(){if(!(!n||!i)&&!(!n.ready||!n.domElement))try{i.update(n.domElement);let e=i.getProjectionMatrix?.();a&&e&&a.projectionMatrix.copy(e)}catch(e){console.warn(`AR.js update error:`,e)}},dispose(){if(o&&=(window.removeEventListener(`resize`,o),void 0),i&&typeof i.dispose==`function`&&i.dispose(),n?.domElement){let e=n.domElement.parentNode;e&&e.removeChild(n.domElement)}n=null,i=null,a=null},getInternal:()=>({arSource:n,arContext:i})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),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}});
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-7Gy83DEg.cjs`);const e=require(`./fiducial-dapuWTXg.cjs`);exports.FiducialAnchor=e.r,exports.FiducialSession=e.n,exports.createFiducialBackend=e.t,exports.useFiducialBackend=e.i;
@@ -0,0 +1,2 @@
1
+ export * from './fiducial/index'
2
+ export {}
@@ -0,0 +1,3 @@
1
+ import "./useXRStore-B3-MaaCu.js";
2
+ import { i as e, n as t, r as n, t as r } from "./fiducial-CqsG94R9.js";
3
+ export { n as FiducialAnchor, t as FiducialSession, r as createFiducialBackend, e as useFiducialBackend };
@@ -1 +1 @@
1
- {"version":3,"file":"GeoLine.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoLine.tsx"],"names":[],"mappings":"AAWA,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,GAAI,iEAOd,YAAY,gCAyEd,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"GeoLine.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoLine.tsx"],"names":[],"mappings":"AAWA,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,QAAA,MAAM,OAAO,GAAI,iEAOd,YAAY,gCAmFd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GeolocationAnchor.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeolocationAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EACpD,iBAAiB;IACnB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,QAAA,MAAM,iBAAiB,GAAI,2GAQxB,sBAAsB,gCA4DxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"GeolocationAnchor.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeolocationAnchor.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEtE,MAAM,WAAW,sBACf,SAAQ,IAAI,CAAC,yBAAyB,EAAE,aAAa,CAAC,EACpD,iBAAiB;IACnB,wFAAwF;IACxF,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,QAAA,MAAM,iBAAiB,GAAI,2GAQxB,sBAAsB,gCA6DxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,IAAI,KAAK,EACtB,MAAM,EACP,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,OAAO,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E;AAED;;GAEG;AACH,QAAA,MAAM,wBAAwB,GAC5B,UAAU,yBAAyB,KAClC,OAAO,CAAC,mBAAmB,CA+N7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
1
+ {"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,aAAa,IAAI,KAAK,EACtB,MAAM,EACP,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,OAAO,CAAC;AAEjE;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E;AAED;;GAEG;AACH,QAAA,MAAM,wBAAwB,GAC5B,UAAU,yBAAyB,KAClC,OAAO,CAAC,mBAAmB,CAsO7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1,288 @@
1
+ import { i as e, r as t } from "./useXRStore-B3-MaaCu.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, DoubleSide as f, FrontSide as p, Group as m, Path as h, Shape as g, ShapeGeometry as _, Vector3 as v } from "three";
6
+ import { Line2 as y } from "three/addons/lines/Line2.js";
7
+ import { LineGeometry as b } from "three/addons/lines/LineGeometry.js";
8
+ import { LineMaterial as x } from "three/addons/lines/LineMaterial.js";
9
+ import { DeviceOrientationControls as S, LocationBased as C, Webcam as w } from "locar";
10
+ //#region src/geolocation/useGeolocationBackend.ts
11
+ var T = {
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
+ }, E = () => {
24
+ let n = t((e) => e.backends).get(e.GEOLOCATION);
25
+ return n ? {
26
+ ...n.getInternal(),
27
+ isPending: !1,
28
+ isSuccess: !0
29
+ } : T;
30
+ }, D = ({ coordinates: e, color: t = "#ff0000", isDashed: n = !1, dashSize: c = 3, gapSize: l = 1, lineWidth: d = 1 }) => {
31
+ let f = E(), p = a(f);
32
+ p.current = f;
33
+ let [h] = o(() => new m()), g = i(() => Math.random().toString(36).slice(2, 11), []), [_, S] = o(null);
34
+ return r(() => {
35
+ if (!f.isSuccess || e.length < 2) return;
36
+ let [r, i, a = 0] = e[0];
37
+ return p.current.registerAnchor(g, {
38
+ anchor: h,
39
+ isAttached: !1,
40
+ latitude: i,
41
+ longitude: r,
42
+ altitude: a,
43
+ onAttach: (r) => {
44
+ let [i, a, o = 0] = e[0], [s, u] = r.lonLatToWorldCoords(i, a), f = e.map(([e, t, n = 0]) => {
45
+ let [i, a] = r.lonLatToWorldCoords(e, t);
46
+ return new v(i - s, n - o, a - u);
47
+ }), p = new y(new b().setFromPoints(f), new x({
48
+ color: t,
49
+ dashSize: c,
50
+ gapSize: l,
51
+ dashed: n,
52
+ worldUnits: !0,
53
+ linewidth: d
54
+ }));
55
+ n && p.computeLineDistances(), S(p);
56
+ }
57
+ }), () => {
58
+ p.current.unregisterAnchor(g), S((e) => (e && (e.geometry.dispose(), e.material.dispose()), null));
59
+ };
60
+ }, [
61
+ g,
62
+ h,
63
+ e,
64
+ t,
65
+ n,
66
+ c,
67
+ l,
68
+ d,
69
+ f.isSuccess
70
+ ]), s(/* @__PURE__ */ u("group", { children: _ && /* @__PURE__ */ u("primitive", { object: _ }) }), h);
71
+ }, O = ({ latitude: e, longitude: t, altitude: d = 0, isBillboard: f = !0, onAttach: p, onGpsUpdate: h, children: g }) => {
72
+ let _ = E(), v = a(_);
73
+ v.current = _;
74
+ let { camera: y } = l(), [b] = o(() => new m()), x = i(() => Math.random().toString(36).slice(2, 11), []), S = n(() => {
75
+ p?.();
76
+ }, [p]), C = n((e, t) => {
77
+ h?.(e, t);
78
+ }, [h]);
79
+ return r(() => {
80
+ if (_.isSuccess) return v.current.registerAnchor(x, {
81
+ anchor: b,
82
+ isAttached: !1,
83
+ latitude: e,
84
+ longitude: t,
85
+ altitude: d,
86
+ onAttach: S,
87
+ onGpsUpdate: C
88
+ }), () => {
89
+ v.current.unregisterAnchor(x);
90
+ };
91
+ }, [
92
+ b,
93
+ x,
94
+ e,
95
+ t,
96
+ d,
97
+ S,
98
+ C,
99
+ _.isSuccess
100
+ ]), c(() => {
101
+ !f || !y || !_.isSuccess || _.getAnchor(x)?.isAttached && b.lookAt(y.position);
102
+ }), s(/* @__PURE__ */ u("group", { children: g }), b);
103
+ }, k = ({ options: e = {}, children: n }) => {
104
+ let { scene: i, camera: o, gl: s } = l(), { registerBackend: c, unregisterBackend: u } = t(), d = a(null), f = a(e);
105
+ return f.current = e, r(() => {
106
+ if (d.current) return;
107
+ let e = !1;
108
+ return (async () => {
109
+ try {
110
+ let t = M(f.current);
111
+ if (e) return;
112
+ await c(t, {
113
+ scene: i,
114
+ camera: o,
115
+ renderer: s
116
+ }), d.current = t;
117
+ } catch (e) {
118
+ console.error("[GeolocationSession] Failed to initialize:", e);
119
+ }
120
+ })(), () => {
121
+ e = !0, d.current &&= (u(d.current), null);
122
+ };
123
+ }, [
124
+ i,
125
+ o,
126
+ s,
127
+ c,
128
+ u
129
+ ]), n;
130
+ }, A = {
131
+ front: p,
132
+ back: d,
133
+ double: f
134
+ }, j = ({ coordinates: e, holes: t, color: n = "#ff0000", opacity: c = 1, isWireframe: l = !1, side: d = "double" }) => {
135
+ let f = E(), p = a(f);
136
+ p.current = f;
137
+ let [v] = o(() => new m()), y = i(() => Math.random().toString(36).slice(2, 11), []), [b, x] = o(null);
138
+ return r(() => {
139
+ if (!f.isSuccess || e.length < 3) return;
140
+ let [n, r, i = 0] = e[0];
141
+ return p.current.registerAnchor(y, {
142
+ anchor: v,
143
+ isAttached: !1,
144
+ latitude: r,
145
+ longitude: n,
146
+ altitude: i,
147
+ onAttach: (n) => {
148
+ let [r, i, a = 0] = e[0], [o, s] = n.lonLatToWorldCoords(r, i), c = [];
149
+ for (let [t, r, i = 0] of e) {
150
+ let [e, l] = n.lonLatToWorldCoords(t, r);
151
+ c.push({
152
+ x: e - o,
153
+ z: l - s,
154
+ elev: i - a
155
+ });
156
+ }
157
+ let l = new g();
158
+ l.moveTo(c[0].x, c[0].z);
159
+ for (let e = 1; e < c.length; e++) l.lineTo(c[e].x, c[e].z);
160
+ if (l.closePath(), t && t.length > 0) for (let e of t) {
161
+ if (e.length < 3) continue;
162
+ let t = new h(), [r, i] = e[0], [a, c] = n.lonLatToWorldCoords(r, i);
163
+ t.moveTo(a - o, c - s);
164
+ for (let r = 1; r < e.length; r++) {
165
+ let [i, a] = e[r], [c, l] = n.lonLatToWorldCoords(i, a);
166
+ t.lineTo(c - o, l - s);
167
+ }
168
+ t.closePath(), l.holes.push(t);
169
+ }
170
+ let u = new _(l), d = c.reduce((e, t) => e + t.elev, 0) / c.length;
171
+ u.rotateX(-Math.PI / 2), x({
172
+ geometry: u,
173
+ avgElevation: d
174
+ });
175
+ }
176
+ }), () => {
177
+ p.current.unregisterAnchor(y), x((e) => (e && e.geometry.dispose(), null));
178
+ };
179
+ }, [
180
+ y,
181
+ v,
182
+ e,
183
+ t,
184
+ f.isSuccess
185
+ ]), s(/* @__PURE__ */ u("group", { children: b && /* @__PURE__ */ u("group", {
186
+ position: [
187
+ 0,
188
+ b.avgElevation,
189
+ 0
190
+ ],
191
+ children: /* @__PURE__ */ u("mesh", {
192
+ geometry: b.geometry,
193
+ children: /* @__PURE__ */ u("meshBasicMaterial", {
194
+ color: n,
195
+ opacity: c,
196
+ transparent: c < 1,
197
+ wireframe: l,
198
+ side: A[d]
199
+ })
200
+ })
201
+ }) }), v);
202
+ }, M = (t) => {
203
+ let n = null, r = null, i = null, a, o = null, s = null, c = null, l = null, u = /* @__PURE__ */ new Map(), d = null, f = (e) => {
204
+ if (!(!n || e.isAttached)) try {
205
+ n.add(e.anchor, e.longitude, e.latitude, e.altitude), e.isAttached = !0, e.onAttach?.(n);
206
+ } catch (e) {
207
+ console.error("❌ Failed to attach anchor:", e);
208
+ }
209
+ }, p = (e, t) => {
210
+ u.set(e, t), d !== null && !t.isAttached && (f(t), t.onGpsUpdate?.(d, 0));
211
+ }, m = (e) => {
212
+ let t = u.get(e);
213
+ if (t?.isAttached) try {
214
+ t.anchor.removeFromParent();
215
+ } catch (t) {
216
+ console.error(`⚠️ Error removing anchor ${e}:`, t);
217
+ }
218
+ u.delete(e);
219
+ }, h = (e) => u.get(e);
220
+ return {
221
+ type: e.GEOLOCATION,
222
+ async init(e) {
223
+ let { camera: p, renderer: m, scene: h } = e;
224
+ if (!h) throw Error("[geolocationBackend] A THREE.Scene is required for location-based AR");
225
+ s = p, c = m, l = h, n = new C(h, p), r = new w(t?.webcamConstraints ?? { video: { facingMode: "environment" } }), o = (e) => {
226
+ d = e.position;
227
+ for (let t of u.values()) t.isAttached || f(t), t.onGpsUpdate?.(e.position, e.distMoved);
228
+ t?.onGpsUpdate?.(e.position, e.distMoved);
229
+ }, n.on("gpsupdate", o), r.on("webcamstarted", (e) => {
230
+ h.background = e.texture;
231
+ }), r.on("webcamerror", (e) => {
232
+ console.error("[geolocationBackend] webcam error:", e);
233
+ }), i = new S(p), i.on("deviceorientationgranted", (e) => {
234
+ e.target?.connect?.();
235
+ }), i.on("deviceorientationerror", (e) => {
236
+ console.error("[geolocationBackend] Device orientation error:", e);
237
+ }), i.init?.(), n.on("gpserror", (e) => {
238
+ console.error("[geolocationBackend] gps error:", e);
239
+ }), n.startGps(), typeof t?.fakeLat == "number" && typeof t?.fakeLon == "number" && n.fakeGps(t.fakeLon, t.fakeLat);
240
+ let g = n.getLastKnownLocation();
241
+ g !== null && (d = {
242
+ coords: {
243
+ longitude: g.longitude,
244
+ latitude: g.latitude,
245
+ accuracy: 0,
246
+ altitude: null,
247
+ altitudeAccuracy: null,
248
+ heading: null,
249
+ speed: null,
250
+ toJSON: () => g
251
+ },
252
+ timestamp: Date.now(),
253
+ toJSON: () => g
254
+ });
255
+ let _ = () => {
256
+ if (!c || !s) return;
257
+ let e = window.innerWidth, t = window.innerHeight;
258
+ c.setSize(e, t, !1), s.aspect = e / t, s.updateProjectionMatrix?.();
259
+ };
260
+ _(), window.addEventListener("resize", _), a = _;
261
+ },
262
+ update() {
263
+ i?.update?.();
264
+ },
265
+ dispose() {
266
+ n && o && n.off("gpsupdate", o), n?.stopGps?.(), r?.stop?.(), i?.dispose?.(), a &&= (window.removeEventListener("resize", a), void 0);
267
+ for (let e of u.values()) if (e.isAttached) try {
268
+ e.anchor.removeFromParent();
269
+ } catch (e) {
270
+ console.error("⚠️ Error removing anchor:", e);
271
+ }
272
+ u.clear(), n = null, r = null, i = null, s = null, c = null, l = null, o = null, d = null;
273
+ },
274
+ getInternal: () => ({
275
+ locar: n,
276
+ webcam: r,
277
+ deviceOrientation: i,
278
+ scene: l,
279
+ camera: s,
280
+ lastPosition: d,
281
+ registerAnchor: p,
282
+ unregisterAnchor: m,
283
+ getAnchor: h
284
+ })
285
+ };
286
+ };
287
+ //#endregion
288
+ export { D as a, O as i, j as n, E as o, k as r, M as t };
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-7Gy83DEg.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=({coordinates:e,color:c=`#ff0000`,isDashed:l=!1,dashSize:d=3,gapSize:f=1,lineWidth:p=1})=>{let m=u(),h=(0,t.useRef)(m);h.current=m;let[g]=(0,t.useState)(()=>new i.Group),_=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[v,y]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!m.isSuccess||e.length<2)return;let[t,n,r=0]=e[0];return h.current.registerAnchor(_,{anchor:g,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,u=0]=e[0],[m,h]=t.lonLatToWorldCoords(n,r),g=e.map(([e,n,r=0])=>{let[a,o]=t.lonLatToWorldCoords(e,n);return new i.Vector3(a-m,r-u,o-h)}),_=new a.Line2(new o.LineGeometry().setFromPoints(g),new s.LineMaterial({color:c,dashSize:d,gapSize:f,dashed:l,worldUnits:!0,linewidth:p}));l&&_.computeLineDistances(),y(_)}}),()=>{h.current.unregisterAnchor(_),y(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[_,g,e,c,l,d,f,p,m.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:v&&(0,r.jsx)(`primitive`,{object:v})}),g)},f=({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)},p=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s}=(0,n.useThree)(),{registerBackend:c,unregisterBackend:l}=e.r(),u=(0,t.useRef)(null),d=(0,t.useRef)(r);return d.current=r,(0,t.useEffect)(()=>{if(u.current)return;let e=!1;return(async()=>{try{let t=g(d.current);if(e)return;await c(t,{scene:a,camera:o,renderer:s}),u.current=t}catch(e){console.error(`[GeolocationSession] Failed to initialize:`,e)}})(),()=>{e=!0,u.current&&=(l(u.current),null)}},[a,o,s,c,l]),i},m={front:i.FrontSide,back:i.BackSide,double:i.DoubleSide},h=({coordinates:e,holes:a,color:o=`#ff0000`,opacity:s=1,isWireframe:c=!1,side:l=`double`})=>{let d=u(),f=(0,t.useRef)(d);f.current=d;let[p]=(0,t.useState)(()=>new i.Group),h=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[g,_]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!d.isSuccess||e.length<3)return;let[t,n,r=0]=e[0];return f.current.registerAnchor(h,{anchor:p,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),_({geometry:d,avgElevation:f})}}),()=>{f.current.unregisterAnchor(h),_(e=>(e&&e.geometry.dispose(),null))}},[h,p,e,a,d.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:g&&(0,r.jsx)(`group`,{position:[0,g.avgElevation,0],children:(0,r.jsx)(`mesh`,{geometry:g.geometry,children:(0,r.jsx)(`meshBasicMaterial`,{color:o,opacity:s,transparent:s<1,wireframe:c,side:m[l]})})})}),p)},g=t=>{let n=null,r=null,i=null,a,o=null,s=null,l=null,u=null,d=new Map,f=null,p=e=>{if(!(!n||e.isAttached))try{n.add(e.anchor,e.longitude,e.latitude,e.altitude),e.isAttached=!0,e.onAttach?.(n)}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:m,renderer:h,scene:g}=e;if(!g)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);s=m,l=h,u=g,n=new c.LocationBased(g,m),r=new c.Webcam(t?.webcamConstraints??{video:{facingMode:`environment`}}),o=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)},n.on(`gpsupdate`,o),r.on(`webcamstarted`,e=>{g.background=e.texture}),r.on(`webcamerror`,e=>{console.error(`[geolocationBackend] webcam error:`,e)}),i=new c.DeviceOrientationControls(m),i.on(`deviceorientationgranted`,e=>{e.target?.connect?.()}),i.on(`deviceorientationerror`,e=>{console.error(`[geolocationBackend] Device orientation error:`,e)}),i.init?.(),n.on(`gpserror`,e=>{console.error(`[geolocationBackend] gps error:`,e)}),n.startGps(),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`&&n.fakeGps(t.fakeLon,t.fakeLat);let _=n.getLastKnownLocation();_!==null&&(f={coords:{longitude:_.longitude,latitude:_.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>_},timestamp:Date.now(),toJSON:()=>_});let v=()=>{if(!l||!s)return;let e=window.innerWidth,t=window.innerHeight;l.setSize(e,t,!1),s.aspect=e/t,s.updateProjectionMatrix?.()};v(),window.addEventListener(`resize`,v),a=v},update(){i?.update?.()},dispose(){n&&o&&n.off(`gpsupdate`,o),n?.stopGps?.(),r?.stop?.(),i?.dispose?.(),a&&=(window.removeEventListener(`resize`,a),void 0);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,i=null,s=null,l=null,u=null,o=null,f=null},getInternal:()=>({locar:n,webcam:r,deviceOrientation:i,scene:u,camera:s,lastPosition:f,registerAnchor:m,unregisterAnchor:h,getAnchor:g})}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}});
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-7Gy83DEg.cjs`);const e=require(`./geolocation-uko8RwgK.cjs`);exports.GeoLine=e.a,exports.GeoPolygon=e.n,exports.GeolocationAnchor=e.i,exports.GeolocationSession=e.r,exports.createGeolocationBackend=e.t,exports.useGeolocationBackend=e.o;
@@ -0,0 +1,2 @@
1
+ export * from './geolocation/index'
2
+ export {}
@@ -0,0 +1,3 @@
1
+ import "./useXRStore-B3-MaaCu.js";
2
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-U_vaIjuk.js";
3
+ export { e as GeoLine, n as GeoPolygon, t as GeolocationAnchor, i as GeolocationSession, a as createGeolocationBackend, r as useGeolocationBackend };
@@ -1 +1 @@
1
- {"version":3,"file":"ImmersiveSession.d.ts","sourceRoot":"","sources":["../../src/immersive/ImmersiveSession.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAc/C;;GAEG;AACH,QAAA,MAAM,gBAAgB,GAAI,cAAc,iBAAiB,4CAqBxD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"ImmersiveSession.d.ts","sourceRoot":"","sources":["../../src/immersive/ImmersiveSession.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAY/C;;GAEG;AACH,QAAA,MAAM,gBAAgB,GAAI,cAAc,iBAAiB,4CAqBxD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-7Gy83DEg.cjs`);let t=require(`react`),n=require(`react/jsx-runtime`),r=require(`@react-three/xr`);var i=()=>({type:e.i.IMMERSIVE,init:()=>{},getInternal:()=>null}),a=({children:a})=>{let o=(0,t.useMemo)(()=>(0,r.createXRStore)(),[]);return(0,t.useEffect)(()=>{let t=e.t(),n=i();return t.backends.set(e.i.IMMERSIVE,n),t.setImmersiveStore(o),()=>{t.backends.delete(e.i.IMMERSIVE),t.setImmersiveStore(null)}},[o]),(0,n.jsx)(r.XR,{store:o,children:a})};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
@@ -0,0 +1,23 @@
1
+ import { i as e, t } from "./useXRStore-B3-MaaCu.js";
2
+ import { useEffect as n, useMemo as r } from "react";
3
+ import { jsx as i } from "react/jsx-runtime";
4
+ import { XR as a, createXRStore as o } from "@react-three/xr";
5
+ //#region src/immersive/ImmersiveSession.tsx
6
+ var s = () => ({
7
+ type: e.IMMERSIVE,
8
+ init: () => {},
9
+ getInternal: () => null
10
+ }), c = ({ children: c }) => {
11
+ let l = r(() => o(), []);
12
+ return n(() => {
13
+ let n = t(), r = s();
14
+ return n.backends.set(e.IMMERSIVE, r), n.setImmersiveStore(l), () => {
15
+ n.backends.delete(e.IMMERSIVE), n.setImmersiveStore(null);
16
+ };
17
+ }, [l]), /* @__PURE__ */ i(a, {
18
+ store: l,
19
+ children: c
20
+ });
21
+ };
22
+ //#endregion
23
+ export { c as t };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-7Gy83DEg.cjs`);const e=require(`./immersive-8m33PLug.cjs`);exports.ImmersiveSession=e.t;
@@ -0,0 +1,2 @@
1
+ export * from './immersive/index'
2
+ export {}
@@ -0,0 +1,3 @@
1
+ import "./useXRStore-B3-MaaCu.js";
2
+ import { t as e } from "./immersive-Dp2-ZCRC.js";
3
+ export { e as ImmersiveSession };
package/build/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),R=require("@react-three/fiber"),v=require("react/jsx-runtime"),P=require("@ar-js-org/ar.js/three.js/build/ar-threex"),I=require("three"),re=require("three/addons/lines/Line2.js"),oe=require("three/addons/lines/LineGeometry.js"),se=require("three/addons/lines/LineMaterial.js"),N=require("locar"),U=require("@react-three/xr");var X=typeof document<"u"?document.currentScript:null;const b={FIDUCIAL:"fiducial",GEOLOCATION:"geolocation",IMMERSIVE:"immersive"},W=t=>{let e;const n=new Set,r=(s,f)=>{const u=typeof s=="function"?s(e):s;if(!Object.is(u,e)){const c=e;e=f??(typeof u!="object"||u===null)?u:Object.assign({},e,u),n.forEach(A=>A(e,c))}},i=()=>e,o={setState:r,getState:i,getInitialState:()=>d,subscribe:s=>(n.add(s),()=>n.delete(s))},d=e=t(r,i,o);return o},ce=(t=>t?W(t):W),ie=t=>t;function ae(t,e=ie){const n=m.useSyncExternalStore(t.subscribe,m.useCallback(()=>e(t.getState()),[t,e]),m.useCallback(()=>e(t.getInitialState()),[t,e]));return m.useDebugValue(n),n}const le=t=>{const e=ce(t),n=r=>ae(e,r);return Object.assign(n,e),n},ue=(t=>le),de=t=>(e,n,r)=>{const i=r.subscribe;return r.subscribe=((l,o,d)=>{let s=l;if(o){const f=d?.equalityFn||Object.is;let u=l(r.getState());s=c=>{const A=l(c);if(!f(u,A)){const h=u;o(u=A,h)}},d?.fireImmediately&&o(u,u)}return i(s)}),t(e,n,r)},Ae=de,_=t=>Symbol.iterator in t,H=t=>"entries"in t,K=(t,e)=>{const n=t instanceof Map?t:new Map(t.entries()),r=e instanceof Map?e:new Map(e.entries());if(n.size!==r.size)return!1;for(const[i,a]of n)if(!r.has(i)||!Object.is(a,r.get(i)))return!1;return!0},fe=(t,e)=>{const n=t[Symbol.iterator](),r=e[Symbol.iterator]();let 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 me(t,e){return Object.is(t,e)?!0:typeof t!="object"||t===null||typeof e!="object"||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e)?!1:_(t)&&_(e)?H(t)&&H(e)?K(t,e):fe(t,e):K({entries:()=>Object.entries(t)},{entries:()=>Object.entries(e)})}function ge(t){const e=m.useRef(void 0);return n=>{const r=t(n);return me(e.current,r)?e.current:e.current=r}}const q=ue()(Ae((t,e)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(n,r)=>{try{const i=e(),a=new Set(i.backends.keys()),l=a.has(b.FIDUCIAL)||n.type===b.FIDUCIAL,o=a.has(b.GEOLOCATION)||n.type===b.GEOLOCATION;if(l&&o){const d="❌ [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(d),new Error(d)}await n.init({scene:r.scene,camera:r.camera,renderer:r.renderer}),t(d=>{const s=new Map(d.backends);return s.set(n.type,n),{backends:s}})}catch(i){throw console.error("[XRStore] Failed to register backend:",i),i}},unregisterBackend:n=>{t(r=>{const i=new Map(r.backends);i.delete(n.type);try{n.dispose?.()}catch(a){console.error("[XRStore] Error disposing backend:",a)}return{backends:i}})},setVideo:n=>{t({video:n})},updateBackends:n=>{const{backends:r}=e();for(const i of r.values())try{i.update?.(n)}catch(a){console.error("[XRStore] Backend update error:",a)}},setImmersiveStore:n=>{t({immersiveStore:n})}}))),V=()=>q.getState(),he=q.subscribe,C=t=>q(ge(n=>{const r={...n,isImmersive:n.backends.has(b.IMMERSIVE),immersive:n.immersiveStore||null};return t?t(r):r})),Se=({children:t})=>{const{updateBackends:e}=C();return R.useFrame((n,r)=>{e(r)}),t},pe={isPending:!0,isSuccess:!1,arSource:null,arContext:null},Y=()=>{const e=C(n=>n.backends).get(b.FIDUCIAL);return e?{...e.getInternal(),isPending:!1,isSuccess:!0}:pe},be=({patternUrl:t,barcodeValue:e,params:n,onMarkerFound:r,onMarkerLost:i,children:a})=>{const l=m.useRef(null),o=Y(),d=m.useRef(!1),s=m.useRef(!1),f=m.useRef(null);return m.useEffect(()=>{if(!o.isSuccess)return;let u=!1;return(()=>{try{const{arContext:A}=o,h=l.current;if(!A||!h||u)return;if(h.visible=!1,s.current=!1,!A.arController){requestAnimationFrame(()=>{if(!l.current||u||!o.arContext?.arController)return;const y=new P.ArMarkerControls(o.arContext,l.current,{type:t?"pattern":e?"barcode":"unknown",patternUrl:t,barcodeValue:e,...n});f.current=y,s.current=!0});return}const p=new P.ArMarkerControls(A,h,{type:t?"pattern":e?"barcode":"unknown",patternUrl:t,barcodeValue:e,...n});f.current=p,s.current=!0}catch(A){console.error("Failed to initialize fiducial anchor:",A)}})(),()=>{u=!0;const A=f.current;typeof A?.dispose=="function"&&A.dispose(),s.current=!1}},[o.isSuccess,o.arContext,t,e,n,o]),R.useFrame(()=>{const u=l.current;if(!u||!s.current){u&&(u.visible=!1);return}const c=u.visible;c&&!d.current?(d.current=!0,r?.()):!c&&d.current&&(d.current=!1,i?.())}),v.jsx("group",{ref:l,visible:!1,children:a})},we=({options:t={},children:e})=>{const{scene:n,camera:r,gl:i}=R.useThree(),{registerBackend:a,unregisterBackend:l}=C(),o=m.useRef(null),d=m.useRef(t);return d.current=t,m.useEffect(()=>{if(o.current)return;let s=!1;return(async()=>{try{const u=Q(d.current);if(s)return;await a(u,{scene:n,camera:r,renderer:i}),o.current=u}catch(u){console.error("[FiducialSession] Failed to initialize:",u)}})(),()=>{s=!0,o.current&&(l(o.current),o.current=null)}},[n,r,i,a,l]),e},Q=t=>{let e=null,n=null,r=null,i;return{type:b.FIDUCIAL,async init({camera:a,renderer:l}){e=new P.ArToolkitSource({sourceType:t?.sourceType??"webcam"}),await new Promise((s,f)=>{const u=setTimeout(()=>{f(new Error("AR source initialization timeout"))},1e4);e?.init(()=>{clearTimeout(u);const c=e?.domElement;c&&(c.style.position="fixed",c.style.top="0",c.style.left="0",c.style.width="100vw",c.style.height="100vh",c.style.objectFit="cover",c.style.zIndex="-1",c.style.pointerEvents="none"),s()})});const o={cameraParametersUrl:t?.cameraParametersUrl??new URL("data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=",typeof document>"u"?require("url").pathToFileURL(__filename).href:X&&X.tagName.toUpperCase()==="SCRIPT"&&X.src||new URL("index.cjs",document.baseURI).href).toString(),detectionMode:t?.detectionMode??"mono",patternRatio:t?.patternRatio??.5,matrixCodeType:t?.matrixCodeType??"3x3"};n=new P.ArToolkitContext(o),r=a;const d=()=>{e?.onResizeElement();const s=window.innerWidth,f=window.innerHeight;l.setSize(s,f,!1),e?.copyElementSizeTo(l.domElement),n?.arController&&e?.copyElementSizeTo(n.arController.canvas)};await new Promise((s,f)=>{const u=setTimeout(()=>{f(new Error("AR context initialization timeout"))},1e4);n?.init(()=>{clearTimeout(u);try{const c=n?.getProjectionMatrix();c&&a.projectionMatrix.copy(c),d(),s()}catch(c){f(c)}})}),window.addEventListener("resize",d),i=d},update(){if(!(!e||!n)&&!(!e.ready||!e.domElement))try{n.update(e.domElement);const a=n.getProjectionMatrix?.();r&&a&&r.projectionMatrix.copy(a)}catch(a){console.warn("AR.js update error:",a)}},dispose(){if(i&&(window.removeEventListener("resize",i),i=void 0),n&&typeof n.dispose=="function"&&n.dispose(),e?.domElement){const a=e.domElement.parentNode;a&&a.removeChild(e.domElement)}e=null,n=null,r=null},getInternal:()=>({arSource:e,arContext:n})}},ye={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>{}},G=()=>{const e=C(n=>n.backends).get(b.GEOLOCATION);return e?{...e.getInternal(),isPending:!1,isSuccess:!0}:ye},ke=({coordinates:t,color:e="#ff0000",isDashed:n=!1,dashSize:r=3,gapSize:i=1,lineWidth:a=1})=>{const l=G(),[o]=m.useState(()=>new I.Group),d=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,f]=m.useState(null);return m.useEffect(()=>{if(!l.isSuccess||t.length<2)return;const[u,c,A=0]=t[0],h=p=>{const[y,L,g=0]=t[0],[w,M]=p.lonLatToWorldCoords(y,L),k=t.map(([z,S,E=0])=>{const[T,j]=p.lonLatToWorldCoords(z,S);return new I.Vector3(T-w,E-g,j-M)}),x=new oe.LineGeometry().setFromPoints(k),O=new se.LineMaterial({color:e,dashSize:r,gapSize:i,dashed:n,worldUnits:!0,linewidth:a}),F=new re.Line2(x,O);n&&F.computeLineDistances(),f(F)};return l.registerAnchor(d,{anchor:o,isAttached:!1,latitude:c,longitude:u,altitude:A,onAttach:h}),()=>{l.unregisterAnchor(d)}},[l.isSuccess,l.registerAnchor,l.unregisterAnchor,d,o,t,e,n,r,i,a]),R.createPortal(v.jsx("group",{children:s&&v.jsx("primitive",{object:s})}),o)},Ee=({latitude:t,longitude:e,altitude:n=0,isBillboard:r=!0,onAttach:i,onGpsUpdate:a,children:l})=>{const o=G(),{camera:d}=R.useThree(),[s]=m.useState(()=>new I.Group),f=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),u=m.useCallback(()=>{i?.()},[i]),c=m.useCallback((A,h)=>{a?.(A,h)},[a]);return m.useEffect(()=>{if(o.isSuccess)return o.registerAnchor(f,{anchor:s,isAttached:!1,latitude:t,longitude:e,altitude:n,onAttach:u,onGpsUpdate:c}),()=>{o.unregisterAnchor(f)}},[o.isSuccess,o.registerAnchor,o.unregisterAnchor,s,f,t,e,n,u,c]),R.useFrame(()=>{!r||!d||!o.isSuccess||!o.getAnchor(f)?.isAttached||s.lookAt(d.position)}),R.createPortal(v.jsx("group",{children:l}),s)},Ie=({options:t={},children:e})=>{const{scene:n,camera:r,gl:i}=R.useThree(),{registerBackend:a,unregisterBackend:l}=C(),o=m.useRef(null),d=m.useRef(t);return d.current=t,m.useEffect(()=>{if(o.current)return;let s=!1;return(async()=>{try{const u=J(d.current);if(s)return;await a(u,{scene:n,camera:r,renderer:i}),o.current=u}catch(u){console.error("[GeolocationSession] Failed to initialize:",u)}})(),()=>{s=!0,o.current&&(l(o.current),o.current=null)}},[n,r,i,a,l]),e},ve={front:I.FrontSide,back:I.BackSide,double:I.DoubleSide},Re=({coordinates:t,holes:e,color:n="#ff0000",opacity:r=1,isWireframe:i=!1,side:a="double"})=>{const l=G(),[o]=m.useState(()=>new I.Group),d=m.useMemo(()=>Math.random().toString(36).slice(2,11),[]),[s,f]=m.useState(null);return m.useEffect(()=>{if(!l.isSuccess||t.length<3)return;const[u,c,A=0]=t[0],h=p=>{const[y,L,g=0]=t[0],[w,M]=p.lonLatToWorldCoords(y,L),k=[];for(const[S,E,T=0]of t){const[j,B]=p.lonLatToWorldCoords(S,E);k.push({x:j-w,z:B-M,elev:T-g})}const x=new I.Shape;x.moveTo(k[0].x,k[0].z);for(let S=1;S<k.length;S++)x.lineTo(k[S].x,k[S].z);if(x.closePath(),e&&e.length>0)for(const S of e){if(S.length<3)continue;const E=new I.Path,[T,j]=S[0],[B,Z]=p.lonLatToWorldCoords(T,j);E.moveTo(B-w,Z-M);for(let D=1;D<S.length;D++){const[$,ee]=S[D],[te,ne]=p.lonLatToWorldCoords($,ee);E.lineTo(te-w,ne-M)}E.closePath(),x.holes.push(E)}const O=new I.ShapeGeometry(x),z=k.reduce((S,E)=>S+E.elev,0)/k.length;O.rotateX(-Math.PI/2),f({geometry:O,avgElevation:z})};return l.registerAnchor(d,{anchor:o,isAttached:!1,latitude:c,longitude:u,altitude:A,onAttach:h}),()=>{l.unregisterAnchor(d)}},[l.isSuccess,l.registerAnchor,l.unregisterAnchor,d,o,t,e]),R.createPortal(v.jsx("group",{children:s&&v.jsx("group",{position:[0,s.avgElevation,0],children:v.jsx("mesh",{geometry:s.geometry,children:v.jsx("meshBasicMaterial",{color:n,opacity:r,transparent:r<1,wireframe:i,side:ve[a]})})})}),o)},J=t=>{let e=null,n=null,r=null,i,a=null,l=null,o=null,d=null;const s=new Map;let f=null;const u=c=>{if(!(!e||c.isAttached))try{e.add(c.anchor,c.longitude,c.latitude,c.altitude),c.isAttached=!0,c.onAttach?.(e)}catch(A){console.error("❌ Failed to attach anchor:",A)}};return{type:b.GEOLOCATION,async init(c){const{camera:A,renderer:h,scene:p}=c;if(!p)throw new Error("[geolocationBackend] A THREE.Scene is required for location-based AR");l=A,o=h,d=p,e=new N.LocationBased(p,A),n=new N.Webcam(t?.webcamConstraints??{video:{facingMode:"environment"}}),a=g=>{f=g.position;for(const w of s.values())w.isAttached||u(w),w.onGpsUpdate?.(g.position,g.distMoved);t?.onGpsUpdate?.(g.position,g.distMoved)},e.on("gpsupdate",a),n.on("webcamstarted",g=>{p.background=g.texture}),n.on("webcamerror",g=>{console.error("[geolocationBackend] webcam error:",g)}),r=new N.DeviceOrientationControls(A),r.on("deviceorientationgranted",g=>{g.target?.connect?.()}),r.on("deviceorientationerror",g=>{console.error("[geolocationBackend] Device orientation error:",g)}),r.init?.(),e.on("gpserror",g=>{console.error("[geolocationBackend] gps error:",g)}),e.startGps(),typeof t?.fakeLat=="number"&&typeof t?.fakeLon=="number"&&e.fakeGps(t.fakeLon,t.fakeLat);const y=e.getLastKnownLocation();y!==null&&(f={coords:{longitude:y.longitude,latitude:y.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>y},timestamp:Date.now(),toJSON:()=>y});const L=()=>{if(!o||!l)return;const g=window.innerWidth,w=window.innerHeight;o.setSize(g,w,!1),l.aspect=g/w,l.updateProjectionMatrix?.()};L(),window.addEventListener("resize",L),i=L},update(){r?.update?.()},dispose(){e&&a&&e.off("gpsupdate",a),e?.stopGps?.(),n?.stop?.(),r?.dispose?.(),i&&(window.removeEventListener("resize",i),i=void 0);for(const c of s.values())if(c.isAttached)try{c.anchor.removeFromParent()}catch(A){console.error("⚠️ Error removing anchor:",A)}s.clear(),e=null,n=null,r=null,l=null,o=null,d=null,a=null,f=null},getInternal:()=>({locar:e,webcam:n,deviceOrientation:r,scene:d,camera:l,lastPosition:f,registerAnchor:(c,A)=>{s.set(c,A),f!==null&&!A.isAttached&&(u(A),A.onGpsUpdate?.(f,0))},unregisterAnchor:c=>{const A=s.get(c);if(A?.isAttached)try{A.anchor.removeFromParent()}catch(h){console.error(`⚠️ Error removing anchor ${c}:`,h)}s.delete(c)},getAnchor:c=>s.get(c)})}},Le=()=>({type:b.IMMERSIVE,init:()=>{},getInternal:()=>null}),xe=({children:t})=>{const e=m.useMemo(()=>U.createXRStore(),[]);return m.useEffect(()=>{const n=V(),r=Le();return n.backends.set(b.IMMERSIVE,r),n.setImmersiveStore(e),()=>{n.backends.delete(b.IMMERSIVE),n.setImmersiveStore(null)}},[e]),v.jsx(U.XR,{store:e,children:t})};exports.BACKEND_TYPES=b;exports.FiducialAnchor=be;exports.FiducialSession=we;exports.GeoLine=ke;exports.GeoPolygon=Re;exports.GeolocationAnchor=Ee;exports.GeolocationSession=Ie;exports.ImmersiveSession=xe;exports.XR=Se;exports.createFiducialBackend=Q;exports.createGeolocationBackend=J;exports.getXRStore=V;exports.subscribeToXRStore=he;exports.useFiducialBackend=Y;exports.useGeolocationBackend=G;exports.useXRStore=C;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-7Gy83DEg.cjs`),t=require(`./fiducial-dapuWTXg.cjs`),n=require(`./geolocation-uko8RwgK.cjs`),r=require(`./immersive-8m33PLug.cjs`),i=require(`./magic-DznuBYgG.cjs`);let a=require(`@react-three/fiber`);var o=({children:t})=>{let{updateBackends:n}=e.r();return(0,a.useFrame)((e,t)=>{n(t)}),t};exports.BACKEND_TYPES=e.i,exports.FiducialAnchor=t.r,exports.FiducialSession=t.n,exports.GeoLine=n.a,exports.GeoPolygon=n.n,exports.GeolocationAnchor=n.i,exports.GeolocationSession=n.r,exports.ImmersiveSession=r.t,exports.MagicSession=i.n,exports.WorldAnchor=i.t,exports.XR=o,exports.createFiducialBackend=t.t,exports.createGeolocationBackend=n.t,exports.createMagicBackend=i.r,exports.getXRStore=e.t,exports.subscribeToXRStore=e.n,exports.useFiducialBackend=t.i,exports.useGeolocationBackend=n.o,exports.useXRStore=e.r;
package/build/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export * from './fiducial';
4
4
  export * from './geolocation';
5
5
  export * from './immersive';
6
6
  export { BACKEND_TYPES } from './lib/types/engine';
7
+ export * from './magic';
7
8
  export type { Backend, BackendType, } from './lib/types/engine';
8
9
  export type { ImmersiveMode } from './lib/types/immersive';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EACV,OAAO,EACP,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,SAAS,CAAC;AAExB,YAAY,EACV,OAAO,EACP,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,oBAAoB,CAAC"}