@omnidotdev/rdk 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/geolocation/geolocationBackend.d.ts +1 -1
- package/build/geolocation/geolocationBackend.d.ts.map +1 -1
- package/build/{geolocation-D_rCGA-C.cjs → geolocation-CT1kLdSh.cjs} +1 -1
- package/build/{geolocation-DqxybM8d.js → geolocation-Dl910ZC5.js} +74 -73
- package/build/geolocation.cjs +1 -1
- package/build/geolocation.js +1 -1
- package/build/index.cjs +1 -1
- package/build/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeviceOrientationControls, LocAR, Webcam } from 'locar';
|
|
2
1
|
import { Backend } from 'lib/types/engine';
|
|
2
|
+
import { DeviceOrientationControls, LocAR, Webcam } from 'locar';
|
|
3
3
|
import { Camera, Group, Scene } from 'three';
|
|
4
4
|
/**
|
|
5
5
|
* GPS update event structure emitted by LocAR.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geolocationBackend.d.ts","sourceRoot":"","sources":["../../src/geolocation/geolocationBackend.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EAEL,KAAK,EAEN,MAAM,OAAO,CAAC;AAEf;;GAEG;AAEH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1E;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iBAAiB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+BAA+B;IAC/B,YAAY,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,2CAA2C;IAC3C,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACzD,6CAA6C;IAC7C,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iCAAiC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,iEAAiE;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,2DAA2D;IAC3D,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9E;AAED;;GAEG;AACH,QAAA,MAAM,wBAAwB,GAC5B,UAAU,yBAAyB,KAClC,OAAO,CAAC,mBAAmB,CAqQ7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./useXRStore-8Vl3wsP5.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})=>{let h=u(),g=(0,t.useRef)(h);g.current=h;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(!h.isSuccess||e.length<2)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,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}));e.computeLineDistances(),b(e)}else b(new i.Mesh(d(_,m),new i.MeshBasicMaterial({color:c,side:i.DoubleSide})))}}),()=>{g.current.unregisterAnchor(v),b(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[v,_,e,c,l,f,p,m,h.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:y&&(0,r.jsx)(`primitive`,{object:y})}),_)},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=null,
|
|
1
|
+
const e=require(`./useXRStore-8Vl3wsP5.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})=>{let h=u(),g=(0,t.useRef)(h);g.current=h;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(!h.isSuccess||e.length<2)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,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}));e.computeLineDistances(),b(e)}else b(new i.Mesh(d(_,m),new i.MeshBasicMaterial({color:c,side:i.DoubleSide})))}}),()=>{g.current.unregisterAnchor(v),b(e=>(e&&(e.geometry.dispose(),e.material.dispose()),null))}},[v,_,e,c,l,f,p,m,h.isSuccess]),(0,n.createPortal)((0,r.jsx)(`group`,{children:y&&(0,r.jsx)(`primitive`,{object:y})}),_)},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 _}});
|
|
@@ -6,9 +6,9 @@ import { BackSide as d, BufferAttribute as f, BufferGeometry as p, DoubleSide as
|
|
|
6
6
|
import { Line2 as C } from "three/addons/lines/Line2.js";
|
|
7
7
|
import { LineGeometry as w } from "three/addons/lines/LineGeometry.js";
|
|
8
8
|
import { LineMaterial as T } from "three/addons/lines/LineMaterial.js";
|
|
9
|
-
import {
|
|
9
|
+
import { App as E } from "locar";
|
|
10
10
|
//#region src/geolocation/useGeolocationBackend.ts
|
|
11
|
-
var
|
|
11
|
+
var D = {
|
|
12
12
|
isPending: !0,
|
|
13
13
|
isSuccess: !1,
|
|
14
14
|
locar: null,
|
|
@@ -20,14 +20,14 @@ var k = {
|
|
|
20
20
|
registerAnchor: () => {},
|
|
21
21
|
unregisterAnchor: () => {},
|
|
22
22
|
getAnchor: () => void 0
|
|
23
|
-
},
|
|
23
|
+
}, O = () => {
|
|
24
24
|
let n = t((e) => e.backends).get(e.GEOLOCATION);
|
|
25
25
|
return n ? {
|
|
26
26
|
...n.getInternal(),
|
|
27
27
|
isPending: !1,
|
|
28
28
|
isSuccess: !0
|
|
29
|
-
} :
|
|
30
|
-
},
|
|
29
|
+
} : D;
|
|
30
|
+
}, k = (e, t) => {
|
|
31
31
|
let n = e.length - 1, r = [], i = 0, a = 0;
|
|
32
32
|
for (let o = 0; o < n; o++) {
|
|
33
33
|
let n = e[o + 1].x - e[o].x, s = e[o + 1].y - e[o].y, c = e[o + 1].z - e[o].z, l = Math.sqrt(n * n + s * s + c * c), u = t / 2, d = -(c * u) / l, f = n * u / l, p = o > 0 ? (d + i) / 2 : d, m = o > 0 ? (f + a) / 2 : f;
|
|
@@ -38,8 +38,8 @@ var k = {
|
|
|
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
|
-
},
|
|
42
|
-
let f =
|
|
41
|
+
}, A = ({ coordinates: e, color: t = "#ff0000", isDashed: n = !1, dashSize: c = 3, gapSize: l = 1, lineWidth: d = 1 }) => {
|
|
42
|
+
let f = O(), p = a(f);
|
|
43
43
|
p.current = f;
|
|
44
44
|
let [h] = o(() => new g()), y = i(() => Math.random().toString(36).slice(2, 11), []), [b, x] = o(null);
|
|
45
45
|
return r(() => {
|
|
@@ -66,7 +66,7 @@ var k = {
|
|
|
66
66
|
linewidth: d
|
|
67
67
|
}));
|
|
68
68
|
e.computeLineDistances(), x(e);
|
|
69
|
-
} else x(new _(
|
|
69
|
+
} else x(new _(k(f, d), new v({
|
|
70
70
|
color: t,
|
|
71
71
|
side: m
|
|
72
72
|
})));
|
|
@@ -85,8 +85,8 @@ var k = {
|
|
|
85
85
|
d,
|
|
86
86
|
f.isSuccess
|
|
87
87
|
]), s(/* @__PURE__ */ u("group", { children: b && /* @__PURE__ */ u("primitive", { object: b }) }), h);
|
|
88
|
-
},
|
|
89
|
-
let _ =
|
|
88
|
+
}, j = ({ latitude: e, longitude: t, altitude: d = 0, isBillboard: f = !0, onAttach: p, onGpsUpdate: m, children: h }) => {
|
|
89
|
+
let _ = O(), v = a(_);
|
|
90
90
|
v.current = _;
|
|
91
91
|
let { camera: y } = l(), [b] = o(() => new g()), x = i(() => Math.random().toString(36).slice(2, 11), []), S = n(() => {
|
|
92
92
|
p?.();
|
|
@@ -117,14 +117,14 @@ var k = {
|
|
|
117
117
|
]), c(() => {
|
|
118
118
|
!f || !y || !_.isSuccess || _.getAnchor(x)?.isAttached && b.lookAt(y.position);
|
|
119
119
|
}), s(/* @__PURE__ */ u("group", { children: h }), b);
|
|
120
|
-
},
|
|
120
|
+
}, M = ({ options: e = {}, children: n }) => {
|
|
121
121
|
let { scene: i, camera: o, gl: s } = l(), { registerBackend: c, unregisterBackend: u } = t(), d = a(null), f = a(e);
|
|
122
122
|
return f.current = e, r(() => {
|
|
123
123
|
if (d.current) return;
|
|
124
124
|
let e = !1;
|
|
125
125
|
return (async () => {
|
|
126
126
|
try {
|
|
127
|
-
let t =
|
|
127
|
+
let t = F(f.current);
|
|
128
128
|
if (e) return;
|
|
129
129
|
await c(t, {
|
|
130
130
|
scene: i,
|
|
@@ -144,12 +144,12 @@ var k = {
|
|
|
144
144
|
c,
|
|
145
145
|
u
|
|
146
146
|
]), n;
|
|
147
|
-
},
|
|
147
|
+
}, N = {
|
|
148
148
|
front: h,
|
|
149
149
|
back: d,
|
|
150
150
|
double: m
|
|
151
|
-
},
|
|
152
|
-
let f =
|
|
151
|
+
}, P = ({ coordinates: e, holes: t, color: n = "#ff0000", opacity: c = 1, isWireframe: l = !1, side: d = "double" }) => {
|
|
152
|
+
let f = O(), p = a(f);
|
|
153
153
|
p.current = f;
|
|
154
154
|
let [m] = o(() => new g()), h = i(() => Math.random().toString(36).slice(2, 11), []), [_, v] = o(null);
|
|
155
155
|
return r(() => {
|
|
@@ -212,104 +212,105 @@ var k = {
|
|
|
212
212
|
opacity: c,
|
|
213
213
|
transparent: c < 1,
|
|
214
214
|
wireframe: l,
|
|
215
|
-
side:
|
|
215
|
+
side: N[d]
|
|
216
216
|
})
|
|
217
217
|
})
|
|
218
218
|
}) }), m);
|
|
219
|
-
},
|
|
220
|
-
let n = null, r = null, i = null,
|
|
221
|
-
if (!(!
|
|
222
|
-
|
|
219
|
+
}, F = (t) => {
|
|
220
|
+
let n = null, r = null, i, a = null, o = null, s = null, c = null, l = /* @__PURE__ */ new Map(), u = null, d = (e) => {
|
|
221
|
+
if (!(!r || e.isAttached)) try {
|
|
222
|
+
r.add(e.anchor, e.longitude, e.latitude, e.altitude), e.isAttached = !0, e.onAttach?.(r);
|
|
223
223
|
} catch (e) {
|
|
224
224
|
console.error("❌ Failed to attach anchor:", e);
|
|
225
225
|
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
},
|
|
229
|
-
let t =
|
|
226
|
+
}, f = (e, t) => {
|
|
227
|
+
l.set(e, t), u !== null && !t.isAttached && (d(t), t.onGpsUpdate?.(u, 0));
|
|
228
|
+
}, p = (e) => {
|
|
229
|
+
let t = l.get(e);
|
|
230
230
|
if (t?.isAttached) try {
|
|
231
231
|
t.anchor.removeFromParent();
|
|
232
232
|
} catch (t) {
|
|
233
233
|
console.error(`⚠️ Error removing anchor ${e}:`, t);
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
},
|
|
235
|
+
l.delete(e);
|
|
236
|
+
}, m = (e) => l.get(e);
|
|
237
237
|
return {
|
|
238
238
|
type: e.GEOLOCATION,
|
|
239
239
|
async init(e) {
|
|
240
|
-
let { camera:
|
|
241
|
-
if (!
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
240
|
+
let { camera: f, renderer: p, scene: m } = e;
|
|
241
|
+
if (!m) throw Error("[geolocationBackend] A THREE.Scene is required for location-based AR");
|
|
242
|
+
o = f, s = p, c = m, n = new E({
|
|
243
|
+
threeObjects: {
|
|
244
|
+
camera: f,
|
|
245
|
+
renderer: p,
|
|
246
|
+
scene: m
|
|
247
|
+
},
|
|
248
|
+
videoConstraints: t?.webcamConstraints ?? { video: { facingMode: "environment" } },
|
|
249
|
+
deviceOrientationOptions: { enabled: !0 }
|
|
250
|
+
}), p.setClearAlpha?.(0), a = (e) => {
|
|
251
|
+
u = e.position;
|
|
252
|
+
for (let t of l.values()) t.isAttached || d(t), t.onGpsUpdate?.(e.position, e.distMoved);
|
|
252
253
|
t?.onGpsUpdate?.(e.position, e.distMoved);
|
|
253
|
-
},
|
|
254
|
+
}, r = await n.start();
|
|
255
|
+
let h = n.deviceOrientationControls;
|
|
256
|
+
if (h && h.orientationChangeEventName !== "deviceorientation") try {
|
|
257
|
+
h.disconnect(), h.orientationChangeEventName = "deviceorientation", h.connect();
|
|
258
|
+
} catch (e) {
|
|
259
|
+
console.error("[geolocationBackend] failed to rebind device orientation event:", e);
|
|
260
|
+
}
|
|
261
|
+
r.on("gpsupdate", a), n.webcam?.on?.("webcamerror", (e) => {
|
|
254
262
|
console.error("[geolocationBackend] webcam error:", e);
|
|
255
|
-
}),
|
|
256
|
-
e.target?.connect?.();
|
|
257
|
-
}), i.on("deviceorientationerror", (e) => {
|
|
263
|
+
}), n.deviceOrientationControls?.on?.("deviceorientationerror", (e) => {
|
|
258
264
|
console.error("[geolocationBackend] Device orientation error:", e);
|
|
259
|
-
}),
|
|
265
|
+
}), r.on("gpserror", (e) => {
|
|
260
266
|
console.error("[geolocationBackend] gps error:", e);
|
|
261
|
-
}),
|
|
262
|
-
let
|
|
263
|
-
|
|
267
|
+
}), r.startGps(), typeof t?.fakeLat == "number" && typeof t?.fakeLon == "number" && r.fakeGps(t.fakeLon, t.fakeLat);
|
|
268
|
+
let g = r.getLastKnownLocation();
|
|
269
|
+
g !== null && (u = {
|
|
264
270
|
coords: {
|
|
265
|
-
longitude:
|
|
266
|
-
latitude:
|
|
271
|
+
longitude: g.longitude,
|
|
272
|
+
latitude: g.latitude,
|
|
267
273
|
accuracy: 0,
|
|
268
274
|
altitude: null,
|
|
269
275
|
altitudeAccuracy: null,
|
|
270
276
|
heading: null,
|
|
271
277
|
speed: null,
|
|
272
|
-
toJSON: () =>
|
|
278
|
+
toJSON: () => g
|
|
273
279
|
},
|
|
274
280
|
timestamp: Date.now(),
|
|
275
|
-
toJSON: () =>
|
|
281
|
+
toJSON: () => g
|
|
276
282
|
});
|
|
277
|
-
let
|
|
278
|
-
if (!
|
|
283
|
+
let _ = () => {
|
|
284
|
+
if (!s || !o) return;
|
|
279
285
|
let e = window.innerWidth, t = window.innerHeight;
|
|
280
|
-
|
|
286
|
+
s.setSize(e, t, !1), o.aspect = e / t, o.updateProjectionMatrix?.();
|
|
281
287
|
};
|
|
282
|
-
|
|
288
|
+
_(), window.addEventListener("resize", _), i = _;
|
|
283
289
|
},
|
|
284
290
|
update() {
|
|
285
|
-
|
|
291
|
+
n?.deviceOrientationControls?.update?.();
|
|
286
292
|
},
|
|
287
293
|
dispose() {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
for (let t of e?.getTracks() ?? []) t.stop();
|
|
291
|
-
o.srcObject = null, o.remove(), o = null;
|
|
292
|
-
}
|
|
293
|
-
l?.setClearAlpha?.(1), i?.dispose?.(), a &&= (window.removeEventListener("resize", a), void 0);
|
|
294
|
-
for (let e of d.values()) if (e.isAttached) try {
|
|
294
|
+
r && a && r.off("gpsupdate", a), r?.stopGps?.(), n?.webcam?.dispose?.(), s?.setClearAlpha?.(1), n?.deviceOrientationControls?.dispose?.(), i &&= (window.removeEventListener("resize", i), void 0);
|
|
295
|
+
for (let e of l.values()) if (e.isAttached) try {
|
|
295
296
|
e.anchor.removeFromParent();
|
|
296
297
|
} catch (e) {
|
|
297
298
|
console.error("⚠️ Error removing anchor:", e);
|
|
298
299
|
}
|
|
299
|
-
|
|
300
|
+
l.clear(), n = null, r = null, o = null, s = null, c = null, a = null, u = null;
|
|
300
301
|
},
|
|
301
302
|
getInternal: () => ({
|
|
302
|
-
locar:
|
|
303
|
-
webcam:
|
|
304
|
-
deviceOrientation:
|
|
305
|
-
scene:
|
|
306
|
-
camera:
|
|
307
|
-
lastPosition:
|
|
308
|
-
registerAnchor:
|
|
309
|
-
unregisterAnchor:
|
|
310
|
-
getAnchor:
|
|
303
|
+
locar: r,
|
|
304
|
+
webcam: n?.webcam ?? null,
|
|
305
|
+
deviceOrientation: n?.deviceOrientationControls ?? null,
|
|
306
|
+
scene: c,
|
|
307
|
+
camera: o,
|
|
308
|
+
lastPosition: u,
|
|
309
|
+
registerAnchor: f,
|
|
310
|
+
unregisterAnchor: p,
|
|
311
|
+
getAnchor: m
|
|
311
312
|
})
|
|
312
313
|
};
|
|
313
314
|
};
|
|
314
315
|
//#endregion
|
|
315
|
-
export {
|
|
316
|
+
export { A as a, j as i, P as n, O as o, M as r, F as t };
|
package/build/geolocation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./geolocation-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./geolocation-CT1kLdSh.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;
|
package/build/geolocation.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./useXRStore-Dsm1C1fI.js";
|
|
2
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-
|
|
2
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-Dl910ZC5.js";
|
|
3
3
|
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-8Vl3wsP5.cjs`),t=require(`./fiducial-DdfnVsvF.cjs`),n=require(`./geolocation-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-8Vl3wsP5.cjs`),t=require(`./fiducial-DdfnVsvF.cjs`),n=require(`./geolocation-CT1kLdSh.cjs`),r=require(`./immersive-DKHCJlkN.cjs`),i=require(`./magic-CWhj_WTi.cjs`),a=require(`./vision-sMKG7-na.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;
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as e, n as t, r as n, t as r } from "./useXRStore-Dsm1C1fI.js";
|
|
2
2
|
import { i, n as a, r as o, t as s } from "./fiducial-Bi9lhbyN.js";
|
|
3
|
-
import { a as c, i as l, n as u, o as d, r as f, t as p } from "./geolocation-
|
|
3
|
+
import { a as c, i as l, n as u, o as d, r as f, t as p } from "./geolocation-Dl910ZC5.js";
|
|
4
4
|
import { t as m } from "./immersive-BTwiipnT.js";
|
|
5
5
|
import { n as h, r as g, t as _ } from "./magic-CPIBm_8-.js";
|
|
6
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-Bdhf3N-w.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.12.
|
|
4
|
+
"version": "0.12.1",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "build/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@mediapipe/tasks-vision": "^0.10.0",
|
|
77
77
|
"@react-three/fiber": "^9.5.0",
|
|
78
78
|
"@react-three/xr": "^6.6.29",
|
|
79
|
-
"locar": "^0.2.
|
|
79
|
+
"locar": "^0.2.7",
|
|
80
80
|
"onnxruntime-web": "^1.22.0",
|
|
81
81
|
"react": "^19.2.0",
|
|
82
82
|
"react-dom": "^19.2.0",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"@types/react-dom": "^19.2.3",
|
|
112
112
|
"@types/three": "^0.185.0",
|
|
113
113
|
"jsdom": "^29.0.0",
|
|
114
|
-
"locar": "^0.2.
|
|
114
|
+
"locar": "^0.2.7",
|
|
115
115
|
"onnxruntime-web": "^1.27.0",
|
|
116
116
|
"react": "^19.2.3",
|
|
117
117
|
"react-dom": "^19.2.3",
|