@omnidotdev/rdk 0.12.2 → 0.13.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 (36) hide show
  1. package/build/engine-BBW4dx9u.cjs +1 -0
  2. package/build/engine-DQC0zTpL.js +11 -0
  3. package/build/engine.cjs +1 -0
  4. package/build/engine.d.ts +2 -0
  5. package/build/engine.js +3 -0
  6. package/build/fiducial.cjs +1 -1
  7. package/build/fiducial.js +1 -2
  8. package/build/geolocation/GeoLine.d.ts +14 -1
  9. package/build/geolocation/GeoLine.d.ts.map +1 -1
  10. package/build/geolocation/GeoPolygon.d.ts +14 -1
  11. package/build/geolocation/GeoPolygon.d.ts.map +1 -1
  12. package/build/geolocation/geolocationBackend.d.ts.map +1 -1
  13. package/build/geolocation-D9FbCT8T.cjs +1 -0
  14. package/build/{geolocation-DbT8iR2H.js → geolocation-DCMGm6Xo.js} +81 -79
  15. package/build/geolocation.cjs +1 -1
  16. package/build/geolocation.js +1 -2
  17. package/build/immersive.cjs +1 -1
  18. package/build/immersive.js +1 -2
  19. package/build/index.cjs +1 -1
  20. package/build/index.js +8 -15
  21. package/build/magic/magicBackend.d.ts.map +1 -1
  22. package/build/{magic-DAyR255x.js → magic-DQmRfsb_.js} +33 -39
  23. package/build/magic-Dzl9O3jU.cjs +1 -0
  24. package/build/magic.cjs +1 -1
  25. package/build/magic.js +1 -2
  26. package/build/vision.cjs +1 -1
  27. package/build/vision.js +1 -2
  28. package/package.json +9 -3
  29. package/build/geolocation-BKCHn-Gq.cjs +0 -1
  30. package/build/magic-Brm3MYTP.cjs +0 -1
  31. /package/build/{fiducial-C4M9sMNn.cjs → fiducial-Ccrn4lFL.cjs} +0 -0
  32. /package/build/{fiducial-C7jQpZcK.js → fiducial-DpJVvX22.js} +0 -0
  33. /package/build/{immersive-DZ9J_acN.js → immersive-CR4YCvJ0.js} +0 -0
  34. /package/build/{immersive-ikuE6hTP.cjs → immersive-YdcOrh6T.cjs} +0 -0
  35. /package/build/{vision-DmoN9LKO.cjs → vision-Ci0b3-oF.cjs} +0 -0
  36. /package/build/{vision-Dogx4i9B.js → vision-DPLI9maM.js} +0 -0
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-XWI97jRe.cjs`);let t=require(`@react-three/fiber`);var n=({children:n})=>{let{updateBackends:r}=e.r();return(0,t.useFrame)((e,t)=>{r(t)}),n};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
@@ -0,0 +1,11 @@
1
+ import { r as e } from "./useXRStore-CousLTRl.js";
2
+ import { useFrame as t } from "@react-three/fiber";
3
+ //#region src/engine/XR.tsx
4
+ var n = ({ children: n }) => {
5
+ let { updateBackends: r } = e();
6
+ return t((e, t) => {
7
+ r(t);
8
+ }), n;
9
+ };
10
+ //#endregion
11
+ export { n as t };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-XWI97jRe.cjs`),t=require(`./engine-BBW4dx9u.cjs`);exports.XR=t.t,exports.getXRStore=e.t,exports.subscribeToXRStore=e.n,exports.useXRStore=e.r;
@@ -0,0 +1,2 @@
1
+ export * from './engine/index.js'
2
+ export {}
@@ -0,0 +1,3 @@
1
+ import { n as e, r as t, t as n } from "./useXRStore-CousLTRl.js";
2
+ import { t as r } from "./engine-DQC0zTpL.js";
3
+ export { r as XR, n as getXRStore, e as subscribeToXRStore, t as useXRStore };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-XWI97jRe.cjs`);const e=require(`./fiducial-C4M9sMNn.cjs`);exports.FiducialAnchor=e.r,exports.FiducialSession=e.n,exports.createFiducialBackend=e.t,exports.useFiducialBackend=e.i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./fiducial-Ccrn4lFL.cjs`);exports.FiducialAnchor=e.r,exports.FiducialSession=e.n,exports.createFiducialBackend=e.t,exports.useFiducialBackend=e.i;
package/build/fiducial.js CHANGED
@@ -1,3 +1,2 @@
1
- import "./useXRStore-CousLTRl.js";
2
- import { i as e, n as t, r as n, t as r } from "./fiducial-C7jQpZcK.js";
1
+ import { i as e, n as t, r as n, t as r } from "./fiducial-DpJVvX22.js";
3
2
  export { n as FiducialAnchor, t as FiducialSession, r as createFiducialBackend, e as useFiducialBackend };
@@ -1,3 +1,4 @@
1
+ import { ThreeEvent } from '@react-three/fiber';
1
2
  import { ColorRepresentation } from 'three';
