@omnidotdev/rdk 0.14.0 → 0.14.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.
@@ -1 +1 @@
1
- {"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,OAAO,CAAC;AAInC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EAEL,KAAK,EAEN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,oBAAoB,CAAC;AAEnE;;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,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG;IAC/C,OAAO,EAAE,CAAC,OAAO,EAAE,IAAI,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;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mB,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,2KAA2K;IAC3K,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;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,kBAAkB,CAAC,mBAAmB,CA2PxC,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -279,34 +279,27 @@ var O = {
279
279
  d = e.position;
280
280
  for (let t of u.values()) t.isAttached || f(t), t.onGpsUpdate?.(e.position, e.distMoved);
281
281
  t?.onGpsUpdate?.(e.position, e.distMoved);
282
- }, r = await n.start();
283
- let v = n.deviceOrientationControls;
284
- if (v && v.orientationChangeEventName !== "deviceorientation") try {
285
- v.disconnect(), v.orientationChangeEventName = "deviceorientation", v.connect();
286
- } catch (e) {
287
- console.error("[geolocationBackend] failed to rebind device orientation event:", e);
288
- }
289
- r.on("gpsupdate", i), n.webcam?.on?.("webcamerror", (e) => {
282
+ }, r = await n.start(), r.on("gpsupdate", i), n.webcam?.on?.("webcamerror", (e) => {
290
283
  console.error("[geolocationBackend] webcam error:", e);
291
284
  }), n.deviceOrientationControls?.on?.("deviceorientationerror", (e) => {
292
285
  console.error("[geolocationBackend] Device orientation error:", e);
293
286
  }), r.on("gpserror", (e) => {
294
287
  console.error("[geolocationBackend] gps error:", e);
295
288
  }), typeof t?.fakeLat == "number" && typeof t?.fakeLon == "number" ? r.fakeGps(t.fakeLon, t.fakeLat) : r.startGps();
296
- let y = r.getLastKnownLocation();
297
- y !== null && (d = {
289
+ let v = r.getLastKnownLocation();
290
+ v !== null && (d = {
298
291
  coords: {
299
- longitude: y.longitude,
300
- latitude: y.latitude,
292
+ longitude: v.longitude,
293
+ latitude: v.latitude,
301
294
  accuracy: 0,
302
295
  altitude: null,
303
296
  altitudeAccuracy: null,
304
297
  heading: null,
305
298
  speed: null,
306
- toJSON: () => y
299
+ toJSON: () => v
307
300
  },
308
301
  timestamp: Date.now(),
309
- toJSON: () => y
302
+ toJSON: () => v
310
303
  });
311
304
  },
312
305
  update() {
@@ -1 +1 @@
1
- const e=require(`./useXRStore-Cf_XL0aI.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`react/jsx-runtime`),i=require(`three`),a=require(`three/addons/lines/Line2.js`),o=require(`three/addons/lines/LineGeometry.js`),s=require(`three/addons/lines/LineMaterial.js`),c=require(`locar`);var l={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>void 0},u=()=>{let t=e.r(e=>e.backends).get(e.i.GEOLOCATION);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:l},d=(e,t)=>{let n=e.length-1,r=[],a=0,o=0;for(let i=0;i<n;i++){let n=e[i+1].x-e[i].x,s=e[i+1].y-e[i].y,c=e[i+1].z-e[i].z,l=Math.sqrt(n*n+s*s+c*c),u=t/2,d=-(c*u)/l,f=n*u/l,p=i>0?(d+a)/2:d,m=i>0?(f+o)/2:f;r.push(e[i].x-p,e[i].y,e[i].z-m,e[i].x+p,e[i].y,e[i].z+m),a=d,o=f}r.push(e[n].x-a,e[n].y,e[n].z-o,e[n].x+a,e[n].y,e[n].z+o);let s=[];for(let e=0;e<n;e++)s.push(e*2,e*2+1,e*2+2),s.push(e*2+1,e*2+3,e*2+2);let c=new i.BufferGeometry;return c.setIndex(s),c.setAttribute(`position`,new i.BufferAttribute(new Float32Array(r),3)),c.computeBoundingBox(),c},f=({coordinates:e,color:c=`#ff0000`,isDashed:l=!1,dashSize:f=3,gapSize:p=1,lineWidth:m=1,onClick:h,onPointerOut:g,onPointerOver:_,opacity:v=1})=>{let y=u(),b=(0,t.useRef)(y);b.current=y;let[x]=(0,t.useState)(()=>new i.Group),S=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[C,w]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!y.isSuccess||e.length<2)return;let[t,n,r=0]=e[0];return b.current.registerAnchor(S,{anchor:x,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,u=0]=e[0],[h,g]=t.lonLatToWorldCoords(n,r),_=e.map(([e,n,r=0])=>{let[a,o]=t.lonLatToWorldCoords(e,n);return new i.Vector3(a-h,r-u,o-g)});if(l){let e=new a.Line2(new o.LineGeometry().setFromPoints(_),new s.LineMaterial({color:c,dashSize:f,gapSize:p,dashed:!0,worldUnits:!0,linewidth:m,transparent:v<1,opacity:v}));e.computeLineDistances(),w(e)}else w(new i.Mesh(d(_,m),new i.MeshBasicMaterial({color:c,transparent:v<1,opacity:v,side:i.DoubleSide})))}}),()=>{b.current.unregisterAnchor(S),w(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[S,x,e,c,l,f,p,m,v,y.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{onClick:h,onPointerOut:g,onPointerOver:_,children:C&&(0,r.jsx)(`primitive`,{object:C})}),x)},p=({latitude:e,longitude:a,altitude:o=0,isBillboard:s=!0,onAttach:c,onGpsUpdate:l,children:d})=>{let f=u(),p=(0,t.useRef)(f);p.current=f;let{camera:m}=(0,n.useThree)(),[h]=(0,t.useState)(()=>new i.Group),g=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),_=(0,t.useCallback)(()=>{c?.()},[c]),v=(0,t.useCallback)((e,t)=>{l?.(e,t)},[l]);return(0,t.useEffect)(()=>{if(f.isSuccess)return p.current.registerAnchor(g,{anchor:h,isAttached:!1,latitude:e,longitude:a,altitude:o,onAttach:_,onGpsUpdate:v}),()=>{p.current.unregisterAnchor(g)}},[h,g,e,a,o,_,v,f.isSuccess]),(0,n.useFrame)(()=>{!s||!m||!f.isSuccess||f.getAnchor(g)?.isAttached&&h.lookAt(m.position)}),(0,n.createPortal)((0,r.jsx)(`group`,{children:d}),h)},m=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s,size:c}=(0,n.useThree)(),{registerBackend:l,unregisterBackend:u}=e.r(),d=(0,t.useRef)(null),f=(0,t.useRef)(r);return f.current=r,(0,t.useEffect)(()=>{if(d.current)return;let e=!1;return(async()=>{try{let t=_(f.current);if(e)return;await l(t,{scene:a,camera:o,renderer:s,size:c}),d.current=t}catch(e){console.error(`[GeolocationSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,s,l,u]),(0,t.useEffect)(()=>{d.current?.setSize(c)},[c]),i},h={front:i.FrontSide,back:i.BackSide,double:i.DoubleSide},g=({coordinates:e,holes:a,color:o=`#ff0000`,opacity:s=1,isWireframe:c=!1,onClick:l,onPointerOut:d,onPointerOver:f,side:p=`double`})=>{let m=u(),g=(0,t.useRef)(m);g.current=m;let[_]=(0,t.useState)(()=>new i.Group),v=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[y,b]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!m.isSuccess||e.length<3)return;let[t,n,r=0]=e[0];return g.current.registerAnchor(v,{anchor:_,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,o=0]=e[0],[s,c]=t.lonLatToWorldCoords(n,r),l=[];for(let[n,r,i=0]of e){let[e,a]=t.lonLatToWorldCoords(n,r);l.push({x:e-s,z:a-c,elev:i-o})}let u=new i.Shape;u.moveTo(l[0].x,l[0].z);for(let e=1;e<l.length;e++)u.lineTo(l[e].x,l[e].z);if(u.closePath(),a&&a.length>0)for(let e of a){if(e.length<3)continue;let n=new i.Path,[r,a]=e[0],[o,l]=t.lonLatToWorldCoords(r,a);n.moveTo(o-s,l-c);for(let r=1;r<e.length;r++){let[i,a]=e[r],[o,l]=t.lonLatToWorldCoords(i,a);n.lineTo(o-s,l-c)}n.closePath(),u.holes.push(n)}let d=new i.ShapeGeometry(u),f=l.reduce((e,t)=>e+t.elev,0)/l.length;d.rotateX(-Math.PI/2),b({geometry:d,avgElevation:f})}}),()=>{g.current.unregisterAnchor(v),b(e=>(e&&e.geometry.dispose(),null))}},[v,_,e,a,m.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:y&&(0,r.jsx)(`group`,{position:[0,y.avgElevation,0],children:(0,r.jsx)(`mesh`,{geometry:y.geometry,onClick:l,onPointerOut:d,onPointerOver:f,children:(0,r.jsx)(`meshBasicMaterial`,{color:o,opacity:s,transparent:s<1,wireframe:c,side:h[p]})})})}),_)},_=t=>{let n=null,r=null,i=null,a=null,o=null,s=null,l=null,u={width:0,height:0},d=new Map,f=null,p=e=>{if(!(!r||e.isAttached))try{r.add(e.anchor,e.longitude,e.latitude,e.altitude),e.isAttached=!0,e.onAttach?.(r)}catch(e){console.error(`❌ Failed to attach anchor:`,e)}},m=(e,t)=>{d.set(e,t),f!==null&&!t.isAttached&&(p(t),t.onGpsUpdate?.(f,0))},h=e=>{let t=d.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}d.delete(e)},g=e=>d.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:u,renderer:m,scene:h,size:g}=e;if(!h)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);a=u,o=m,s=h,l=g;let _=a,v=t?.hFov??80;_.fov=c.LocAR.htov(v,g.width/g.height),_.updateProjectionMatrix(),n=new c.App({threeObjects:{camera:u,renderer:m,scene:h},videoConstraints:t?.webcamConstraints??{video:{facingMode:`environment`}},deviceOrientationOptions:{enabled:!0},dimensionsProvider:()=>l?{width:l.width,height:l.height}:{width:0,height:0}}),m.setClearAlpha?.(0),i=e=>{f=e.position;for(let t of d.values())t.isAttached||p(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},r=await n.start();let y=n.deviceOrientationControls;if(y&&y.orientationChangeEventName!==`deviceorientation`)try{y.disconnect(),y.orientationChangeEventName=`deviceorientation`,y.connect()}catch(e){console.error(`[geolocationBackend] failed to rebind device orientation event:`,e)}r.on(`gpsupdate`,i),n.webcam?.on?.(`webcamerror`,e=>{console.error(`[geolocationBackend] webcam error:`,e)}),n.deviceOrientationControls?.on?.(`deviceorientationerror`,e=>{console.error(`[geolocationBackend] Device orientation error:`,e)}),r.on(`gpserror`,e=>{console.error(`[geolocationBackend] gps error:`,e)}),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`?r.fakeGps(t.fakeLon,t.fakeLat):r.startGps();let b=r.getLastKnownLocation();b!==null&&(f={coords:{longitude:b.longitude,latitude:b.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>b},timestamp:Date.now(),toJSON:()=>b})},update(){if(n?.deviceOrientationControls?.update?.(),l!==null&&(l.width!==u.width||l.height!==u.height)){u={width:l.width,height:l.height};let e=l.width/l.height,t=a;t.aspect=e,t.updateProjectionMatrix(),n?.syncFovWithWebcam(e)}},dispose(){r&&i&&r.off(`gpsupdate`,i),r?.stopGps?.(),n?.webcam?.dispose?.(),o?.setClearAlpha?.(1),n?.deviceOrientationControls?.dispose?.();for(let e of d.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}d.clear(),n=null,r=null,a=null,o=null,s=null,i=null,f=null},setSize(e){l={width:e.width,height:e.height,top:0,left:0}},getInternal:()=>({locar:r,webcam:n?.webcam??null,deviceOrientation:n?.deviceOrientationControls??null,scene:s,camera:a,lastPosition:f,registerAnchor:m,unregisterAnchor:h,getAnchor:g})}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
1
+ const e=require(`./useXRStore-Cf_XL0aI.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`react/jsx-runtime`),i=require(`three`),a=require(`three/addons/lines/Line2.js`),o=require(`three/addons/lines/LineGeometry.js`),s=require(`three/addons/lines/LineMaterial.js`),c=require(`locar`);var l={isPending:!0,isSuccess:!1,locar:null,webcam:null,deviceOrientation:null,scene:null,camera:null,lastPosition:null,registerAnchor:()=>{},unregisterAnchor:()=>{},getAnchor:()=>void 0},u=()=>{let t=e.r(e=>e.backends).get(e.i.GEOLOCATION);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:l},d=(e,t)=>{let n=e.length-1,r=[],a=0,o=0;for(let i=0;i<n;i++){let n=e[i+1].x-e[i].x,s=e[i+1].y-e[i].y,c=e[i+1].z-e[i].z,l=Math.sqrt(n*n+s*s+c*c),u=t/2,d=-(c*u)/l,f=n*u/l,p=i>0?(d+a)/2:d,m=i>0?(f+o)/2:f;r.push(e[i].x-p,e[i].y,e[i].z-m,e[i].x+p,e[i].y,e[i].z+m),a=d,o=f}r.push(e[n].x-a,e[n].y,e[n].z-o,e[n].x+a,e[n].y,e[n].z+o);let s=[];for(let e=0;e<n;e++)s.push(e*2,e*2+1,e*2+2),s.push(e*2+1,e*2+3,e*2+2);let c=new i.BufferGeometry;return c.setIndex(s),c.setAttribute(`position`,new i.BufferAttribute(new Float32Array(r),3)),c.computeBoundingBox(),c},f=({coordinates:e,color:c=`#ff0000`,isDashed:l=!1,dashSize:f=3,gapSize:p=1,lineWidth:m=1,onClick:h,onPointerOut:g,onPointerOver:_,opacity:v=1})=>{let y=u(),b=(0,t.useRef)(y);b.current=y;let[x]=(0,t.useState)(()=>new i.Group),S=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[C,w]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!y.isSuccess||e.length<2)return;let[t,n,r=0]=e[0];return b.current.registerAnchor(S,{anchor:x,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,u=0]=e[0],[h,g]=t.lonLatToWorldCoords(n,r),_=e.map(([e,n,r=0])=>{let[a,o]=t.lonLatToWorldCoords(e,n);return new i.Vector3(a-h,r-u,o-g)});if(l){let e=new a.Line2(new o.LineGeometry().setFromPoints(_),new s.LineMaterial({color:c,dashSize:f,gapSize:p,dashed:!0,worldUnits:!0,linewidth:m,transparent:v<1,opacity:v}));e.computeLineDistances(),w(e)}else w(new i.Mesh(d(_,m),new i.MeshBasicMaterial({color:c,transparent:v<1,opacity:v,side:i.DoubleSide})))}}),()=>{b.current.unregisterAnchor(S),w(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[S,x,e,c,l,f,p,m,v,y.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{onClick:h,onPointerOut:g,onPointerOver:_,children:C&&(0,r.jsx)(`primitive`,{object:C})}),x)},p=({latitude:e,longitude:a,altitude:o=0,isBillboard:s=!0,onAttach:c,onGpsUpdate:l,children:d})=>{let f=u(),p=(0,t.useRef)(f);p.current=f;let{camera:m}=(0,n.useThree)(),[h]=(0,t.useState)(()=>new i.Group),g=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),_=(0,t.useCallback)(()=>{c?.()},[c]),v=(0,t.useCallback)((e,t)=>{l?.(e,t)},[l]);return(0,t.useEffect)(()=>{if(f.isSuccess)return p.current.registerAnchor(g,{anchor:h,isAttached:!1,latitude:e,longitude:a,altitude:o,onAttach:_,onGpsUpdate:v}),()=>{p.current.unregisterAnchor(g)}},[h,g,e,a,o,_,v,f.isSuccess]),(0,n.useFrame)(()=>{!s||!m||!f.isSuccess||f.getAnchor(g)?.isAttached&&h.lookAt(m.position)}),(0,n.createPortal)((0,r.jsx)(`group`,{children:d}),h)},m=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s,size:c}=(0,n.useThree)(),{registerBackend:l,unregisterBackend:u}=e.r(),d=(0,t.useRef)(null),f=(0,t.useRef)(r);return f.current=r,(0,t.useEffect)(()=>{if(d.current)return;let e=!1;return(async()=>{try{let t=_(f.current);if(e)return;await l(t,{scene:a,camera:o,renderer:s,size:c}),d.current=t}catch(e){console.error(`[GeolocationSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,s,l,u]),(0,t.useEffect)(()=>{d.current?.setSize(c)},[c]),i},h={front:i.FrontSide,back:i.BackSide,double:i.DoubleSide},g=({coordinates:e,holes:a,color:o=`#ff0000`,opacity:s=1,isWireframe:c=!1,onClick:l,onPointerOut:d,onPointerOver:f,side:p=`double`})=>{let m=u(),g=(0,t.useRef)(m);g.current=m;let[_]=(0,t.useState)(()=>new i.Group),v=(0,t.useMemo)(()=>Math.random().toString(36).slice(2,11),[]),[y,b]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!m.isSuccess||e.length<3)return;let[t,n,r=0]=e[0];return g.current.registerAnchor(v,{anchor:_,isAttached:!1,latitude:n,longitude:t,altitude:r,onAttach:t=>{let[n,r,o=0]=e[0],[s,c]=t.lonLatToWorldCoords(n,r),l=[];for(let[n,r,i=0]of e){let[e,a]=t.lonLatToWorldCoords(n,r);l.push({x:e-s,z:a-c,elev:i-o})}let u=new i.Shape;u.moveTo(l[0].x,l[0].z);for(let e=1;e<l.length;e++)u.lineTo(l[e].x,l[e].z);if(u.closePath(),a&&a.length>0)for(let e of a){if(e.length<3)continue;let n=new i.Path,[r,a]=e[0],[o,l]=t.lonLatToWorldCoords(r,a);n.moveTo(o-s,l-c);for(let r=1;r<e.length;r++){let[i,a]=e[r],[o,l]=t.lonLatToWorldCoords(i,a);n.lineTo(o-s,l-c)}n.closePath(),u.holes.push(n)}let d=new i.ShapeGeometry(u),f=l.reduce((e,t)=>e+t.elev,0)/l.length;d.rotateX(-Math.PI/2),b({geometry:d,avgElevation:f})}}),()=>{g.current.unregisterAnchor(v),b(e=>(e&&e.geometry.dispose(),null))}},[v,_,e,a,m.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:y&&(0,r.jsx)(`group`,{position:[0,y.avgElevation,0],children:(0,r.jsx)(`mesh`,{geometry:y.geometry,onClick:l,onPointerOut:d,onPointerOver:f,children:(0,r.jsx)(`meshBasicMaterial`,{color:o,opacity:s,transparent:s<1,wireframe:c,side:h[p]})})})}),_)},_=t=>{let n=null,r=null,i=null,a=null,o=null,s=null,l=null,u={width:0,height:0},d=new Map,f=null,p=e=>{if(!(!r||e.isAttached))try{r.add(e.anchor,e.longitude,e.latitude,e.altitude),e.isAttached=!0,e.onAttach?.(r)}catch(e){console.error(`❌ Failed to attach anchor:`,e)}},m=(e,t)=>{d.set(e,t),f!==null&&!t.isAttached&&(p(t),t.onGpsUpdate?.(f,0))},h=e=>{let t=d.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}d.delete(e)},g=e=>d.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:u,renderer:m,scene:h,size:g}=e;if(!h)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);a=u,o=m,s=h,l=g;let _=a,v=t?.hFov??80;_.fov=c.LocAR.htov(v,g.width/g.height),_.updateProjectionMatrix(),n=new c.App({threeObjects:{camera:u,renderer:m,scene:h},videoConstraints:t?.webcamConstraints??{video:{facingMode:`environment`}},deviceOrientationOptions:{enabled:!0},dimensionsProvider:()=>l?{width:l.width,height:l.height}:{width:0,height:0}}),m.setClearAlpha?.(0),i=e=>{f=e.position;for(let t of d.values())t.isAttached||p(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},r=await n.start(),r.on(`gpsupdate`,i),n.webcam?.on?.(`webcamerror`,e=>{console.error(`[geolocationBackend] webcam error:`,e)}),n.deviceOrientationControls?.on?.(`deviceorientationerror`,e=>{console.error(`[geolocationBackend] Device orientation error:`,e)}),r.on(`gpserror`,e=>{console.error(`[geolocationBackend] gps error:`,e)}),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`?r.fakeGps(t.fakeLon,t.fakeLat):r.startGps();let y=r.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})},update(){if(n?.deviceOrientationControls?.update?.(),l!==null&&(l.width!==u.width||l.height!==u.height)){u={width:l.width,height:l.height};let e=l.width/l.height,t=a;t.aspect=e,t.updateProjectionMatrix(),n?.syncFovWithWebcam(e)}},dispose(){r&&i&&r.off(`gpsupdate`,i),r?.stopGps?.(),n?.webcam?.dispose?.(),o?.setClearAlpha?.(1),n?.deviceOrientationControls?.dispose?.();for(let e of d.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}d.clear(),n=null,r=null,a=null,o=null,s=null,i=null,f=null},setSize(e){l={width:e.width,height:e.height,top:0,left:0}},getInternal:()=>({locar:r,webcam:n?.webcam??null,deviceOrientation:n?.deviceOrientationControls??null,scene:s,camera:a,lastPosition:f,registerAnchor:m,unregisterAnchor:h,getAnchor:g})}};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./geolocation-D0RxA8Tv.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-ypey8aeT.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,2 +1,2 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-C_n3zwq4.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-B7zCO7n6.js";
2
2
  export { e as GeoLine, n as GeoPolygon, t as GeolocationAnchor, i as GeolocationSession, a as createGeolocationBackend, r as useGeolocationBackend };
package/build/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-Cf_XL0aI.cjs`),t=require(`./engine-EvzyijbY.cjs`),n=require(`./fiducial-Tris7XAY.cjs`),r=require(`./geolocation-D0RxA8Tv.cjs`),i=require(`./immersive-DMYGUy_v.cjs`),a=require(`./magic-B9pQnRYJ.cjs`),o=require(`./vision-BLWMU9Ys.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-Cf_XL0aI.cjs`),t=require(`./engine-EvzyijbY.cjs`),n=require(`./fiducial-Tris7XAY.cjs`),r=require(`./geolocation-ypey8aeT.cjs`),i=require(`./immersive-DMYGUy_v.cjs`),a=require(`./magic-B9pQnRYJ.cjs`),o=require(`./vision-BLWMU9Ys.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,7 +1,7 @@
1
1
  import { i as e, n as t, r as n, t as r } from "./useXRStore-BTnI1ZM2.js";
2
2
  import { t as i } from "./engine-NEJZ-OgD.js";
3
3
  import { i as a, n as o, r as s, t as c } from "./fiducial-7pF-ErgE.js";
4
- import { a as l, i as u, n as d, o as f, r as p, t as m } from "./geolocation-C_n3zwq4.js";
4
+ import { a as l, i as u, n as d, o as f, r as p, t as m } from "./geolocation-B7zCO7n6.js";
5
5
  import { t as h } from "./immersive-CoSRZ58s.js";
6
6
  import { n as g, r as _, t as v } from "./magic-CjnX9lWp.js";
7
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-Vp2iuVNJ.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@omnidotdev/rdk",
3
3
  "description": "Reality Development Kit, a unified React-first XR engine",
4
- "version": "0.14.0",
4
+ "version": "0.14.1",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "sideEffects": false,