@omnidotdev/rdk 0.10.1 → 0.11.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.
- package/build/assets/onnxWorker-B_g0sj2t.js +1 -0
- package/build/{fiducial-CqsG94R9.js → fiducial-Bi9lhbyN.js} +1 -1
- package/build/{fiducial-dapuWTXg.cjs → fiducial-DdfnVsvF.cjs} +1 -1
- package/build/fiducial.cjs +1 -1
- package/build/fiducial.js +2 -2
- package/build/{geolocation-tCLtH8CU.cjs → geolocation-D_rCGA-C.cjs} +1 -1
- package/build/{geolocation-BIUFKLO_.js → geolocation-DqxybM8d.js} +1 -1
- package/build/geolocation.cjs +1 -1
- package/build/geolocation.js +2 -2
- package/build/{immersive-Dp2-ZCRC.js → immersive-BTwiipnT.js} +1 -1
- package/build/{immersive-8m33PLug.cjs → immersive-DKHCJlkN.cjs} +1 -1
- package/build/immersive.cjs +1 -1
- package/build/immersive.js +2 -2
- package/build/index.cjs +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +10 -9
- package/build/lib/types/engine/backend/Backend.interface.d.ts +1 -0
- package/build/lib/types/engine/backend/Backend.interface.d.ts.map +1 -1
- package/build/{magic-DAQdGGEO.js → magic-CPIBm_8-.js} +1 -1
- package/build/{magic-DznuBYgG.cjs → magic-CWhj_WTi.cjs} +1 -1
- package/build/magic.cjs +1 -1
- package/build/magic.js +2 -2
- package/build/useXRStore-8Vl3wsP5.cjs +1 -0
- package/build/{useXRStore-B3-MaaCu.js → useXRStore-Dsm1C1fI.js} +2 -1
- package/build/vision/CameraBackground.d.ts +15 -0
- package/build/vision/CameraBackground.d.ts.map +1 -0
- package/build/vision/HandTracker.d.ts +23 -0
- package/build/vision/HandTracker.d.ts.map +1 -0
- package/build/vision/VisionAnchor.d.ts +28 -0
- package/build/vision/VisionAnchor.d.ts.map +1 -0
- package/build/vision/VisionDebug.d.ts +18 -0
- package/build/vision/VisionDebug.d.ts.map +1 -0
- package/build/vision/VisionOverlay.d.ts +28 -0
- package/build/vision/VisionOverlay.d.ts.map +1 -0
- package/build/vision/VisionSession.d.ts +18 -0
- package/build/vision/VisionSession.d.ts.map +1 -0
- package/build/vision/VisionStatus.d.ts +15 -0
- package/build/vision/VisionStatus.d.ts.map +1 -0
- package/build/vision/gestures/builtinGestures.d.ts +9 -0
- package/build/vision/gestures/builtinGestures.d.ts.map +1 -0
- package/build/vision/gestures/detectGesture.d.ts +9 -0
- package/build/vision/gestures/detectGesture.d.ts.map +1 -0
- package/build/vision/gestures/index.d.ts +4 -0
- package/build/vision/gestures/index.d.ts.map +1 -0
- package/build/vision/gestures/types.d.ts +7 -0
- package/build/vision/gestures/types.d.ts.map +1 -0
- package/build/vision/index.d.ts +27 -0
- package/build/vision/index.d.ts.map +1 -0
- package/build/vision/landmarkMapping.d.ts +25 -0
- package/build/vision/landmarkMapping.d.ts.map +1 -0
- package/build/vision/presets.d.ts +25 -0
- package/build/vision/presets.d.ts.map +1 -0
- package/build/vision/providers/createVisionProvider.d.ts +5 -0
- package/build/vision/providers/createVisionProvider.d.ts.map +1 -0
- package/build/vision/providers/index.d.ts +2 -0
- package/build/vision/providers/index.d.ts.map +1 -0
- package/build/vision/providers/mediapipeProvider.d.ts +23 -0
- package/build/vision/providers/mediapipeProvider.d.ts.map +1 -0
- package/build/vision/providers/onnxProvider.d.ts +30 -0
- package/build/vision/providers/onnxProvider.d.ts.map +1 -0
- package/build/vision/types.d.ts +92 -0
- package/build/vision/types.d.ts.map +1 -0
- package/build/vision/useVisionBackend.d.ts +8 -0
- package/build/vision/useVisionBackend.d.ts.map +1 -0
- package/build/vision/useVisionFrame.d.ts +13 -0
- package/build/vision/useVisionFrame.d.ts.map +1 -0
- package/build/vision/visionBackend.d.ts +17 -0
- package/build/vision/visionBackend.d.ts.map +1 -0
- package/build/vision/worker/decoders/index.d.ts +6 -0
- package/build/vision/worker/decoders/index.d.ts.map +1 -0
- package/build/vision/worker/decoders/nms.d.ts +23 -0
- package/build/vision/worker/decoders/nms.d.ts.map +1 -0
- package/build/vision/worker/decoders/rfDetr.d.ts +10 -0
- package/build/vision/worker/decoders/rfDetr.d.ts.map +1 -0
- package/build/vision/worker/decoders/types.d.ts +40 -0
- package/build/vision/worker/decoders/types.d.ts.map +1 -0
- package/build/vision/worker/decoders/yolo.d.ts +11 -0
- package/build/vision/worker/decoders/yolo.d.ts.map +1 -0
- package/build/vision/worker/onnxWorker.d.ts +2 -0
- package/build/vision/worker/onnxWorker.d.ts.map +1 -0
- package/build/vision/worker/preprocess.d.ts +22 -0
- package/build/vision/worker/preprocess.d.ts.map +1 -0
- package/build/vision/worker/types.d.ts +50 -0
- package/build/vision/worker/types.d.ts.map +1 -0
- package/build/vision-BKOfvNSR.js +836 -0
- package/build/vision-CRUCg7uc.cjs +1 -0
- package/build/vision.cjs +1 -0
- package/build/vision.d.ts +2 -0
- package/build/vision.js +3 -0
- package/package.json +16 -1
- package/build/useXRStore-7Gy83DEg.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t)=>{let n=e.x+e.width,r=e.y+e.height,i=t.x+t.width,a=t.y+t.height,o=Math.max(e.x,t.x),s=Math.max(e.y,t.y),c=Math.min(n,i),l=Math.min(r,a),u=Math.max(0,c-o)*Math.max(0,l-s);if(u===0)return 0;let d=e.width*e.height+t.width*t.height-u;return d<=0?0:u/d},t=(t,n)=>{let r=[...t].sort((e,t)=>t.confidence-e.confidence),i=[];for(let t of r)i.some(r=>r.label===t.label&&e(r.bbox,t.bbox)>n)||i.push(t);return i},n=(e,t,n,r,i)=>{let a=(e-i.padX)/i.scale,o=(t-i.padY)/i.scale,s=(n-i.padX)/i.scale,c=(r-i.padY)/i.scale,l=Math.max(0,Math.min(a,i.sourceWidth)),u=Math.max(0,Math.min(o,i.sourceHeight)),d=Math.max(0,Math.min(s,i.sourceWidth)),f=Math.max(0,Math.min(c,i.sourceHeight)),p=d-l,m=f-u;return p<=0||m<=0?null:{x:l,y:u,width:p,height:m}},r=e=>1/(1+Math.exp(-e)),i=e=>{let t=Object.values(e).filter(e=>e.dims.length===3),n=t.find(e=>e.dims[2]===4),r=t.find(e=>e!==n);if(!n||!r)throw Error(`RF-DETR decoder: expected a [1, Q, 4] boxes tensor and a [1, Q, C] logits tensor`);return{boxes:n,logits:r}},a={name:`rfdetr`,decode(e,t){let{boxes:a,logits:o}=i(e),s=a.dims[1],c=o.dims[2],l=a.data,u=o.data,d=[];for(let e=0;e<s;e++){let i=0,a=-1;for(let t=0;t<c;t++){let n=r(u[e*c+t]);n>i&&(i=n,a=t)}if(a<0||i<t.minConfidence)continue;let o=e*4,s=l[o]*t.inputSize,f=l[o+1]*t.inputSize,p=l[o+2]*t.inputSize,m=l[o+3]*t.inputSize,h=n(s-p/2,f-m/2,s+p/2,f+m/2,t);h&&d.push({label:t.labels[a]??String(a),confidence:i,bbox:h})}return d.sort((e,t)=>t.confidence-e.confidence).slice(0,t.maxResults)}},o=e=>{let t=Object.values(e);if(t.length===0)throw Error(`YOLO decoder: no output tensors`);return t[0]},s={name:`yolo`,decode(e,r){let{dims:i,data:a}=o(e);if(i.length!==3||i[0]!==1)throw Error(`YOLO decoder: expected [1, C, A] output, got [${i.join(`, `)}]`);let s=i[1],c=i[2],l=s-4;if(l<=0)throw Error(`YOLO decoder: too few channels (${s})`);let u=[];for(let e=0;e<c;e++){let t=0,i=-1;for(let n=0;n<l;n++){let r=a[(4+n)*c+e];r>t&&(t=r,i=n)}if(i<0||t<r.minConfidence)continue;let o=a[e],s=a[c+e],d=a[2*c+e],f=a[3*c+e],p=n(o-d/2,s-f/2,o+d/2,s+f/2,r);p&&u.push({label:r.labels[i]??String(i),confidence:t,bbox:p})}return t(u,.45).sort((e,t)=>t.confidence-e.confidence).slice(0,r.maxResults)}},c={yolo:s,rfdetr:a},l=(e=`yolo`)=>c[e]??s,u=(e,t,n)=>{let r=Math.min(n/e,n/t),i=e*r,a=t*r;return{scale:r,drawWidth:i,drawHeight:a,padX:(n-i)/2,padY:(n-a)/2}},d=(e,t)=>{let n=t*t,r=new Float32Array(3*n);for(let t=0;t<n;t++)r[t]=e[t*4]/255,r[n+t]=e[t*4+1]/255,r[2*n+t]=e[t*4+2]/255;return r};let f=null;const p=new Map,m=()=>(f||=import(`onnxruntime-web`).then(e=>(e.env.wasm.wasmPaths=`https://cdn.jsdelivr.net/npm/onnxruntime-web/dist/`,e)),f),h=e=>{self.postMessage(e)},g=async(e,t,n,r,i,a)=>{let o=t.config.inputSize??640,{scale:s,padX:c,padY:f,drawWidth:p,drawHeight:m}=u(r,i,o),h=new OffscreenCanvas(o,o).getContext(`2d`);if(!h)throw Error(`Failed to acquire OffscreenCanvas 2D context`);h.fillStyle=`rgb(114, 114, 114)`,h.fillRect(0,0,o,o),h.drawImage(n,c,f,p,m);let{data:g}=h.getImageData(0,0,o,o),_=new e.Tensor(`float32`,d(g,o),[1,3,o,o]),v={[t.session.inputNames[0]]:_},y=await t.session.run(v),b={};for(let[e,t]of Object.entries(y))b[e]={data:t.data,dims:t.dims};let x={inputSize:o,sourceWidth:r,sourceHeight:i,scale:s,padX:c,padY:f,labels:t.config.labels??[],minConfidence:a.minConfidence,maxResults:a.maxResults};return l(t.config.decoder).decode(b,x)};self.addEventListener(`message`,async e=>{let t=e.data;switch(t.type){case`init`:h({type:`initialized`});break;case`loadModel`:{let{model:e}=t;try{let t=await(await m()).InferenceSession.create(e.path,{executionProviders:[`webgpu`,`wasm`]});p.set(e.name,{config:e,session:t}),h({type:`modelLoaded`,modelName:e.name})}catch(t){h({type:`modelError`,modelName:e.name,error:t instanceof Error?t.message:`Unknown error`})}break}case`process`:{let{imageBitmap:e,sourceWidth:n,sourceHeight:r,options:i}=t;try{let t=await m(),a=performance.now(),o=[];for(let a of p.values())o.push(...await g(t,a,e,n,r,i));h({type:`result`,result:{detections:o,frameSize:{width:n,height:r},timestamp:Date.now(),processingTime:performance.now()-a}})}catch(e){h({type:`error`,error:e instanceof Error?e.message:`Unknown error`})}finally{e.close()}break}case`dispose`:for(let{session:e}of p.values())e.release();p.clear();break}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, r as t } from "./useXRStore-
|
|
1
|
+
import { i as e, r as t } from "./useXRStore-Dsm1C1fI.js";
|
|
2
2
|
import { useEffect as n, useRef as r } from "react";
|
|
3
3
|
import { useFrame as i, useThree as a } from "@react-three/fiber";
|
|
4
4
|
import { ArMarkerControls as o, ArToolkitContext as s, ArToolkitSource as c } from "@ar-js-org/ar.js/three.js/build/ar-threex";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./useXRStore-
|
|
1
|
+
const e=require(`./useXRStore-8Vl3wsP5.cjs`);let t=require(`react`),n=require(`@react-three/fiber`),r=require(`@ar-js-org/ar.js/three.js/build/ar-threex`),i=require(`react/jsx-runtime`);var a={isPending:!0,isSuccess:!1,arSource:null,arContext:null},o=()=>{let t=e.r(e=>e.backends).get(e.i.FIDUCIAL);return t?{...t.getInternal(),isPending:!1,isSuccess:!0}:a},s=({patternUrl:e,barcodeValue:a,params:s,onMarkerFound:c,onMarkerLost:l,children:u})=>{let d=(0,t.useRef)(null),f=o(),p=(0,t.useRef)(!1),m=(0,t.useRef)(!1),h=(0,t.useRef)(null);return(0,t.useEffect)(()=>{if(!f.isSuccess)return;let t=!1;return(()=>{try{let{arContext:n}=f,i=d.current;if(!n||!i||t)return;if(i.visible=!1,m.current=!1,!n.arController){requestAnimationFrame(()=>{!d.current||t||!f.arContext?.arController||(h.current=new r.ArMarkerControls(f.arContext,d.current,{type:e?`pattern`:a?`barcode`:`unknown`,patternUrl:e,barcodeValue:a,...s}),m.current=!0)});return}h.current=new r.ArMarkerControls(n,i,{type:e?`pattern`:a?`barcode`:`unknown`,patternUrl:e,barcodeValue:a,...s}),m.current=!0}catch(e){console.error(`Failed to initialize fiducial anchor:`,e)}})(),()=>{t=!0;let e=h.current;typeof e?.dispose==`function`&&e.dispose(),m.current=!1}},[f.isSuccess,f.arContext,e,a,s,f]),(0,n.useFrame)(()=>{let e=d.current;if(!e||!m.current){e&&(e.visible=!1);return}let t=e.visible;t&&!p.current?(p.current=!0,c?.()):!t&&p.current&&(p.current=!1,l?.())}),(0,i.jsx)(`group`,{ref:d,visible:!1,children:u})},c=({options:r={},children:i})=>{let{scene:a,camera:o,gl:s}=(0,n.useThree)(),{registerBackend:c,unregisterBackend:u}=e.r(),d=(0,t.useRef)(null),f=(0,t.useRef)(r);return f.current=r,(0,t.useEffect)(()=>{if(d.current)return;let e=!1;return(async()=>{try{let t=l(f.current);if(e)return;await c(t,{scene:a,camera:o,renderer:s}),d.current=t}catch(e){console.error(`[FiducialSession] Failed to initialize:`,e)}})(),()=>{e=!0,d.current&&=(u(d.current),null)}},[a,o,s,c,u]),i},l=t=>{let n=null,i=null,a=null,o;return{type:e.i.FIDUCIAL,async init({camera:e,renderer:s}){n=new r.ArToolkitSource({sourceType:t?.sourceType??`webcam`}),await new Promise((e,t)=>{let r=setTimeout(()=>{t(Error(`AR source initialization timeout`))},1e4);n?.init(()=>{clearTimeout(r);let t=n?.domElement;t&&(t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.width=`100vw`,t.style.height=`100vh`,t.style.objectFit=`cover`,t.style.zIndex=`-1`,t.style.pointerEvents=`none`),e()})}),i=new r.ArToolkitContext({cameraParametersUrl:t?.cameraParametersUrl??new URL(`data:application/octet-stream;base64,AAACgAAAAeBAgwrsW6bUSwAAAAAAAAAAQHQ3KqAAAAAAAAAAAAAAAAAAAAAAAAAAQIL0K3dHyf9AbbNowAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAAAAAAAAAAA/uWNa4AAAAL+3lTLAAAAAv17YFWAAAAA/VYLXIAAAAECCe0YgAAAAQIJlMOAAAABAdDcqoAAAAEBts2jAAAAAP+8OmzqkDy4=`,``+{}.url).toString(),detectionMode:t?.detectionMode??`mono`,patternRatio:t?.patternRatio??.5,matrixCodeType:t?.matrixCodeType??`3x3`}),a=e;let c=()=>{n?.onResizeElement();let e=window.innerWidth,t=window.innerHeight;s.setSize(e,t,!1),n?.copyElementSizeTo(s.domElement),i?.arController&&n?.copyElementSizeTo(i.arController.canvas)};await new Promise((t,n)=>{let r=setTimeout(()=>{n(Error(`AR context initialization timeout`))},1e4);i?.init(()=>{clearTimeout(r);try{let n=i?.getProjectionMatrix();n&&e.projectionMatrix.copy(n),c(),t()}catch(e){n(e)}})}),window.addEventListener(`resize`,c),o=c},update(){if(!(!n||!i)&&!(!n.ready||!n.domElement))try{i.update(n.domElement);let e=i.getProjectionMatrix?.();a&&e&&a.projectionMatrix.copy(e)}catch(e){console.warn(`AR.js update error:`,e)}},dispose(){if(o&&=(window.removeEventListener(`resize`,o),void 0),i&&typeof i.dispose==`function`&&i.dispose(),n?.domElement){let e=n.domElement.parentNode;e&&e.removeChild(n.domElement)}n=null,i=null,a=null},getInternal:()=>({arSource:n,arContext:i})}};Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
package/build/fiducial.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./fiducial-DdfnVsvF.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,3 @@
|
|
|
1
|
-
import "./useXRStore-
|
|
2
|
-
import { i as e, n as t, r as n, t as r } from "./fiducial-
|
|
1
|
+
import "./useXRStore-Dsm1C1fI.js";
|
|
2
|
+
import { i as e, n as t, r as n, t as r } from "./fiducial-Bi9lhbyN.js";
|
|
3
3
|
export { n as FiducialAnchor, t as FiducialSession, r as createFiducialBackend, e as useFiducialBackend };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./useXRStore-
|
|
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,a,o=null,s=null,l=null,u=null,d=null,f=new Map,p=null,m=e=>{if(!(!n||e.isAttached))try{n.add(e.anchor,e.longitude,e.latitude,e.altitude),e.isAttached=!0,e.onAttach?.(n)}catch(e){console.error(`❌ Failed to attach anchor:`,e)}},h=(e,t)=>{f.set(e,t),p!==null&&!t.isAttached&&(m(t),t.onGpsUpdate?.(p,0))},g=e=>{let t=f.get(e);if(t?.isAttached)try{t.anchor.removeFromParent()}catch(t){console.error(`⚠️ Error removing anchor ${e}:`,t)}f.delete(e)},_=e=>f.get(e);return{type:e.i.GEOLOCATION,async init(e){let{camera:h,renderer:g,scene:_}=e;if(!_)throw Error(`[geolocationBackend] A THREE.Scene is required for location-based AR`);l=h,u=g,d=_,n=new c.LocAR(_,h),g.setClearAlpha?.(0);let v=new Set(document.querySelectorAll(`video`));r=new c.Webcam(t?.webcamConstraints??{video:{facingMode:`environment`}});for(let e of document.querySelectorAll(`video`))if(!v.has(e)){o=e;break}s=e=>{p=e.position;for(let t of f.values())t.isAttached||m(t),t.onGpsUpdate?.(e.position,e.distMoved);t?.onGpsUpdate?.(e.position,e.distMoved)},n.on(`gpsupdate`,s),r.on(`webcamerror`,e=>{console.error(`[geolocationBackend] webcam error:`,e)}),i=new c.DeviceOrientationControls(h),i.on(`deviceorientationgranted`,e=>{e.target?.connect?.()}),i.on(`deviceorientationerror`,e=>{console.error(`[geolocationBackend] Device orientation error:`,e)}),i.init?.(),n.on(`gpserror`,e=>{console.error(`[geolocationBackend] gps error:`,e)}),n.startGps(),typeof t?.fakeLat==`number`&&typeof t?.fakeLon==`number`&&n.fakeGps(t.fakeLon,t.fakeLat);let y=n.getLastKnownLocation();y!==null&&(p={coords:{longitude:y.longitude,latitude:y.latitude,accuracy:0,altitude:null,altitudeAccuracy:null,heading:null,speed:null,toJSON:()=>y},timestamp:Date.now(),toJSON:()=>y});let b=()=>{if(!u||!l)return;let e=window.innerWidth,t=window.innerHeight;u.setSize(e,t,!1),l.aspect=e/t,l.updateProjectionMatrix?.()};b(),window.addEventListener(`resize`,b),a=b},update(){i?.update?.()},dispose(){if(n&&s&&n.off(`gpsupdate`,s),n?.stopGps?.(),o){let e=o.srcObject;for(let t of e?.getTracks()??[])t.stop();o.srcObject=null,o.remove(),o=null}u?.setClearAlpha?.(1),i?.dispose?.(),a&&=(window.removeEventListener(`resize`,a),void 0);for(let e of f.values())if(e.isAttached)try{e.anchor.removeFromParent()}catch(e){console.error(`⚠️ Error removing anchor:`,e)}f.clear(),n=null,r=null,i=null,l=null,u=null,d=null,s=null,p=null},getInternal:()=>({locar:n,webcam:r,deviceOrientation:i,scene:d,camera:l,lastPosition:p,registerAnchor:h,unregisterAnchor:g,getAnchor:_})}};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,4 +1,4 @@
|
|
|
1
|
-
import { i as e, r as t } from "./useXRStore-
|
|
1
|
+
import { i as e, r as t } from "./useXRStore-Dsm1C1fI.js";
|
|
2
2
|
import { useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
3
3
|
import { createPortal as s, useFrame as c, useThree as l } from "@react-three/fiber";
|
|
4
4
|
import { jsx as u } from "react/jsx-runtime";
|
package/build/geolocation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./geolocation-D_rCGA-C.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
|
-
import "./useXRStore-
|
|
2
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "./geolocation-
|
|
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-DqxybM8d.js";
|
|
3
3
|
export { e as GeoLine, n as GeoPolygon, t as GeolocationAnchor, i as GeolocationSession, a as createGeolocationBackend, r as useGeolocationBackend };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, t } from "./useXRStore-
|
|
1
|
+
import { i as e, t } from "./useXRStore-Dsm1C1fI.js";
|
|
2
2
|
import { useEffect as n, useMemo as r } from "react";
|
|
3
3
|
import { jsx as i } from "react/jsx-runtime";
|
|
4
4
|
import { XR as a, createXRStore as o } from "@react-three/xr";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./useXRStore-
|
|
1
|
+
const e=require(`./useXRStore-8Vl3wsP5.cjs`);let t=require(`react`),n=require(`react/jsx-runtime`),r=require(`@react-three/xr`);var i=()=>({type:e.i.IMMERSIVE,init:()=>{},getInternal:()=>null}),a=({children:a})=>{let o=(0,t.useMemo)(()=>(0,r.createXRStore)(),[]);return(0,t.useEffect)(()=>{let t=e.t(),n=i();return t.backends.set(e.i.IMMERSIVE,n),t.setImmersiveStore(o),()=>{t.backends.delete(e.i.IMMERSIVE),t.setImmersiveStore(null)}},[o]),(0,n.jsx)(r.XR,{store:o,children:a})};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
package/build/immersive.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./immersive-DKHCJlkN.cjs`);exports.ImmersiveSession=e.t;
|
package/build/immersive.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./useXRStore-
|
|
2
|
-
import { t as e } from "./immersive-
|
|
1
|
+
import "./useXRStore-Dsm1C1fI.js";
|
|
2
|
+
import { t as e } from "./immersive-BTwiipnT.js";
|
|
3
3
|
export { e as ImmersiveSession };
|
package/build/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./useXRStore-8Vl3wsP5.cjs`),t=require(`./fiducial-DdfnVsvF.cjs`),n=require(`./geolocation-D_rCGA-C.cjs`),r=require(`./immersive-DKHCJlkN.cjs`),i=require(`./magic-CWhj_WTi.cjs`),a=require(`./vision-CRUCg7uc.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.S,exports.DEFAULT_GESTURES=a.g,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.d,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.h,exports.fist=a._,exports.getXRStore=e.t,exports.landmarkToWorld=a.p,exports.landmarksCentroid=a.m,exports.ok=a.v,exports.openHand=a.y,exports.peace=a.b,exports.rfDetr=a.l,exports.subscribeToXRStore=e.n,exports.thumbsUp=a.x,exports.useFiducialBackend=t.i,exports.useGeolocationBackend=n.o,exports.useVisionBackend=a.f,exports.useVisionFrame=a.s,exports.useXRStore=e.r,exports.yolo=a.u;
|
package/build/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './geolocation';
|
|
|
5
5
|
export * from './immersive';
|
|
6
6
|
export { BACKEND_TYPES } from './lib/types/engine';
|
|
7
7
|
export * from './magic';
|
|
8
|
+
export * from './vision';
|
|
8
9
|
export type { Backend, BackendType, } from './lib/types/engine';
|
|
9
10
|
export type { ImmersiveMode } from './lib/types/immersive';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,OAAO,EACL,UAAU,EACV,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,YAAY,EACV,OAAO,EACP,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,oBAAoB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { i as e, n as t, r as n, t as r } from "./useXRStore-
|
|
2
|
-
import { i, n as a, r as o, t as s } from "./fiducial-
|
|
3
|
-
import { a as c, i as l, n as u, o as d, r as f, t as p } from "./geolocation-
|
|
4
|
-
import { t as m } from "./immersive-
|
|
5
|
-
import { n as h, r as g, t as _ } from "./magic-
|
|
6
|
-
import {
|
|
1
|
+
import { i as e, n as t, r as n, t as r } from "./useXRStore-Dsm1C1fI.js";
|
|
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-DqxybM8d.js";
|
|
4
|
+
import { t as m } from "./immersive-BTwiipnT.js";
|
|
5
|
+
import { n as h, r as g, t as _ } from "./magic-CPIBm_8-.js";
|
|
6
|
+
import { S as v, _ as y, a as b, b as x, c as S, d as C, f as w, g as T, h as E, i as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, x as R, y as z } from "./vision-BKOfvNSR.js";
|
|
7
|
+
import { useFrame as B } from "@react-three/fiber";
|
|
7
8
|
//#region src/engine/XR.tsx
|
|
8
|
-
var
|
|
9
|
+
var V = ({ children: e }) => {
|
|
9
10
|
let { updateBackends: t } = n();
|
|
10
|
-
return
|
|
11
|
+
return B((e, n) => {
|
|
11
12
|
t(n);
|
|
12
13
|
}), e;
|
|
13
14
|
};
|
|
14
15
|
//#endregion
|
|
15
|
-
export { e as BACKEND_TYPES, o as FiducialAnchor, a as FiducialSession, c as GeoLine, u as GeoPolygon, l as GeolocationAnchor, f as GeolocationSession, m as ImmersiveSession, h as MagicSession, _ as WorldAnchor,
|
|
16
|
+
export { e as BACKEND_TYPES, S as COCO_LABELS, v as CameraBackground, T as DEFAULT_GESTURES, o as FiducialAnchor, a as FiducialSession, c as GeoLine, u as GeoPolygon, l as GeolocationAnchor, f as GeolocationSession, C as HandTracker, m as ImmersiveSession, h as MagicSession, j as VisionAnchor, b as VisionDebug, F as VisionOverlay, N as VisionSession, A as VisionStatus, _ as WorldAnchor, V as XR, s as createFiducialBackend, p as createGeolocationBackend, g as createMagicBackend, D as createVisionBackend, E as detectGesture, y as fist, r as getXRStore, M as landmarkToWorld, k as landmarksCentroid, L as ok, z as openHand, x as peace, O as rfDetr, t as subscribeToXRStore, R as thumbsUp, i as useFiducialBackend, d as useGeolocationBackend, w as useVisionBackend, P as useVisionFrame, n as useXRStore, I as yolo };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Backend.interface.d.ts","sourceRoot":"","sources":["../../../../../src/lib/types/engine/backend/Backend.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"Backend.interface.d.ts","sourceRoot":"","sources":["../../../../../src/lib/types/engine/backend/Backend.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClD;;;OAGG;IACH,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;;OAGG;IACH,WAAW,IAAI,CAAC,CAAC;CAClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as e, r as t } from "./useXRStore-
|
|
1
|
+
import { i as e, r as t } from "./useXRStore-Dsm1C1fI.js";
|
|
2
2
|
import { useEffect as n, useRef as r } from "react";
|
|
3
3
|
import { useFrame as i, useThree as a } from "@react-three/fiber";
|
|
4
4
|
import { jsx as o } from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./useXRStore-
|
|
1
|
+
const e=require(`./useXRStore-8Vl3wsP5.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}});
|
package/build/magic.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./useXRStore-8Vl3wsP5.cjs`);const e=require(`./magic-CWhj_WTi.cjs`);exports.MagicSession=e.n,exports.WorldAnchor=e.t,exports.createMagicBackend=e.r;
|
package/build/magic.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./useXRStore-
|
|
2
|
-
import { n as e, r as t, t as n } from "./magic-
|
|
1
|
+
import "./useXRStore-Dsm1C1fI.js";
|
|
2
|
+
import { n as e, r as t, t as n } from "./magic-CPIBm_8-.js";
|
|
3
3
|
export { e as MagicSession, n as WorldAnchor, t as createMagicBackend };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);var l={FIDUCIAL:`fiducial`,GEOLOCATION:`geolocation`,IMMERSIVE:`immersive`,MAGIC:`magic`,VISION:`vision`},u=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},d=(e=>e?u(e):u),f=e=>e;function p(e,t=f){let n=c.default.useSyncExternalStore(e.subscribe,c.default.useCallback(()=>t(e.getState()),[e,t]),c.default.useCallback(()=>t(e.getInitialState()),[e,t]));return c.default.useDebugValue(n),n}var m=e=>{let t=d(e),n=e=>p(t,e);return Object.assign(n,t),n},h=(e=>e?m(e):m),g=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=((e,t,n)=>{let a=e;if(t){let i=n?.equalityFn||Object.is,o=e(r.getState());a=n=>{let r=e(n);if(!i(o,r)){let e=o;t(o=r,e)}},n?.fireImmediately&&t(o,o)}return i(a)}),e(t,n,r)},_=e=>Symbol.iterator in e,v=e=>`entries`in e,y=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},b=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function x(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:_(e)&&_(t)?v(e)&&v(t)?y(e,t):b(e,t):y({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function S(e){let t=c.default.useRef(void 0);return n=>{let r=e(n);return x(t.current,r)?t.current:t.current=r}}var C=h()(g((e,t)=>({video:null,backends:new Map,immersiveStore:null,registerBackend:async(n,r)=>{try{let i=t(),a=new Set(i.backends.keys()),o=a.has(l.FIDUCIAL)||n.type===l.FIDUCIAL,s=a.has(l.GEOLOCATION)||n.type===l.GEOLOCATION;if(o&&s){let e=`❌ [RDK] INCOMPATIBLE SESSIONS: fiducial and geolocation backends cannot be used together due to camera/video conflicts between AR.js and LocAR.js libraries. Use only one session type per app.`;throw console.error(e),Error(e)}await n.init({scene:r.scene,camera:r.camera,renderer:r.renderer}),e(e=>{let t=new Map(e.backends);return t.set(n.type,n),{backends:t}})}catch(e){throw console.error(`[XRStore] Failed to register backend:`,e),e}},unregisterBackend:t=>{e(e=>{let n=new Map(e.backends);n.delete(t.type);try{t.dispose?.()}catch(e){console.error(`[XRStore] Error disposing backend:`,e)}return{backends:n}})},setVideo:t=>{e({video:t})},updateBackends:e=>{let{backends:n}=t();for(let t of n.values())try{t.update?.(e)}catch(e){console.error(`[XRStore] Backend update error:`,e)}},setImmersiveStore:t=>{e({immersiveStore:t})}}))),w=()=>C.getState(),T=C.subscribe,E=e=>C(S(t=>{let n={...t,isImmersive:t.backends.has(l.IMMERSIVE),immersive:t.immersiveStore||null};return e?e(n):n}));Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return w}});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export type CameraBackgroundProps = {
|
|
3
|
+
constraints?: MediaStreamConstraints["video"];
|
|
4
|
+
onReady?: (video: HTMLVideoElement) => void;
|
|
5
|
+
onError?: (error: Error) => void;
|
|
6
|
+
/** Mirror the preview horizontally, matching a user-facing (selfie) camera */
|
|
7
|
+
mirrored?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Camera background component.
|
|
11
|
+
* Handle camera stream setup and display as a fullscreen video element.
|
|
12
|
+
*/
|
|
13
|
+
declare const CameraBackground: React.FC<CameraBackgroundProps>;
|
|
14
|
+
export default CameraBackground;
|
|
15
|
+
//# sourceMappingURL=CameraBackground.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraBackground.d.ts","sourceRoot":"","sources":["../../src/vision/CameraBackground.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA2GrD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Vector3 } from 'three';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type HandTrackerProps = {
|
|
4
|
+
/** Called each frame with the tracked hand anchor in R3F world space */
|
|
5
|
+
onHandMove?: (position: Vector3) => void;
|
|
6
|
+
/** Called when the detected gesture changes */
|
|
7
|
+
onGesture?: (gesture: string, confidence: number) => void;
|
|
8
|
+
/** Hand landmark index used as the anchor (default 9, palm base) */
|
|
9
|
+
landmarkIndex?: number;
|
|
10
|
+
/** Mirror x to match a mirrored (selfie) preview (default true) */
|
|
11
|
+
mirror?: boolean;
|
|
12
|
+
/** Content rendered inside the tracker's group */
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Tracks the first detected hand from the active vision session, reporting its
|
|
17
|
+
* world-space position and detected gesture. Reads detections imperatively in
|
|
18
|
+
* the render loop (no per-frame React state). Renders inside an R3F Canvas
|
|
19
|
+
* (e.g. as a child of `VisionOverlay`).
|
|
20
|
+
*/
|
|
21
|
+
declare const HandTracker: ({ onHandMove, onGesture, landmarkIndex, mirror, children, }: HandTrackerProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export default HandTracker;
|
|
23
|
+
//# sourceMappingURL=HandTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandTracker.d.ts","sourceRoot":"","sources":["../../src/vision/HandTracker.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAMhC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wEAAwE;IACxE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1D,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,6DAMlB,gBAAgB,4CAwClB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type VisionAnchorProps = {
|
|
3
|
+
/** Landmark task to anchor to (hands, faces, or poses) */
|
|
4
|
+
task: "hands" | "faces" | "poses";
|
|
5
|
+
/** Which detection to anchor to when several are present (default 0) */
|
|
6
|
+
index?: number;
|
|
7
|
+
/** Render a marker at every landmark for debugging */
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
/** Mirror x to match a mirrored (selfie) preview (default true) */
|
|
10
|
+
mirror?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Per-frame lerp factor (0-1) smoothing the anchor toward the detection.
|
|
13
|
+
* 1 snaps instantly; lower gives smoother, laggier motion (default 0.4).
|
|
14
|
+
*/
|
|
15
|
+
smoothing?: number;
|
|
16
|
+
/** Content rendered anchored at the detection centroid */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Anchors its children to the centroid of a detected hand, face, or pose from
|
|
21
|
+
* the active vision session, optionally rendering per-landmark debug markers.
|
|
22
|
+
* Updates imperatively in the render loop (no per-frame React state; debug
|
|
23
|
+
* markers use a single instanced mesh). Renders inside an R3F Canvas (e.g. as a
|
|
24
|
+
* child of `VisionOverlay`).
|
|
25
|
+
*/
|
|
26
|
+
declare const VisionAnchor: ({ task, index, debug, mirror, smoothing, children, }: VisionAnchorProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default VisionAnchor;
|
|
28
|
+
//# sourceMappingURL=VisionAnchor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionAnchor.d.ts","sourceRoot":"","sources":["../../src/vision/VisionAnchor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,0DAA0D;IAC1D,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAClC,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mEAAmE;IACnE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAWF;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,GAAI,sDAOnB,iBAAiB,4CAyFnB,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { VisionTask } from './types';
|
|
3
|
+
export type VisionDebugProps = {
|
|
4
|
+
/** Which tasks to show debug info for */
|
|
5
|
+
tasks: VisionTask[];
|
|
6
|
+
/** Canvas width */
|
|
7
|
+
width?: number;
|
|
8
|
+
/** Canvas height */
|
|
9
|
+
height?: number;
|
|
10
|
+
/** Style overrides */
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Debug overlay showing raw detection data (landmark counts, FPS, etc.)
|
|
15
|
+
*/
|
|
16
|
+
declare const VisionDebug: React.FC<VisionDebugProps>;
|
|
17
|
+
export default VisionDebug;
|
|
18
|
+
//# sourceMappingURL=VisionDebug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionDebug.d.ts","sourceRoot":"","sources":["../../src/vision/VisionDebug.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,yCAAyC;IACzC,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sBAAsB;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAuC3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CameraBackgroundProps } from './CameraBackground';
|
|
3
|
+
import { VisionSessionOptions, VisionTask } from './types';
|
|
4
|
+
export type VisionOverlayProps = {
|
|
5
|
+
/** Vision tasks to enable */
|
|
6
|
+
tasks?: VisionTask[];
|
|
7
|
+
/** Vision configuration options */
|
|
8
|
+
options?: VisionSessionOptions;
|
|
9
|
+
/** Children components to render in 3D scene */
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** Show debug overlay */
|
|
12
|
+
showDebug?: boolean;
|
|
13
|
+
/** Camera constraints */
|
|
14
|
+
cameraConstraints?: CameraBackgroundProps["constraints"];
|
|
15
|
+
/** Canvas style overrides */
|
|
16
|
+
canvasStyle?: React.CSSProperties;
|
|
17
|
+
/** Callback when camera is ready */
|
|
18
|
+
onReady?: () => void;
|
|
19
|
+
/** Callback for vision errors */
|
|
20
|
+
onError?: (error: Error) => void;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* High-level component that combines camera, vision tracking, and 3D rendering.
|
|
24
|
+
* Compose camera background, vision session, and 3D canvas as an overlay.
|
|
25
|
+
*/
|
|
26
|
+
declare const VisionOverlay: React.FC<VisionOverlayProps>;
|
|
27
|
+
export default VisionOverlay;
|
|
28
|
+
//# sourceMappingURL=VisionOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionOverlay.d.ts","sourceRoot":"","sources":["../../src/vision/VisionOverlay.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKhE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,6BAA6B;IAC7B,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,mCAAmC;IACnC,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,gDAAgD;IAChD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,yBAAyB;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB;IACzB,iBAAiB,CAAC,EAAE,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACzD,6BAA6B;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAClC,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,iCAAiC;IACjC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAkG/C,CAAC;AAkBF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { VisionSessionOptions } from './types';
|
|
3
|
+
export type VisionSessionProps = {
|
|
4
|
+
/** Vision session configuration */
|
|
5
|
+
options: VisionSessionOptions;
|
|
6
|
+
/** Children to render inside the session */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Error callback */
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Vision session component that creates and registers the vision backend
|
|
13
|
+
* with the XR store, providing detection context to child components.
|
|
14
|
+
* Must render inside a `@react-three/fiber` Canvas (uses `useThree`).
|
|
15
|
+
*/
|
|
16
|
+
declare const VisionSession: React.FC<VisionSessionProps>;
|
|
17
|
+
export default VisionSession;
|
|
18
|
+
//# sourceMappingURL=VisionSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionSession.d.ts","sourceRoot":"","sources":["../../src/vision/VisionSession.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,mCAAmC;IACnC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,qBAAqB;IACrB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAyD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { VisionTask } from './types';
|
|
3
|
+
import { VisionProgress } from './worker/types';
|
|
4
|
+
export type VisionStatusProps = {
|
|
5
|
+
tasks: VisionTask[];
|
|
6
|
+
progress?: VisionProgress | null;
|
|
7
|
+
showDebug: boolean;
|
|
8
|
+
onToggleDebug: () => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Vision status overlay showing detection state for each task
|
|
12
|
+
*/
|
|
13
|
+
declare const VisionStatus: React.FC<VisionStatusProps>;
|
|
14
|
+
export default VisionStatus;
|
|
15
|
+
//# sourceMappingURL=VisionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisionStatus.d.ts","sourceRoot":"","sources":["../../src/vision/VisionStatus.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAkH7C,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GestureDetector } from './types';
|
|
2
|
+
declare const thumbsUp: GestureDetector;
|
|
3
|
+
declare const peace: GestureDetector;
|
|
4
|
+
declare const ok: GestureDetector;
|
|
5
|
+
declare const openHand: GestureDetector;
|
|
6
|
+
declare const fist: GestureDetector;
|
|
7
|
+
declare const DEFAULT_GESTURES: GestureDetector[];
|
|
8
|
+
export { DEFAULT_GESTURES, fist, ok, openHand, peace, thumbsUp };
|
|
9
|
+
//# sourceMappingURL=builtinGestures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtinGestures.d.ts","sourceRoot":"","sources":["../../../src/vision/gestures/builtinGestures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAiB,MAAM,SAAS,CAAC;AAiB9D,QAAA,MAAM,QAAQ,EAAE,eASf,CAAC;AAEF,QAAA,MAAM,KAAK,EAAE,eASZ,CAAC;AAEF,QAAA,MAAM,EAAE,EAAE,eAeT,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,eAUf,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,eAUX,CAAC;AAEF,QAAA,MAAM,gBAAgB,EAAE,eAAe,EAMtC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VisionLandmark } from '../types';
|
|
2
|
+
import { GestureDetector, GestureResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Detect gestures from hand landmarks using the provided detectors.
|
|
5
|
+
* Returns the highest-confidence match, or `{ gesture: "none", confidence: 0 }`.
|
|
6
|
+
*/
|
|
7
|
+
declare const detectGesture: (landmarks: VisionLandmark[], detectors?: GestureDetector[]) => GestureResult;
|
|
8
|
+
export default detectGesture;
|
|
9
|
+
//# sourceMappingURL=detectGesture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detectGesture.d.ts","sourceRoot":"","sources":["../../../src/vision/gestures/detectGesture.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI9D;;;GAGG;AACH,QAAA,MAAM,aAAa,GACjB,WAAW,cAAc,EAAE,EAC3B,YAAW,eAAe,EAAqB,KAC9C,aAWF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vision/gestures/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,KAAK,EACL,QAAQ,GACT,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vision/gestures/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,eAAe,GAAG,CAC5B,SAAS,EAAE,cAAc,EAAE,KACxB,aAAa,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export { default as CameraBackground } from './CameraBackground';
|
|
2
|
+
export { DEFAULT_GESTURES, detectGesture, fist, ok, openHand, peace, thumbsUp, } from './gestures';
|
|
3
|
+
export { default as HandTracker } from './HandTracker';
|
|
4
|
+
export { landmarksCentroid, landmarkToWorld } from './landmarkMapping';
|
|
5
|
+
export { COCO_LABELS, rfDetr, yolo } from './presets';
|
|
6
|
+
export { default as useVisionBackend } from './useVisionBackend';
|
|
7
|
+
export { default as useVisionFrame } from './useVisionFrame';
|
|
8
|
+
export { default as VisionAnchor } from './VisionAnchor';
|
|
9
|
+
export { default as VisionDebug } from './VisionDebug';
|
|
10
|
+
export { default as VisionOverlay } from './VisionOverlay';
|
|
11
|
+
export { default as VisionSession } from './VisionSession';
|
|
12
|
+
export { default as VisionStatus } from './VisionStatus';
|
|
13
|
+
export { default as createVisionBackend } from './visionBackend';
|
|
14
|
+
export type { CameraBackgroundProps } from './CameraBackground';
|
|
15
|
+
export type { GestureDetector, GestureResult } from './gestures';
|
|
16
|
+
export type { HandTrackerProps } from './HandTracker';
|
|
17
|
+
export type { FrameSize, Viewport } from './landmarkMapping';
|
|
18
|
+
export type { PresetOverrides } from './presets';
|
|
19
|
+
export type { LandmarkDetection, ObjectDetection, ONNXDecoderName, ONNXModelConfig, VisionFrame, VisionLandmark, VisionProgress, VisionProvider, VisionSessionOptions, VisionTask, } from './types';
|
|
20
|
+
export type { UseVisionFrameOptions } from './useVisionFrame';
|
|
21
|
+
export type { VisionAnchorProps } from './VisionAnchor';
|
|
22
|
+
export type { VisionDebugProps } from './VisionDebug';
|
|
23
|
+
export type { VisionOverlayProps } from './VisionOverlay';
|
|
24
|
+
export type { VisionSessionProps } from './VisionSession';
|
|
25
|
+
export type { VisionStatusProps } from './VisionStatus';
|
|
26
|
+
export type { VisionBackendState, VisionInternal, } from './visionBackend';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vision/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,IAAI,EACJ,EAAE,EACF,QAAQ,EACR,KAAK,EACL,QAAQ,GACT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACjE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,kBAAkB,EAClB,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { VisionLandmark } from './types';
|
|
2
|
+
/** World-space dimensions of the camera focal plane (from R3F `useThree().viewport`) */
|
|
3
|
+
export type Viewport = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
/** Pixel dimensions of the source video frame (from `VisionFrame.frameSize`) */
|
|
8
|
+
export type FrameSize = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Map a normalized MediaPipe landmark (x, y in [0, 1] with y top-down) into R3F
|
|
14
|
+
* world coordinates on the camera focal plane (z = 0), accounting for the
|
|
15
|
+
* `object-fit: cover` center-crop used to display the camera feed. `mirror`
|
|
16
|
+
* flips x to match a mirrored (selfie) preview.
|
|
17
|
+
*
|
|
18
|
+
* The camera feed is displayed with `cover`, so the axis whose aspect overflows
|
|
19
|
+
* the canvas is cropped; landmarks are normalized to the full frame, so that
|
|
20
|
+
* crop must be undone or overlays drift toward the edges (badly on portrait).
|
|
21
|
+
*/
|
|
22
|
+
export declare const landmarkToWorld: (landmark: VisionLandmark, viewport: Viewport, frameSize: FrameSize, mirror?: boolean) => [number, number, number];
|
|
23
|
+
/** Average a set of landmarks into a single centroid landmark */
|
|
24
|
+
export declare const landmarksCentroid: (landmarks: VisionLandmark[]) => VisionLandmark;
|
|
25
|
+
//# sourceMappingURL=landmarkMapping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landmarkMapping.d.ts","sourceRoot":"","sources":["../../src/vision/landmarkMapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,wFAAwF;AACxF,MAAM,MAAM,QAAQ,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,cAAc,EACxB,UAAU,QAAQ,EAClB,WAAW,SAAS,EACpB,gBAAa,KACZ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAezB,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,GAC5B,WAAW,cAAc,EAAE,KAC1B,cAWF,CAAC"}
|