2
3
  export interface GeoLineProps {
3
4
  /** Array of coordinates forming the line. GeoJSON-style: [lon, lat, elevation?] */
@@ -27,6 +28,18 @@ export interface GeoLineProps {
27
28
  * @default 1
28
29
  */
29
30
  gapSize?: number;
31
+ /**
32
+ * Click event handler. When omitted, the line is not registered for pointer raycasting.
33
+ */
34
+ onClick?: (e: ThreeEvent<MouseEvent>) => void;
35
+ /**
36
+ * Pointer out event handler. When omitted, the line is not registered for pointer raycasting.
37
+ */
38
+ onPointerOut?: (e: ThreeEvent<PointerEvent>) => void;
39
+ /**
40
+ * Pointer over event handler. When omitted, the line is not registered for pointer raycasting.
41
+ */
42
+ onPointerOver?: (e: ThreeEvent<PointerEvent>) => void;
30
43
  /**
31
44
  * Opacity
32
45
  * @default 1
@@ -38,6 +51,6 @@ export interface GeoLineProps {
38
51
  * Uses triangle-strip meshes for smooth rendering. Falls back to Line2 when dashing is enabled.
39
52
  * Accepts an array of lon/lat coordinates in GeoJSON-style format.
40
53
  */
41
- declare const GeoLine: ({ coordinates, color, isDashed, dashSize, gapSize, lineWidth, opacity, }: GeoLineProps) => import("react").JSX.Element;
54
+ declare const GeoLine: ({ coordinates, color, isDashed, dashSize, gapSize, lineWidth, onClick, onPointerOut, onPointerOver, opacity, }: GeoLineProps) => import("react").JSX.Element;
42
55
  export default GeoLine;
43
56
  //# sourceMappingURL=GeoLine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeoLine.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoLine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AAE,CAAC,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;IAC9C;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACrD;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;IACtD;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA+DD;;;;GAIG;AACH,QAAA,MAAM,OAAO,GAAI,gHAWd,YAAY,gCAuGd,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { ThreeEvent } from '@react-three/fiber';
1
2
  export interface GeoPolygonProps {
2
3
  /** Outer ring coordinates. GeoJSON-style: [lon, lat, elevation?] */
3
4
  coordinates: Array<[number, number, number?]>;
@@ -20,6 +21,18 @@ export interface GeoPolygonProps {
20
21
  * @default false
21
22
  */
22
23
  isWireframe?: boolean;
24
+ /**
25
+ * Click event handler. When omitted, the polygon is not registered for pointer raycasting.
26
+ */
27
+ onClick?: (e: ThreeEvent<MouseEvent>) => void;
28
+ /**
29
+ * Pointer out event handler. When omitted, the polygon is not registered for pointer raycasting.
30
+ */
31
+ onPointerOut?: (e: ThreeEvent<PointerEvent>) => void;
32
+ /**
33
+ * Pointer over event handler. When omitted, the polygon is not registered for pointer raycasting.
34
+ */
35
+ onPointerOver?: (e: ThreeEvent<PointerEvent>) => void;
23
36
  /**
24
37
  * Side to render: front, back, or double.
25
38
  * @default "double"
@@ -30,6 +43,6 @@ export interface GeoPolygonProps {
30
43
  * Geolocation polygon component for rendering filled areas in AR space.
31
44
  * Accepts an array of lon/lat coordinates in GeoJSON-style format.
32
45
  */
33
- declare const GeoPolygon: ({ coordinates, holes, color, opacity, isWireframe, side, }: GeoPolygonProps) => import("react").JSX.Element;
46
+ declare const GeoPolygon: ({ coordinates, holes, color, opacity, isWireframe, onClick, onPointerOut, onPointerOver, side, }: GeoPolygonProps) => import("react").JSX.Element;
34
47
  export default GeoPolygon;
35
48
  //# sourceMappingURL=GeoPolygon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GeoPolygon.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoPolygon.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;CACpC;AAQD;;;GAGG;AACH,QAAA,MAAM,UAAU,GAAI,4DAOjB,eAAe,gCA6HjB,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"GeoPolygon.d.ts","sourceRoot":"","sources":["../../src/geolocation/GeoPolygon.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9C;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD;;;OAGG;IACH,KAAK,CAAC,E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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,CA0O7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-XWI97jRe.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}=(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=_(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},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=new Map,u=null,d=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)}},f=(e,t)=>{l.set(e,t),u!==null&&!t.isAttached&&(d(t),t.onGpsUpdate?.(u,0))},p=e=>{let t=l.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}l.delete(e)},m=e=>l.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:f,renderer:p,scene:m}=e;if(!m)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);a=f,o=p,s=m,n=new c.App({threeObjects:{camera:f,renderer:p,scene:m},videoConstraints:t?.webcamConstraints??{video:{facingMode:`environment`}},deviceOrientationOptions:{enabled:!0}}),p.setClearAlpha?.(0),i=e=>{u=e.position;for(let t of l.values())t.isAttached||d(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},r=await n.start();let h=n.deviceOrientationControls;if(h&&h.orientationChangeEventName!==`deviceorientation`)try{h.disconnect(),h.orientationChangeEventName=`deviceorientation`,h.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)}),r.startGps(),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`&&r.fakeGps(t.fakeLon,t.fakeLat);let g=r.getLastKnownLocation();g!==null&&(u={coords:{longitude:g.longitude,latitude:g.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>g},timestamp:Date.now(),toJSON:()=>g})},update(){n?.deviceOrientationControls?.update?.()},dispose(){r&&i&&r.off(`gpsupdate`,i),r?.stopGps?.(),n?.webcam?.dispose?.(),o?.setClearAlpha?.(1),n?.deviceOrientationControls?.dispose?.();for(let e of l.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}l.clear(),n=null,r=null,a=null,o=null,s=null,i=null,u=null},getInternal:()=>({locar:r,webcam:n?.webcam??null,deviceOrientation:n?.deviceOrientationControls??null,scene:s,camera:a,lastPosition:u,registerAnchor:f,unregisterAnchor:p,getAnchor:m})}};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 _}});
@@ -38,58 +38,63 @@ var D = {
38
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
39
  let s = new p();
40
40
  return s.setIndex(o), s.setAttribute("position", new f(new Float32Array(r), 3)), s.computeBoundingBox(), s;
41
- }, A = ({ coordinates: e, color: t = "#ff0000", isDashed: n = !1, dashSize: c = 3, gapSize: l = 1, lineWidth: d = 1, opacity: f = 1 }) => {
42
- let p = O(), h = a(p);
43
- h.current = p;
44
- let [y] = o(() => new g()), b = i(() => Math.random().toString(36).slice(2, 11), []), [x, E] = o(null);
41
+ }, A = ({ 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 = O(), x = a(b);
43
+ x.current = b;
44
+ let [E] = o(() => new g()), D = i(() => Math.random().toString(36).slice(2, 11), []), [A, j] = o(null);
45
45
  return r(() => {
46
- if (!p.isSuccess || e.length < 2) return;
46
+ if (!b.isSuccess || e.length < 2) return;
47
47
  let [r, i, a = 0] = e[0];
48
- return h.current.registerAnchor(b, {
49
- anchor: y,
48
+ return x.current.registerAnchor(D, {
49
+ anchor: E,
50
50
  isAttached: !1,
51
51
  latitude: i,
52
52
  longitude: r,
53
53
  altitude: a,
54
54
  onAttach: (r) => {
55
- let [i, a, o = 0] = e[0], [s, u] = r.lonLatToWorldCoords(i, a), p = e.map(([e, t, n = 0]) => {
55
+ let [i, a, o = 0] = e[0], [s, u] = r.lonLatToWorldCoords(i, a), f = e.map(([e, t, n = 0]) => {
56
56
  let [i, a] = r.lonLatToWorldCoords(e, t);
57
57
  return new S(i - s, n - o, a - u);
58
58
  });
59
59
  if (n) {
60
- let e = new C(new w().setFromPoints(p), new T({
60
+ let e = new C(new w().setFromPoints(f), new T({
61
61
  color: t,
62
62
  dashSize: c,
63
63
  gapSize: l,
64
64
  dashed: !0,
65
65
  worldUnits: !0,
66
66
  linewidth: d,
67
- transparent: f < 1,
68
- opacity: f
67
+ transparent: y < 1,
68
+ opacity: y
69
69
  }));
70
- e.computeLineDistances(), E(e);
71
- } else E(new _(k(p, d), new v({
70
+ e.computeLineDistances(), j(e);
71
+ } else j(new _(k(f, d), new v({
72
72
  color: t,
73
- transparent: f < 1,
74
- opacity: f,
73
+ transparent: y < 1,
74
+ opacity: y,
75
75
  side: m
76
76
  })));
77
77
  }
78
78
  }), () => {
79
- h.current.unregisterAnchor(b), E((e) => (e && (e.geometry.dispose(), e.material.dispose()), null));
79
+ x.current.unregisterAnchor(D), j((e) => (e && (e.geometry.dispose(), e.material.dispose()), null));
80
80
  };
81
81
  }, [
82
- b,
83
- y,
82
+ D,
83
+ E,
84
84
  e,
85
85
  t,
86
86
  n,
87
87
  c,
88
88
  l,
89
89
  d,
90
- f,
91
- p.isSuccess
92
- ]), s(/* @__PURE__ */ u("group", { children: x && /* @__PURE__ */ u("primitive", { object: x }) }), y);
90
+ y,
91
+ b.isSuccess
92
+ ]), s(/* @__PURE__ */ u("group", {
93
+ onClick: f,
94
+ onPointerOut: p,
95
+ onPointerOver: h,
96
+ children: A && /* @__PURE__ */ u("primitive", { object: A })
97
+ }), E);
93
98
  }, j = ({ latitude: e, longitude: t, altitude: d = 0, isBillboard: f = !0, onAttach: p, onGpsUpdate: m, children: h }) => {
94
99
  let _ = O(), v = a(_);
95
100
  v.current = _;
@@ -153,15 +158,15 @@ var D = {
153
158
  front: h,
154
159
  back: d,
155
160
  double: m
156
- }, P = ({ coordinates: e, holes: t, color: n = "#ff0000", opacity: c = 1, isWireframe: l = !1, side: d = "double" }) => {
157
- let f = O(), p = a(f);
158
- p.current = f;
159
- let [m] = o(() => new g()), h = i(() => Math.random().toString(36).slice(2, 11), []), [_, v] = o(null);
161
+ }, P = ({ coordinates: e, holes: t, color: n = "#ff0000", opacity: c = 1, isWireframe: l = !1, onClick: d, onPointerOut: f, onPointerOver: p, side: m = "double" }) => {
162
+ let h = O(), _ = a(h);
163
+ _.current = h;
164
+ let [v] = o(() => new g()), S = i(() => Math.random().toString(36).slice(2, 11), []), [C, w] = o(null);
160
165
  return r(() => {
161
- if (!f.isSuccess || e.length < 3) return;
166
+ if (!h.isSuccess || e.length < 3) return;
162
167
  let [n, r, i = 0] = e[0];
163
- return p.current.registerAnchor(h, {
164
- anchor: m,
168
+ return _.current.registerAnchor(S, {
169
+ anchor: v,
165
170
  isAttached: !1,
166
171
  latitude: r,
167
172
  longitude: n,
@@ -190,130 +195,127 @@ var D = {
190
195
  t.closePath(), l.holes.push(t);
191
196
  }
192
197
  let u = new x(l), d = c.reduce((e, t) => e + t.elev, 0) / c.length;
193
- u.rotateX(-Math.PI / 2), v({
198
+ u.rotateX(-Math.PI / 2), w({
194
199
  geometry: u,
195
200
  avgElevation: d
196
201
  });
197
202
  }
198
203
  }), () => {
199
- p.current.unregisterAnchor(h), v((e) => (e && e.geometry.dispose(), null));
204
+ _.current.unregisterAnchor(S), w((e) => (e && e.geometry.dispose(), null));
200
205
  };
201
206
  }, [
202
- h,
203
- m,
207
+ S,
208
+ v,
204
209
  e,
205
210
  t,
206
- f.isSuccess
207
- ]), s(/* @__PURE__ */ u("group", { children: _ && /* @__PURE__ */ u("group", {
211
+ h.isSuccess
212
+ ]), s(/* @__PURE__ */ u("group", { children: C && /* @__PURE__ */ u("group", {
208
213
  position: [
209
214
  0,
210
- _.avgElevation,
215
+ C.avgElevation,
211
216
  0
212
217
  ],
213
218
  children: /* @__PURE__ */ u("mesh", {
214
- geometry: _.geometry,
219
+ geometry: C.geometry,
220
+ onClick: d,
221
+ onPointerOut: f,
222
+ onPointerOver: p,
215
223
  children: /* @__PURE__ */ u("meshBasicMaterial", {
216
224
  color: n,
217
225
  opacity: c,
218
226
  transparent: c < 1,
219
227
  wireframe: l,
220
- side: N[d]
228
+ side: N[m]
221
229
  })
222
230
  })
223
- }) }), m);
231
+ }) }), v);
224
232
  }, F = (t) => {
225
- let n = null, r = null, i, a = null, o = null, s = null, c = null, l = /* @__PURE__ */ new Map(), u = null, d = (e) => {
233
+ let n = null, r = null, i = null, a = null, o = null, s = null, c = /* @__PURE__ */ new Map(), l = null, u = (e) => {
226
234
  if (!(!r || e.isAttached)) try {
227
235
  r.add(e.anchor, e.longitude, e.latitude, e.altitude), e.isAttached = !0, e.onAttach?.(r);
228
236
  } catch (e) {
229
237
  console.error("❌ Failed to attach anchor:", e);
230
238
  }
231
- }, f = (e, t) => {
232
- l.set(e, t), u !== null && !t.isAttached && (d(t), t.onGpsUpdate?.(u, 0));
233
- }, p = (e) => {
234
- let t = l.get(e);
239
+ }, d = (e, t) => {
240
+ c.set(e, t), l !== null && !t.isAttached && (u(t), t.onGpsUpdate?.(l, 0));
241
+ }, f = (e) => {
242
+ let t = c.get(e);
235
243
  if (t?.isAttached) try {
236
244
  t.anchor.removeFromParent();
237
245
  } catch (t) {
238
246
  console.error(`⚠️ Error removing anchor ${e}:`, t);
239
247
  }
240
- l.delete(e);
241
- }, m = (e) => l.get(e);
248
+ c.delete(e);
249
+ }, p = (e) => c.get(e);
242
250
  return {
243
251
  type: e.GEOLOCATION,
244
252
  async init(e) {
245
- let { camera: f, renderer: p, scene: m } = e;
246
- if (!m) throw Error("[geolocationBackend] A THREE.Scene is required for location-based AR");
247
- o = f, s = p, c = m, n = new E({
253
+ let { camera: d, renderer: f, scene: p } = e;
254
+ if (!p) throw Error("[geolocationBackend] A THREE.Scene is required for location-based AR");
255
+ a = d, o = f, s = p, n = new E({
248
256
  threeObjects: {
249
- camera: f,
250
- renderer: p,
251
- scene: m
257
+ camera: d,
258
+ renderer: f,
259
+ scene: p
252
260
  },
253
261
  videoConstraints: t?.webcamConstraints ?? { video: { facingMode: "environment" } },
254
262
  deviceOrientationOptions: { enabled: !0 }
255
- }), p.setClearAlpha?.(0), a = (e) => {
256
- u = e.position;
257
- for (let t of l.values()) t.isAttached || d(t), t.onGpsUpdate?.(e.position, e.distMoved);
263
+ }), f.setClearAlpha?.(0), i = (e) => {
264
+ l = e.position;
265
+ for (let t of c.values()) t.isAttached || u(t), t.onGpsUpdate?.(e.position, e.distMoved);
258
266
  t?.onGpsUpdate?.(e.position, e.distMoved);
259
267
  }, r = await n.start();
260
- let h = n.deviceOrientationControls;
261
- if (h && h.orientationChangeEventName !== "deviceorientation") try {
262
- h.disconnect(), h.orientationChangeEventName = "deviceorientation", h.connect();
268
+ let m = n.deviceOrientationControls;
269
+ if (m && m.orientationChangeEventName !== "deviceorientation") try {
270
+ m.disconnect(), m.orientationChangeEventName = "deviceorientation", m.connect();
263
271
  } catch (e) {
264
272
  console.error("[geolocationBackend] failed to rebind device orientation event:", e);
265
273
  }
266
- r.on("gpsupdate", a), n.webcam?.on?.("webcamerror", (e) => {
274
+ r.on("gpsupdate", i), n.webcam?.on?.("webcamerror", (e) => {
267
275
  console.error("[geolocationBackend] webcam error:", e);
268
276
  }), n.deviceOrientationControls?.on?.("deviceorientationerror", (e) => {
269
277
  console.error("[geolocationBackend] Device orientation error:", e);
270
278
  }), r.on("gpserror", (e) => {
271
279
  console.error("[geolocationBackend] gps error:", e);
272
280
  }), r.startGps(), typeof t?.fakeLat == "number" && typeof t?.fakeLon == "number" && r.fakeGps(t.fakeLon, t.fakeLat);
273
- let g = r.getLastKnownLocation();
274
- g !== null && (u = {
281
+ let h = r.getLastKnownLocation();
282
+ h !== null && (l = {
275
283
  coords: {
276
- longitude: g.longitude,
277
- latitude: g.latitude,
284
+ longitude: h.longitude,
285
+ latitude: h.latitude,
278
286
  accuracy: 0,
279
287
  altitude: null,
280
288
  altitudeAccuracy: null,
281
289
  heading: null,
282
290
  speed: null,
283
- toJSON: () => g
291
+ toJSON: () => h
284
292
  },
285
293
  timestamp: Date.now(),
286
- toJSON: () => g
294
+ toJSON: () => h
287
295
  });
288
- let _ = () => {
289
- if (!s || !o) return;
290
- let e = window.innerWidth, t = window.innerHeight;
291
- s.setSize(e, t, !1), o.aspect = e / t, o.updateProjectionMatrix?.();
292
- };
293
- _(), window.addEventListener("resize", _), i = _;
294
296
  },
295
297
  update() {
296
298
  n?.deviceOrientationControls?.update?.();
297
299
  },
298
300
  dispose() {
299
- r && a && r.off("gpsupdate", a), r?.stopGps?.(), n?.webcam?.dispose?.(), s?.setClearAlpha?.(1), n?.deviceOrientationControls?.dispose?.(), i &&= (window.removeEventListener("resize", i), void 0);
300
- for (let e of l.values()) if (e.isAttached) try {
301
+ r && i && r.off("gpsupdate", i), r?.stopGps?.(), n?.webcam?.dispose?.(), o?.setClearAlpha?.(1), n?.deviceOrientationControls?.dispose?.();
302
+ for (let e of c.values()) if (e.isAttached) try {
301
303
  e.anchor.removeFromParent();
302
304
  } catch (e) {
303
305
  console.error("⚠️ Error removing anchor:", e);
304
306
  }
305
- l.clear(), n = null, r = null, o = null, s = null, c = null, a = null, u = null;
307
+ c.clear(), n = null, r = null, a = null, o = null, s = null, i = null, l = null;
306
308
  },
307
309
  getInternal: () => ({
308
310
  locar: r,
309
311
  webcam: n?.webcam ?? null,
310
312
  deviceOrientation: n?.deviceOrientationControls ?? null,
311
- scene: c,
312
- camera: o,
313
- lastPosition: u,
314
- registerAnchor: f,
315
- unregisterAnchor: p,
316
- getAnchor: m
313
+ scene: s,
314
+ camera: a,
315
+ lastPosition: l,
316
+ registerAnchor: d,
317
+ unregisterAnchor: f,
318
+ getAnchor: p
317
319
  })
318
320
  };
319
321
  };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-XWI97jRe.cjs`);const e=require(`./geolocation-BKCHn-Gq.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./geolocation-D9FbCT8T.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;
@@ -1,3 +1,2 @@
1
- import "./useXRStore-CousLTRl.js";
2
- import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-DbT8iR2H.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-DCMGm6Xo.js";
3
2
  export { e as GeoLine, n as GeoPolygon, t as GeolocationAnchor, i as GeolocationSession, a as createGeolocationBackend, r as useGeolocationBackend };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-XWI97jRe.cjs`);const e=require(`./immersive-ikuE6hTP.cjs`);exports.ImmersiveSession=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./immersive-YdcOrh6T.cjs`);exports.ImmersiveSession=e.t;
@@ -1,3 +1,2 @@
1
- import "./useXRStore-CousLTRl.js";
2
- import { t as e } from "./immersive-DZ9J_acN.js";
1
+ import { t as e } from "./immersive-CR4YCvJ0.js";
3
2
  export { e as ImmersiveSession };
package/build/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-XWI97jRe.cjs`),t=require(`./fiducial-C4M9sMNn.cjs`),n=require(`./geolocation-BKCHn-Gq.cjs`),r=require(`./immersive-ikuE6hTP.cjs`),i=require(`./magic-Brm3MYTP.cjs`),a=require(`./vision-DmoN9LKO.cjs`);let o=require(`@react-three/fiber`);var s=({children:t})=>{let{updateBackends:n}=e.r();return(0,o.useFrame)((e,t)=>{n(t)}),t};exports.BACKEND_TYPES=e.i,exports.COCO_LABELS=a.c,exports.CameraBackground=a.C,exports.DEFAULT_GESTURES=a._,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.HandTracker=a.f,exports.ImmersiveSession=r.t,exports.MagicSession=i.n,exports.VisionAnchor=a.o,exports.VisionDebug=a.a,exports.VisionOverlay=a.t,exports.VisionSession=a.r,exports.VisionStatus=a.n,exports.WorldAnchor=i.t,exports.XR=s,exports.createFiducialBackend=t.t,exports.createGeolocationBackend=n.t,exports.createMagicBackend=i.r,exports.createVisionBackend=a.i,exports.detectGesture=a.g,exports.fist=a.v,exports.getXRStore=e.t,exports.landmarkToWorld=a.m,exports.landmarksCentroid=a.h,exports.ok=a.y,exports.openHand=a.b,exports.peace=a.x,exports.rfDetr=a.l,exports.subscribeToXRStore=e.n,exports.thumbsUp=a.S,exports.useFiducialBackend=t.i,exports.useGeolocationBackend=n.o,exports.useVisionBackend=a.p,exports.useVisionFrame=a.s,exports.useXRStore=e.r,exports.yolo=a.u,exports.yoloSeg=a.d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-XWI97jRe.cjs`),t=require(`./engine-BBW4dx9u.cjs`),n=require(`./fiducial-Ccrn4lFL.cjs`),r=require(`./geolocation-D9FbCT8T.cjs`),i=require(`./immersive-YdcOrh6T.cjs`),a=require(`./magic-Dzl9O3jU.cjs`),o=require(`./vision-Ci0b3-oF.cjs`);require(`@react-three/fiber`),exports.BACKEND_TYPES=e.i,exports.COCO_LABELS=o.c,exports.CameraBackground=o.C,exports.DEFAULT_GESTURES=o._,exports.FiducialAnchor=n.r,exports.FiducialSession=n.n,exports.GeoLine=r.a,exports.GeoPolygon=r.n,exports.GeolocationAnchor=r.i,exports.GeolocationSession=r.r,exports.HandTracker=o.f,exports.ImmersiveSession=i.t,exports.MagicSession=a.n,exports.VisionAnchor=o.o,exports.VisionDebug=o.a,exports.VisionOverlay=o.t,exports.VisionSession=o.r,exports.VisionStatus=o.n,exports.WorldAnchor=a.t,exports.XR=t.t,exports.createFiducialBackend=n.t,exports.createGeolocationBackend=r.t,exports.createMagicBackend=a.r,exports.createVisionBackend=o.i,exports.detectGesture=o.g,exports.fist=o.v,exports.getXRStore=e.t,exports.landmarkToWorld=o.m,exports.landmarksCentroid=o.h,exports.ok=o.y,exports.openHand=o.b,exports.peace=o.x,exports.rfDetr=o.l,exports.subscribeToXRStore=e.n,exports.thumbsUp=o.S,exports.useFiducialBackend=n.i,exports.useGeolocationBackend=r.o,exports.useVisionBackend=o.p,exports.useVisionFrame=o.s,exports.useXRStore=e.r,exports.yolo=o.u,exports.yoloSeg=o.d;
package/build/index.js CHANGED
@@ -1,16 +1,9 @@
1
1
  import { i as e, n as t, r as n, t as r } from "./useXRStore-CousLTRl.js";
2
- import { i, n as a, r as o, t as s } from "./fiducial-C7jQpZcK.js";
3
- import { a as c, i as l, n as u, o as d, r as f, t as p } from "./geolocation-DbT8iR2H.js";
4
- import { t as m } from "./immersive-DZ9J_acN.js";
5
- import { n as h, r as g, t as _ } from "./magic-DAyR255x.js";
6
- import { C as v, S as y, _ as b, a as x, b as S, c as C, d as w, f as T, g as E, h as D, i as O, l as k, m as A, n as j, o as M, p as N, r as P, s as F, t as I, u as L, v as R, x as z, y as B } from "./vision-Dogx4i9B.js";
7
- import { useFrame as V } from "@react-three/fiber";
8
- //#region src/engine/XR.tsx
9
- var H = ({ children: e }) => {
10
- let { updateBackends: t } = n();
11
- return V((e, n) => {
12
- t(n);
13
- }), e;
14
- };
15
- //#endregion
16
- export { e as BACKEND_TYPES, C as COCO_LABELS, v as CameraBackground, b as DEFAULT_GESTURES, o as FiducialAnchor, a as FiducialSession, c as GeoLine, u as GeoPolygon, l as GeolocationAnchor, f as GeolocationSession, T as HandTracker, m as ImmersiveSession, h as MagicSession, M as VisionAnchor, x as VisionDebug, I as VisionOverlay, P as VisionSession, j as VisionStatus, _ as WorldAnchor, H as XR, s as createFiducialBackend, p as createGeolocationBackend, g as createMagicBackend, O as createVisionBackend, E as detectGesture, R as fist, r as getXRStore, A as landmarkToWorld, D as landmarksCentroid, B as ok, S as openHand, z as peace, k as rfDetr, t as subscribeToXRStore, y as thumbsUp, i as useFiducialBackend, d as useGeolocationBackend, N as useVisionBackend, F as useVisionFrame, n as useXRStore, L as yolo, w as yoloSeg };
2
+ import { t as i } from "./engine-DQC0zTpL.js";
3
+ import { i as a, n as o, r as s, t as c } from "./fiducial-DpJVvX22.js";
4
+ import { a as l, i as u, n as d, o as f, r as p, t as m } from "./geolocation-DCMGm6Xo.js";
5
+ import { t as h } from "./immersive-CR4YCvJ0.js";
6
+ import { n as g, r as _, t as v } from "./magic-DQmRfsb_.js";
7
+ import { C as y, S as b, _ as x, a as S, b as C, c as w, d as T, f as E, g as D, h as O, i as k, l as A, m as j, n as M, o as N, p as P, r as F, s as I, t as L, u as R, v as z, x as B, y as V } from "./vision-DPLI9maM.js";
8
+ import "@react-three/fiber";
9
+ export { e as BACKEND_TYPES, w as COCO_LABELS, y as CameraBackground, x as DEFAULT_GESTURES, s as FiducialAnchor, o as FiducialSession, l as GeoLine, d as GeoPolygon, u as GeolocationAnchor, p as GeolocationSession, E as HandTracker, h as ImmersiveSession, g as MagicSession, N as VisionAnchor, S as VisionDebug, L as VisionOverlay, F as VisionSession, M as VisionStatus, v as WorldAnchor, i as XR, c as createFiducialBackend, m as createGeolocationBackend, _ as createMagicBackend, k as createVisionBackend, D as detectGesture, z as fist, r as getXRStore, j as landmarkToWorld, O as landmarksCentroid, V as ok, C as openHand, B as peace, A as rfDetr, t as subscribeToXRStore, b as thumbsUp, a as useFiducialBackend, f as useGeolocationBackend, P as useVisionBackend, I as useVisionFrame, n as useXRStore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UAAU,mBAAmB,KAC5B,OAAO,CAAC,aAAa,CAgZvB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -5,41 +5,41 @@ import { jsx as o } from "react/jsx-runtime";
5
5
  import * as s from "three";
6
6
  //#region src/magic/magicBackend.ts
7
7
  var c = .15, l = .5, u = (t) => {
8
- let n = null, r = null, i = null, a, o = t?.enableOrientation ?? !0, u = !1, d = t?.enableWorldAnchoring ?? !0, f = null, p = null, m = t?.smoothingFactor ?? c, h = t?.deadZone ?? l, g = {
8
+ let n = null, r = null, i = null, a = t?.enableOrientation ?? !0, o = !1, u = t?.enableWorldAnchoring ?? !0, d = null, f = null, p = t?.smoothingFactor ?? c, m = t?.deadZone ?? l, h = {
9
9
  alpha: 0,
10
10
  beta: 0,
11
11
  gamma: 0
12
- }, _ = {
12
+ }, g = {
13
13
  alpha: 0,
14
14
  beta: 0,
15
15
  gamma: 0
16
- }, v = {
16
+ }, _ = {
17
17
  alpha: 0,
18
18
  beta: 0,
19
19
  gamma: 0
20
- }, y = !1, b = null, x = null, S = null, C = new s.Quaternion(), w = new s.Quaternion(), T = new s.Euler(), E = new s.Quaternion(), D = new s.Quaternion(-Math.sqrt(.5), 0, 0, Math.sqrt(.5)), O = new s.Vector3(0, 0, 1), k = new s.Quaternion(), A = new s.Quaternion(), j = (e, t, n, r) => {
20
+ }, v = !1, y = null, b = null, x = new s.Quaternion(), S = new s.Quaternion(), C = new s.Euler(), w = new s.Quaternion(), T = new s.Quaternion(-Math.sqrt(.5), 0, 0, Math.sqrt(.5)), E = new s.Vector3(0, 0, 1), D = new s.Quaternion(), O = new s.Quaternion(), k = (e, t, n, r) => {
21
21
  let i = (screen.orientation?.angle ?? 0) * Math.PI / 180;
22
- T.set(n, t, -r, "YXZ"), e.setFromEuler(T), e.multiply(D), e.multiply(E.setFromAxisAngle(O, -i));
23
- }, M = (e, t) => {
22
+ C.set(n, t, -r, "YXZ"), e.setFromEuler(C), e.multiply(T), e.multiply(w.setFromAxisAngle(E, -i));
23
+ }, A = (e, t) => {
24
24
  let n = (t - e) % 360 + 360;
25
25
  return n = (n + 180) % 360 - 180, n;
26
- }, N = (e, t, n = !1) => Math.abs(n ? M(e, t) : t - e) < h ? e : t, P = (e, t, n) => e + (t - e) * n, F = (e, t, n) => ((e + M(e, t) * n) % 360 + 360) % 360, I = async () => {
26
+ }, 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 () => {
27
27
  let e = DeviceOrientationEvent;
28
28
  if (typeof e.requestPermission == "function") try {
29
- return await e.requestPermission() === "granted" ? (u = !0, !0) : (console.warn("[MagicBackend] Device orientation permission denied"), !1);
29
+ return await e.requestPermission() === "granted" ? (o = !0, !0) : (console.warn("[MagicBackend] Device orientation permission denied"), !1);
30
30
  } catch (e) {
31
31
  return console.error("[MagicBackend] Error requesting orientation permission:", e), !1;
32
32
  }
33
- return u = !0, !0;
34
- }, L = () => {
35
- f = (e) => {
36
- if (g.alpha = e.alpha ?? 0, g.beta = e.beta ?? 0, g.gamma = e.gamma ?? 0, !y && (g.alpha !== 0 || g.beta !== 0 || g.gamma !== 0)) {
37
- v.alpha = g.alpha, v.beta = g.beta, v.gamma = g.gamma;
33
+ return o = !0, !0;
34
+ }, F = () => {
35
+ d = (e) => {
36
+ 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)) {
37
+ _.alpha = h.alpha, _.beta = h.beta, _.gamma = h.gamma;
38
38
  let { degToRad: e } = s.MathUtils;
39
- j(k, e(g.alpha), e(g.beta), e(g.gamma)), A.copy(k).invert(), y = !0;
39
+ k(D, e(h.alpha), e(h.beta), e(h.gamma)), O.copy(D).invert(), v = !0;
40
40
  }
41
- }, window.addEventListener("deviceorientation", f, !0);
42
- }, R = async (e, a) => {
41
+ }, window.addEventListener("deviceorientation", d, !0);
42
+ }, I = async (e, a) => {
43
43
  let o = t?.webcamConstraints ?? { video: { facingMode: "environment" } };
44
44
  try {
45
45
  i = await navigator.mediaDevices.getUserMedia(o);
@@ -51,49 +51,43 @@ var c = .15, l = .5, u = (t) => {
51
51
  return {
52
52
  type: e.MAGIC,
53
53
  async init({ scene: e, camera: t, renderer: n }) {
54
- if (b = t, x = n, S = e, await R(e, n), o) if (await I()) L();
54
+ if (y = t, b = e, await I(e, n), a) if (await P()) F();
55
55
  else {
56
56
  let e = async () => {
57
- document.removeEventListener("click", e), document.removeEventListener("touchend", e), p = null, await I() && L();
57
+ document.removeEventListener("click", e), document.removeEventListener("touchend", e), f = null, await P() && F();
58
58
  };
59
- p = e, document.addEventListener("click", e), document.addEventListener("touchend", e);
59
+ f = e, document.addEventListener("click", e), document.addEventListener("touchend", e);
60
60
  }
61
- let r = () => {
62
- if (!x || !b) return;
63
- let e = window.innerWidth, t = window.innerHeight;
64
- x.setSize(e, t, !1), b.aspect = e / t, b.updateProjectionMatrix?.();
65
- };
66
- r(), window.addEventListener("resize", r), a = r;
67
61
  },
68
62
  update() {
69
- if (!o || !u) return;
70
- let e = N(_.alpha, g.alpha, !0), t = N(_.beta, g.beta), n = N(_.gamma, g.gamma);
71
- if (_.alpha = F(_.alpha, e, m), _.beta = P(_.beta, t, m), _.gamma = P(_.gamma, n, m), d && b && y) {
63
+ if (!a || !o) return;
64
+ let e = j(g.alpha, h.alpha, !0), t = j(g.beta, h.beta), n = j(g.gamma, h.gamma);
65
+ 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) {
72
66
  let { degToRad: e } = s.MathUtils;
73
- j(C, e(g.alpha), e(g.beta), e(g.gamma)), w.copy(A).multiply(C), b.quaternion.slerp(w, m);
67
+ k(x, e(h.alpha), e(h.beta), e(h.gamma)), S.copy(O).multiply(x), y.quaternion.slerp(S, p);
74
68
  }
75
69
  r && (r.needsUpdate = !0);
76
70
  },
77
71
  dispose() {
78
- if (f &&= (window.removeEventListener("deviceorientation", f), null), p &&= (document.removeEventListener("click", p), document.removeEventListener("touchend", p), null), a &&= (window.removeEventListener("resize", a), void 0), i) {
72
+ if (d &&= (window.removeEventListener("deviceorientation", d), null), f &&= (document.removeEventListener("click", f), document.removeEventListener("touchend", f), null), i) {
79
73
  for (let e of i.getTracks()) e.stop();
80
74
  i = null;
81
75
  }
82
- n &&= (n.pause(), n.srcObject = null, n.parentNode?.removeChild(n), null), r &&= (r.dispose(), null), S && (S.background = null), b = null, x = null, S = null, o = !1, u = !1, d = !1, y = !1, _.alpha = 0, _.beta = 0, _.gamma = 0, g.alpha = 0, g.beta = 0, g.gamma = 0, v.alpha = 0, v.beta = 0, v.gamma = 0, k.identity(), A.identity();
76
+ n &&= (n.pause(), n.srcObject = null, n.parentNode?.removeChild(n), null), r &&= (r.dispose(), null), b && (b.background = null), y = null, b = null, a = !1, o = !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();
83
77
  },
84
78
  getInternal: () => ({
85
79
  videoElement: n,
86
80
  videoTexture: r,
87
81
  stream: i,
88
- orientationEnabled: o,
89
- orientationPermissionGranted: u,
90
- worldAnchoringEnabled: d,
91
- currentOrientation: { ..._ },
92
- initialOrientation: { ...v },
93
- hasInitialOrientation: y,
82
+ orientationEnabled: a,
83
+ orientationPermissionGranted: o,
84
+ worldAnchoringEnabled: u,
85
+ currentOrientation: { ...g },
86
+ initialOrientation: { ..._ },
87
+ hasInitialOrientation: v,
94
88
  requestOrientationPermission: async () => {
95
- let e = await I();
96
- return e && !f && L(), e;
89
+ let e = await P();
90
+ return e && !d && F(), e;
97
91
  }
98
92
  })
99
93
  };
@@ -0,0 +1 @@
1
+ const e=require(`./useXRStore-XWI97jRe.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}=(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=s(f.current);if(e)return;await l(t,{scene:a,camera:o,renderer:c}),d.current=t}catch(e){console.error(`[MagicSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,c,l,u]),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}});
package/build/magic.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-XWI97jRe.cjs`);const e=require(`./magic-Brm3MYTP.cjs`);exports.MagicSession=e.n,exports.WorldAnchor=e.t,exports.createMagicBackend=e.r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./magic-Dzl9O3jU.cjs`);exports.MagicSession=e.n,exports.WorldAnchor=e.t,exports.createMagicBackend=e.r;
package/build/magic.js CHANGED
@@ -1,3 +1,2 @@
1
- import "./useXRStore-CousLTRl.js";
2
- import { n as e, r as t, t as n } from "./magic-DAyR255x.js";
1
+ import { n as e, r as t, t as n } from "./magic-DQmRfsb_.js";
3
2
  export { e as MagicSession, n as WorldAnchor, t as createMagicBackend };
package/build/vision.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-XWI97jRe.cjs`);const e=require(`./vision-DmoN9LKO.cjs`);exports.COCO_LABELS=e.c,exports.CameraBackground=e.C,exports.DEFAULT_GESTURES=e._,exports.HandTracker=e.f,exports.VisionAnchor=e.o,exports.VisionDebug=e.a,exports.VisionOverlay=e.t,exports.VisionSession=e.r,exports.VisionStatus=e.n,exports.createVisionBackend=e.i,exports.detectGesture=e.g,exports.fist=e.v,exports.landmarkToWorld=e.m,exports.landmarksCentroid=e.h,exports.ok=e.y,exports.openHand=e.b,exports.peace=e.x,exports.rfDetr=e.l,exports.thumbsUp=e.S,exports.useVisionBackend=e.p,exports.useVisionFrame=e.s,exports.yolo=e.u,exports.yoloSeg=e.d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./vision-Ci0b3-oF.cjs`);exports.COCO_LABELS=e.c,exports.CameraBackground=e.C,exports.DEFAULT_GESTURES=e._,exports.HandTracker=e.f,exports.VisionAnchor=e.o,exports.VisionDebug=e.a,exports.VisionOverlay=e.t,exports.VisionSession=e.r,exports.VisionStatus=e.n,exports.createVisionBackend=e.i,exports.detectGesture=e.g,exports.fist=e.v,exports.landmarkToWorld=e.m,exports.landmarksCentroid=e.h,exports.ok=e.y,exports.openHand=e.b,exports.peace=e.x,exports.rfDetr=e.l,exports.thumbsUp=e.S,exports.useVisionBackend=e.p,exports.useVisionFrame=e.s,exports.yolo=e.u,exports.yoloSeg=e.d;
package/build/vision.js CHANGED
@@ -1,3 +1,2 @@
1
- import "./useXRStore-CousLTRl.js";
2
- import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, x, y as S } from "./vision-Dogx4i9B.js";
1
+ import { C as e, S as t, _ as n, a as r, b as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, x, y as S } from "./vision-DPLI9maM.js";
3
2
  export { a as COCO_LABELS, e as CameraBackground, n as DEFAULT_GESTURES, s as HandTracker, m as VisionAnchor, r as VisionDebug, v as VisionOverlay, g as VisionSession, p as VisionStatus, u as createVisionBackend, c as detectGesture, b as fist, f as landmarkToWorld, l as landmarksCentroid, S as ok, i as openHand, x as peace, d as rfDetr, t as thumbsUp, h as useVisionBackend, _ as useVisionFrame, y as yolo, o as yoloSeg };
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@omnidotdev/rdk",
3
3
  "description": "Reality Development Kit, a unified React-first XR engine",
4
- "version": "0.12.2",
4
+ "version": "0.13.0",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
+ "sideEffects": false,
7
8
  "main": "build/index.js",
8
9
  "module": "build/index.js",
9
10
  "types": "build/index.d.ts",
@@ -35,6 +36,11 @@
35
36
  "import": "./build/index.js",
36
37
  "require": "./build/index.cjs"
37
38
  },
39
+ "./engine": {
40
+ "types": "./build/engine.d.ts",
41
+ "import": "./build/engine.js",
42
+ "require": "./build/engine.cjs"
43
+ },
38
44
  "./fiducial": {
39
45
  "types": "./build/fiducial.d.ts",
40
46
  "import": "./build/fiducial.js",
@@ -104,14 +110,14 @@
104
110
  "@biomejs/biome": "^2.4.8",
105
111
  "@mediapipe/tasks-vision": "^0.10.35",
106
112
  "@react-three/fiber": "^9.5.0",
107
- "@testing-library/jest-dom": "^6.9.1",
113
+ "@testing-library/jest-dom": "^7.0.0",
108
114
  "@testing-library/react": "^16.3.1",
109
115
  "@types/node": "^26.0.0",
110
116
  "@types/react": "^19.2.7",
111
117
  "@types/react-dom": "^19.2.3",
112
118
  "@types/three": "^0.185.0",
113
119
  "@typescript/typescript6": "^6.0.2",
114
- "jsdom": "^29.0.0",
120
+ "jsdom": "^30.0.0",
115
121
  "locar": "^0.2.7",
116
122
  "onnxruntime-web": "^1.27.0",
117
123
  "react": "^19.2.3",
@@ -1 +0,0 @@
1
- const e=require(`./useXRStore-XWI97jRe.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,opacity:h=1})=>{let g=u(),_=(0,t.useRef)(g);_.current=g;let[v]=(0,t.useState)(()=>new i.Group),y=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[b,x]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!g.isSuccess||e.length<2)return;let[t,n,r=0]=e[0];return _.current.registerAnchor(y,{anchor:v,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,u=0]=e[0],[g,_]=t.lonLatToWorldCoords(n,r),v=e.map(([e,n,r=0])=>{let[a,o]=t.lonLatToWorldCoords(e,n);return new i.Vector3(a-g,r-u,o-_)});if(l){let e=new a.Line2(new o.LineGeometry().setFromPoints(v),new s.LineMaterial({color:c,dashSize:f,gapSize:p,dashed:!0,worldUnits:!0,linewidth:m,transparent:h<1,opacity:h}));e.computeLineDistances(),x(e)}else x(new i.Mesh(d(v,m),new i.MeshBasicMaterial({color:c,transparent:h<1,opacity:h,side:i.DoubleSide})))}}),()=>{_.current.unregisterAnchor(y),x(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[y,v,e,c,l,f,p,m,h,g.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:b&&(0,r.jsx)(`primitive`,{object:b})}),v)},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}=(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=_(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},h={front:i.FrontSide,back:i.BackSide,double:i.DoubleSide},g=({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),m=(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(m,{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(m),_(e=>(e&&e.geometry.dispose(),null))}},[m,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:h[l]})})})}),p)},_=t=>{let n=null,r=null,i,a=null,o=null,s=null,l=null,u=new Map,d=null,f=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)}},p=(e,t)=>{u.set(e,t),d!==null&&!t.isAttached&&(f(t),t.onGpsUpdate?.(d,0))},m=e=>{let t=u.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}u.delete(e)},h=e=>u.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:p,renderer:m,scene:h}=e;if(!h)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);o=p,s=m,l=h,n=new c.App({threeObjects:{camera:p,renderer:m,scene:h},videoConstraints:t?.webcamConstraints??{video:{facingMode:`environment`}},deviceOrientationOptions:{enabled:!0}}),m.setClearAlpha?.(0),a=e=>{d=e.position;for(let t of u.values())t.isAttached||f(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},r=await n.start();let g=n.deviceOrientationControls;if(g&&g.orientationChangeEventName!==`deviceorientation`)try{g.disconnect(),g.orientationChangeEventName=`deviceorientation`,g.connect()}catch(e){console.error(`[geolocationBackend] failed to rebind device orientation event:`,e)}r.on(`gpsupdate`,a),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)}),r.startGps(),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`&&r.fakeGps(t.fakeLon,t.fakeLat);let _=r.getLastKnownLocation();_!==null&&(d={coords:{longitude:_.longitude,latitude:_.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>_},timestamp:Date.now(),toJSON:()=>_});let v=()=>{if(!s||!o)return;let e=window.innerWidth,t=window.innerHeight;s.setSize(e,t,!1),o.aspect=e/t,o.updateProjectionMatrix?.()};v(),window.addEventListener(`resize`,v),i=v},update(){n?.deviceOrientationControls?.update?.()},dispose(){r&&a&&r.off(`gpsupdate`,a),r?.stopGps?.(),n?.webcam?.dispose?.(),s?.setClearAlpha?.(1),n?.deviceOrientationControls?.dispose?.(),i&&=(window.removeEventListener(`resize`,i),void 0);for(let e of u.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}u.clear(),n=null,r=null,o=null,s=null,l=null,a=null,d=null},getInternal:()=>({locar:r,webcam:n?.webcam??null,deviceOrientation:n?.deviceOrientationControls??null,scene:l,camera:o,lastPosition:d,registerAnchor:p,unregisterAnchor:m,getAnchor:h})}};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-XWI97jRe.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,l=t?.enableOrientation??!0,u=!1,d=t?.enableWorldAnchoring??!0,f=null,p=null,m=t?.smoothingFactor??a,h=t?.deadZone??o,g={alpha:0,beta:0,gamma:0},_={alpha:0,beta:0,gamma:0},v={alpha:0,beta:0,gamma:0},y=!1,b=null,x=null,S=null,C=new i.Quaternion,w=new i.Quaternion,T=new i.Euler,E=new i.Quaternion,D=new i.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),O=new i.Vector3(0,0,1),k=new i.Quaternion,A=new i.Quaternion,j=(e,t,n,r)=>{let i=(screen.orientation?.angle??0)*Math.PI/180;T.set(n,t,-r,`YXZ`),e.setFromEuler(T),e.multiply(D),e.multiply(E.setFromAxisAngle(O,-i))},M=(e,t)=>{let n=(t-e)%360+360;return n=(n+180)%360-180,n},N=(e,t,n=!1)=>Math.abs(n?M(e,t):t-e)<h?e:t,P=(e,t,n)=>e+(t-e)*n,F=(e,t,n)=>((e+M(e,t)*n)%360+360)%360,I=async()=>{let e=DeviceOrientationEvent;if(typeof e.requestPermission==`function`)try{return await e.requestPermission()===`granted`?(u=!0,!0):(console.warn(`[MagicBackend] Device orientation permission denied`),!1)}catch(e){return console.error(`[MagicBackend] Error requesting orientation permission:`,e),!1}return u=!0,!0},L=()=>{f=e=>{if(g.alpha=e.alpha??0,g.beta=e.beta??0,g.gamma=e.gamma??0,!y&&(g.alpha!==0||g.beta!==0||g.gamma!==0)){v.alpha=g.alpha,v.beta=g.beta,v.gamma=g.gamma;let{degToRad:e}=i.MathUtils;j(k,e(g.alpha),e(g.beta),e(g.gamma)),A.copy(k).invert(),y=!0}},window.addEventListener(`deviceorientation`,f,!0)},R=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(b=t,x=n,S=e,await R(e,n),l)if(await I())L();else{let e=async()=>{document.removeEventListener(`click`,e),document.removeEventListener(`touchend`,e),p=null,await I()&&L()};p=e,document.addEventListener(`click`,e),document.addEventListener(`touchend`,e)}let r=()=>{if(!x||!b)return;let e=window.innerWidth,t=window.innerHeight;x.setSize(e,t,!1),b.aspect=e/t,b.updateProjectionMatrix?.()};r(),window.addEventListener(`resize`,r),c=r},update(){if(!l||!u)return;let e=N(_.alpha,g.alpha,!0),t=N(_.beta,g.beta),n=N(_.gamma,g.gamma);if(_.alpha=F(_.alpha,e,m),_.beta=P(_.beta,t,m),_.gamma=P(_.gamma,n,m),d&&b&&y){let{degToRad:e}=i.MathUtils;j(C,e(g.alpha),e(g.beta),e(g.gamma)),w.copy(A).multiply(C),b.quaternion.slerp(w,m)}r&&(r.needsUpdate=!0)},dispose(){if(f&&=(window.removeEventListener(`deviceorientation`,f),null),p&&=(document.removeEventListener(`click`,p),document.removeEventListener(`touchend`,p),null),c&&=(window.removeEventListener(`resize`,c),void 0),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),S&&(S.background=null),b=null,x=null,S=null,l=!1,u=!1,d=!1,y=!1,_.alpha=0,_.beta=0,_.gamma=0,g.alpha=0,g.beta=0,g.gamma=0,v.alpha=0,v.beta=0,v.gamma=0,k.identity(),A.identity()},getInternal:()=>({videoElement:n,videoTexture:r,stream:s,orientationEnabled:l,orientationPermissionGranted:u,worldAnchoringEnabled:d,currentOrientation:{..._},initialOrientation:{...v},hasInitialOrientation:y,requestOrientationPermission:async()=>{let e=await I();return e&&!f&&L(),e}})}},c=({options:r={},children:i})=>{let{scene:a,camera:o,gl: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=s(f.current);if(e)return;await l(t,{scene:a,camera:o,renderer:c}),d.current=t}catch(e){console.error(`[MagicSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,c,l,u]),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}});