@vincentt-xr/sdk 2.0.0-alpha.6 → 2.0.0-alpha.7
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/GROUNDING.md +81 -3
- package/dist/{DebuggerUI-DYT_dk1E.cjs → DebuggerUI-B6bP6P9r.cjs} +1 -1
- package/dist/{DebuggerUI-C_rbLdkh.js → DebuggerUI-BjOMr8q_.js} +1 -1
- package/dist/{FaceMeshRenderer-D1WsrTLA.cjs → FaceMeshRenderer-C5l6VLdO.cjs} +6 -6
- package/dist/{FaceMeshRenderer-DSCd1H55.js → FaceMeshRenderer-wjAHrJzP.js} +102 -96
- package/dist/{FaceRetouch-DsE0Dbw-.cjs → FaceRetouch-BkJzoA79.cjs} +1 -1
- package/dist/{FaceRetouch-CMJbGThL.js → FaceRetouch-DwbKQJAN.js} +4 -4
- package/dist/components/FaceMesh/FaceMeshRenderer.d.ts +11 -3
- package/dist/components/FaceMesh/canonical/CanonicalFaceMeshRenderer.d.ts +10 -4
- package/dist/components/FaceMesh/index.d.ts +2 -2
- package/dist/components/SceneObjectRenderer/index.d.ts +9 -2
- package/dist/components/XRMediaSurface/index.d.ts +2 -1
- package/dist/{contexts-DvQI4PqI.js → contexts-ByhzppYl.js} +3 -3
- package/dist/{contexts-h-9TRH0r.cjs → contexts-Dr62It_K.cjs} +1 -1
- package/dist/debug-ui/media-source.cjs +1 -1
- package/dist/debug-ui/media-source.js +1 -1
- package/dist/debug-ui.cjs +1 -1
- package/dist/debug-ui.js +10 -10
- package/dist/entries/core.d.ts +3 -2
- package/dist/entries/face-effects.d.ts +2 -2
- package/dist/entries/tracking.d.ts +2 -0
- package/dist/face-effects.cjs +1 -1
- package/dist/face-effects.js +25 -24
- package/dist/{getFaceInfo-B43Cwq4n.js → getFaceInfo-C4QpCQIY.js} +1 -1
- package/dist/{getFaceInfo-DEzcL_Ub.cjs → getFaceInfo-fA1bFBub.cjs} +1 -1
- package/dist/hooks/useXRSession/facade.d.ts +2 -0
- package/dist/{index-I4eF5TKT.js → index-9dlAQAhy.js} +405 -400
- package/dist/{index-CY7Z8cHV.cjs → index-BjmTe9eM.cjs} +1 -1
- package/dist/{index-D67hHm44.cjs → index-BpEf2BBb.cjs} +1 -1
- package/dist/{index-B-s4YbWu.js → index-ByoNj0QP.js} +1 -1
- package/dist/{index-CxMEeCRP.cjs → index-CyUUurQT.cjs} +1 -1
- package/dist/index-DCiMbxC3.cjs +1 -0
- package/dist/{index-G_5h_FJQ.js → index-DXT3WccE.js} +808 -787
- package/dist/index-DpI-qo5X.cjs +17 -0
- package/dist/{index-DYfY9ljy.js → index-DyVF4vEW.js} +1 -1
- package/dist/{index-uE3sKczj.js → index-VJ0SJwmG.js} +1 -1
- package/dist/{internal-MvKrz0Nt.cjs → internal-Cq-TEQ5Y.cjs} +1 -1
- package/dist/{internal-ldPYiUF0.js → internal-Dmk1cTXq.js} +3 -3
- package/dist/internal.cjs +1 -1
- package/dist/internal.js +1 -1
- package/dist/low-level.cjs +1 -1
- package/dist/low-level.js +344 -330
- package/dist/main.cjs +1 -1
- package/dist/main.js +94 -91
- package/dist/{renderGroups-BJsx32q5.cjs → renderGroups-80H3DpTl.cjs} +1 -1
- package/dist/{renderGroups-CFt1yYLB.js → renderGroups-KZk6eRiY.js} +1 -1
- package/dist/{renderPasses-D-Krl6D0.cjs → renderPasses-BOoBSr8z.cjs} +1 -1
- package/dist/{renderPasses-C72MbZ-a.js → renderPasses-BcquyVtu.js} +4 -4
- package/dist/scene-object.cjs +1 -1
- package/dist/scene-object.js +2 -2
- package/dist/screen2d/coordinates.d.ts +20 -0
- package/dist/{selectors-ByKNTXeA.js → selectors-B8H97CKA.js} +1 -1
- package/dist/{selectors-CAwmL9VW.cjs → selectors-CZLKT2Iv.cjs} +1 -1
- package/dist/{session-CANvoLD6.cjs → session-CpkiK5YA.cjs} +1 -1
- package/dist/{session-Dhi0OqZo.js → session-DLFN_VII.js} +1 -1
- package/dist/tracking/coordinates.d.ts +5 -0
- package/dist/tracking.cjs +1 -1
- package/dist/tracking.js +69 -66
- package/dist/types/common.d.ts +11 -1
- package/dist/types/gesture-tracking.d.ts +2 -2
- package/dist/types/hand-tracking.d.ts +3 -3
- package/dist/types/nodes.d.ts +2 -2
- package/dist/types/session.d.ts +7 -1
- package/dist/{useFaceInfo-BSZq7AO1.cjs → useFaceInfo-BJ8-_MOs.cjs} +1 -1
- package/dist/{useFaceInfo-FVQBBNdY.js → useFaceInfo-Dk426LTu.js} +3 -3
- package/dist/{useFaceResults-D62STzT1.js → useFaceResults-CtetsO9M.js} +1 -1
- package/dist/{useFaceResults-C3oZkn2Z.cjs → useFaceResults-wBJF3zyp.cjs} +1 -1
- package/docs/SDK_DOCUMENTATION.md +3 -0
- package/docs/api/capture-recording.mdx +9 -1
- package/docs/api/face-mesh.mdx +33 -0
- package/docs/api/runtime-3d.mdx +5 -0
- package/docs/api/screen-image.mdx +3 -1
- package/docs/api/screen-space-coordinates.mdx +31 -0
- package/docs/api/trackers.mdx +13 -0
- package/package.json +4 -1
- package/dist/index-C0-fg1Hk.cjs +0 -1
- package/dist/index-DPPpU5By.cjs +0 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const M=require("react"),m=require("react/jsx-runtime"),v=require("@react-three/drei"),N=require("@react-three/fiber"),c=require("three"),U=require("./index-
|
|
1
|
+
"use strict";const M=require("react"),m=require("react/jsx-runtime"),v=require("@react-three/drei"),N=require("@react-three/fiber"),c=require("three"),U=require("./index-CyUUurQT.cjs"),y=M.createContext(null),F=()=>{const e=M.useContext(y);if(!e)throw new Error("useScreenSpace must be used within ScreenSpaceUI");return e},_=M.createContext(null),P=()=>M.useContext(_)??1;function W(e){const r=new Map,t=new Map,i=e.clone();return x(e,i,function(a,o){r.set(o,a),t.set(a,o)}),i.traverse(function(a){if(!a.isSkinnedMesh)return;const o=a,f=r.get(a),l=f.skeleton.bones;o.skeleton=f.skeleton.clone(),o.bindMatrix.copy(f.bindMatrix),o.skeleton.bones=l.map(function(p){return t.get(p)}),o.bind(o.skeleton,o.bindMatrix)}),i}function x(e,r,t){t(e,r);for(let i=0;i<e.children.length;i++)x(e.children[i],r.children[i],t)}const K={enabled:!0,mesh:"cube",material:{type:"standard",color:"#ffffff",opacity:1,wireframe:!1,roughness:.42,metalness:.08},shadowMode:"off",visible:!0},g={depthTest:!0,depthWrite:!0,depthFunc:"lessEqual",colorWrite:!0,colorMask:{r:!0,g:!0,b:!0,a:!0},cullMode:"back",blendMode:"normal",polygonOffset:{enabled:!1,factor:0,units:0}},E=e=>({...g,...e,colorMask:{...g.colorMask,...e==null?void 0:e.colorMask},polygonOffset:{...g.polygonOffset,...e==null?void 0:e.polygonOffset}}),D=e=>e==="never"?c.NeverDepth:e==="less"?c.LessDepth:e==="equal"?c.EqualDepth:e==="greater"?c.GreaterDepth:e==="notEqual"?c.NotEqualDepth:e==="greaterEqual"?c.GreaterEqualDepth:e==="always"?c.AlwaysDepth:c.LessEqualDepth,C=e=>e==="front"?c.BackSide:e==="off"?c.DoubleSide:c.FrontSide,O=e=>e==="additive"?c.AdditiveBlending:e==="subtractive"?c.SubtractiveBlending:e==="multiply"?c.MultiplyBlending:e==="none"?c.NoBlending:c.NormalBlending,w=e=>{const r=E(e),t=r.colorWrite&&(r.colorMask.r||r.colorMask.g||r.colorMask.b||r.colorMask.a);return{depthTest:r.depthTest,depthWrite:r.depthWrite,depthFunc:D(r.depthFunc),colorWrite:t,side:C(r.cullMode),blending:O(r.blendMode),polygonOffset:r.polygonOffset.enabled,polygonOffsetFactor:r.polygonOffset.factor,polygonOffsetUnits:r.polygonOffset.units}},T=(e,r)=>{const t=E(r);return e<1||t.blendMode!=="normal"&&t.blendMode!=="none"},b=e=>e.colorWrite&&(!e.colorMask.r||!e.colorMask.g||!e.colorMask.b||!e.colorMask.a),R="__vincenttPreviousColorMask",A="__vincenttColorMaskBaseBefore",S="__vincenttColorMaskBaseAfter",G=(e,r)=>{const t=e.userData,i=t[A]??e.onBeforeRender.bind(e),a=t[S]??e.onAfterRender.bind(e);if(t[A]=i,t[S]=a,!b(r)){e.onBeforeRender=i,e.onAfterRender=a;return}e.onBeforeRender=(o,f,l,p,n,u)=>{i(o,f,l,p,n,u);const s=o.getContext();e.userData[R]=s.getParameter(s.COLOR_WRITEMASK),s.colorMask(r.colorMask.r,r.colorMask.g,r.colorMask.b,r.colorMask.a)},e.onAfterRender=(o,f,l,p,n,u)=>{const s=e.userData[R];s&&(o.getContext().colorMask(...s),delete e.userData[R]),a(o,f,l,p,n,u)}},B=e=>({castShadow:e==="cast"||e==="castReceive",receiveShadow:e==="receive"||e==="castReceive"}),H=({mesh:e})=>e==="sphere"?m.jsx("sphereGeometry",{args:[.85,48,32]}):e==="plane"?m.jsx("planeGeometry",{args:[1.6,1.6]}):m.jsx("boxGeometry",{args:[1.4,1.4,1.4]}),I=({url:e,nodeName:r,settings:t,renderOrder:i})=>{const{scene:a,animations:o}=v.useGLTF(e),f=M.useRef(null),l=M.useMemo(()=>{const n=o.length?W(a):a.clone(!0);return n.traverse(u=>{const s=u;!s.isMesh||!s.material||(s.material=Array.isArray(s.material)?s.material.map(k=>k.clone()):s.material.clone())}),n},[a,o.length]);M.useEffect(()=>{const n=B(t.shadowMode),u=Math.min(1,Math.max(0,t.material.opacity)),s=w(t.material.renderState),k=T(u,t.material.renderState);l.traverse(L=>{const d=L;if(!d.isMesh||!d.material)return;d.castShadow=n.castShadow,d.receiveShadow=n.receiveShadow,(Array.isArray(d.material)?d.material:[d.material]).forEach(h=>{if(!h)return;const q=h;q.wireframe=t.material.wireframe,h.opacity=u,h.transparent=k,Object.assign(h,s),h.needsUpdate=!0}),G(d,E(t.material.renderState))})},[l,t.material.opacity,t.material.renderState,t.material.wireframe,t.shadowMode]);const p=r?l.getObjectByName(r):l;return M.useEffect(()=>{if(!o.length)return;const n=new c.AnimationMixer(l);return o.filter(s=>t.assetAnimation==="all"||s.name===t.assetAnimation).forEach(s=>n.clipAction(s).setLoop(c.LoopRepeat,1/0).play()),f.current=n,()=>{n.stopAllAction(),n.uncacheRoot(l),f.current=null}},[o,l,t.assetAnimation]),N.useFrame((n,u)=>{var s;return(s=f.current)==null?void 0:s.update(u)}),m.jsx("group",{renderOrder:i,children:m.jsx("primitive",{object:p??l})})},z=({renderOrder:e,value:r})=>{if(!r.enabled||!r.visible)return null;if(r.assetUrl)return m.jsx(M.Suspense,{fallback:null,children:m.jsx(I,{url:r.assetUrl,nodeName:r.assetNodeName,settings:r,renderOrder:e})});const t=Math.min(1,Math.max(0,r.material.opacity)),i={color:r.material.color,transparent:T(t,r.material.renderState),opacity:t,wireframe:r.material.wireframe,...w(r.material.renderState)};return m.jsxs("mesh",{...B(r.shadowMode),onBeforeRender:(a,o,f,l,p)=>{const n=E(r.material.renderState);if(!b(n))return;const u=a.getContext();p.userData[R]=u.getParameter(u.COLOR_WRITEMASK),u.colorMask(n.colorMask.r,n.colorMask.g,n.colorMask.b,n.colorMask.a)},onAfterRender:(a,o,f,l,p)=>{const n=p.userData[R];n&&(a.getContext().colorMask(...n),delete p.userData[R])},renderOrder:e,children:[m.jsx(H,{mesh:r.mesh}),m.jsx(U.MeshMaterial,{settings:r.material,materialProps:i})]})};exports.DEFAULT_MESH_RENDERER=K;exports.DEFAULT_MESH_RENDERER_RENDER_STATE=g;exports.MeshRenderer=z;exports.ScreenRectAspectContext=_;exports.ScreenSpaceContext=y;exports.getThreeBlending=O;exports.getThreeDepthFunction=D;exports.getThreeSide=C;exports.normalizeMeshRendererRenderState=E;exports.useScreenRectAspect=P;exports.useScreenSpace=F;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const w=require("react/jsx-runtime"),_=require("@react-three/fiber"),p=require("react"),H=require("three"),O=require("./renderLayers-lDtL0_43.cjs"),S=require("./index-
|
|
1
|
+
"use strict";const w=require("react/jsx-runtime"),_=require("@react-three/fiber"),p=require("react"),H=require("three"),O=require("./renderLayers-lDtL0_43.cjs"),S=require("./index-CyUUurQT.cjs");function D(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const h=D(H),q=["face.center","face.forehead","face.noseTip","face.chin","face.leftEyeOuter","face.rightEyeOuter","face.leftCheek","face.rightCheek","face.mouthCenter","face.leftEye","face.rightEye","face.leftEarlobe","face.rightEarlobe","face.custom"],v=["hand.wrist","hand.thumbTip","hand.indexTip","hand.middleTip","hand.ringTip","hand.pinkyTip","hand.indexBase","hand.middleBase","hand.ringBase","hand.pinkyBase"],z=["body.head","body.neck","body.leftShoulder","body.rightShoulder","body.leftElbow","body.rightElbow","body.leftWrist","body.rightWrist","body.leftHip","body.rightHip","body.leftKnee","body.rightKnee","body.leftAnkle","body.rightAnkle"],A=e=>e.startsWith("face.")?"face":e.startsWith("hand.")?"hand":e.startsWith("body.")?"body":null,N={target:"face.center",customAnchorPoint:{x:0,y:0,z:0},offset:{x:0,y:0,z:0},smoothing:0,followFaceRoll:!1},R=(e,r,n)=>r+n*(e-r),E=(e,r)=>1/(1+1/(2*Math.PI*e)/r),C=(e,r,n,a,T,t)=>{if(!e.initialized||n<=0)return e.pos.copy(r),e.prevRaw.copy(r),e.dxHat.set(0,0,0),e.initialized=!0,e;const c=E(t,n),u=["x","y","z"];for(const o of u){const l=(r[o]-e.prevRaw[o])/n,i=R(l,e.dxHat[o],c);e.dxHat[o]=i;const f=a+T*Math.abs(i),d=E(f,n);e.pos[o]=R(r[o],e.pos[o],d),e.prevRaw[o]=r[o]}return e},m=(e,r,n,a)=>C(e,r,n,a*.1,.5,1),F=({target:e,customAnchorPoint:r,offset:n,smoothing:a=0,children:T})=>{const t=S.useTrackerContext(),c=p.useRef(null),u=p.useRef(!1),o=p.useRef(new h.Vector3),l=p.useRef({pos:new h.Vector3,prevRaw:new h.Vector3,dxHat:new h.Vector3,initialized:!1}),i=A(e),f=t!==null&&i!==null&&t.type!==i,d=t===null,b=d||f||i===null;return p.useEffect(()=>{d?console.warn(`[TrackingAnchor] target "${e}" requires a FaceTracker / HandTracker / BodyTracker ancestor; rendering null.`):f?console.warn(`[TrackingAnchor] target "${e}" namespace does not match parent tracker type "${t==null?void 0:t.type}"; rendering null.`):i===null&&console.warn(`[TrackingAnchor] target "${e}" is not a recognized face/hand/body landmark; rendering null.`)},[e,i,d,f,t==null?void 0:t.type]),_.useFrame((G,k)=>{if(b||!c.current||!t)return;const y=t.resolveLandmark(e,r);if(!y){c.current.visible=!1,u.current=!1,l.current.initialized=!1;return}c.current.visible=!0;const s=o.current.copy(y.position),g=c.current.parent;if(g){g.updateMatrixWorld();const x=new h.Matrix4().copy(g.matrixWorld).invert();s.applyMatrix4(x)}n&&(s.x+=n[0],s.y+=n[1],s.z+=n[2]),a>0?(m(l.current,s,u.current?k:0,a),c.current.position.copy(l.current.pos)):c.current.position.copy(s),u.current=!0,y.quaternion&&c.current.quaternion.copy(y.quaternion)}),b?null:w.jsx("group",{ref:c,renderOrder:O.RENDER_LAYERS.TRACKED,children:T})};exports.BODY_TARGETS=z;exports.DEFAULT_TRACKING_ANCHOR=N;exports.FACE_TARGETS=q;exports.HAND_TARGETS=v;exports.TrackingAnchor=F;exports.getTargetNamespace=A;exports.stepTrackingSmoothing=m;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _, jsxs as w } from "react/jsx-runtime";
|
|
2
2
|
import { useThree as k, useFrame as U } from "@react-three/fiber";
|
|
3
3
|
import z, { useId as B, useState as W, useRef as A, useEffect as F, useSyncExternalStore as q, useMemo as v, useContext as G, createContext as J, useCallback as Q } from "react";
|
|
4
|
-
import { u as $, a as e0, X as P, b as t0 } from "./index-
|
|
4
|
+
import { u as $, a as e0, X as P, b as t0 } from "./index-9dlAQAhy.js";
|
|
5
5
|
import { R as n0 } from "./renderLayers-zrK2pv5O.js";
|
|
6
6
|
import * as T from "three";
|
|
7
7
|
function r0(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const _=require("react/jsx-runtime"),v=require("@react-three/fiber"),s=require("react"),S=require("./index-C0-fg1Hk.cjs"),X=require("./renderLayers-lDtL0_43.cjs"),V=require("three");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=Y(V);function Z(e){return JSON.stringify(e??{})}function N(e,t,n=!0){const{session:r}=S.useXRContext(),o=s.useId(),[u,d]=s.useState(null),l=Z(t),c=s.useRef(t);c.current=t,s.useEffect(()=>{let i=!1;return d(null),r.registry.acquire(e,o,c.current).catch(f=>{i||d(f instanceof Error?f:new Error(String(f)))}),()=>{i=!0,r.registry.release(e,o)}},[r,e,o,l]),s.useEffect(()=>{r.registry.setActive(e,o,n)},[r,e,o,n]);const y=r.store,A=s.useSyncExternalStore(i=>y.subscribe(i),()=>y.getSnapshot().pipeline.get(e)??null,()=>null),E=s.useMemo(()=>A?A.getModelNode():null,[A]);return{ready:A!==null&&u===null,node:E,error:u}}const U=({materialProps:e,settings:t})=>t.type==="basic"?_.jsx("meshBasicMaterial",{...e}):_.jsx("meshStandardMaterial",{...e,roughness:t.roughness,metalness:t.metalness}),j=1e-6,B=e=>{const{x:t,y:n,z:r}=e.scale;return Math.abs(t-n)<=j&&Math.abs(t-r)<=j?t:1},W=(e,t,n,r)=>{if(!n.enabled)return e;const o=B(n);return r.x=t.x+(e.x-t.x)*o+n.position.x,r.y=t.y+(e.y-t.y)*o-n.position.y,r.z=t.z+(e.z-t.z)*o+n.position.z,r},G=(e,t,n)=>S.unprojectToZZeroInto(e,t,n),J=(e,t,n)=>{const r=(e.x-.5)*2,o=(.5-e.y)*2,u=b.MathUtils.clamp(e.z*2,-1,1);return n.set(r,o,u).unproject(t)},Q=(e,t,n,r,o,u)=>{const d=Math.min(t,e.length);for(let l=0;l<d;l++){o(e[l],r,u);const c=l*3;n[c]=u.x,n[c+1]=u.y,n[c+2]=u.z}return d},$=[[127,34,139],[11,0,37],[232,231,120],[72,37,39],[128,121,47],[232,121,128],[104,69,67],[175,171,148],[118,50,101],[73,39,40],[9,151,108],[48,115,131],[194,204,211],[74,40,185],[80,42,183],[40,92,186],[230,229,118],[202,212,214],[83,18,17],[76,61,146],[160,29,30],[56,157,173],[106,204,194],[135,214,192],[203,165,98],[21,71,68],[51,45,4],[144,24,23],[77,146,91],[205,50,187],[201,200,18],[91,106,182],[90,91,181],[85,84,17],[206,203,36],[148,171,140],[92,40,39],[193,189,244],[159,158,28],[247,246,161],[236,3,196],[54,68,104],[193,168,8],[117,228,31],[189,193,55],[98,97,99],[126,47,100],[166,79,218],[155,154,26],[209,49,131],[135,136,150],[47,126,217],[223,52,53],[45,51,134],[211,170,140],[67,69,108],[43,106,91],[230,119,120],[226,130,247],[63,53,52],[238,20,242],[46,70,156],[78,62,96],[46,53,63],[143,34,227],[123,117,111],[44,125,19],[236,134,51],[216,206,205],[154,153,22],[39,37,167],[200,201,208],[36,142,100],[57,212,202],[20,60,99],[28,158,157],[35,226,113],[160,159,27],[204,202,210],[113,225,46],[43,202,204],[62,76,77],[137,123,116],[41,38,72],[203,129,142],[64,98,240],[49,102,64],[41,73,74],[212,216,207],[42,74,184],[169,170,211],[170,149,176],[105,66,69],[122,6,168],[123,147,187],[96,77,90],[65,55,107],[89,90,180],[101,100,120],[63,105,104],[93,137,227],[15,86,85],[129,102,49],[14,87,86],[55,8,9],[100,47,121],[145,23,22],[88,89,179],[6,122,196],[88,95,96],[138,172,136],[215,58,172],[115,48,219],[42,80,81],[195,3,51],[43,146,61],[171,175,199],[81,82,38],[53,46,225],[144,163,110],[52,65,66],[229,228,117],[34,127,234],[107,108,69],[109,108,151],[48,64,235],[62,78,191],[129,209,126],[111,35,143],[117,123,50],[222,65,52],[19,125,141],[221,55,65],[3,195,197],[25,7,33],[220,237,44],[70,71,139],[122,193,245],[247,130,33],[71,21,162],[170,169,150],[188,174,196],[216,186,92],[2,97,167],[141,125,241],[164,167,37],[72,38,12],[38,82,13],[63,68,71],[226,35,111],[101,50,205],[206,92,165],[209,198,217],[165,167,97],[220,115,218],[133,112,243],[239,238,241],[214,135,169],[190,173,133],[171,208,32],[125,44,237],[86,87,178],[85,86,179],[84,85,180],[83,84,181],[201,83,182],[137,93,132],[76,62,183],[61,76,184],[57,61,185],[212,57,186],[214,207,187],[34,143,156],[79,239,237],[123,137,177],[44,1,4],[201,194,32],[64,102,129],[213,215,138],[59,166,219],[242,99,97],[2,94,141],[75,59,235],[24,110,228],[25,130,226],[23,24,229],[22,23,230],[26,22,231],[112,26,232],[189,190,243],[221,56,190],[28,56,221],[27,28,222],[29,27,223],[30,29,224],[247,30,225],[238,79,20],[166,59,75],[60,75,240],[147,177,215],[20,79,166],[187,147,213],[112,233,244],[233,128,245],[128,114,188],[114,217,174],[131,115,220],[217,198,236],[198,131,134],[177,132,58],[143,35,124],[110,163,7],[228,110,25],[356,389,368],[11,302,267],[452,350,349],[302,303,269],[357,343,277],[452,453,357],[333,332,297],[175,152,377],[347,348,330],[303,304,270],[9,336,337],[278,279,360],[418,262,431],[304,408,409],[310,415,407],[270,409,410],[450,348,347],[422,430,434],[313,314,17],[306,307,375],[387,388,260],[286,414,398],[335,406,418],[364,367,416],[423,358,327],[251,284,298],[281,5,4],[373,374,253],[307,320,321],[425,427,411],[421,313,18],[321,405,406],[320,404,405],[315,16,17],[426,425,266],[377,400,369],[322,391,269],[417,465,464],[386,257,258],[466,260,388],[456,399,419],[284,332,333],[417,285,8],[346,340,261],[413,441,285],[327,460,328],[355,371,329],[392,439,438],[382,341,256],[429,420,360],[364,394,379],[277,343,437],[443,444,283],[275,440,363],[431,262,369],[297,338,337],[273,375,321],[450,451,349],[446,342,467],[293,334,282],[458,461,462],[276,353,383],[308,324,325],[276,300,293],[372,345,447],[352,345,340],[274,1,19],[456,248,281],[436,427,425],[381,256,252],[269,391,393],[200,199,428],[266,330,329],[287,273,422],[250,462,328],[258,286,384],[265,353,342],[387,259,257],[424,431,430],[342,353,276],[273,335,424],[292,325,307],[366,447,345],[271,303,302],[423,266,371],[294,455,460],[279,278,294],[271,272,304],[432,434,427],[272,407,408],[394,430,431],[395,369,400],[334,333,299],[351,417,168],[352,280,411],[325,319,320],[295,296,336],[319,403,404],[330,348,349],[293,298,333],[323,454,447],[15,16,315],[358,429,279],[14,15,316],[285,336,9],[329,349,350],[374,380,252],[318,402,403],[6,197,419],[318,319,325],[367,364,365],[435,367,397],[344,438,439],[272,271,311],[195,5,281],[273,287,291],[396,428,199],[311,271,268],[283,444,445],[373,254,339],[282,334,296],[449,347,346],[264,447,454],[336,296,299],[338,10,151],[278,439,455],[292,407,415],[358,371,355],[340,345,372],[346,347,280],[442,443,282],[19,94,370],[441,442,295],[248,419,197],[263,255,359],[440,275,274],[300,383,368],[351,412,465],[263,467,466],[301,368,389],[395,378,379],[412,351,419],[436,426,322],[2,164,393],[370,462,461],[164,0,267],[302,11,12],[268,12,13],[293,300,301],[446,261,340],[330,266,425],[426,423,391],[429,355,437],[391,327,326],[440,457,438],[341,382,362],[459,457,461],[434,430,394],[414,463,362],[396,369,262],[354,461,457],[316,403,402],[315,404,403],[314,405,404],[313,406,405],[421,418,406],[366,401,361],[306,408,407],[291,409,408],[287,410,409],[432,436,410],[434,416,411],[264,368,383],[309,438,457],[352,376,401],[274,275,4],[421,428,262],[294,327,358],[433,416,367],[289,455,439],[462,370,326],[2,326,370],[305,460,455],[254,449,448],[255,261,446],[253,450,449],[252,451,450],[256,452,451],[341,453,452],[413,464,463],[441,413,414],[258,442,441],[257,443,442],[259,444,443],[260,445,444],[467,342,445],[459,458,250],[289,392,290],[290,328,460],[376,433,435],[250,290,392],[411,416,433],[341,463,464],[453,464,465],[357,465,412],[343,412,399],[360,363,440],[437,399,456],[420,456,363],[401,435,288],[372,383,353],[339,255,249],[448,261,255],[133,243,190],[133,155,112],[33,246,247],[33,130,25],[398,384,286],[362,398,414],[362,463,341],[263,359,467],[263,249,255],[466,467,260],[75,60,166],[238,239,79],[162,127,139],[72,11,37],[121,232,120],[73,72,39],[114,128,47],[233,232,128],[103,104,67],[152,175,148],[119,118,101],[74,73,40],[107,9,108],[49,48,131],[32,194,211],[184,74,185],[191,80,183],[185,40,186],[119,230,118],[210,202,214],[84,83,17],[77,76,146],[161,160,30],[190,56,173],[182,106,194],[138,135,192],[129,203,98],[54,21,68],[5,51,4],[145,144,23],[90,77,91],[207,205,187],[83,201,18],[181,91,182],[180,90,181],[16,85,17],[205,206,36],[176,148,140],[165,92,39],[245,193,244],[27,159,28],[30,247,161],[174,236,196],[103,54,104],[55,193,8],[111,117,31],[221,189,55],[240,98,99],[142,126,100],[219,166,218],[112,155,26],[198,209,131],[169,135,150],[114,47,217],[224,223,53],[220,45,134],[32,211,140],[109,67,108],[146,43,91],[231,230,120],[113,226,247],[105,63,52],[241,238,242],[124,46,156],[95,78,96],[70,46,63],[116,143,227],[116,123,111],[1,44,19],[3,236,51],[207,216,205],[26,154,22],[165,39,167],[199,200,208],[101,36,100],[43,57,202],[242,20,99],[56,28,157],[124,35,113],[29,160,27],[211,204,210],[124,113,46],[106,43,204],[96,62,77],[227,137,116],[73,41,72],[36,203,142],[235,64,240],[48,49,64],[42,41,74],[214,212,207],[183,42,184],[210,169,211],[140,170,176],[104,105,69],[193,122,168],[50,123,187],[89,96,90],[66,65,107],[179,89,180],[119,101,120],[68,63,104],[234,93,227],[16,15,85],[209,129,49],[15,14,86],[107,55,9],[120,100,121],[153,145,22],[178,88,179],[197,6,196],[89,88,96],[135,138,136],[138,215,172],[218,115,219],[41,42,81],[5,195,51],[57,43,61],[208,171,199],[41,81,38],[224,53,225],[24,144,110],[105,52,66],[118,229,117],[227,34,234],[66,107,69],[10,109,151],[219,48,235],[183,62,191],[142,129,126],[116,111,143],[118,117,50],[223,222,52],[94,19,141],[222,221,65],[196,3,197],[45,220,44],[156,70,139],[188,122,245],[139,71,162],[149,170,150],[122,188,196],[206,216,92],[164,2,167],[242,141,241],[0,164,37],[11,72,12],[12,38,13],[70,63,71],[31,226,111],[36,101,205],[203,206,165],[126,209,217],[98,165,97],[237,220,218],[237,239,241],[210,214,169],[140,171,32],[241,125,237],[179,86,178],[180,85,179],[181,84,180],[182,83,181],[194,201,182],[177,137,132],[184,76,183],[185,61,184],[186,57,185],[216,212,186],[192,214,187],[139,34,156],[218,79,237],[147,123,177],[45,44,4],[208,201,32],[98,64,129],[192,213,138],[235,59,219],[141,242,97],[97,2,141],[240,75,235],[229,24,228],[31,25,226],[230,23,229],[231,22,230],[232,26,231],[233,112,232],[244,189,243],[189,221,190],[222,28,221],[223,27,222],[224,29,223],[225,30,224],[113,247,225],[99,60,240],[213,147,215],[60,20,166],[192,187,213],[243,112,244],[244,233,245],[245,128,188],[188,114,174],[134,131,220],[174,217,236],[236,198,134],[215,177,58],[156,143,124],[25,110,7],[31,228,25],[264,356,368],[0,11,267],[451,452,349],[267,302,269],[350,357,277],[350,452,357],[299,333,297],[396,175,377],[280,347,330],[269,303,270],[151,9,337],[344,278,360],[424,418,431],[270,304,409],[272,310,407],[322,270,410],[449,450,347],[432,422,434],[18,313,17],[291,306,375],[259,387,260],[424,335,418],[434,364,416],[391,423,327],[301,251,298],[275,281,4],[254,373,253],[375,307,321],[280,425,411],[200,421,18],[335,321,406],[321,320,405],[314,315,17],[423,426,266],[396,377,369],[270,322,269],[413,417,464],[385,386,258],[248,456,419],[298,284,333],[168,417,8],[448,346,261],[417,413,285],[326,327,328],[277,355,329],[309,392,438],[381,382,256],[279,429,360],[365,364,379],[355,277,437],[282,443,283],[281,275,363],[395,431,369],[299,297,337],[335,273,321],[348,450,349],[359,446,467],[283,293,282],[250,458,462],[300,276,383],[292,308,325],[283,276,293],[264,372,447],[346,352,340],[354,274,19],[363,456,281],[426,436,425],[380,381,252],[267,269,393],[421,200,428],[371,266,329],[432,287,422],[290,250,328],[385,258,384],[446,265,342],[386,387,257],[422,424,430],[445,342,276],[422,273,424],[306,292,307],[352,366,345],[268,271,302],[358,423,371],[327,294,460],[331,279,294],[303,271,304],[436,432,427],[304,272,408],[395,394,431],[378,395,400],[296,334,299],[6,351,168],[376,352,411],[307,325,320],[285,295,336],[320,319,404],[329,330,349],[334,293,333],[366,323,447],[316,15,315],[331,358,279],[317,14,316],[8,285,9],[277,329,350],[253,374,252],[319,318,403],[351,6,419],[324,318,325],[397,367,365],[288,435,397],[278,344,439],[310,272,311],[248,195,281],[375,273,291],[175,396,199],[312,311,268],[276,283,445],[390,373,339],[295,282,296],[448,449,346],[356,264,454],[337,336,299],[337,338,151],[294,278,455],[308,292,415],[429,358,355],[265,340,372],[352,346,280],[295,442,282],[354,19,370],[285,441,295],[195,248,197],[457,440,274],[301,300,368],[417,351,465],[251,301,389],[394,395,379],[399,412,419],[410,436,322],[326,2,393],[354,370,461],[393,164,267],[268,302,12],[312,268,13],[298,293,301],[265,446,340],[280,330,425],[322,426,391],[420,429,437],[393,391,326],[344,440,438],[458,459,461],[364,434,394],[428,396,262],[274,354,457],[317,316,402],[316,315,403],[315,314,404],[314,313,405],[313,421,406],[323,366,361],[292,306,407],[306,291,408],[291,287,409],[287,432,410],[427,434,411],[372,264,383],[459,309,457],[366,352,401],[1,274,4],[418,421,262],[331,294,358],[435,433,367],[392,289,439],[328,462,326],[94,2,370],[289,305,455],[339,254,448],[359,255,446],[254,253,449],[253,252,450],[252,256,451],[256,341,452],[414,413,463],[286,441,414],[286,258,441],[258,257,442],[257,259,443],[259,260,444],[260,467,445],[309,459,250],[305,289,290],[305,290,460],[401,376,435],[309,250,392],[376,411,433],[453,341,464],[357,453,465],[343,357,412],[437,343,399],[344,360,440],[420,437,456],[360,420,363],[361,401,288],[265,372,353],[390,339,249],[339,448,255],[255,339,448]].flat(),e0=[.5104879319667817,.33515610277652746,.5174233198165894,.43859300494194037,.5123749554157258,.406469448208809,.5423470318317414,.5244461464881898,.5190713584423066,.46557595014572145,.5194876372814179,.5006013351678849,.5178673148155213,.5855525898933411,.7009655416011811,.5918984371423721,.5193980515003205,.6528422343730926,.520683366060257,.689273599088192,.5248700261116028,.8232529717683792,.5099657952785492,.32301718473434454,.5088536620140076,.31080526888370513,.5081197202205658,.3013389307260514,.5072353065013886,.29900476515293123,.5073091566562653,.28442813932895666,.5065075337886811,.26649361431598667,.5061309516429902,.24778731942176818,.5031875848770142,.22179436564445493,.515326726436615,.4231037962436676,.5375777959823609,.4205444622039795,.8049442350864411,.6867966356873512,.6222659975290299,.570705144405365,.6496635556221009,.567776631116867,.6773027807474137,.5670208501815797,.7126377105712891,.5800703662633897,.5999099642038346,.5764724123477936,.674340370297432,.6495546865463258,.639536875486374,.6477413746714593,.703840109705925,.642201315164566,.7209078550338746,.6294069054722786,.7342745542526246,.5601695317029953,.6015644401311875,.18118685364723203,.7114282578229905,.598883952498436,.809715884923935,.5682615923881531,.7667155593633652,.5767241555452347,.6445030301809311,.45154162526130676,.541424173116684,.34213731765747074,.5359058856964112,.3113374251127243,.5710002213716507,.33134433805942537,.5891562283039093,.31890978991985325,.5585465461015702,.3096196609735489,.5759132236242295,.30601608335971836,.6229794204235077,.2713706839084626,.5398103773593903,.43802148282527925,.545369166135788,.46441581428051,.7616913348436356,.6473416510224344,.5914883643388749,.5243312466144563,.5945767045021058,.44076132655143746,.5964909076690674,.4544808346033096,.7225886166095734,.4498931097984314,.5443432211875916,.49703910827636727,.7029067009687424,.6777765545248986,.7391736537218094,.6677046212553979,.7836920201778412,.7359224516153335,.577455359697342,.6573990839719772,.6085408657789231,.6353888112306596,.6427326381206513,.298196165561676,.7550604224205018,.30743678390979773,.5732827365398407,.4262381809949875,.5523188143968583,.417594336271286,.6096987754106522,.29745593249797825,.6036115020513535,.2985246556997299,.7549919366836548,.6845966669917107,.592850747704506,.4273046988248826,.6501948565244675,.6762702855467797,.6582381755113602,.699515787065029,.682483646273613,.802994977235794,.768890205025673,.710366437137127,.6672395795583725,.752104974091053,.7775519520044327,.6584857258200645,.7920276552438736,.6709628927707671,.5397542297840119,.3256357330083847,.5643998861312867,.3199443298578262,.5826229482889176,.313130943775177,.5657853364944458,.42035281538963326,.606510478258133,.2980171996355057,.5952901721000672,.2918463486433029,.5999826073646546,.29865378022193906,.565356719493866,.4374908703565598,.570739108324051,.30172707617282873,.5532697021961213,.303354971408844,.532040822505951,.3026815611124039,.5385064661502839,.22311560392379765,.5377482950687409,.25083183526992797,.5373399734497071,.26933391273021695,.5351483404636384,.28629542768001554,.5317461371421814,.3004490631818772,.5704152762889863,.30009212374687194,.5761924862861634,.2931597578525544,.5817892730236054,.28451425909996036,.5862761169672013,.27445026516914367,.6169582635164261,.3500816184282303,.7930811375379563,.4456584650278092,.5136566936969758,.41420710563659674,.5836256474256516,.29897587478160864,.5893380820751191,.29504160165786747,.5458188831806183,.4063113230466843,.581692311167717,.41034119904041294,.5490593492984772,.4114610868692398,.6189475685358048,.5063568043708802,.6631498366594315,.48547921061515814,.5990702986717225,.44076220870018007,.7452016949653626,.7754116746783257,.729542288184166,.7380649703741073,.7152380675077439,.6996659177541733,.6012845069169999,.2532631474733353,.5908916622400284,.6924743655323982,.6002487272024155,.7558749470114707,.611236396431923,.817432113289833,.6991332352161408,.5705236423015594,.7608276635408402,.5389788854122162,.5859951555728913,.5837152945995332,.7452233761548996,.6138822454214097,.5740126550197602,.542653586268425,.5829357832670212,.45267452478408815,.7883433729410172,.5171645599603654,.7431249052286149,.5203535276651383,.7091684520244599,.5116798001527787,.6566549122333527,.5192352938652038,.6176983743906022,.532645167708397,.590181502699852,.5458893078565599,.5431278228759766,.5780327129364013,.7785866141319275,.4588600414991379,.7662802815437317,.614813904762268,.528258103132248,.42353384375572206,.5884005159139634,.49679056286811835,.8132390558719635,.5690749335289003,.5698921114206315,.5609081107378007,.5997681200504303,.4383326607942582,.7258545190095902,.5959577548503876,.5829301953315735,.4692867088317872,.7767194837331772,.37870833754539496,.5859857678413392,.5927838939428329,.5655010223388672,.4863545227050781,.7103684276342392,.24216726005077366,.7039464592933655,.21081999421119696,.7955554753541947,.45157338261604313,.7394011497497559,.27975760281085965,.8023439675569535,.6235768947005271,.6065513819456101,.1520459520816803,.5237656712532044,.4144193726778031,.6113508373498917,.4744607317447663,.7872020035982132,.5706054615974427,.6744208365678788,.5840893256664277,.6509357273578644,.5835042405128479,.599469143152237,.28584001839160916,.76683469414711,.4027401643991471,.5548133134841919,.11242247700691227,.6348527550697327,.15134210765361789,.6676738739013672,.17523885548114776,.5231557369232178,.758142014145851,.49590798020362853,.10746171355247497,.6282390981912613,.5856175380945206,.6072420954704285,.5888098138570785,.592762503027916,.5906054276227952,.7843813925981522,.61877524882555,.610203567147255,.6159668180346489,.6345708996057511,.625477318763733,.6599059730768204,.6266139122843744,.6838259130716324,.6209151762723923,.6978932946920395,.6127474161982536,.8138886868953705,.6332776087522507,.690067994594574,.587394626736641,.5115295231342316,.3814830261468887,.593753132224083,.3682318288087845,.5745513767004014,.43174642801284796,.5468618154525757,.38006519258022314,.5175330221652985,.6183956491947173,.6776301890611649,.20638245522975923,.6439310491085053,.1795444029569626,.5587406486272812,.13319884419441225,.7303948730230332,.25156523168087,.5936179041862488,.6020026791095734,.5595558166503907,.5354639637470247,.49903409481048583,.12705478847026824,.5986292988061905,.12926876127719883,.7810411036014557,.3901792484521866,.5526776045560837,.3004089254140854,.5582781463861466,.2904709684848786,.5625745087862015,.2769930589199066,.5656344175338746,.26021293580532073,.5736826092004776,.23544175803661344,.5897697389125824,.3026730704307556,.5960018962621689,.3050022739171982,.6013990819454194,.30801084220409397,.6334722220897675,.32613734483718876,.7345953911542893,.3890004771947861,.5586504369974137,.5622388321161271,.5686756849288941,.6147718372941018,.5835970371961594,.6114995065331459,.58382708132267,.30018893957138065,.7323651343584061,.3204736191034317,.5478970587253571,.6144195291399956,.5885591685771943,.20925473153591162,.5188342511653901,.5294416445493699,.5430448532104493,.5502454686164857,.5189176678657532,.5563708889484407,.5749752998352051,.4918947476148606,.5015926539897919,.1563655036687851,.5023517191410065,.19124654710292815,.5467969954013825,.1949619370698929,.6493796885013581,.2596786844730377,.6223085105419159,.4147812741994858,.6219283074140549,.2305004018545151,.6836527764797211,.41583852946758276,.6457133769989014,.38482945740222935,.7015091359615326,.3687519657611847,.5560723870992661,.1615346747636795,.5877480685710907,.4753766226768494,.672212439775467,.23758670270442966,.6372418433427811,.20715841531753537,.6714329898357392,.2934120523929596,.7559577107429505,.3546825754642487,.7028004407882691,.28965476036071774,.7641248583793641,.3323610144853592,.6633666038513184,.34586538851261145,.5732450067996979,.5168171036243439,.5740206122398377,.4420601803064346,.5862565368413926,.4328912365436554,.5658091634511948,.46056721985340127,.5935333251953125,.6414948242902756,.643502163887024,.6581727835536004,.6862205892801285,.6599488797783852,.71900634765625,.6517863023281099,.7387710094451905,.6366994085907935,.7436862468719483,.5870225805044174,.8067718029022217,.5102852332592012,.719052392244339,.549573050737381,.6912373930215836,.5426725524663925,.6540380597114563,.5452089506387712,.6191460520029068,.5529706466197968,.5933077514171601,.5624450343847276,.5760908752679825,.5711276936531067,.8037864595651627,.5079354095458986,.5832139283418656,.42433229863643646,.5602819353342057,.5111040878295898,.5571386992931366,.44193623840808877,.5406022548675538,.42711933732032775,.5550468444824219,.43675835609436037,.5743813246488572,.4152073520421982,.5367868125438691,.42474128484725954,.5321040332317353,.41727378547191624,.5769275009632111,.5919214832782747,.5631695121526719,.5864408034086228,.555830317735672,.5819090950489045,.7057080000638962,.6055842030048371,.7297580271959305,.614007951617241,.49450652599334716,.5258826154470444,.30584611296653746,.6040364730358123,.4885244846343994,.4224347966909409,.188004332780838,.7111089858412742,.3873521864414215,.5786778944730759,.3588928759098053,.5761974024772645,.32972376346588134,.5772378969192504,.29263614416122435,.5937507289648056,.4124107241630554,.5837435233592987,.3437161326408386,.6627882960438729,.3795058310031891,.6574259343743325,.3114838480949402,.657741964161396,.2904722273349762,.6461278694868089,.2668101370334625,.5759735572338105,.3916287899017334,.18396661460399627,.2956514835357666,.6133467811346054,.17441000342369078,.5913206297159195,.23045413494110106,.5952582108974458,.3695909559726715,.4586390632390976,.4777859032154083,.34189285218715665,.4799880862236023,.31095413148403167,.4436598002910614,.32987600147724155,.42009713053703307,.3173161882162094,.4536511182785034,.3079365211725235,.431768137216568,.30468503117561346,.37606616616249083,.27423435926437384,.49449856877326964,.4396295297145844,.4917183697223663,.4654612708091736,.2524005055427551,.6652582022547722,.4289156973361969,.5291139262914657,.4268526315689087,.44427823305130004,.42474048137664794,.45817836105823523,.2809027314186096,.46354105353355407,.49383275508880614,.49885324716567997,.3271153151988983,.6924127805233002,.28349151015281676,.6843035730719567,.22369228601455687,.7584647151827812,.4591939032077789,.6617383736371993,.40913431644439696,.6426751393079757,.35715471506118773,.30240225076675414,.1987894058227539,.3237072455883026,.4482724845409393,.42876928627491,.4697932779788971,.4196605491638184,.39104996919631957,.2959751355648041,.3971476137638092,.29665681600570676,.26748310327529906,.7016683402657509,.4251814365386963,.4304117369651795,.3845069885253906,.6860294970870018,.3804918110370636,.7099798905849457,.35481985211372374,.8164000543951988,.2475942552089691,.730037857890129,.37163846492767333,.7639490339159964,.23443256616592406,.677293357551098,.2116762578487396,.6924480664730073,.4783883273601532,.32515374898910526,.44883744716644286,.3184075164794922,.42566208839416503,.31092865943908693,.45405327081680297,.4228447753190994,.3932682454586029,.2964416819810867,.4071350872516632,.290535255074501,.40034677386283873,.29673135757446295,.4610676050186157,.44076672971248626,.4361940503120422,.3005809444189072,.45694692730903624,.30211268544197084,.4812539994716644,.30183855772018436,.46574126482009887,.22492808878421783,.47153966426849364,.25130698263645174,.4740802526473999,.2694691020250321,.4768980026245117,.28705804526805884,.48090897798538207,.2996276724338532,.43501039147377013,.2992805469036102,.4293511092662811,.2932880002260208,.4233271360397339,.28415390133857726,.41761367321014403,.27479386210441586,.39445154666900634,.3538810330629349,.16652100086212157,.4672100204229355,.4183532476425171,.29779809594154355,.41378535628318786,.29400077641010286,.47695048451423644,.40816306352615356,.43489335775375365,.41207451105117804,.473628032207489,.41300628066062933,.3975309908390045,.5133917200565339,.34924407601356505,.4949547010660172,.4189921498298645,.44448454558849343,.27738903760910033,.7946441161632538,.29866914749145507,.7549788492918015,.3170970857143402,.7143296006321906,.39919986128807067,.2556870716810226,.4517517566680908,.6986333075165749,.44375439286231994,.7623249980807305,.4346091330051422,.8250303360819817,.3058603286743164,.5830274391174317,.235262531042099,.5560186910629272,.4279192566871643,.5892863947153091,.2622906148433685,.6309370476007461,.45053591132164,.5464099961519242,.44443781971931456,.45605955004692084,.20207332372665404,.5370177584886551,.25663607120513915,.5358516681194305,.29581143260002135,.5243526387214661,.3525206625461578,.5284005987644196,.39442025423049926,.5392975616455078,.42579718232154845,.5511161494255066,.49076547026634215,.5801296907663345,.20957841277122496,.47626241028308874,.23929433822631835,.6331100556254388,.5024659812450409,.4247821944952011,.432133811712265,.5009672063589097,.15906893014907836,.5940177994966507,.4492078602313995,.5648097443580629,.41579030752182006,.4419312763214112,.2798506796360016,.6113770532608032,.44294874668121337,.47275686144828805,.1783646523952484,.3979667472839356,.42730753421783446,.5981915760040284,.46777849197387694,.4889896112680436,.26486464142799376,.2499848622083664,.26026474237442015,.21801546096801755,.17761032581329345,.47220298230648045,.23215438723564147,.29172880232334136,.1906857371330261,.6463678139448166,.3811529755592346,.1541750180721283,.5033367156982422,.41569132089614874,.40528597235679625,.4797393995523453,.2049500823020935,.59123428940773,.3344294309616089,.5942869651317597,.35825960636138915,.5929379391670226,.4015964150428772,.28595646202564245,.21618961095809935,.4194869863986969,.43316020369529723,.11274379968643189,.34098224639892577,.1526068884134293,.3026312172412872,.17882644414901733,.3831480026245117,.5945327538251877,.40483357310295104,.5966399866342544,.419615763425827,.5973996269702913,.2160478115081787,.6388220790028571,.40051244497299193,.6220169800519944,.37555851340293883,.6336345481872558,.3499592423439026,.6373451414704323,.32648445963859557,.6342222797870636,.3108482539653778,.6266552078723908,.16784127354621886,.6591027337312698,.3177972316741943,.5982361245155334,.4220952868461609,.3706905978918075,.4483287215232849,.43451813936233524,.4753179132938385,.38104525983333587,.30160035490989684,.21209139108657843,.33879016637802123,.18215490162372588,.4353105306625366,.1335425513982773,.22725783586502074,.2627154815196991,.4187734603881836,.6076370733976364,.471796441078186,.5377814787626267,.3835057199001312,.13003402531147007,.18837626576423644,.4081169712543488,.4558822691440582,.3006539422273636,.45070006251335143,.29020555198192594,.44506027102470397,.276558490395546,.441160249710083,.26132532536983494,.42807196378707885,.237567846775055,.413764613866806,.300301303267479,.40849854350090026,.3033808845281601,.40325652360916137,.3060078132152558,.3719393193721771,.3296157675981522,.2585947096347809,.4027331072092057,.4712364852428436,.5652889716625213,.4525624096393585,.6187475714087487,.43274884223937987,.6166740807890891,.4197424530982971,.2985221195220948,.25107048749923705,.3324888157844544,.48253663182258605,.6165598976612092,.40862621665000914,.21186126053333282,.4922338902950287,.5517929780483246,.4509614884853363,.49562425196170806,.45456190705299376,.19553345918655402,.3438455045223236,.2646773803234101,.39053775668144225,.41997271955013277,.3724295377731323,.2345973211526871,.32362549304962157,.42551548063755035,.3627460479736328,.39166522800922393,.2982912242412567,.37974442124366764,.44216259121894835,.16258520364761353,.4327280104160309,.47912641644477844,.31535937190055846,.24389803588390352,.35182328820228576,.2114975947141648,.3249718725681305,.3009969878196716,.22358919978141784,.36996547162532806,.2854694604873657,.29810287833213805,.2033691883087158,.34796677708625795,.3403308272361755,.35305335700511936,.4522935628890991,.520306442975998,.45397244691848754,.4453733104467393,.4360526978969574,.4358169931173325,.4670851409435272,.463337938785553,.430365788936615,.6462299782037735,.3818374752998352,.6678127396106721,.3376319885253906,.6731280717253685,.3007634162902832,.6677066612243652,.2756028652191162,.6542664083838463,.25909878611564635,.6035455572605133,.17238967418670653,.5322284626960754,.28373541235923766,.5632325726747514,.3148886442184448,.5544471430778504,.35481600761413573,.554238184094429,.39195387363433837,.5604119020700455,.4199950277805328,.5684955823421478,.4408359706401825,.5755523312091828,.1607656955718994,.5315613377094268,.43638269901275634,.4271241891384125,.4722903251647949,.513996543288231,.4744726598262787,.4443250972032547,.48785080313682555,.4292660462856293,.4740713119506836,.43900651216506964,.443528014421463,.4168834346532822,.49345849752426146,.4267724323272705,.49457465410232543,.4177086848020554,.438745903968811,.5969951617717744,.4560649275779724,.5900395292043685,.4670982837677002,.5844003933668136,.3021982192993164,.6197374525666237,.27794389724731444,.6304952013492584,.6290517628192902,.6082503873109817,.601810845732689,.608769752383232,.6309714198112488,.6319623801112175,.657788547873497,.6077486652135848,.6277183473110199,.5834045577049256,.333698707818985,.6181534442305565,.3082489252090454,.6187389704585076,.3358501076698303,.6419334176182747,.3613401234149933,.618020570576191,.33353258967399596,.5936576622724534],P=468,t0=P*3,r0={type:"standard",color:"#ffffff",opacity:1,wireframe:!1,roughness:1,metalness:0},O=({material:e,faceIndex:t=0,numFaces:n,visible:r=!0,children:o})=>{const{ready:u,node:d}=N(S.XRModel.FACE_TRACKER,n===void 0?void 0:{numFaces:n}),{camera:l}=v.useThree(),c=s.useRef(null),y=s.useRef(null),A=s.useRef(null),E=s.useRef(null),i=s.useRef(null),f=s.useRef(new b.Vector3),p=s.useMemo(()=>{const R=new Uint16Array($),M=new b.BufferAttribute(R,1),h=new b.Float32BufferAttribute(e0,2),C=new Float32Array(t0),a=new b.Float32BufferAttribute(C,3);return a.setUsage(b.DynamicDrawUsage),{indexAttr:M,uvAttr:h,positionAttr:a,positions:C}},[]);s.useEffect(()=>{E.current=p.indexAttr,i.current=p.uvAttr,A.current=p.positionAttr,y.current=p.positions;const R=c.current;if(R){const M=R.geometry;M.setAttribute("position",p.positionAttr),M.setAttribute("uv",p.uvAttr),M.setIndex(p.indexAttr)}return()=>{E.current=null,i.current=null,A.current=null,y.current=null}},[p]),v.useFrame(()=>{var x;if(!u||!d||!c.current)return;const{detectionResults:R}=d,M=(x=R==null?void 0:R.faceLandmarks)==null?void 0:x[t],h=c.current.geometry,C=y.current,a=A.current;if(!M||M.length===0||!C||!a){h.drawRange.count!==0&&h.setDrawRange(0,0);return}h.getAttribute("position")!==a&&(h.setAttribute("position",a),h.setAttribute("uv",i.current),h.setIndex(E.current)),h.drawRange.count===0&&h.setDrawRange(0,1/0),Q(M,P,C,l,G,f.current),a.needsUpdate=!0,h.computeVertexNormals()});const F=o!=null&&o!==!1;return _.jsxs("mesh",{material:e,ref:c,visible:r,children:[_.jsx("bufferGeometry",{}),!e&&!F&&_.jsx(U,{settings:r0,materialProps:{attach:"material",transparent:!0,depthWrite:!1,side:b.DoubleSide,needsUpdate:!0}}),!e&&F?o:null]})};O.displayName="FaceMesh";const L={"face.forehead":10,"face.noseTip":1,"face.chin":152,"face.leftEyeOuter":263,"face.rightEyeOuter":33,"face.leftCheek":425,"face.rightCheek":205,"face.mouthCenter":13,"face.leftEarlobe":454,"face.rightEarlobe":234},n0={"face.center":[10,152,234,454],"face.leftEye":[263,362,387,373],"face.rightEye":[33,133,158,145]},K=(e,t=0)=>Number.isFinite(e)?e:t,w=e=>Math.max(-1,Math.min(1,K(e))),s0={x:0,y:0,z:0},H=(e,t,n=s0,r={x:0,y:0,z:0,visibility:0})=>{const o=L[e];if(o!==void 0){const i=t[o];return i?Object.assign(r,i):null}const u=n0[e];if(u){r.x=0,r.y=0,r.z=0;for(const i of u){const f=t[i];if(!f)return null;r.x+=f.x,r.y+=f.y,r.z+=f.z}return r.x/=u.length,r.y/=u.length,r.z/=u.length,r.visibility=1,r}if(e!=="face.custom"||t.length===0)return null;let d=1/0,l=1/0,c=-1/0,y=-1/0,A=0;for(const i of t)d=Math.min(d,i.x),l=Math.min(l,i.y),c=Math.max(c,i.x),y=Math.max(y,i.y),A+=i.z;const E=c-d;return r.x=(d+c)*.5-w(n.x)*E*.5,r.y=(l+y)*.5-w(n.y)*(y-l)*.5,r.z=A/t.length-K(n.z)*E,r.visibility=1,r},o0={left:L["face.leftEyeOuter"],right:L["face.rightEyeOuter"]},z=s.createContext(null),c0=()=>s.useContext(z),i0=({faceIndex:e=0,numFaces:t,scaleWithFace:n=!1,followFaceRoll:r=!0,targetFps:o,active:u=!0,children:d})=>{const l=s.useRef(!1),c=s.useRef(null),y=s.useMemo(()=>{if(!(t===void 0&&o===void 0))return{...t===void 0?{}:{numFaces:t},...o===void 0?{}:{targetFps:o}}},[t,o]),{ready:A,node:E}=N(S.XRModel.FACE_TRACKER,y,u),{camera:i}=v.useThree(),f=s.useRef(i);f.current!==i&&(f.current=i,l.current=!1);const p=s.useRef(null),F=s.useRef({x:0,y:0,z:0,visibility:0});v.useFrame(()=>{if(!A||!E||!c.current)return;p.current=E,!l.current&&f.current&&(E.setCamera(f.current,e),l.current=!0);const a=E.getFace(e);if(!a){c.current.visible=!1;return}c.current.visible=!0;const{position:x,rotation:m,scale:T}=a.transform;c.current.position.set(x.x,x.y,x.z),c.current.rotation.set(m.x,m.y,r?m.z:0),n?c.current.scale.set(T.x,T.y,T.z):c.current.scale.set(1,1,1)});const R=s.useCallback((a,x)=>{var I,k;const m=p.current,T=(k=(I=m==null?void 0:m.detectionResults)==null?void 0:I.faceLandmarks)==null?void 0:k[e];if(!T||T.length===0)return null;const g=H(a,T,x,F.current);return g?{position:S.unprojectToZZero(g,f.current)}:null},[e]),M=s.useMemo(()=>({type:"face",resolveLandmark:R}),[R]);let h;const C=[];return s.Children.forEach(d,a=>{var x,m;s.isValidElement(a)&&(((x=a.type)==null?void 0:x.displayName)==="FaceTracker.Mesh"||((m=a.type)==null?void 0:m.displayName)==="FaceMesh")?h=s.cloneElement(a,{faceIndex:e,numFaces:t}):C.push(a)}),_.jsxs(z.Provider,{value:M,children:[_.jsx("group",{ref:c,renderOrder:X.RENDER_LAYERS.TRACKED,children:C}),h]})},q=e=>_.jsx(O,{...e});q.displayName="FaceTracker.Mesh";const D=i0;D.Mesh=q;const u0=D;exports.FACE_EYE_DISTANCE_LANDMARKS=o0;exports.FACE_LANDMARK_INDICES=L;exports.FaceMesh=O;exports.FaceTracker=D;exports.HeadTracker=u0;exports.MeshMaterial=U;exports.TrackerContext=z;exports.projectLandmarkWithDepth=J;exports.resolveFaceAnchorPoint=H;exports.transformFaceMeshLandmark=W;exports.useTrackerContext=c0;exports.useXRModel=N;
|
|
1
|
+
"use strict";const _=require("react/jsx-runtime"),v=require("@react-three/fiber"),s=require("react"),S=require("./index-DCiMbxC3.cjs"),X=require("./renderLayers-lDtL0_43.cjs"),V=require("three");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=Y(V);function Z(e){return JSON.stringify(e??{})}function N(e,t,n=!0){const{session:r}=S.useXRContext(),o=s.useId(),[u,d]=s.useState(null),l=Z(t),c=s.useRef(t);c.current=t,s.useEffect(()=>{let i=!1;return d(null),r.registry.acquire(e,o,c.current).catch(f=>{i||d(f instanceof Error?f:new Error(String(f)))}),()=>{i=!0,r.registry.release(e,o)}},[r,e,o,l]),s.useEffect(()=>{r.registry.setActive(e,o,n)},[r,e,o,n]);const y=r.store,A=s.useSyncExternalStore(i=>y.subscribe(i),()=>y.getSnapshot().pipeline.get(e)??null,()=>null),E=s.useMemo(()=>A?A.getModelNode():null,[A]);return{ready:A!==null&&u===null,node:E,error:u}}const U=({materialProps:e,settings:t})=>t.type==="basic"?_.jsx("meshBasicMaterial",{...e}):_.jsx("meshStandardMaterial",{...e,roughness:t.roughness,metalness:t.metalness}),j=1e-6,B=e=>{const{x:t,y:n,z:r}=e.scale;return Math.abs(t-n)<=j&&Math.abs(t-r)<=j?t:1},W=(e,t,n,r)=>{if(!n.enabled)return e;const o=B(n);return r.x=t.x+(e.x-t.x)*o+n.position.x,r.y=t.y+(e.y-t.y)*o-n.position.y,r.z=t.z+(e.z-t.z)*o+n.position.z,r},G=(e,t,n)=>S.unprojectToZZeroInto(e,t,n),J=(e,t,n)=>{const r=(e.x-.5)*2,o=(.5-e.y)*2,u=b.MathUtils.clamp(e.z*2,-1,1);return n.set(r,o,u).unproject(t)},Q=(e,t,n,r,o,u)=>{const d=Math.min(t,e.length);for(let l=0;l<d;l++){o(e[l],r,u);const c=l*3;n[c]=u.x,n[c+1]=u.y,n[c+2]=u.z}return d},$=[[127,34,139],[11,0,37],[232,231,120],[72,37,39],[128,121,47],[232,121,128],[104,69,67],[175,171,148],[118,50,101],[73,39,40],[9,151,108],[48,115,131],[194,204,211],[74,40,185],[80,42,183],[40,92,186],[230,229,118],[202,212,214],[83,18,17],[76,61,146],[160,29,30],[56,157,173],[106,204,194],[135,214,192],[203,165,98],[21,71,68],[51,45,4],[144,24,23],[77,146,91],[205,50,187],[201,200,18],[91,106,182],[90,91,181],[85,84,17],[206,203,36],[148,171,140],[92,40,39],[193,189,244],[159,158,28],[247,246,161],[236,3,196],[54,68,104],[193,168,8],[117,228,31],[189,193,55],[98,97,99],[126,47,100],[166,79,218],[155,154,26],[209,49,131],[135,136,150],[47,126,217],[223,52,53],[45,51,134],[211,170,140],[67,69,108],[43,106,91],[230,119,120],[226,130,247],[63,53,52],[238,20,242],[46,70,156],[78,62,96],[46,53,63],[143,34,227],[123,117,111],[44,125,19],[236,134,51],[216,206,205],[154,153,22],[39,37,167],[200,201,208],[36,142,100],[57,212,202],[20,60,99],[28,158,157],[35,226,113],[160,159,27],[204,202,210],[113,225,46],[43,202,204],[62,76,77],[137,123,116],[41,38,72],[203,129,142],[64,98,240],[49,102,64],[41,73,74],[212,216,207],[42,74,184],[169,170,211],[170,149,176],[105,66,69],[122,6,168],[123,147,187],[96,77,90],[65,55,107],[89,90,180],[101,100,120],[63,105,104],[93,137,227],[15,86,85],[129,102,49],[14,87,86],[55,8,9],[100,47,121],[145,23,22],[88,89,179],[6,122,196],[88,95,96],[138,172,136],[215,58,172],[115,48,219],[42,80,81],[195,3,51],[43,146,61],[171,175,199],[81,82,38],[53,46,225],[144,163,110],[52,65,66],[229,228,117],[34,127,234],[107,108,69],[109,108,151],[48,64,235],[62,78,191],[129,209,126],[111,35,143],[117,123,50],[222,65,52],[19,125,141],[221,55,65],[3,195,197],[25,7,33],[220,237,44],[70,71,139],[122,193,245],[247,130,33],[71,21,162],[170,169,150],[188,174,196],[216,186,92],[2,97,167],[141,125,241],[164,167,37],[72,38,12],[38,82,13],[63,68,71],[226,35,111],[101,50,205],[206,92,165],[209,198,217],[165,167,97],[220,115,218],[133,112,243],[239,238,241],[214,135,169],[190,173,133],[171,208,32],[125,44,237],[86,87,178],[85,86,179],[84,85,180],[83,84,181],[201,83,182],[137,93,132],[76,62,183],[61,76,184],[57,61,185],[212,57,186],[214,207,187],[34,143,156],[79,239,237],[123,137,177],[44,1,4],[201,194,32],[64,102,129],[213,215,138],[59,166,219],[242,99,97],[2,94,141],[75,59,235],[24,110,228],[25,130,226],[23,24,229],[22,23,230],[26,22,231],[112,26,232],[189,190,243],[221,56,190],[28,56,221],[27,28,222],[29,27,223],[30,29,224],[247,30,225],[238,79,20],[166,59,75],[60,75,240],[147,177,215],[20,79,166],[187,147,213],[112,233,244],[233,128,245],[128,114,188],[114,217,174],[131,115,220],[217,198,236],[198,131,134],[177,132,58],[143,35,124],[110,163,7],[228,110,25],[356,389,368],[11,302,267],[452,350,349],[302,303,269],[357,343,277],[452,453,357],[333,332,297],[175,152,377],[347,348,330],[303,304,270],[9,336,337],[278,279,360],[418,262,431],[304,408,409],[310,415,407],[270,409,410],[450,348,347],[422,430,434],[313,314,17],[306,307,375],[387,388,260],[286,414,398],[335,406,418],[364,367,416],[423,358,327],[251,284,298],[281,5,4],[373,374,253],[307,320,321],[425,427,411],[421,313,18],[321,405,406],[320,404,405],[315,16,17],[426,425,266],[377,400,369],[322,391,269],[417,465,464],[386,257,258],[466,260,388],[456,399,419],[284,332,333],[417,285,8],[346,340,261],[413,441,285],[327,460,328],[355,371,329],[392,439,438],[382,341,256],[429,420,360],[364,394,379],[277,343,437],[443,444,283],[275,440,363],[431,262,369],[297,338,337],[273,375,321],[450,451,349],[446,342,467],[293,334,282],[458,461,462],[276,353,383],[308,324,325],[276,300,293],[372,345,447],[352,345,340],[274,1,19],[456,248,281],[436,427,425],[381,256,252],[269,391,393],[200,199,428],[266,330,329],[287,273,422],[250,462,328],[258,286,384],[265,353,342],[387,259,257],[424,431,430],[342,353,276],[273,335,424],[292,325,307],[366,447,345],[271,303,302],[423,266,371],[294,455,460],[279,278,294],[271,272,304],[432,434,427],[272,407,408],[394,430,431],[395,369,400],[334,333,299],[351,417,168],[352,280,411],[325,319,320],[295,296,336],[319,403,404],[330,348,349],[293,298,333],[323,454,447],[15,16,315],[358,429,279],[14,15,316],[285,336,9],[329,349,350],[374,380,252],[318,402,403],[6,197,419],[318,319,325],[367,364,365],[435,367,397],[344,438,439],[272,271,311],[195,5,281],[273,287,291],[396,428,199],[311,271,268],[283,444,445],[373,254,339],[282,334,296],[449,347,346],[264,447,454],[336,296,299],[338,10,151],[278,439,455],[292,407,415],[358,371,355],[340,345,372],[346,347,280],[442,443,282],[19,94,370],[441,442,295],[248,419,197],[263,255,359],[440,275,274],[300,383,368],[351,412,465],[263,467,466],[301,368,389],[395,378,379],[412,351,419],[436,426,322],[2,164,393],[370,462,461],[164,0,267],[302,11,12],[268,12,13],[293,300,301],[446,261,340],[330,266,425],[426,423,391],[429,355,437],[391,327,326],[440,457,438],[341,382,362],[459,457,461],[434,430,394],[414,463,362],[396,369,262],[354,461,457],[316,403,402],[315,404,403],[314,405,404],[313,406,405],[421,418,406],[366,401,361],[306,408,407],[291,409,408],[287,410,409],[432,436,410],[434,416,411],[264,368,383],[309,438,457],[352,376,401],[274,275,4],[421,428,262],[294,327,358],[433,416,367],[289,455,439],[462,370,326],[2,326,370],[305,460,455],[254,449,448],[255,261,446],[253,450,449],[252,451,450],[256,452,451],[341,453,452],[413,464,463],[441,413,414],[258,442,441],[257,443,442],[259,444,443],[260,445,444],[467,342,445],[459,458,250],[289,392,290],[290,328,460],[376,433,435],[250,290,392],[411,416,433],[341,463,464],[453,464,465],[357,465,412],[343,412,399],[360,363,440],[437,399,456],[420,456,363],[401,435,288],[372,383,353],[339,255,249],[448,261,255],[133,243,190],[133,155,112],[33,246,247],[33,130,25],[398,384,286],[362,398,414],[362,463,341],[263,359,467],[263,249,255],[466,467,260],[75,60,166],[238,239,79],[162,127,139],[72,11,37],[121,232,120],[73,72,39],[114,128,47],[233,232,128],[103,104,67],[152,175,148],[119,118,101],[74,73,40],[107,9,108],[49,48,131],[32,194,211],[184,74,185],[191,80,183],[185,40,186],[119,230,118],[210,202,214],[84,83,17],[77,76,146],[161,160,30],[190,56,173],[182,106,194],[138,135,192],[129,203,98],[54,21,68],[5,51,4],[145,144,23],[90,77,91],[207,205,187],[83,201,18],[181,91,182],[180,90,181],[16,85,17],[205,206,36],[176,148,140],[165,92,39],[245,193,244],[27,159,28],[30,247,161],[174,236,196],[103,54,104],[55,193,8],[111,117,31],[221,189,55],[240,98,99],[142,126,100],[219,166,218],[112,155,26],[198,209,131],[169,135,150],[114,47,217],[224,223,53],[220,45,134],[32,211,140],[109,67,108],[146,43,91],[231,230,120],[113,226,247],[105,63,52],[241,238,242],[124,46,156],[95,78,96],[70,46,63],[116,143,227],[116,123,111],[1,44,19],[3,236,51],[207,216,205],[26,154,22],[165,39,167],[199,200,208],[101,36,100],[43,57,202],[242,20,99],[56,28,157],[124,35,113],[29,160,27],[211,204,210],[124,113,46],[106,43,204],[96,62,77],[227,137,116],[73,41,72],[36,203,142],[235,64,240],[48,49,64],[42,41,74],[214,212,207],[183,42,184],[210,169,211],[140,170,176],[104,105,69],[193,122,168],[50,123,187],[89,96,90],[66,65,107],[179,89,180],[119,101,120],[68,63,104],[234,93,227],[16,15,85],[209,129,49],[15,14,86],[107,55,9],[120,100,121],[153,145,22],[178,88,179],[197,6,196],[89,88,96],[135,138,136],[138,215,172],[218,115,219],[41,42,81],[5,195,51],[57,43,61],[208,171,199],[41,81,38],[224,53,225],[24,144,110],[105,52,66],[118,229,117],[227,34,234],[66,107,69],[10,109,151],[219,48,235],[183,62,191],[142,129,126],[116,111,143],[118,117,50],[223,222,52],[94,19,141],[222,221,65],[196,3,197],[45,220,44],[156,70,139],[188,122,245],[139,71,162],[149,170,150],[122,188,196],[206,216,92],[164,2,167],[242,141,241],[0,164,37],[11,72,12],[12,38,13],[70,63,71],[31,226,111],[36,101,205],[203,206,165],[126,209,217],[98,165,97],[237,220,218],[237,239,241],[210,214,169],[140,171,32],[241,125,237],[179,86,178],[180,85,179],[181,84,180],[182,83,181],[194,201,182],[177,137,132],[184,76,183],[185,61,184],[186,57,185],[216,212,186],[192,214,187],[139,34,156],[218,79,237],[147,123,177],[45,44,4],[208,201,32],[98,64,129],[192,213,138],[235,59,219],[141,242,97],[97,2,141],[240,75,235],[229,24,228],[31,25,226],[230,23,229],[231,22,230],[232,26,231],[233,112,232],[244,189,243],[189,221,190],[222,28,221],[223,27,222],[224,29,223],[225,30,224],[113,247,225],[99,60,240],[213,147,215],[60,20,166],[192,187,213],[243,112,244],[244,233,245],[245,128,188],[188,114,174],[134,131,220],[174,217,236],[236,198,134],[215,177,58],[156,143,124],[25,110,7],[31,228,25],[264,356,368],[0,11,267],[451,452,349],[267,302,269],[350,357,277],[350,452,357],[299,333,297],[396,175,377],[280,347,330],[269,303,270],[151,9,337],[344,278,360],[424,418,431],[270,304,409],[272,310,407],[322,270,410],[449,450,347],[432,422,434],[18,313,17],[291,306,375],[259,387,260],[424,335,418],[434,364,416],[391,423,327],[301,251,298],[275,281,4],[254,373,253],[375,307,321],[280,425,411],[200,421,18],[335,321,406],[321,320,405],[314,315,17],[423,426,266],[396,377,369],[270,322,269],[413,417,464],[385,386,258],[248,456,419],[298,284,333],[168,417,8],[448,346,261],[417,413,285],[326,327,328],[277,355,329],[309,392,438],[381,382,256],[279,429,360],[365,364,379],[355,277,437],[282,443,283],[281,275,363],[395,431,369],[299,297,337],[335,273,321],[348,450,349],[359,446,467],[283,293,282],[250,458,462],[300,276,383],[292,308,325],[283,276,293],[264,372,447],[346,352,340],[354,274,19],[363,456,281],[426,436,425],[380,381,252],[267,269,393],[421,200,428],[371,266,329],[432,287,422],[290,250,328],[385,258,384],[446,265,342],[386,387,257],[422,424,430],[445,342,276],[422,273,424],[306,292,307],[352,366,345],[268,271,302],[358,423,371],[327,294,460],[331,279,294],[303,271,304],[436,432,427],[304,272,408],[395,394,431],[378,395,400],[296,334,299],[6,351,168],[376,352,411],[307,325,320],[285,295,336],[320,319,404],[329,330,349],[334,293,333],[366,323,447],[316,15,315],[331,358,279],[317,14,316],[8,285,9],[277,329,350],[253,374,252],[319,318,403],[351,6,419],[324,318,325],[397,367,365],[288,435,397],[278,344,439],[310,272,311],[248,195,281],[375,273,291],[175,396,199],[312,311,268],[276,283,445],[390,373,339],[295,282,296],[448,449,346],[356,264,454],[337,336,299],[337,338,151],[294,278,455],[308,292,415],[429,358,355],[265,340,372],[352,346,280],[295,442,282],[354,19,370],[285,441,295],[195,248,197],[457,440,274],[301,300,368],[417,351,465],[251,301,389],[394,395,379],[399,412,419],[410,436,322],[326,2,393],[354,370,461],[393,164,267],[268,302,12],[312,268,13],[298,293,301],[265,446,340],[280,330,425],[322,426,391],[420,429,437],[393,391,326],[344,440,438],[458,459,461],[364,434,394],[428,396,262],[274,354,457],[317,316,402],[316,315,403],[315,314,404],[314,313,405],[313,421,406],[323,366,361],[292,306,407],[306,291,408],[291,287,409],[287,432,410],[427,434,411],[372,264,383],[459,309,457],[366,352,401],[1,274,4],[418,421,262],[331,294,358],[435,433,367],[392,289,439],[328,462,326],[94,2,370],[289,305,455],[339,254,448],[359,255,446],[254,253,449],[253,252,450],[252,256,451],[256,341,452],[414,413,463],[286,441,414],[286,258,441],[258,257,442],[257,259,443],[259,260,444],[260,467,445],[309,459,250],[305,289,290],[305,290,460],[401,376,435],[309,250,392],[376,411,433],[453,341,464],[357,453,465],[343,357,412],[437,343,399],[344,360,440],[420,437,456],[360,420,363],[361,401,288],[265,372,353],[390,339,249],[339,448,255],[255,339,448]].flat(),e0=[.5104879319667817,.33515610277652746,.5174233198165894,.43859300494194037,.5123749554157258,.406469448208809,.5423470318317414,.5244461464881898,.5190713584423066,.46557595014572145,.5194876372814179,.5006013351678849,.5178673148155213,.5855525898933411,.7009655416011811,.5918984371423721,.5193980515003205,.6528422343730926,.520683366060257,.689273599088192,.5248700261116028,.8232529717683792,.5099657952785492,.32301718473434454,.5088536620140076,.31080526888370513,.5081197202205658,.3013389307260514,.5072353065013886,.29900476515293123,.5073091566562653,.28442813932895666,.5065075337886811,.26649361431598667,.5061309516429902,.24778731942176818,.5031875848770142,.22179436564445493,.515326726436615,.4231037962436676,.5375777959823609,.4205444622039795,.8049442350864411,.6867966356873512,.6222659975290299,.570705144405365,.6496635556221009,.567776631116867,.6773027807474137,.5670208501815797,.7126377105712891,.5800703662633897,.5999099642038346,.5764724123477936,.674340370297432,.6495546865463258,.639536875486374,.6477413746714593,.703840109705925,.642201315164566,.7209078550338746,.6294069054722786,.7342745542526246,.5601695317029953,.6015644401311875,.18118685364723203,.7114282578229905,.598883952498436,.809715884923935,.5682615923881531,.7667155593633652,.5767241555452347,.6445030301809311,.45154162526130676,.541424173116684,.34213731765747074,.5359058856964112,.3113374251127243,.5710002213716507,.33134433805942537,.5891562283039093,.31890978991985325,.5585465461015702,.3096196609735489,.5759132236242295,.30601608335971836,.6229794204235077,.2713706839084626,.5398103773593903,.43802148282527925,.545369166135788,.46441581428051,.7616913348436356,.6473416510224344,.5914883643388749,.5243312466144563,.5945767045021058,.44076132655143746,.5964909076690674,.4544808346033096,.7225886166095734,.4498931097984314,.5443432211875916,.49703910827636727,.7029067009687424,.6777765545248986,.7391736537218094,.6677046212553979,.7836920201778412,.7359224516153335,.577455359697342,.6573990839719772,.6085408657789231,.6353888112306596,.6427326381206513,.298196165561676,.7550604224205018,.30743678390979773,.5732827365398407,.4262381809949875,.5523188143968583,.417594336271286,.6096987754106522,.29745593249797825,.6036115020513535,.2985246556997299,.7549919366836548,.6845966669917107,.592850747704506,.4273046988248826,.6501948565244675,.6762702855467797,.6582381755113602,.699515787065029,.682483646273613,.802994977235794,.768890205025673,.710366437137127,.6672395795583725,.752104974091053,.7775519520044327,.6584857258200645,.7920276552438736,.6709628927707671,.5397542297840119,.3256357330083847,.5643998861312867,.3199443298578262,.5826229482889176,.313130943775177,.5657853364944458,.42035281538963326,.606510478258133,.2980171996355057,.5952901721000672,.2918463486433029,.5999826073646546,.29865378022193906,.565356719493866,.4374908703565598,.570739108324051,.30172707617282873,.5532697021961213,.303354971408844,.532040822505951,.3026815611124039,.5385064661502839,.22311560392379765,.5377482950687409,.25083183526992797,.5373399734497071,.26933391273021695,.5351483404636384,.28629542768001554,.5317461371421814,.3004490631818772,.5704152762889863,.30009212374687194,.5761924862861634,.2931597578525544,.5817892730236054,.28451425909996036,.5862761169672013,.27445026516914367,.6169582635164261,.3500816184282303,.7930811375379563,.4456584650278092,.5136566936969758,.41420710563659674,.5836256474256516,.29897587478160864,.5893380820751191,.29504160165786747,.5458188831806183,.4063113230466843,.581692311167717,.41034119904041294,.5490593492984772,.4114610868692398,.6189475685358048,.5063568043708802,.6631498366594315,.48547921061515814,.5990702986717225,.44076220870018007,.7452016949653626,.7754116746783257,.729542288184166,.7380649703741073,.7152380675077439,.6996659177541733,.6012845069169999,.2532631474733353,.5908916622400284,.6924743655323982,.6002487272024155,.7558749470114707,.611236396431923,.817432113289833,.6991332352161408,.5705236423015594,.7608276635408402,.5389788854122162,.5859951555728913,.5837152945995332,.7452233761548996,.6138822454214097,.5740126550197602,.542653586268425,.5829357832670212,.45267452478408815,.7883433729410172,.5171645599603654,.7431249052286149,.5203535276651383,.7091684520244599,.5116798001527787,.6566549122333527,.5192352938652038,.6176983743906022,.532645167708397,.590181502699852,.5458893078565599,.5431278228759766,.5780327129364013,.7785866141319275,.4588600414991379,.7662802815437317,.614813904762268,.528258103132248,.42353384375572206,.5884005159139634,.49679056286811835,.8132390558719635,.5690749335289003,.5698921114206315,.5609081107378007,.5997681200504303,.4383326607942582,.7258545190095902,.5959577548503876,.5829301953315735,.4692867088317872,.7767194837331772,.37870833754539496,.5859857678413392,.5927838939428329,.5655010223388672,.4863545227050781,.7103684276342392,.24216726005077366,.7039464592933655,.21081999421119696,.7955554753541947,.45157338261604313,.7394011497497559,.27975760281085965,.8023439675569535,.6235768947005271,.6065513819456101,.1520459520816803,.5237656712532044,.4144193726778031,.6113508373498917,.4744607317447663,.7872020035982132,.5706054615974427,.6744208365678788,.5840893256664277,.6509357273578644,.5835042405128479,.599469143152237,.28584001839160916,.76683469414711,.4027401643991471,.5548133134841919,.11242247700691227,.6348527550697327,.15134210765361789,.6676738739013672,.17523885548114776,.5231557369232178,.758142014145851,.49590798020362853,.10746171355247497,.6282390981912613,.5856175380945206,.6072420954704285,.5888098138570785,.592762503027916,.5906054276227952,.7843813925981522,.61877524882555,.610203567147255,.6159668180346489,.6345708996057511,.625477318763733,.6599059730768204,.6266139122843744,.6838259130716324,.6209151762723923,.6978932946920395,.6127474161982536,.8138886868953705,.6332776087522507,.690067994594574,.587394626736641,.5115295231342316,.3814830261468887,.593753132224083,.3682318288087845,.5745513767004014,.43174642801284796,.5468618154525757,.38006519258022314,.5175330221652985,.6183956491947173,.6776301890611649,.20638245522975923,.6439310491085053,.1795444029569626,.5587406486272812,.13319884419441225,.7303948730230332,.25156523168087,.5936179041862488,.6020026791095734,.5595558166503907,.5354639637470247,.49903409481048583,.12705478847026824,.5986292988061905,.12926876127719883,.7810411036014557,.3901792484521866,.5526776045560837,.3004089254140854,.5582781463861466,.2904709684848786,.5625745087862015,.2769930589199066,.5656344175338746,.26021293580532073,.5736826092004776,.23544175803661344,.5897697389125824,.3026730704307556,.5960018962621689,.3050022739171982,.6013990819454194,.30801084220409397,.6334722220897675,.32613734483718876,.7345953911542893,.3890004771947861,.5586504369974137,.5622388321161271,.5686756849288941,.6147718372941018,.5835970371961594,.6114995065331459,.58382708132267,.30018893957138065,.7323651343584061,.3204736191034317,.5478970587253571,.6144195291399956,.5885591685771943,.20925473153591162,.5188342511653901,.5294416445493699,.5430448532104493,.5502454686164857,.5189176678657532,.5563708889484407,.5749752998352051,.4918947476148606,.5015926539897919,.1563655036687851,.5023517191410065,.19124654710292815,.5467969954013825,.1949619370698929,.6493796885013581,.2596786844730377,.6223085105419159,.4147812741994858,.6219283074140549,.2305004018545151,.6836527764797211,.41583852946758276,.6457133769989014,.38482945740222935,.7015091359615326,.3687519657611847,.5560723870992661,.1615346747636795,.5877480685710907,.4753766226768494,.672212439775467,.23758670270442966,.6372418433427811,.20715841531753537,.6714329898357392,.2934120523929596,.7559577107429505,.3546825754642487,.7028004407882691,.28965476036071774,.7641248583793641,.3323610144853592,.6633666038513184,.34586538851261145,.5732450067996979,.5168171036243439,.5740206122398377,.4420601803064346,.5862565368413926,.4328912365436554,.5658091634511948,.46056721985340127,.5935333251953125,.6414948242902756,.643502163887024,.6581727835536004,.6862205892801285,.6599488797783852,.71900634765625,.6517863023281099,.7387710094451905,.6366994085907935,.7436862468719483,.5870225805044174,.8067718029022217,.5102852332592012,.719052392244339,.549573050737381,.6912373930215836,.5426725524663925,.6540380597114563,.5452089506387712,.6191460520029068,.5529706466197968,.5933077514171601,.5624450343847276,.5760908752679825,.5711276936531067,.8037864595651627,.5079354095458986,.5832139283418656,.42433229863643646,.5602819353342057,.5111040878295898,.5571386992931366,.44193623840808877,.5406022548675538,.42711933732032775,.5550468444824219,.43675835609436037,.5743813246488572,.4152073520421982,.5367868125438691,.42474128484725954,.5321040332317353,.41727378547191624,.5769275009632111,.5919214832782747,.5631695121526719,.5864408034086228,.555830317735672,.5819090950489045,.7057080000638962,.6055842030048371,.7297580271959305,.614007951617241,.49450652599334716,.5258826154470444,.30584611296653746,.6040364730358123,.4885244846343994,.4224347966909409,.188004332780838,.7111089858412742,.3873521864414215,.5786778944730759,.3588928759098053,.5761974024772645,.32972376346588134,.5772378969192504,.29263614416122435,.5937507289648056,.4124107241630554,.5837435233592987,.3437161326408386,.6627882960438729,.3795058310031891,.6574259343743325,.3114838480949402,.657741964161396,.2904722273349762,.6461278694868089,.2668101370334625,.5759735572338105,.3916287899017334,.18396661460399627,.2956514835357666,.6133467811346054,.17441000342369078,.5913206297159195,.23045413494110106,.5952582108974458,.3695909559726715,.4586390632390976,.4777859032154083,.34189285218715665,.4799880862236023,.31095413148403167,.4436598002910614,.32987600147724155,.42009713053703307,.3173161882162094,.4536511182785034,.3079365211725235,.431768137216568,.30468503117561346,.37606616616249083,.27423435926437384,.49449856877326964,.4396295297145844,.4917183697223663,.4654612708091736,.2524005055427551,.6652582022547722,.4289156973361969,.5291139262914657,.4268526315689087,.44427823305130004,.42474048137664794,.45817836105823523,.2809027314186096,.46354105353355407,.49383275508880614,.49885324716567997,.3271153151988983,.6924127805233002,.28349151015281676,.6843035730719567,.22369228601455687,.7584647151827812,.4591939032077789,.6617383736371993,.40913431644439696,.6426751393079757,.35715471506118773,.30240225076675414,.1987894058227539,.3237072455883026,.4482724845409393,.42876928627491,.4697932779788971,.4196605491638184,.39104996919631957,.2959751355648041,.3971476137638092,.29665681600570676,.26748310327529906,.7016683402657509,.4251814365386963,.4304117369651795,.3845069885253906,.6860294970870018,.3804918110370636,.7099798905849457,.35481985211372374,.8164000543951988,.2475942552089691,.730037857890129,.37163846492767333,.7639490339159964,.23443256616592406,.677293357551098,.2116762578487396,.6924480664730073,.4783883273601532,.32515374898910526,.44883744716644286,.3184075164794922,.42566208839416503,.31092865943908693,.45405327081680297,.4228447753190994,.3932682454586029,.2964416819810867,.4071350872516632,.290535255074501,.40034677386283873,.29673135757446295,.4610676050186157,.44076672971248626,.4361940503120422,.3005809444189072,.45694692730903624,.30211268544197084,.4812539994716644,.30183855772018436,.46574126482009887,.22492808878421783,.47153966426849364,.25130698263645174,.4740802526473999,.2694691020250321,.4768980026245117,.28705804526805884,.48090897798538207,.2996276724338532,.43501039147377013,.2992805469036102,.4293511092662811,.2932880002260208,.4233271360397339,.28415390133857726,.41761367321014403,.27479386210441586,.39445154666900634,.3538810330629349,.16652100086212157,.4672100204229355,.4183532476425171,.29779809594154355,.41378535628318786,.29400077641010286,.47695048451423644,.40816306352615356,.43489335775375365,.41207451105117804,.473628032207489,.41300628066062933,.3975309908390045,.5133917200565339,.34924407601356505,.4949547010660172,.4189921498298645,.44448454558849343,.27738903760910033,.7946441161632538,.29866914749145507,.7549788492918015,.3170970857143402,.7143296006321906,.39919986128807067,.2556870716810226,.4517517566680908,.6986333075165749,.44375439286231994,.7623249980807305,.4346091330051422,.8250303360819817,.3058603286743164,.5830274391174317,.235262531042099,.5560186910629272,.4279192566871643,.5892863947153091,.2622906148433685,.6309370476007461,.45053591132164,.5464099961519242,.44443781971931456,.45605955004692084,.20207332372665404,.5370177584886551,.25663607120513915,.5358516681194305,.29581143260002135,.5243526387214661,.3525206625461578,.5284005987644196,.39442025423049926,.5392975616455078,.42579718232154845,.5511161494255066,.49076547026634215,.5801296907663345,.20957841277122496,.47626241028308874,.23929433822631835,.6331100556254388,.5024659812450409,.4247821944952011,.432133811712265,.5009672063589097,.15906893014907836,.5940177994966507,.4492078602313995,.5648097443580629,.41579030752182006,.4419312763214112,.2798506796360016,.6113770532608032,.44294874668121337,.47275686144828805,.1783646523952484,.3979667472839356,.42730753421783446,.5981915760040284,.46777849197387694,.4889896112680436,.26486464142799376,.2499848622083664,.26026474237442015,.21801546096801755,.17761032581329345,.47220298230648045,.23215438723564147,.29172880232334136,.1906857371330261,.6463678139448166,.3811529755592346,.1541750180721283,.5033367156982422,.41569132089614874,.40528597235679625,.4797393995523453,.2049500823020935,.59123428940773,.3344294309616089,.5942869651317597,.35825960636138915,.5929379391670226,.4015964150428772,.28595646202564245,.21618961095809935,.4194869863986969,.43316020369529723,.11274379968643189,.34098224639892577,.1526068884134293,.3026312172412872,.17882644414901733,.3831480026245117,.5945327538251877,.40483357310295104,.5966399866342544,.419615763425827,.5973996269702913,.2160478115081787,.6388220790028571,.40051244497299193,.6220169800519944,.37555851340293883,.6336345481872558,.3499592423439026,.6373451414704323,.32648445963859557,.6342222797870636,.3108482539653778,.6266552078723908,.16784127354621886,.6591027337312698,.3177972316741943,.5982361245155334,.4220952868461609,.3706905978918075,.4483287215232849,.43451813936233524,.4753179132938385,.38104525983333587,.30160035490989684,.21209139108657843,.33879016637802123,.18215490162372588,.4353105306625366,.1335425513982773,.22725783586502074,.2627154815196991,.4187734603881836,.6076370733976364,.471796441078186,.5377814787626267,.3835057199001312,.13003402531147007,.18837626576423644,.4081169712543488,.4558822691440582,.3006539422273636,.45070006251335143,.29020555198192594,.44506027102470397,.276558490395546,.441160249710083,.26132532536983494,.42807196378707885,.237567846775055,.413764613866806,.300301303267479,.40849854350090026,.3033808845281601,.40325652360916137,.3060078132152558,.3719393193721771,.3296157675981522,.2585947096347809,.4027331072092057,.4712364852428436,.5652889716625213,.4525624096393585,.6187475714087487,.43274884223937987,.6166740807890891,.4197424530982971,.2985221195220948,.25107048749923705,.3324888157844544,.48253663182258605,.6165598976612092,.40862621665000914,.21186126053333282,.4922338902950287,.5517929780483246,.4509614884853363,.49562425196170806,.45456190705299376,.19553345918655402,.3438455045223236,.2646773803234101,.39053775668144225,.41997271955013277,.3724295377731323,.2345973211526871,.32362549304962157,.42551548063755035,.3627460479736328,.39166522800922393,.2982912242412567,.37974442124366764,.44216259121894835,.16258520364761353,.4327280104160309,.47912641644477844,.31535937190055846,.24389803588390352,.35182328820228576,.2114975947141648,.3249718725681305,.3009969878196716,.22358919978141784,.36996547162532806,.2854694604873657,.29810287833213805,.2033691883087158,.34796677708625795,.3403308272361755,.35305335700511936,.4522935628890991,.520306442975998,.45397244691848754,.4453733104467393,.4360526978969574,.4358169931173325,.4670851409435272,.463337938785553,.430365788936615,.6462299782037735,.3818374752998352,.6678127396106721,.3376319885253906,.6731280717253685,.3007634162902832,.6677066612243652,.2756028652191162,.6542664083838463,.25909878611564635,.6035455572605133,.17238967418670653,.5322284626960754,.28373541235923766,.5632325726747514,.3148886442184448,.5544471430778504,.35481600761413573,.554238184094429,.39195387363433837,.5604119020700455,.4199950277805328,.5684955823421478,.4408359706401825,.5755523312091828,.1607656955718994,.5315613377094268,.43638269901275634,.4271241891384125,.4722903251647949,.513996543288231,.4744726598262787,.4443250972032547,.48785080313682555,.4292660462856293,.4740713119506836,.43900651216506964,.443528014421463,.4168834346532822,.49345849752426146,.4267724323272705,.49457465410232543,.4177086848020554,.438745903968811,.5969951617717744,.4560649275779724,.5900395292043685,.4670982837677002,.5844003933668136,.3021982192993164,.6197374525666237,.27794389724731444,.6304952013492584,.6290517628192902,.6082503873109817,.601810845732689,.608769752383232,.6309714198112488,.6319623801112175,.657788547873497,.6077486652135848,.6277183473110199,.5834045577049256,.333698707818985,.6181534442305565,.3082489252090454,.6187389704585076,.3358501076698303,.6419334176182747,.3613401234149933,.618020570576191,.33353258967399596,.5936576622724534],P=468,t0=P*3,r0={type:"standard",color:"#ffffff",opacity:1,wireframe:!1,roughness:1,metalness:0},O=({material:e,faceIndex:t=0,numFaces:n,visible:r=!0,children:o})=>{const{ready:u,node:d}=N(S.XRModel.FACE_TRACKER,n===void 0?void 0:{numFaces:n}),{camera:l}=v.useThree(),c=s.useRef(null),y=s.useRef(null),A=s.useRef(null),E=s.useRef(null),i=s.useRef(null),f=s.useRef(new b.Vector3),p=s.useMemo(()=>{const R=new Uint16Array($),M=new b.BufferAttribute(R,1),h=new b.Float32BufferAttribute(e0,2),C=new Float32Array(t0),a=new b.Float32BufferAttribute(C,3);return a.setUsage(b.DynamicDrawUsage),{indexAttr:M,uvAttr:h,positionAttr:a,positions:C}},[]);s.useEffect(()=>{E.current=p.indexAttr,i.current=p.uvAttr,A.current=p.positionAttr,y.current=p.positions;const R=c.current;if(R){const M=R.geometry;M.setAttribute("position",p.positionAttr),M.setAttribute("uv",p.uvAttr),M.setIndex(p.indexAttr)}return()=>{E.current=null,i.current=null,A.current=null,y.current=null}},[p]),v.useFrame(()=>{var x;if(!u||!d||!c.current)return;const{detectionResults:R}=d,M=(x=R==null?void 0:R.faceLandmarks)==null?void 0:x[t],h=c.current.geometry,C=y.current,a=A.current;if(!M||M.length===0||!C||!a){h.drawRange.count!==0&&h.setDrawRange(0,0);return}h.getAttribute("position")!==a&&(h.setAttribute("position",a),h.setAttribute("uv",i.current),h.setIndex(E.current)),h.drawRange.count===0&&h.setDrawRange(0,1/0),Q(M,P,C,l,G,f.current),a.needsUpdate=!0,h.computeVertexNormals()});const F=o!=null&&o!==!1;return _.jsxs("mesh",{material:e,ref:c,visible:r,children:[_.jsx("bufferGeometry",{}),!e&&!F&&_.jsx(U,{settings:r0,materialProps:{attach:"material",transparent:!0,depthWrite:!1,side:b.DoubleSide,needsUpdate:!0}}),!e&&F?o:null]})};O.displayName="FaceMesh";const L={"face.forehead":10,"face.noseTip":1,"face.chin":152,"face.leftEyeOuter":263,"face.rightEyeOuter":33,"face.leftCheek":425,"face.rightCheek":205,"face.mouthCenter":13,"face.leftEarlobe":454,"face.rightEarlobe":234},n0={"face.center":[10,152,234,454],"face.leftEye":[263,362,387,373],"face.rightEye":[33,133,158,145]},K=(e,t=0)=>Number.isFinite(e)?e:t,w=e=>Math.max(-1,Math.min(1,K(e))),s0={x:0,y:0,z:0},H=(e,t,n=s0,r={x:0,y:0,z:0,visibility:0})=>{const o=L[e];if(o!==void 0){const i=t[o];return i?Object.assign(r,i):null}const u=n0[e];if(u){r.x=0,r.y=0,r.z=0;for(const i of u){const f=t[i];if(!f)return null;r.x+=f.x,r.y+=f.y,r.z+=f.z}return r.x/=u.length,r.y/=u.length,r.z/=u.length,r.visibility=1,r}if(e!=="face.custom"||t.length===0)return null;let d=1/0,l=1/0,c=-1/0,y=-1/0,A=0;for(const i of t)d=Math.min(d,i.x),l=Math.min(l,i.y),c=Math.max(c,i.x),y=Math.max(y,i.y),A+=i.z;const E=c-d;return r.x=(d+c)*.5-w(n.x)*E*.5,r.y=(l+y)*.5-w(n.y)*(y-l)*.5,r.z=A/t.length-K(n.z)*E,r.visibility=1,r},o0={left:L["face.leftEyeOuter"],right:L["face.rightEyeOuter"]},z=s.createContext(null),c0=()=>s.useContext(z),i0=({faceIndex:e=0,numFaces:t,scaleWithFace:n=!1,followFaceRoll:r=!0,targetFps:o,active:u=!0,children:d})=>{const l=s.useRef(!1),c=s.useRef(null),y=s.useMemo(()=>{if(!(t===void 0&&o===void 0))return{...t===void 0?{}:{numFaces:t},...o===void 0?{}:{targetFps:o}}},[t,o]),{ready:A,node:E}=N(S.XRModel.FACE_TRACKER,y,u),{camera:i}=v.useThree(),f=s.useRef(i);f.current!==i&&(f.current=i,l.current=!1);const p=s.useRef(null),F=s.useRef({x:0,y:0,z:0,visibility:0});v.useFrame(()=>{if(!A||!E||!c.current)return;p.current=E,!l.current&&f.current&&(E.setCamera(f.current,e),l.current=!0);const a=E.getFace(e);if(!a){c.current.visible=!1;return}c.current.visible=!0;const{position:x,rotation:m,scale:T}=a.transform;c.current.position.set(x.x,x.y,x.z),c.current.rotation.set(m.x,m.y,r?m.z:0),n?c.current.scale.set(T.x,T.y,T.z):c.current.scale.set(1,1,1)});const R=s.useCallback((a,x)=>{var I,k;const m=p.current,T=(k=(I=m==null?void 0:m.detectionResults)==null?void 0:I.faceLandmarks)==null?void 0:k[e];if(!T||T.length===0)return null;const g=H(a,T,x,F.current);return g?{position:S.unprojectToZZero(g,f.current)}:null},[e]),M=s.useMemo(()=>({type:"face",resolveLandmark:R}),[R]);let h;const C=[];return s.Children.forEach(d,a=>{var x,m;s.isValidElement(a)&&(((x=a.type)==null?void 0:x.displayName)==="FaceTracker.Mesh"||((m=a.type)==null?void 0:m.displayName)==="FaceMesh")?h=s.cloneElement(a,{faceIndex:e,numFaces:t}):C.push(a)}),_.jsxs(z.Provider,{value:M,children:[_.jsx("group",{ref:c,renderOrder:X.RENDER_LAYERS.TRACKED,children:C}),h]})},q=e=>_.jsx(O,{...e});q.displayName="FaceTracker.Mesh";const D=i0;D.Mesh=q;const u0=D;exports.FACE_EYE_DISTANCE_LANDMARKS=o0;exports.FACE_LANDMARK_INDICES=L;exports.FaceMesh=O;exports.FaceTracker=D;exports.HeadTracker=u0;exports.MeshMaterial=U;exports.TrackerContext=z;exports.projectLandmarkWithDepth=J;exports.resolveFaceAnchorPoint=H;exports.transformFaceMeshLandmark=W;exports.useTrackerContext=c0;exports.useXRModel=N;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Ae=Object.defineProperty;var be=(n,s,e)=>s in n?Ae(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e;var h=(n,s,e)=>be(n,typeof s!="symbol"?s+"":s,e);const ce=require("react/jsx-runtime"),x=require("react"),D=require("@mediapipe/tasks-vision"),_=require("three");function Ee(n){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(s,e,t.get?t:{enumerable:!0,get:()=>n[e]})}}return s.default=n,Object.freeze(s)}const P=Ee(_);var R=(n=>(n.WEBCAM="webcam",n.STREAM="stream",n.CANVAS="canvas",n))(R||{}),V=(n=>(n.HAND_TRACKER="vincentt.xr.hand-tracker",n.GESTURE_TRACKER="vincentt.xr.gesture-tracker",n.FACE_TRACKER="vincentt.xr.face-tracker",n.BODY_TRACKER="vincentt.xr.body-tracker",n.BACKGROUND_SEGMENTATION="vincentt.xr.background-segmentation",n))(V||{});class I extends Error{constructor(s){super(s),this.name="VincenttXRError"}}const Ie=(n,s)=>s,F={apiBaseUrl:Ie(void 0,"https://api.vincentt.studio"),assetStorageEndpoint:"https://cdn.vincentt.studio",sdkAssetsBaseUrl:"https://cdn.vincentt.studio/assets/sdk/face/v1",loggerPrefix:"[vincentt-xr]:",sessionCheckInterval:3e4};class Pe{constructor(s){h(this,"options");const e={verbose:!1,prefix:F.loggerPrefix};this.options={...e,...s}}log(...s){const{verbose:e,prefix:t}=this.options;e&&console.info(t,...s)}error(...s){const{verbose:e,prefix:t}=this.options;e&&console.error(t,...s)}}const X=(n,s={x:0,y:0,z:0})=>(s.x=n.x*2-1,s.y=1-n.y*2,s.z=-n.z,s),De=(n,s={x:0,y:0,z:0})=>(s.x=(n.x+1)/2,s.y=(1-n.y)/2,s.z=-n.z,s),Z=new P.Vector3,J=new P.Vector3,q=({x:n,y:s,z:e},t,i)=>{Z.set((n-.5)*2,(.5-s)*2,-e),Z.unproject(t),J.copy(Z).sub(t.position).normalize();const r=-t.position.z/J.z;return i.copy(t.position).addScaledVector(J,r),i},_e=(n,s)=>q(n,s,new P.Vector3),Oe=(n,s,e=.2)=>e*s+(1-e)*n;class se{constructor(s){h(this,"canvas");this.maxDimension=s}draw(s){const e=s.width,t=s.height,i=Math.min(1,this.maxDimension/Math.max(e,t));if(i>=1)return s;const r=Math.max(1,Math.round(e*i)),c=Math.max(1,Math.round(t*i));(!this.canvas||this.canvas.width!==r||this.canvas.height!==c)&&(this.canvas=new OffscreenCanvas(r,c));const d=this.canvas.getContext("2d");return d?(d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,r,c),d.drawImage(s,0,0,r,c),this.canvas):s}dispose(){this.canvas=void 0}}const Ue={"/assets/xr/models/face_tracking.task":"sha384-tYQh+yJE8llY+zO4RviZmWaSKs5W9tsB0ix5rjQVpF5/CLTqmwtP7bYtkUi2w65P","/assets/xr/models/hand_tracking.task":"sha384-uWvruVKd887ov8k43S+DBHCsi7UXXS+CKvvdM1PX00rjPzx/B0QrAPfJ1U9yKcze","/assets/xr/models/gesture_tracking.task":"sha384-2zuseP9JKKWAYlWQGKA2N+ooabB8V/yIxu23Mv8mtY7SowcySB+xKiOmqBhVvlUC","/assets/xr/models/body_tracking.task":"sha384-3Wk9dvRYo36b3Nc9xVjKamb4wCKt9FwiPjcHKfrvyJL/jXoGs+uRLnii6yjWLKul","/assets/xr/models/segmentation.tflite":"sha384-A2bQ8+iZyQM3KIGVBUf0FyetqxuynyKpjsjCE8uzoJEnj1ghCu6ge2daiRffAiS5","/assets/xr/3d-models/head-occluder-v2.glb":"sha384-+0G60Q6EBVE6hpITxGzQgofAeKexPltpsfPq5T5et9GGBjRhFP5HOdsKAhe73OaI","/assets/sdk/face/v1/canonical_face_model.obj":"sha384-xP8YM/72TXKvbMptXB9a8JUlUf3MZQ8uLurExrsZc05v6/P5RrsaNGMUYS/BZx8A","/opencv/facial_expression_recognition/resolve/main/facial_expression_recognition_mobilefacenet_2022july_int8.onnx":"sha384-g8mtFubiIc/yhqi591RsxD76AJLw2CfYgKhKbVkIiFlwBmIyG7ZAIVyGPXafrDGB"};async function de(n){const s=await fetch(n);if(!s.ok)throw new Error(`fetchAndVerify: ${s.status} ${n}`);const e=await s.arrayBuffer(),t=Le(n);if(!t){if(ze(n))throw new Error(`[xr-sdk integrity] no SRI hash for SDK asset ${n}`);return console.warn(`[xr-sdk integrity] no SRI hash for ${n} — passing through`),e}const i=await Ve(e);if(i!==t)throw new Error(`[xr-sdk integrity] SRI mismatch for ${n}: expected ${t}, got ${i}`);return e}function ze(n){try{return new URL(n).origin===new URL(F.assetStorageEndpoint).origin}catch{return!1}}async function H(n){const s=await de(n);return new Uint8Array(s)}function Le(n){try{const s=new URL(n);return Ue[s.pathname]}catch{return}}async function Ve(n){const s=await crypto.subtle.digest("SHA-384",n),e=new Uint8Array(s);let t="";for(let i=0;i<e.byteLength;i++)t+=String.fromCharCode(e[i]);return`sha384-${btoa(t)}`}const ee=new Map;function G(n){const s=n.wasmBinaryPath;let e=ee.get(s);return e||(e=Be(s).catch(()=>{ee.delete(s)}),ee.set(s,e)),e}async function Be(n){const s=await fetch(n,{credentials:"same-origin"});if(!s.ok||!s.body)throw new Error(`warmVisionWasm: ${s.status} ${n}`);const e=s.body.getReader();for(;;){const{done:t}=await e.read();if(t)return}}class W{constructor(){h(this,"disposed",!1);h(this,"paused",!1);h(this,"rafId",null);h(this,"targetFrameIntervalMs",0);h(this,"lastInferenceMs",0)}setTargetFps(s){this.targetFrameIntervalMs=s&&s>0?1e3/s:0}shouldRunInference(){if(this.targetFrameIntervalMs<=0)return!0;const s=performance.now();return s-this.lastInferenceMs<this.targetFrameIntervalMs?!1:(this.lastInferenceMs=s,!0)}async initialize(s){}async run(s){}getModelNode(){return{}}async getPerformanceData(){return{name:this.constructor.name,processingTime:null}}pause(){this.paused=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}resume(){this.paused=!1}dispose(){this.disposed=!0,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}}const Ne=768;class Ke extends W{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"sourceCanvas");h(this,"downscaler",new se(Ne))}async getBodyData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),i=this.landmarker.detectForVideo(e,t),r=performance.now();this.processingTime=r-t;const c=i.landmarks,d=[];if(c)return c.forEach((m,u)=>{d[u]||(d[u]=[]),m.forEach(S=>{d[u].push(X(S))})}),{coordinatesList:d}}async processBodyTracking(){if(!(this.disposed||this.paused||!this.landmarker)){if(this.shouldRunInference()){const e=await this.getBodyData();e&&(this.coordinates=e.coordinatesList)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processBodyTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processBodyTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.downscaler.dispose(),this.coordinates=void 0}getLandmarks2D(e=0){if(this.coordinates)return this.coordinates[e]}async initialize(e){const t=await D.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",F.assetStorageEndpoint).toString()),[i]=await Promise.all([H(new URL("/assets/xr/models/body_tracking.task",F.assetStorageEndpoint).toString()),G(t)]);this.landmarker=await D.PoseLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:i,delegate:"GPU"},runningMode:"VIDEO",numPoses:(e==null?void 0:e.numPoses)||1})}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t),this.rafId===null&&await this.processBodyTracking()}getModelNode(){return{getLandmarks2D:this.getLandmarks2D.bind(this)}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const qe=.11,He=.004,Ge=(n,s)=>s.set(n.x,-n.y,n.z);class We extends W{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"sourceCanvas");h(this,"analysisCanvas");h(this,"getSource");h(this,"detectionResults");h(this,"numFaces",1);h(this,"cameras",[]);h(this,"faces",[]);h(this,"leftCheekScratch",[]);h(this,"rightCheekScratch",[]);h(this,"landmarkScratch",{x:0,y:0,z:0,visibility:0});h(this,"rotMatrixScratch",new P.Matrix4);h(this,"rotQuatScratch",new P.Quaternion);h(this,"rotEulerScratch",new P.Euler)}landmarkForSource(e,t){return t?(this.landmarkScratch.x=1-e.x,this.landmarkScratch.y=e.y,this.landmarkScratch.z=e.z,this.landmarkScratch.visibility=e.visibility,this.landmarkScratch):e}extractAndUpdateFaceData(e){var i;if(!e.faceLandmarks.length){this.faces=[];return}const t=e.faceLandmarks.length;for(this.faces.length>t&&(this.faces.length=t,this.leftCheekScratch.length=t,this.rightCheekScratch.length=t);this.faces.length<t;)this.faces.push({transform:{position:new P.Vector3,rotation:new P.Vector3,scale:new P.Vector3},gestures:{}}),this.leftCheekScratch.push(new P.Vector3),this.rightCheekScratch.push(new P.Vector3);for(let r=0;r<t;r+=1){if(!this.cameras[r])continue;const c=this.faces[r],d=(i=this.getSource)==null?void 0:i.call(this),m=!(d==="webcam"||!d),u=e.faceLandmarks[r],S=e.facialTransformationMatrixes[r];this.rotMatrixScratch.fromArray(S.data),this.rotQuatScratch.setFromRotationMatrix(this.rotMatrixScratch),this.rotQuatScratch.set(-this.rotQuatScratch.x,this.rotQuatScratch.y,this.rotQuatScratch.z,this.rotQuatScratch.w),this.rotEulerScratch.setFromQuaternion(this.rotQuatScratch,"XYZ"),Ge(this.rotEulerScratch,c.transform.rotation),q(this.landmarkForSource(u[4],m),this.cameras[r],c.transform.position),q(this.landmarkForSource(u[50],m),this.cameras[r],this.leftCheekScratch[r]),q(this.landmarkForSource(u[280],m),this.cameras[r],this.rightCheekScratch[r]);const M=this.leftCheekScratch[r].distanceTo(this.rightCheekScratch[r])*qe,b=Math.abs(P.MathUtils.radToDeg(this.rotEulerScratch.y)),l=M+b*He,f=c.transform.scale.x,v=Oe(isNaN(f)?0:f,l);c.transform.scale.set(v,v,v);const p=c.gestures,k=e.faceBlendshapes[r].categories;for(const C of k)p[C.categoryName]=C.score}}async processFaceTracking(){if(this.disposed||this.paused||!this.landmarker||!this.sourceCanvas)return null;if(!this.shouldRunInference()){this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this));return}const e=Xe(this.numFaces),t=this.sourceCanvas.width,i=this.sourceCanvas.height,r=Math.min(1,e/Math.max(t,i)),c=Math.max(1,Math.round(t*r)),d=Math.max(1,Math.round(i*r));(!this.analysisCanvas||this.analysisCanvas.width!==c||this.analysisCanvas.height!==d)&&(this.analysisCanvas=new OffscreenCanvas(c,d));const m=this.analysisCanvas.getContext("2d");if(!m){this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this));return}m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,c,d),m.drawImage(this.sourceCanvas,0,0,c,d);const u=performance.now(),S=this.landmarker.detectForVideo(this.analysisCanvas,u),A=performance.now();this.processingTime=A-u,this.detectionResults=S,this.extractAndUpdateFaceData(S),!(this.disposed||this.paused)&&(this.rafId=requestAnimationFrame(this.processFaceTracking.bind(this)))}resume(){this.paused&&(super.resume(),this.processFaceTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.analysisCanvas=void 0,this.getSource=void 0,this.detectionResults=void 0,this.processingTime=null,this.cameras=[],this.faces=[],this.leftCheekScratch=[],this.rightCheekScratch=[]}getFace(e=0){return this.faces[e]}getDetectionResults(){return this.detectionResults}getRawFaceTrackingData(e=0){var t,i,r,c;if(this.detectionResults)return{landmarks:(t=this.detectionResults.faceLandmarks)==null?void 0:t[e],blendshapes:(r=(i=this.detectionResults.faceBlendshapes)==null?void 0:i[e])==null?void 0:r.categories,transformationMatrix:(c=this.detectionResults.facialTransformationMatrixes)==null?void 0:c[e]}}async initialize(e){this.numFaces=(e==null?void 0:e.numFaces)||1;const t=await D.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",F.assetStorageEndpoint).toString()),[i]=await Promise.all([H(new URL("/assets/xr/models/face_tracking.task",F.assetStorageEndpoint).toString()),G(t)]),r=await D.FaceLandmarker.createFromOptions(t,{baseOptions:{modelAssetBuffer:i,delegate:"GPU"},minFaceDetectionConfidence:.3,minFacePresenceConfidence:.3,minTrackingConfidence:.3,outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0,runningMode:"VIDEO",numFaces:this.numFaces});if(this.disposed){r.close();return}this.landmarker=r}async run({sourceCanvas:e,getSource:t,targetFps:i}){this.sourceCanvas=e,this.getSource=t,this.setTargetFps(i),this.analysisCanvas=void 0,this.rafId===null&&this.processFaceTracking()}getModelNode(){const e=this;return{get detectionResults(){return e.detectionResults},getDetectionResults:this.getDetectionResults.bind(this),getFace:this.getFace.bind(this),getRawFaceTrackingData:this.getRawFaceTrackingData.bind(this),setCamera:(i,r=0)=>{this.cameras[r]=i}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Xe=n=>n>1?1024:512;var O=(n=>(n.ClosedFist="closed_fist",n.OpenPalm="open_palm",n.PointingUp="pointing_up",n.ThumbDown="thumb_down",n.ThumbUp="thumb_up",n.Victory="victory",n.ILoveYou="i_love_you",n.None="none",n))(O||{});const je=512,Ye={Closed_Fist:O.ClosedFist,Open_Palm:O.OpenPalm,Pointing_Up:O.PointingUp,Thumb_Down:O.ThumbDown,Thumb_Up:O.ThumbUp,Victory:O.Victory,ILoveYou:O.ILoveYou,None:O.None},Qe=15;class $e extends W{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"coordinates");h(this,"gesture");h(this,"sourceCanvas");h(this,"downscaler",new se(je))}async getGestureData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),i=this.landmarker.recognizeForVideo(e,t),r=performance.now();this.processingTime=r-t;const c=i.landmarks[0],d=[];if(c){const m=i.gestures[0][0].categoryName;return c.forEach(u=>{d.push(X(u))}),{coordinates:d,gesture:Ye[m]}}return{coordinates:void 0,gesture:void 0}}async processGestureTracking(){if(!this.disposed){if(this.shouldRunInference()){const e=await this.getGestureData();e&&(this.coordinates=e.coordinates,this.gesture=e.gesture)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processGestureTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processGestureTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.downscaler.dispose(),this.coordinates=void 0,this.gesture=void 0}async initialize(){const e=await D.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",F.assetStorageEndpoint).toString()),[t]=await Promise.all([H(new URL("/assets/xr/models/gesture_tracking.task",F.assetStorageEndpoint).toString()),G(e)]),i=await D.GestureRecognizer.createFromOptions(e,{baseOptions:{modelAssetBuffer:t,delegate:"GPU"},runningMode:"VIDEO",numHands:1});this.landmarker=i}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t??Qe),this.rafId===null&&await this.processGestureTracking()}getModelNode(){const e=this;return{get coordinates(){return e.coordinates},get gesture(){return e.gesture}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const Ze=512;class Je extends W{constructor(){super();h(this,"landmarker",null);h(this,"processingTime",null);h(this,"hands");h(this,"coordinates");h(this,"gesture");h(this,"handedness");h(this,"sourceCanvas");h(this,"downscaler",new se(Ze))}async getHandData(){if(!this.landmarker||!this.sourceCanvas)return;const e=this.downscaler.draw(this.sourceCanvas),t=performance.now(),i=this.landmarker.detectForVideo(e,t),r=performance.now();this.processingTime=r-t;const c=[],d=i.handedness??i.handednesses??[];if(i.landmarks.forEach((u,S)=>{var f,v,p;if(!u||u.length===0)return;const A=u.map(k=>X(k)),M=(p=(v=(f=d[S])==null?void 0:f[0])==null?void 0:v.categoryName)==null?void 0:p.toLowerCase(),b=M==="left"||M==="right"?M:void 0,l=u[0].z<0?"closed_fist":"open_palm";c.push({coordinates:A,gesture:l,handedness:b})}),!c.length)return{hands:void 0,coordinates:void 0,gesture:void 0,handedness:void 0};const m=c[0];return{hands:c,coordinates:m.coordinates,gesture:m.gesture,handedness:m.handedness}}async processHandTracking(){if(!this.disposed){if(this.shouldRunInference()){const e=await this.getHandData();e&&(this.hands=e.hands,this.coordinates=e.coordinates,this.gesture=e.gesture,this.handedness=e.handedness)}this.disposed||this.paused||(this.rafId=requestAnimationFrame(this.processHandTracking.bind(this)))}}resume(){this.paused&&(super.resume(),this.processHandTracking())}dispose(){if(super.dispose(),this.landmarker){try{this.landmarker.close()}catch{}this.landmarker=null}this.sourceCanvas=void 0,this.hands=void 0,this.downscaler.dispose(),this.coordinates=void 0,this.gesture=void 0,this.handedness=void 0}async initialize(){const e=await D.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",F.assetStorageEndpoint).toString()),[t]=await Promise.all([H(new URL("/assets/xr/models/hand_tracking.task",F.assetStorageEndpoint).toString()),G(e)]),i=await D.HandLandmarker.createFromOptions(e,{baseOptions:{modelAssetBuffer:t,delegate:"GPU"},runningMode:"VIDEO",numHands:2});this.landmarker=i}async run({sourceCanvas:e,targetFps:t}){this.sourceCanvas=e,this.setTargetFps(t),this.rafId===null&&await this.processHandTracking()}getModelNode(){const e=this;return{get hands(){return e.hands},get coordinates(){return e.coordinates},get gesture(){return e.gesture},get handedness(){return e.handedness}}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const et=24,tt=720,st=[[255,255,255,255],[0,0,0,0]];class nt extends W{constructor(){super();h(this,"segmenter",null);h(this,"processingTime",null);h(this,"sourceCanvas");h(this,"processCanvas");h(this,"filterCanvas");h(this,"inputSource");h(this,"inputSourceSize");h(this,"glCanvas");h(this,"drawingUtils");h(this,"useGpuMaskPath",!1);h(this,"maskImageData");h(this,"maskCanvas",null);h(this,"segmentationMaskTexture");h(this,"isMaskSetup",!1);h(this,"isProcessing",!1);h(this,"latestMask",null);h(this,"rawCache",null);h(this,"quality","medium");h(this,"stagingCanvas")}getQualityScaleFactor(){switch(this.quality){case"low":return .5;case"medium":return .75;case"high":return 1;default:return .5}}setInputSource(e){this.inputSource=e,this.inputSourceSize=e?this.readIntrinsicSize(e):void 0}readIntrinsicSize(e){if(e instanceof HTMLVideoElement)return e.videoWidth>0?{width:e.videoWidth,height:e.videoHeight}:void 0;if(e instanceof HTMLImageElement)return e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:void 0;const t=e.width,i=e.height;return typeof t=="number"&&t>0&&typeof i=="number"&&i>0?{width:t,height:i}:void 0}ensureProcessCanvasForInput(){if(!this.processCanvas||!this.inputSource)return;const e=this.readIntrinsicSize(this.inputSource);if(!e)return;this.inputSourceSize=e;const t=Math.min(1,tt/Math.max(e.width,e.height)),i=Math.max(1,Math.round(e.width*t)),r=Math.max(1,Math.round(e.height*t));this.processCanvas.width===i&&this.processCanvas.height===r||(this.processCanvas.width=i,this.processCanvas.height=r,this.glCanvas&&(this.glCanvas.width=i,this.glCanvas.height=r),this.maskImageData=void 0)}async processSegmentation(){if(this.disposed||!this.isProcessing||!this.maskCanvas||!this.processCanvas)return;if(!this.shouldRunInference()){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}const e=this.inputSource??this.sourceCanvas;if(!this.segmenter||!e){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}const t=performance.now();this.ensureProcessCanvasForInput();const i=this.processCanvas.getContext("2d");if(i){const d=this.processCanvas.width,m=this.processCanvas.height;if(i.clearRect(0,0,d,m),this.inputSource&&this.inputSourceSize){const{width:u,height:S}=this.inputSourceSize,A=Math.min(d/u,m/S),M=u*A,b=S*A;i.drawImage(this.inputSource,(d-M)/2,(m-b)/2,M,b)}else i.drawImage(e,0,0,d,m)}const c=this.segmenter.segmentForVideo(this.processCanvas,performance.now()).categoryMask;if(!c){if(this.disposed||this.paused)return;this.rafId=requestAnimationFrame(this.processSegmentation.bind(this));return}if(this.rawCache=null,this.latestMask&&(this.latestMask.close(),this.latestMask=null),this.useGpuMaskPath&&this.drawingUtils&&this.glCanvas)this.drawingUtils.drawCategoryMask(c,st),this.latestMask=c.clone(),c.close(),this.blitGlToMask();else{this.latestMask=c.clone();const d=this.readMaskToImageData(c);c.close(),d&&this.blitImageDataToMask(d)}this.segmentationMaskTexture&&(this.isMaskSetup||(this.segmentationMaskTexture.format=_.RGBAFormat,this.segmentationMaskTexture.minFilter=_.LinearFilter,this.segmentationMaskTexture.magFilter=_.LinearFilter,this.segmentationMaskTexture.generateMipmaps=!1,this.isMaskSetup=!0),this.segmentationMaskTexture.needsUpdate=!0),this.processingTime=performance.now()-t,!(this.disposed||this.paused)&&(this.rafId=requestAnimationFrame(this.processSegmentation.bind(this)))}blitGlToMask(){if(!this.maskCanvas||!this.filterCanvas||!this.glCanvas)return;const e=this.maskCanvas.getContext("2d"),t=this.filterCanvas.getContext("2d");!e||!t||(t.filter="blur(0.5px)",t.clearRect(0,0,this.filterCanvas.width,this.filterCanvas.height),t.drawImage(this.glCanvas,0,0,this.filterCanvas.width,this.filterCanvas.height),e.clearRect(0,0,this.maskCanvas.width,this.maskCanvas.height),e.drawImage(this.filterCanvas,0,0,this.maskCanvas.width,this.maskCanvas.height))}readMaskToImageData(e){const t=e.getAsUint8Array(),{width:i,height:r}=e;if(!t||i<=0||r<=0)return null;(!this.maskImageData||this.maskImageData.width!==i||this.maskImageData.height!==r)&&(this.maskImageData=new ImageData(i,r));const c=this.maskImageData.data;for(let d=0;d<t.length;d+=1){const m=t[d]===255?0:255;c[d*4]=255,c[d*4+1]=m,c[d*4+2]=255,c[d*4+3]=m}return this.maskImageData}blitImageDataToMask(e){if(!this.maskCanvas||!this.filterCanvas)return;const t=this.maskCanvas.getContext("2d"),i=this.filterCanvas.getContext("2d");if(!t||!i)return;const r=this.getStagingCanvas(e.width,e.height),c=r.getContext("2d");c&&(c.putImageData(e,0,0),i.filter="blur(0.5px)",i.clearRect(0,0,this.filterCanvas.width,this.filterCanvas.height),i.drawImage(r,0,0,this.filterCanvas.width,this.filterCanvas.height),t.clearRect(0,0,this.maskCanvas.width,this.maskCanvas.height),t.drawImage(this.filterCanvas,0,0,this.maskCanvas.width,this.maskCanvas.height))}getStagingCanvas(e,t){return this.stagingCanvas||(this.stagingCanvas=document.createElement("canvas")),this.stagingCanvas.width!==e&&(this.stagingCanvas.width=e),this.stagingCanvas.height!==t&&(this.stagingCanvas.height=t),this.stagingCanvas}resume(){this.paused&&(super.resume(),this.processSegmentation())}dispose(){if(super.dispose(),this.isProcessing=!1,this.latestMask){try{this.latestMask.close()}catch{}this.latestMask=null}if(this.rawCache=null,this.segmenter){try{this.segmenter.close()}catch{}this.segmenter=null}this.drawingUtils=void 0,this.glCanvas=void 0,this.maskImageData=void 0,this.segmentationMaskTexture&&(this.segmentationMaskTexture.dispose(),this.segmentationMaskTexture=void 0),this.sourceCanvas=void 0,this.inputSource=void 0,this.inputSourceSize=void 0,this.processCanvas=void 0,this.filterCanvas=void 0,this.stagingCanvas=void 0,this.maskCanvas=null}async initialize(e){this.quality=(e==null?void 0:e.quality)??"low";const t=await D.FilesetResolver.forVisionTasks(new URL("/assets/xr/wasm",F.assetStorageEndpoint).toString()),[i]=await Promise.all([H(new URL("/assets/xr/models/segmentation.tflite",F.assetStorageEndpoint).toString()),G(t)]);this.glCanvas=new OffscreenCanvas(1,1);const r=this.glCanvas.getContext("webgl2",{preserveDrawingBuffer:!0});this.segmenter=await D.ImageSegmenter.createFromOptions(t,{baseOptions:{modelAssetBuffer:i,delegate:"GPU"},...r?{canvas:this.glCanvas}:{},outputCategoryMask:!0,outputConfidenceMasks:!1,runningMode:"VIDEO"}),r?(this.drawingUtils=new D.DrawingUtils(r),this.useGpuMaskPath=!0):this.useGpuMaskPath=!1}async run({sourceCanvas:e,renderWidth:t,renderHeight:i,targetFps:r}){var d;if(!e)return;this.setTargetFps(r??et),this.isProcessing=!1,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null);const c=this.getQualityScaleFactor();this.sourceCanvas=e,this.processCanvas=document.createElement("canvas"),this.processCanvas.width=e.width*c,this.processCanvas.height=e.height*c,this.glCanvas&&(this.glCanvas.width=this.processCanvas.width,this.glCanvas.height=this.processCanvas.height),this.maskImageData=void 0,this.maskCanvas=document.createElement("canvas"),this.maskCanvas.width=t,this.maskCanvas.height=i,this.filterCanvas=document.createElement("canvas"),this.filterCanvas.width=t,this.filterCanvas.height=i,(d=this.segmentationMaskTexture)==null||d.dispose(),this.segmentationMaskTexture=new _.CanvasTexture(this.maskCanvas),this.isMaskSetup=!1,this.rawCache=null,this.isProcessing=!0,this.lastInferenceMs=0,this.rafId=requestAnimationFrame(this.processSegmentation.bind(this))}getRawSegmentationData(){if(this.rawCache)return this.rawCache;if(!this.latestMask)return null;const e=this.latestMask.getAsUint8Array();return this.rawCache={maskData:e,width:this.latestMask.width,height:this.latestMask.height},this.rawCache}getModelNode(){const e=this;return{get backgroundSegmentationMask(){return e.segmentationMaskTexture},getMaskCanvas:()=>e.maskCanvas,getRawSegmentationData:()=>e.getRawSegmentationData(),setInputSource:t=>e.setInputSource(t??void 0)}}async getPerformanceData(){return{name:this.constructor.name,processingTime:this.processingTime}}}const he={[V.BACKGROUND_SEGMENTATION]:nt,[V.HAND_TRACKER]:Je,[V.GESTURE_TRACKER]:$e,[V.FACE_TRACKER]:We,[V.BODY_TRACKER]:Ke},at=async n=>{const s=document.createElement("video");s.srcObject=n,s.muted=!0,s.playsInline=!0,s.autoplay=!0,await new Promise(t=>{s.onloadedmetadata=()=>{s.play(),t()}});const e=s;return await new Promise(t=>{const i=setTimeout(t,150),r=()=>{clearTimeout(i),t()};typeof e.requestVideoFrameCallback=="function"?e.requestVideoFrameCallback(r):requestAnimationFrame(()=>requestAnimationFrame(()=>r()))}),s},it=n=>{const s=new _.CanvasTexture(n);return s.colorSpace=_.SRGBColorSpace,s.format=_.RGBAFormat,s.minFilter=_.LinearFilter,s.magFilter=_.LinearFilter,s.generateMipmaps=!1,s.needsUpdate=!0,s},rt=(n,s)=>{const e=n.videoWidth,t=n.videoHeight;e>0&&t>0&&(s.width!==e&&(s.width=e),s.height!==t&&(s.height=t));const i=s.getContext("2d",{colorSpace:"srgb"});i.save(),i.scale(-1,1),i.drawImage(n,-s.width,0,s.width,s.height),i.restore()},ot=(n,s,e=1)=>{const t=s.getContext("2d",{colorSpace:"srgb"}),i=s.width/s.height,r=n.width/n.height;let c,d;r>i?(d=s.height,c=n.width*(s.height/n.height)):(c=s.width,d=n.height*(s.width/n.width));const m=Number.isFinite(e)&&e>0?e:1;c*=m,d*=m;const u=(s.width-c)/2,S=(s.height-d)/2;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,s.width,s.height),t.drawImage(n,0,0,n.width,n.height,u,S,c,d)},ct=n=>{switch(n instanceof DOMException?n.name:""){case"NotAllowedError":case"PermissionDeniedError":return"permission-denied";case"NotReadableError":case"TrackStartError":return"camera-in-use";case"NotFoundError":case"DevicesNotFoundError":return"no-camera";case"NotSupportedError":case"SecurityError":return"unsupported";default:return n instanceof TypeError?"unsupported":"unknown"}},ht={"permission-denied":"Camera access was blocked. Allow camera permissions in your browser, then refresh.","camera-in-use":"Camera is already in use by another app or browser tab. Close it and refresh.","no-camera":"No camera was found on this device.",unsupported:"Unable to access camera. Allow camera permissions in your browser, then refresh.",unknown:"Unable to access camera. Allow camera permissions in your browser, then refresh."},dt=(n,s,e)=>{const t=new Map;let i=!1;const r=(l,f)=>{var v;try{(v=f.dispose)==null||v.call(f)}catch(p){console.warn(`[xr-sdk registry] dispose threw for ${l}`,p)}};return{acquire:async(l,f,v)=>{let p=t.get(l);if(p)return p.refs.add(f),p.activeRefs.add(f),p.initPromise;const k=s[l];if(!k)throw new Error(`Invalid model: ${l}`);const C=new k,L=new Set([f]),B=new Set([f]),U=(async()=>{await C.initialize(v);const z=t.get(l);if(!z||z.model!==C||z.refs.size===0)return r(l,C),C;e&&await e(l,C);const N=t.get(l);return N&&N.refs.size>0&&n.setPipeline(E=>E.set(l,C)),C})();return p={model:C,refs:L,activeRefs:B,initPromise:U,options:v},t.set(l,p),U.catch(()=>{t.get(l)===p&&(t.delete(l),n.setPipeline(N=>N.delete(l))),r(l,C)}),U},release:(l,f)=>{const v=t.get(l);v&&(v.refs.delete(f),v.activeRefs.delete(f)&&v.refs.size>0&&v.activeRefs.size===0&&v.model.pause(),!(v.refs.size>0)&&(t.delete(l),r(l,v.model),n.setPipeline(p=>p.delete(l))))},setActive:(l,f,v)=>{const p=t.get(l);if(!p||!p.refs.has(f))return;const k=p.activeRefs.size>0;v?p.activeRefs.add(f):p.activeRefs.delete(f);const C=p.activeRefs.size>0;k!==C&&(C&&!i?p.model.resume():p.model.pause())},suspendAll:()=>{i=!0;for(const l of t.values())l.model.pause()},resumeActive:()=>{i=!1;for(const l of t.values())l.activeRefs.size>0&&l.model.resume()},get:l=>{var f;return(f=t.get(l))==null?void 0:f.model},getOptions:l=>{var f;return(f=t.get(l))==null?void 0:f.options},releaseAll:()=>{for(const l of Array.from(t.keys())){const f=t.get(l);f&&(f.refs.clear(),t.delete(l),r(l,f.model))}n.setPipeline(l=>l.clear())}}},ut={lifecycle:"idle",ready:!1,error:void 0,cameraTexture:void 0,renderWidth:0,renderHeight:0,source:void 0,sourceKind:void 0,pipeline:new Map},lt=()=>{let n={...ut,pipeline:new Map};const s=new Set,e=()=>{s.forEach(t=>t())};return{getSnapshot:()=>n,set:t=>{let i=!1;for(const r of Object.keys(t))if(t[r]!==n[r]){i=!0;break}i&&(n={...n,...t},e())},setPipeline:t=>{const i=new Map(n.pipeline);return t(i),n={...n,pipeline:i},e(),i},subscribe:t=>(s.add(t),()=>{s.delete(t)})}},gt=({renderHeight:n,renderWidth:s,videoHeight:e,videoWidth:t})=>({height:n||e,width:s||t}),mt=n=>{const s=new Pe({verbose:!0}),e=lt();let t=n;const i=a=>{var g;const o=(g=E.getOptions(a))==null?void 0:g.targetFps;return typeof o=="number"?o:t==null?void 0:t.targetFps};let r,c,d,m,u,S,A,M,b,l,f,v,p=!1,k=!1,C=0;const L=new Set,B=new Set,U=a=>{const o=e.getSnapshot().cameraTexture;o&&o.dispose();const g=it(a);return e.set({cameraTexture:g}),g},z=async(a,o)=>{if(L.has(a)||e.getSnapshot().lifecycle!=="running"||!u)return;L.add(a);const g=C;try{await o.run({sourceCanvas:u,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:i(a)}),k&&(await new Promise(w=>requestAnimationFrame(()=>w())),await new Promise(w=>requestAnimationFrame(()=>w())),k&&C===g&&E.suspendAll())}catch(w){throw L.delete(a),w}},E=dt(e,he,(a,o)=>z(a,o));e.subscribe(()=>{if(e.getSnapshot().lifecycle!=="running")return;const a=e.getSnapshot().pipeline;for(const[o,g]of a.entries())L.has(o)||z(o,g)});const K=()=>{if(v!==void 0&&(cancelAnimationFrame(v),v=void 0),c){try{c.pause()}catch{}try{c.srcObject=null}catch{}c=void 0}if(d){try{d.getTracks().forEach(a=>a.stop())}catch{}d=void 0}},j=()=>{if(p||!c||!m||!u)return;const a=window.__xr_debugger_metrics;if(a!=null&&a.trackCameraFrame&&a.trackCameraFrame(),(e.getSnapshot().sourceKind??"webcam")==="webcam")rt(c,m);else{const w=m.getContext("2d");if(!w)return;const y=c.videoWidth,T=c.videoHeight;m.width!==y&&(m.width=y),m.height!==T&&(m.height=T),w.setTransform(1,0,0,1,0,0),w.clearRect(0,0,y,T),w.drawImage(c,0,0,y,T)}ot(m,u,(t==null?void 0:t.cameraZoom)??1.2);const g=e.getSnapshot().cameraTexture;g&&(g.needsUpdate=!0)},ne=()=>{if(!c||!m||!u)return;if(k){j();return}const a=()=>{v=requestAnimationFrame(a),j()};v=requestAnimationFrame(a)},fe=async a=>{if(a.source===R.WEBCAM)try{const o=t!=null&&t.camRes&&t.camRes>0?t.camRes:960;return await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",frameRate:{min:24,ideal:30,max:60},width:{ideal:o}}})}catch(o){const g=ct(o),w=ht[g];throw e.set({error:{error:"PermissionError",message:w,reason:g}}),new I(o instanceof Error?o.message:"getUserMedia failed")}return a.stream},Y=async a=>{const o=await fe(a);d=o;const g=await at(o);c=g,m=new OffscreenCanvas(g.videoWidth,g.videoHeight);const{renderWidth:w,renderHeight:y}=e.getSnapshot(),T=gt({renderWidth:w,renderHeight:y,videoWidth:g.videoWidth,videoHeight:g.videoHeight});u?(u.width!==T.width||u.height!==T.height)&&(u.width=T.width,u.height=T.height,U(u)):(u=new OffscreenCanvas(T.width,T.height),U(u));const oe=a.source===R.STREAM?a.static===!0:!1;k=oe,r=a.source===R.WEBCAM?{source:R.WEBCAM,sourceKind:"webcam"}:{source:R.STREAM,stream:a.stream,static:oe,sourceKind:a.sourceKind??"webcam"},e.set({source:a.source,sourceKind:r.sourceKind,error:void 0})},Q=async a=>{const o=a.sourceKind??"webcam";u=a.canvas;const g=U(u);e.set({cameraTexture:g,source:R.CANVAS,sourceKind:o,renderWidth:u.width,renderHeight:u.height,error:void 0}),r={source:R.CANVAS,canvas:a.canvas,sourceKind:o}},pe=(a,o)=>!o||a.source!==o.source?!1:a.source===R.STREAM&&o.source===R.STREAM?a.stream===o.stream&&(a.sourceKind??"webcam")===o.sourceKind:!0,we=async()=>{if(!u)return;const a=C,o=e.getSnapshot().pipeline;for(const[,g]of o.entries())g.resume();await new Promise(g=>requestAnimationFrame(()=>g())),await new Promise(g=>requestAnimationFrame(()=>g())),k&&C===a&&E.suspendAll()},ve=(a,o)=>!o||o.source!==R.CANVAS?!1:a.canvas===o.canvas&&(a.sourceKind??"webcam")===o.sourceKind,Ce=async a=>{const o=a.source;if(o!==R.WEBCAM&&o!==R.STREAM)throw new I(`Invalid media source: ${String(o)}`);if(pe(a,r)){s.log("Media source unchanged, skipping rebind.");return}C+=1;const{lifecycle:g}=e.getSnapshot();if(g==="idle"||g==="stopped"){await Y(a),e.set({lifecycle:"media-bound"}),s.log("Media source set to:",a.source);return}if(g==="media-bound"){K(),await Y(a),s.log("Media source rebound to:",a.source);return}p=!0,await new Promise(w=>requestAnimationFrame(()=>w())),K(),await Y(a),p=!1,ne(),k?await we():E.resumeActive(),s.log("Media source swapped to:",a.source)},Se=async a=>{if(ve(a,r)){s.log("Frame source unchanged, skipping rebind.");return}C+=1;const{lifecycle:o}=e.getSnapshot();if(o==="idle"||o==="stopped"){await Q(a),e.set({lifecycle:"media-bound"}),s.log("Frame source set to canvas.");return}if(o==="media-bound"){K(),await Q(a),s.log("Frame source rebound to canvas.");return}p=!0,await new Promise(g=>requestAnimationFrame(()=>g())),K(),await Q(a),p=!1,s.log("Frame source swapped to canvas.")},ke=async()=>{const{lifecycle:a}=e.getSnapshot();if(a==="running")return;if(a==="idle")throw new I("session.start() called before setMediaSource — call setMediaSource first");if(!u)throw new I("session.start(): media source not bound");const o=(r==null?void 0:r.source)===R.CANVAS;if(!o&&(!c||!m))throw a==="stopped"?new I("session.start() called from stopped state without a media source — call setMediaSource first"):new I("session.start(): media source not bound");o||ne(),E.resumeActive(),e.set({lifecycle:"running"}),await new Promise(w=>requestAnimationFrame(()=>w()));const g=e.getSnapshot().pipeline;for(const[w,y]of g.entries())await z(w,y);e.set({ready:!0}),s.log("XR session started.")},ae=async()=>{const{lifecycle:a}=e.getSnapshot();a==="stopped"||a==="idle"||(K(),E.suspendAll(),e.set({lifecycle:"stopped",ready:!1}),s.log("XR session stopped."))},ye=async()=>{await ae(),E.releaseAll(),B.clear();const a=e.getSnapshot().cameraTexture;a&&a.dispose(),L.clear(),r=void 0,C+=1,u=void 0,m=void 0,A=void 0,k=!1,e.set({lifecycle:"idle",cameraTexture:void 0,source:void 0}),s.log("XR session reset.")},Re=async a=>{const o="legacy:registerXRPipeline",g=[];await Promise.all(a.map(async w=>{const{model:y}=w;if(!he[y])throw new I(`Invalid model: ${y}`);B.has(y)||g.push(y);const T="options"in w?w.options:void 0;await E.acquire(y,o,T)})),g.length>0&&(g.forEach(w=>B.add(w)),s.log("XR pipeline registered."))},Me=a=>{const o=E.get(a);if(!o)throw new I(`Model ${a} is not registered in the pipeline`);return o.getModelNode()},ie=async(a,o)=>{a<=0||o<=0||(e.set({renderWidth:a,renderHeight:o}),u&&(u.width!==a||u.height!==o)&&(u.width=a,u.height=o,U(u),k&&j()),s.log(`Source canvas set. Render size: ${a}x${o}`))},Te=async a=>{var y;S=a;const o=(y=a.getBoundingClientRect)==null?void 0:y.call(a),g=o&&o.width>0?Math.round(o.width):a.clientWidth,w=o&&o.height>0?Math.round(o.height):a.clientHeight;await ie(g,w)},xe=a=>{A=a},$=()=>S&&M&&b&&l?S:A,Fe=a=>{M=a.renderer,b=a.scene,l=a.camera,f=a.renderFrame},re=()=>{if(!M||!b||!l)throw new I("XR frame render requested before the R3F state was bound — make sure <XRScene> is mounted");f?f():M.render(b,l)};return{store:e,registry:E,setMediaSource:Ce,start:ke,stop:ae,reset:ye,setFrameSource:Se,registerXRPipeline:Re,getModelNode:Me,captureFrame:()=>{const a=S;if(a&&$()===a)return re(),a.toDataURL("image/png");const o=$();if(o)return o.toDataURL("image/png");throw new I("session.captureFrame() called before an XRScene or XRMediaSurface capture target was bound")},captureStream:(a=30)=>{const o=$();if(!(o!=null&&o.captureStream))throw new I("session.captureStream() called before an XRScene or XRMediaSurface capture target was bound");return o.captureStream(a)},getInputFrame:()=>u??null,_setRenderTarget:Te,_setCaptureTarget:xe,_setRenderSize:ie,_setR3FState:Fe,_renderFrame:re,_getVideoElement:()=>c,_setPerf:a=>{if(t=a,e.getSnapshot().lifecycle!=="running"||!u)return;const o=e.getSnapshot().pipeline;for(const[g,w]of o.entries())w.run({sourceCanvas:u,renderWidth:e.getSnapshot().renderWidth,renderHeight:e.getSnapshot().renderHeight,getSource:()=>e.getSnapshot().sourceKind,targetFps:i(g)})}}},ft=n=>{const s=x.useRef(n),e=x.useMemo(()=>mt(s.current),[]),t=JSON.stringify(n??{});return x.useEffect(()=>{e._setPerf(n)},[e,t]),e},te=new Map,pt=()=>({register:(n,s)=>{s?te.set(n,s):te.delete(n)},resolve:n=>n?te.get(n)??null:null}),ue=pt(),le=x.createContext(null),wt=({children:n})=>{const s=x.useRef(new Map),e=x.useCallback((r,c)=>{c?s.current.set(r,c):s.current.delete(r)},[]),t=x.useCallback(r=>r?s.current.get(r)??null:null,[]),i=x.useMemo(()=>({register:e,resolve:t}),[e,t]);return x.createElement(le.Provider,{value:i},n)},ge=()=>x.useContext(le)??ue,vt=()=>ge().register,Ct=()=>ge().resolve;ue.register;const me=x.createContext(void 0),St=()=>{const n=x.useContext(me);if(!n)throw new I("XR context can only be used inside XRProvider, did you forget to wrap your app in <XRProvider>?");return n},kt=({children:n,perf:s})=>{const e=ft(s),t=x.useMemo(()=>({session:e}),[e]);return ce.jsx(me.Provider,{value:t,children:ce.jsx(wt,{children:n})})};exports.XRMediaSource=R;exports.XRModel=V;exports.XRProvider=kt;exports.fetchAndVerify=de;exports.libConfig=F;exports.normalizedTrackerPointToTrackerPoint=X;exports.trackerPointToNormalizedTrackerPoint=De;exports.unprojectToZZero=_e;exports.unprojectToZZeroInto=q;exports.useRegisterRuntimeObject=vt;exports.useResolveRuntimeObject=Ct;exports.useXRContext=St;
|