@react-three/drei 9.78.0 → 9.78.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("react-dom/client"),n=require("three"),o=require("@react-three/fiber"),a=require("zustand"),i=require("react-merge-refs"),s=require("maath"),l=require("@react-spring/three"),c=require("@use-gesture/react"),u=require("zustand/middleware"),m=require("three-stdlib"),d=require("zustand/shallow"),f=require("troika-three-text"),p=require("suspend-react"),h=require("meshline"),x=require("lodash.pick"),y=require("lodash.omit"),v=require("camera-controls"),g=require("@mediapipe/tasks-vision"),z=require("stats.js"),w=require("detect-gpu"),b=require("three-mesh-bvh"),E=require("react-composer"),M=require("lodash.clamp");function S(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var T=S(t),C=S(r),P=S(n),R=S(o);const D=new n.Vector3,F=new n.Vector3,k=new n.Vector3;function _(e,t,r){const n=D.setFromMatrixPosition(e.matrixWorld);n.project(t);const o=r.width/2,a=r.height/2;return[n.x*o+o,-n.y*a+a]}const L=e=>Math.abs(e)<1e-10?0:e;function A(e,t,r=""){let n="matrix3d(";for(let r=0;16!==r;r++)n+=L(t[r]*e.elements[r])+(15!==r?",":")");return r+n}const B=(U=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>A(e,U));var U;const O=(e,t)=>{return A(e,[1/(r=t),1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1],"translate(-50%,-50%)");var r};const N=T.forwardRef((({children:t,eps:r=.001,style:a,className:i,prepend:s,center:l,fullscreen:c,portal:u,distanceFactor:m,sprite:d=!1,transform:f=!1,occlude:p,onOcclude:h,castShadow:x,receiveShadow:y,material:v,geometry:g,zIndexRange:z=[16777271,0],calculatePosition:w=_,as:b="div",wrapperClass:E,pointerEvents:M="auto",...S},P)=>{const{gl:R,camera:A,scene:U,size:N,raycaster:I,events:V,viewport:j}=o.useThree(),[W]=T.useState((()=>document.createElement(b))),G=T.useRef(),H=T.useRef(null),q=T.useRef(0),$=T.useRef([0,0]),X=T.useRef(null),Y=T.useRef(null),K=(null==u?void 0:u.current)||V.connected||R.domElement.parentNode,Z=T.useRef(null),Q=T.useRef(!1),J=T.useMemo((()=>p&&"blending"!==p||Array.isArray(p)&&p.length&&function(e){return e&&"object"==typeof e&&"current"in e}(p[0])),[p]);T.useLayoutEffect((()=>{const e=R.domElement;p&&"blending"===p?(e.style.zIndex=`${Math.floor(z[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)}),[p]),T.useLayoutEffect((()=>{if(H.current){const e=G.current=C.createRoot(W);if(U.updateMatrixWorld(),f)W.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=w(H.current,A,N);W.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return K&&(s?K.prepend(W):K.appendChild(W)),()=>{K&&K.removeChild(W),e.unmount()}}}),[K,f]),T.useLayoutEffect((()=>{E&&(W.className=E)}),[E]);const ee=T.useMemo((()=>f?{position:"absolute",top:0,left:0,width:N.width,height:N.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:l?"translate3d(-50%,-50%,0)":"none",...c&&{top:-N.height/2,left:-N.width/2,width:N.width,height:N.height},...a}),[a,l,c,N,f]),te=T.useMemo((()=>({position:"absolute",pointerEvents:M})),[M]);T.useLayoutEffect((()=>{var e,r;(Q.current=!1,f)?null==(e=G.current)||e.render(T.createElement("div",{ref:X,style:ee},T.createElement("div",{ref:Y,style:te},T.createElement("div",{ref:P,className:i,style:a,children:t})))):null==(r=G.current)||r.render(T.createElement("div",{ref:P,style:ee,className:i,children:t}))}));const re=T.useRef(!0);o.useFrame((e=>{if(H.current){A.updateMatrixWorld(),H.current.updateWorldMatrix(!0,!1);const e=f?$.current:w(H.current,A,N);if(f||Math.abs(q.current-A.zoom)>r||Math.abs($.current[0]-e[0])>r||Math.abs($.current[1]-e[1])>r){const t=function(e,t){const r=D.setFromMatrixPosition(e.matrixWorld),n=F.setFromMatrixPosition(t.matrixWorld),o=r.sub(n),a=t.getWorldDirection(k);return o.angleTo(a)>Math.PI/2}(H.current,A);let r=!1;J&&("blending"!==p?r=[U]:Array.isArray(p)&&(r=p.map((e=>e.current))));const o=re.current;if(r){const e=function(e,t,r,n){const o=D.setFromMatrixPosition(e.matrixWorld),a=o.clone();a.project(t),r.setFromCamera(a,t);const i=r.intersectObjects(n,!0);if(i.length){const e=i[0].distance;return o.distanceTo(r.ray.origin)<e}return!0}(H.current,A,I,r);re.current=e&&!t}else re.current=!t;o!==re.current&&(h?h(!re.current):W.style.display=re.current?"block":"none");const a=Math.floor(z[0]/2),i=p?J?[z[0],a]:[a-1,0]:z;if(W.style.zIndex=`${function(e,t,r){if(t instanceof n.PerspectiveCamera||t instanceof n.OrthographicCamera){const n=D.setFromMatrixPosition(e.matrixWorld),o=F.setFromMatrixPosition(t.matrixWorld),a=n.distanceTo(o),i=(r[1]-r[0])/(t.far-t.near),s=r[1]-i*t.far;return Math.round(i*a+s)}}(H.current,A,i)}`,f){const[e,t]=[N.width/2,N.height/2],r=A.projectionMatrix.elements[5]*t,{isOrthographicCamera:n,top:o,left:a,bottom:i,right:s}=A,l=B(A.matrixWorldInverse),c=n?`scale(${r})translate(${L(-(s+a)/2)}px,${L((o+i)/2)}px)`:`translateZ(${r}px)`;let u=H.current.matrixWorld;d&&(u=A.matrixWorldInverse.clone().transpose().copyPosition(u).scale(H.current.scale),u.elements[3]=u.elements[7]=u.elements[11]=0,u.elements[15]=1),W.style.width=N.width+"px",W.style.height=N.height+"px",W.style.perspective=n?"":`${r}px`,X.current&&Y.current&&(X.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,Y.current.style.transform=O(u,1/((m||10)/400)))}else{const t=void 0===m?1:function(e,t){if(t instanceof n.OrthographicCamera)return t.zoom;if(t instanceof n.PerspectiveCamera){const r=D.setFromMatrixPosition(e.matrixWorld),n=F.setFromMatrixPosition(t.matrixWorld),o=t.fov*Math.PI/180,a=r.distanceTo(n);return 1/(2*Math.tan(o/2)*a)}return 1}(H.current,A)*m;W.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}$.current=e,q.current=A.zoom}}if(!J&&Z.current&&!Q.current)if(f){if(X.current){const e=X.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){const{isOrthographicCamera:t}=A;if(t||g)S.scale&&(Array.isArray(S.scale)?S.scale instanceof n.Vector3?Z.current.scale.copy(S.scale.clone().divideScalar(1)):Z.current.scale.set(1/S.scale[0],1/S.scale[1],1/S.scale[2]):Z.current.scale.setScalar(1/S.scale));else{const t=(m||10)/400,r=e.clientWidth*t,n=e.clientHeight*t;Z.current.scale.set(r,n,1)}Q.current=!0}}}else{const t=W.children[0];if(null!=t&&t.clientWidth&&null!=t&&t.clientHeight){const e=1/j.factor,r=t.clientWidth*e,n=t.clientHeight*e;Z.current.scale.set(r,n,1),Q.current=!0}Z.current.lookAt(e.camera.position)}}));const ne=T.useMemo((()=>({vertexShader:f?void 0:'\n /*\n This shader is from the THREE\'s SpriteMaterial.\n We need to turn the backing plane into a Sprite\n (make it always face the camera) if "transfrom" \n is false. \n */\n #include <common>\n\n void main() {\n vec2 center = vec2(0., 1.);\n float rotation = 0.0;\n \n // This is somewhat arbitrary, but it seems to work well\n // Need to figure out how to derive this dynamically if it even matters\n float size = 0.03;\n\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n }\n ',fragmentShader:"\n void main() {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n "})),[f]);return T.createElement("group",e({},S,{ref:H}),p&&!J&&T.createElement("mesh",{castShadow:x,receiveShadow:y,ref:Z},g||T.createElement("planeGeometry",null),v||T.createElement("shaderMaterial",{side:n.DoubleSide,vertexShader:ne.vertexShader,fragmentShader:ne.fragmentShader})))}));const I=a.default||a;let V=0;const j=I((e=>(n.DefaultLoadingManager.onStart=(t,r,n)=>{e({active:!0,item:t,loaded:r,total:n,progress:(r-V)/(n-V)*100})},n.DefaultLoadingManager.onLoad=()=>{e({active:!1})},n.DefaultLoadingManager.onError=t=>e((e=>({errors:[...e.errors,t]}))),n.DefaultLoadingManager.onProgress=(t,r,n)=>{r===n&&(V=n),e({active:!0,item:t,loaded:r,total:n,progress:(r-V)/(n-V)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0}))),W=e=>`Loading ${e.toFixed(2)}%`;const G={container:{position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"#171717",display:"flex",alignItems:"center",justifyContent:"center",transition:"opacity 300ms ease",zIndex:1e3},inner:{width:100,height:3,background:"#272727",textAlign:"center"},bar:{height:3,width:"100%",background:"white",transition:"transform 200ms",transformOrigin:"left center"},data:{display:"inline-block",position:"relative",fontVariantNumeric:"tabular-nums",marginTop:"0.8em",color:"#f0f0f0",fontSize:"0.6em",fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Helvetica, Arial, Roboto, Ubuntu, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',whiteSpace:"nowrap"}},H=T.createContext(null);function q(){return T.useContext(H)}const $=T.forwardRef((({children:e},t)=>{const r=T.useRef(null),n=q(),{width:a,height:s}=o.useThree((e=>e.viewport));return o.useFrame((()=>{r.current.position.x=n.horizontal?-a*(n.pages-1)*n.offset:0,r.current.position.y=n.horizontal?0:s*(n.pages-1)*n.offset})),T.createElement("group",{ref:i([t,r])},e)})),X=T.forwardRef((({children:t,style:r,...n},a)=>{const s=q(),l=T.useRef(null),{width:c,height:u}=o.useThree((e=>e.size)),m=T.useContext(o.context),d=T.useMemo((()=>C.createRoot(s.fixed)),[s.fixed]);return o.useFrame((()=>{s.delta>s.eps&&(l.current.style.transform=`translate3d(${s.horizontal?-c*(s.pages-1)*s.offset:0}px,${s.horizontal?0:u*(s.pages-1)*-s.offset}px,0)`)})),d.render(T.createElement("div",e({ref:i([a,l]),style:{...r,position:"absolute",top:0,left:0,willChange:"transform"}},n),T.createElement(H.Provider,{value:s},T.createElement(o.context.Provider,{value:m},t)))),null})),Y=T.forwardRef((({html:t,...r},n)=>{const o=t?X:$;return T.createElement(o,e({ref:n},r))}));const K=a.default||a,Z=T.createContext(null);const Q=d.default||d,J=T.createContext([]);const ee=T.forwardRef((function({follow:t=!0,lockX:r=!1,lockY:n=!1,lockZ:a=!1,...s},l){const c=T.useRef();return o.useFrame((({camera:e})=>{if(!t||!c.current)return;const o=c.current.rotation.clone();e.getWorldQuaternion(c.current.quaternion),r&&(c.current.rotation.x=o.x),n&&(c.current.rotation.y=o.y),a&&(c.current.rotation.z=o.z)})),T.createElement("group",e({ref:i([c,l])},s))})),te=T.forwardRef((({children:t,depth:r=-1,...n},a)=>{const s=T.useRef(null);return o.useFrame((({camera:e})=>{s.current.quaternion.copy(e.quaternion),s.current.position.copy(e.position)})),T.createElement("group",e({ref:i([a,s])},n),T.createElement("group",{"position-z":-r},t))})),re=T.forwardRef((function({points:t,color:r="black",vertexColors:a,linewidth:i,lineWidth:s,segments:l,dashed:c,...u},d){const f=o.useThree((e=>e.size)),p=T.useMemo((()=>l?new m.LineSegments2:new m.Line2),[l]),[h]=T.useState((()=>new m.LineMaterial)),x=T.useMemo((()=>{const e=l?new m.LineSegmentsGeometry:new m.LineGeometry,r=t.map((e=>{const t=Array.isArray(e);return e instanceof n.Vector3?[e.x,e.y,e.z]:e instanceof n.Vector2?[e.x,e.y,0]:t&&3===e.length?[e[0],e[1],e[2]]:t&&2===e.length?[e[0],e[1],0]:e}));if(e.setPositions(r.flat()),a){const t=a.map((e=>e instanceof n.Color?e.toArray():e));e.setColors(t.flat())}return e}),[t,l,a]);return T.useLayoutEffect((()=>{p.computeLineDistances()}),[t,p]),T.useLayoutEffect((()=>{c?h.defines.USE_DASH="":delete h.defines.USE_DASH,h.needsUpdate=!0}),[c,h]),T.useEffect((()=>()=>x.dispose()),[x]),T.createElement("primitive",e({object:p,ref:d},u),T.createElement("primitive",{object:x,attach:"geometry"}),T.createElement("primitive",e({object:h,attach:"material",color:r,vertexColors:Boolean(a),resolution:[f.width,f.height],linewidth:null!=i?i:s,dashed:c},u)))})),ne=new n.Vector3,oe=T.forwardRef((function({start:t=[0,0,0],end:r=[0,0,0],mid:o,segments:a=20,...s},l){const c=T.useRef(null),[u]=T.useState((()=>new n.QuadraticBezierCurve3(void 0,void 0,void 0))),m=T.useCallback(((e,t,r,o=20)=>(e instanceof n.Vector3?u.v0.copy(e):u.v0.set(...e),t instanceof n.Vector3?u.v2.copy(t):u.v2.set(...t),r instanceof n.Vector3?u.v1.copy(r):Array.isArray(r)?u.v1.set(...r):u.v1.copy(u.v0.clone().add(u.v2.clone().sub(u.v0)).add(ne.set(0,u.v0.y-u.v2.y,0))),u.getPoints(o))),[]);T.useLayoutEffect((()=>{c.current.setPoints=(e,t,r)=>{const n=m(e,t,r);c.current.geometry&&c.current.geometry.setPositions(n.map((e=>e.toArray())).flat())}}),[]);const d=T.useMemo((()=>m(t,r,o,a)),[t,r,o,a]);return T.createElement(re,e({ref:i([c,l]),points:d},s))})),ae=T.forwardRef((function({start:t,end:r,midA:o,midB:a,segments:i=20,...s},l){const c=T.useMemo((()=>{const e=t instanceof n.Vector3?t:new n.Vector3(...t),s=r instanceof n.Vector3?r:new n.Vector3(...r),l=o instanceof n.Vector3?o:new n.Vector3(...o),c=a instanceof n.Vector3?a:new n.Vector3(...a);return new n.CubicBezierCurve3(e,l,c,s).getPoints(i)}),[t,r,o,a,i]);return T.createElement(re,e({ref:l,points:c},s))})),ie=T.forwardRef((function({points:t,closed:r=!1,curveType:o="centripetal",tension:a=.5,segments:i=20,vertexColors:s,...l},c){const u=T.useMemo((()=>{const e=t.map((e=>e instanceof n.Vector3?e:new n.Vector3(...e)));return new n.CatmullRomCurve3(e,r,o,a)}),[t,r,o,a]),m=T.useMemo((()=>u.getPoints(i)),[u,i]),d=T.useMemo((()=>{if(!s||s.length<2)return;if(s.length===i+1)return s;const e=s.map((e=>e instanceof n.Color?e:new n.Color(...e)));r&&e.push(e[0].clone());const t=[e[0]],o=i/(e.length-1);for(let r=1;r<i;r++){const n=r%o/o,a=Math.floor(r/o);t.push(e[a].clone().lerp(e[a+1],n))}return t.push(e[e.length-1]),t}),[s,i]);return T.createElement(re,e({ref:c,points:m,vertexColors:d},l))})),se=T.forwardRef((({url:t,distance:r=1,loop:a=!0,autoplay:s,...l},c)=>{const u=T.useRef(),m=o.useThree((({camera:e})=>e)),[d]=T.useState((()=>new n.AudioListener)),f=o.useLoader(n.AudioLoader,t);return T.useEffect((()=>{const e=u.current;e&&(e.setBuffer(f),e.setRefDistance(r),e.setLoop(a),s&&!e.isPlaying&&e.play())}),[f,m,r,a]),T.useEffect((()=>{const e=u.current;return m.add(d),()=>{m.remove(d),e&&(e.isPlaying&&e.stop(),e.source&&e.source._connected&&e.disconnect())}}),[]),T.createElement("positionalAudio",e({ref:i([u,c]),args:[d]},l))})),le=T.forwardRef((({sdfGlyphSize:t=64,anchorX:r="center",anchorY:n="middle",font:a,fontSize:i=1,children:s,characters:l,onSync:c,...u},m)=>{const d=o.useThree((({invalidate:e})=>e)),[h]=T.useState((()=>new f.Text)),[x,y]=T.useMemo((()=>{const e=[];let t="";return T.Children.forEach(s,(r=>{"string"==typeof r||"number"==typeof r?t+=r:e.push(r)})),[e,t]}),[s]);return p.suspend((()=>new Promise((e=>f.preloadFont({font:a,characters:l},e)))),["troika-text",a,l]),T.useLayoutEffect((()=>{h.sync((()=>{d(),c&&c(h)}))})),T.useEffect((()=>()=>h.dispose()),[h]),T.createElement("primitive",e({object:h,ref:m,font:a,text:y,anchorX:r,anchorY:n,fontSize:i,sdfGlyphSize:t},u),x)}));let ce=null;async function ue(e){ce||(ce=new m.FontLoader);let t="string"==typeof e?await(await fetch(e)).json():e;return ce.parse(t)}function me(e){return p.suspend(ue,[e])}me.preload=e=>p.preload(ue,[e]),me.clear=e=>p.clear([e]);const de=["string","number"],fe=T.forwardRef((({font:r,letterSpacing:n=0,lineHeight:a=1,size:i=1,height:s=.2,bevelThickness:l=.1,bevelSize:c=.01,bevelEnabled:u=!1,bevelOffset:d=0,bevelSegments:f=4,curveSegments:p=8,smooth:h,children:x,...y},v)=>{T.useMemo((()=>o.extend({RenamedTextGeometry:m.TextGeometry})),[]);const g=T.useRef(null),z=me(r),w=t.useMemo((()=>({font:z,size:i,height:s,bevelThickness:l,bevelSize:c,bevelEnabled:u,bevelSegments:f,bevelOffset:d,curveSegments:p,letterSpacing:n,lineHeight:a})),[z,i,s,l,c,u,f,d,p,n,a]),[b,...E]=t.useMemo((()=>(e=>{let t="";const r=[];return T.Children.forEach(e,(e=>{de.includes(typeof e)?t+=e+"":r.push(e)})),[t,...r]})(x)),[x]),M=T.useMemo((()=>[b,w]),[b,w]);return T.useLayoutEffect((()=>{h&&(g.current.geometry=m.mergeVertices(g.current.geometry,h),g.current.geometry.computeVertexNormals())}),[M,h]),T.useImperativeHandle(v,(()=>g.current),[]),T.createElement("mesh",e({},y,{ref:g}),T.createElement("renamedTextGeometry",{args:M}),E)})),pe=T.forwardRef((({children:t,multisamping:r=8,renderIndex:a=1,disableRender:s,disableGamma:l,disableRenderPass:c,depthBuffer:u=!0,stencilBuffer:d=!1,anisotropy:f=1,encoding:p,type:h,...x},y)=>{T.useMemo((()=>o.extend({EffectComposer:m.EffectComposer,RenderPass:m.RenderPass,ShaderPass:m.ShaderPass})),[]);const v=T.useRef(),{scene:g,camera:z,gl:w,size:b,viewport:E}=o.useThree(),[M]=T.useState((()=>{const e=new n.WebGLRenderTarget(b.width,b.height,{type:h||n.HalfFloatType,format:n.RGBAFormat,depthBuffer:u,stencilBuffer:d,anisotropy:f});return h===n.UnsignedByteType&&null!=p&&("colorSpace"in e?e.texture.colorSpace=p:e.texture.encoding=p),e.samples=r,e}));T.useEffect((()=>{var e,t;null==(e=v.current)||e.setSize(b.width,b.height),null==(t=v.current)||t.setPixelRatio(E.dpr)}),[w,b,E.dpr]),o.useFrame((()=>{var e;s||null==(e=v.current)||e.render()}),a);const S=[];return c||S.push(T.createElement("renderPass",{key:"renderpass",attach:`passes-${S.length}`,args:[g,z]})),l||S.push(T.createElement("shaderPass",{attach:`passes-${S.length}`,key:"gammapass",args:[m.GammaCorrectionShader]})),T.Children.forEach(t,(e=>{e&&S.push(T.cloneElement(e,{key:S.length,attach:`passes-${S.length}`}))})),T.createElement("effectComposer",e({ref:i([y,v]),args:[w,M]},x),S)}));let he=function(e){return e.Linear="linear",e.Radial="radial",e}({});function xe(e,t,r,n){const o=class extends P.ShaderMaterial{constructor(o={}){const a=Object.entries(e);super({uniforms:a.reduce(((e,[t,r])=>({...e,...P.UniformsUtils.clone({[t]:{value:r}})})),{}),vertexShader:t,fragmentShader:r}),this.key="",a.forEach((([e])=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t}))),Object.assign(this,o),n&&n(this)}};return o.key=P.MathUtils.generateUUID(),o}const ye=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function ve(e,r){const a=o.useThree((e=>e.gl)),i=o.useLoader(n.TextureLoader,ye(e)?Object.values(e):e);if(t.useLayoutEffect((()=>{null==r||r(i)}),[r]),t.useEffect((()=>{(Array.isArray(i)?i:[i]).forEach(a.initTexture)}),[a,i]),ye(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:i[t.indexOf(e)]}))),r}return i}ve.preload=e=>o.useLoader.preload(n.TextureLoader,e),ve.clear=e=>o.useLoader.clear(n.TextureLoader,e);const ge=xe({color:new P.Color("white"),scale:[1,1],imageBounds:[1,1],map:null,zoom:1,grayscale:0,opacity:1},"\n varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }\n","\n // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44\n varying vec2 vUv;\n uniform vec2 scale;\n uniform vec2 imageBounds;\n uniform vec3 color;\n uniform sampler2D map;\n uniform float zoom;\n uniform float grayscale;\n uniform float opacity;\n const vec3 luma = vec3(.299, 0.587, 0.114);\n vec4 toGrayscale(vec4 color, float intensity) {\n return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a);\n }\n vec2 aspect(vec2 size) {\n return size / min(size.x, size.y);\n }\n void main() {\n vec2 s = aspect(scale);\n vec2 i = aspect(imageBounds);\n float rs = s.x / s.y;\n float ri = i.x / i.y;\n vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);\n vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;\n vec2 uv = vUv * s / new + offset;\n vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5);\n gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity), grayscale);\n \n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }\n"),ze=T.forwardRef((({children:t,color:r,segments:n=1,scale:a=1,zoom:i=1,grayscale:s=0,opacity:l=1,texture:c,toneMapped:u,transparent:m,...d},f)=>{o.extend({ImageMaterial:ge});const p=Array.isArray(a)?[a[0],a[1]]:[a,a],h=[c.image.width,c.image.height];return T.createElement("mesh",e({ref:f,scale:Array.isArray(a)?[...a,1]:a},d),T.createElement("planeGeometry",{args:[1,1,n,n]}),T.createElement("imageMaterial",{color:r,map:c,zoom:i,grayscale:s,opacity:l,scale:p,imageBounds:h,toneMapped:u,transparent:m}),t)})),we=T.forwardRef((({url:t,...r},n)=>{const o=ve(t);return T.createElement(ze,e({},r,{texture:o,ref:n}))})),be=T.forwardRef((({url:t,...r},n)=>T.createElement(ze,e({},r,{ref:n})))),Ee=T.forwardRef(((t,r)=>{if(t.url)return T.createElement(we,e({},t,{ref:r}));if(t.texture)return T.createElement(be,e({},t,{ref:r}));throw new Error("<Image /> requires a url or texture")})),Me=T.forwardRef((({userData:t,children:r,geometry:n,threshold:o=15,color:a="black",...i},s)=>{const l=T.useRef(null);return T.useLayoutEffect((()=>{const e=l.current.parent;if(e){const t=n||e.geometry;t===l.current.userData.currentGeom&&o===l.current.userData.currentThreshold||(l.current.userData.currentGeom=t,l.current.userData.currentThreshold=o,l.current.geometry=new P.EdgesGeometry(t,o))}})),T.useImperativeHandle(s,(()=>l.current)),T.createElement("lineSegments",e({ref:l,raycast:()=>null},i),r||T.createElement("lineBasicMaterial",{color:a}))})),Se={width:.2,length:1,decay:1,local:!1,stride:0,interval:1},Te=(e,t=1)=>(e.set(e.subarray(t)),e.fill(-1/0,-t),e);function Ce(e,t){const{length:r,local:a,decay:i,interval:s,stride:l}={...Se,...t},c=T.useRef(),[u]=T.useState((()=>new n.Vector3));T.useLayoutEffect((()=>{e&&(c.current=Float32Array.from({length:10*r*3},((t,r)=>e.position.getComponent(r%3))))}),[r,e]);const m=T.useRef(new n.Vector3),d=T.useRef(0);return o.useFrame((()=>{if(e&&c.current){if(0===d.current){let t;a?t=e.position:(e.getWorldPosition(u),t=u);const r=1*i;for(let e=0;e<r;e++)t.distanceTo(m.current)<l||(Te(c.current,3),c.current.set(t.toArray(),c.current.length-3));m.current.copy(t)}d.current++,d.current=d.current%s}})),c}const Pe=T.forwardRef(((e,t)=>{const{children:r}=e,{width:a,length:i,decay:s,local:l,stride:c,interval:u}={...Se,...e},{color:m="hotpink",attenuation:d,target:f}=e,p=o.useThree((e=>e.size)),x=o.useThree((e=>e.scene)),y=T.useRef(null),[v,g]=T.useState(null),z=Ce(v,{length:i,decay:s,local:l,stride:c,interval:u});T.useEffect((()=>{const e=(null==f?void 0:f.current)||y.current.children.find((e=>e instanceof n.Object3D));e&&g(e)}),[z,f]);const w=T.useMemo((()=>new h.MeshLineGeometry),[]),b=T.useMemo((()=>{var e;const t=new h.MeshLineMaterial({lineWidth:.1*a,color:m,sizeAttenuation:1,resolution:new n.Vector2(p.width,p.height)});let o;if(r)if(Array.isArray(r))o=r.find((e=>{const t=e;return"string"==typeof t.type&&"meshLineMaterial"===t.type}));else{const e=r;"string"==typeof e.type&&"meshLineMaterial"===e.type&&(o=e)}return"object"==typeof(null==(e=o)?void 0:e.props)&&t.setValues(o.props),t}),[a,m,p,r]);return T.useEffect((()=>{b.uniforms.resolution.value.set(p.width,p.height)}),[p]),o.useFrame((()=>{z.current&&w.setPoints(z.current,d)})),T.createElement("group",null,o.createPortal(T.createElement("mesh",{ref:t,geometry:w,material:b}),x),T.createElement("group",{ref:y},r))}));function Re(e,t=16,r,o,a){const[i,s]=T.useState((()=>{const e=Array.from({length:t},(()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])).flat();return new n.InstancedBufferAttribute(Float32Array.from(e),16)}));return T.useLayoutEffect((()=>{if(void 0===e.current)return;const l=new m.MeshSurfaceSampler(e.current);o&&l.setWeightAttribute(o),l.build();const c=new n.Vector3,u=new n.Vector3,d=new n.Color,f=new n.Object3D;e.current.updateMatrixWorld(!0);for(let n=0;n<t;n++)l.sample(c,u,d),"function"==typeof r?r({dummy:f,sampledMesh:e.current,position:c,normal:u,color:d},n):f.position.copy(c),f.updateMatrix(),null!=a&&a.current&&a.current.setMatrixAt(n,f.matrix),f.matrix.toArray(i.array,16*n);null!=a&&a.current&&(a.current.instanceMatrix.needsUpdate=!0),i.needsUpdate=!0,s(i.clone())}),[e,a,o,t,r]),i}const De=T.forwardRef((({isChild:t=!1,object:r,children:n,deep:o,castShadow:a,receiveShadow:i,inject:s,keys:l,...c},u)=>{var d;const f={keys:l,deep:o,inject:s,castShadow:a,receiveShadow:i};if(r=T.useMemo((()=>{if(!1===t&&!Array.isArray(r)){let e=!1;if(r.traverse((t=>{t.isSkinnedMesh&&(e=!0)})),e)return m.SkeletonUtils.clone(r)}return r}),[r,t]),Array.isArray(r))return T.createElement("group",e({},c,{ref:u}),r.map((t=>T.createElement(De,e({key:t.uuid,object:t},f)))),n);const{children:p,...h}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:n,castShadow:o,receiveShadow:a}){let i=x(e,t);return r&&(i.geometry&&"materialsOnly"!==r&&(i.geometry=i.geometry.clone()),i.material&&"geometriesOnly"!==r&&(i.material=i.material.clone())),n&&(i="function"==typeof n?{...i,children:n(e)}:T.isValidElement(n)?{...i,children:n}:{...i,...n}),e instanceof P.Mesh&&(o&&(i.castShadow=!0),a&&(i.receiveShadow=!0)),i}(r,f),y=r.type[0].toLowerCase()+r.type.slice(1);return T.createElement(y,e({},h,c,{ref:u}),(null==(d=r)?void 0:d.children).map((t=>"Bone"===t.type?T.createElement("primitive",e({key:t.uuid,object:t},f)):T.createElement(De,e({key:t.uuid,object:t},f,{isChild:!0})))),n,p)})),Fe=T.createContext(null),ke=T.forwardRef((({resolution:t=28,maxPolyCount:r=1e4,enableUvs:n=!1,enableColors:a=!1,children:s,...l},c)=>{const u=T.useRef(null),d=T.useMemo((()=>new m.MarchingCubes(t,null,n,a,r)),[t,r,n,a]),f=T.useMemo((()=>({getParent:()=>u})),[]);return o.useFrame((()=>{d.update(),d.reset()}),-1),T.createElement(T.Fragment,null,T.createElement("primitive",e({object:d,ref:i([u,c])},l),T.createElement(Fe.Provider,{value:f},s)))})),_e=T.forwardRef((({strength:t=.5,subtract:r=12,color:n,...a},s)=>{const{getParent:l}=T.useContext(Fe),c=T.useMemo((()=>l()),[l]),u=T.useRef(),m=new P.Vector3;return o.useFrame((e=>{c.current&&u.current&&(u.current.getWorldPosition(m),c.current.addBall(.5+.5*m.x,.5+.5*m.y,.5+.5*m.z,t,r,n))})),T.createElement("group",e({ref:i([s,u])},a))})),Le=T.forwardRef((({planeType:t="x",strength:r=.5,subtract:n=12,...a},s)=>{const{getParent:l}=T.useContext(Fe),c=T.useMemo((()=>l()),[l]),u=T.useRef(),m=T.useMemo((()=>"x"===t?"addPlaneX":"y"===t?"addPlaneY":"addPlaneZ"),[t]);return o.useFrame((()=>{c.current&&u.current&&c.current[m](r,n)})),T.createElement("group",e({ref:i([s,u])},a))}));function Ae(e=[0,0,0]){return function(e){return Array.isArray(e)}(e)?e:e instanceof P.Vector3||e instanceof P.Euler?[e.x,e.y,e.z]:[e,e,e]}const Be=T.forwardRef((function({debug:t,depthTest:r=!1,polygonOffsetFactor:n=-10,map:a,mesh:i,children:s,position:l,rotation:c,scale:u,...d},f){const p=T.useRef(null);T.useImperativeHandle(f,(()=>p.current));const h=T.useRef(null);return T.useLayoutEffect((()=>{const e=(null==i?void 0:i.current)||p.current.parent,t=p.current;if(!(e instanceof P.Mesh))throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');const r={position:new P.Vector3,rotation:new P.Euler,scale:new P.Vector3(1,1,1)};if(e){o.applyProps(r,{position:l,scale:u});const n=e.matrixWorld.clone();if(e.matrixWorld.identity(),c&&"number"!=typeof c)o.applyProps(r,{rotation:c});else{const t=new P.Object3D;t.position.copy(r.position),t.lookAt(e.position),"number"==typeof c&&t.rotateZ(c),o.applyProps(r,{rotation:t.rotation})}return t.geometry=new m.DecalGeometry(e,r.position,r.rotation,r.scale),h.current&&(o.applyProps(h.current,r),h.current.traverse((e=>e.raycast=()=>null))),e.matrixWorld=n,()=>{t.geometry.dispose()}}}),[i,...Ae(l),...Ae(u),...Ae(c)]),T.createElement("mesh",e({ref:p,"material-transparent":!0,"material-polygonOffset":!0,"material-polygonOffsetFactor":n,"material-depthTest":r,"material-map":a},d),s,t&&T.createElement("mesh",{ref:h},T.createElement("boxGeometry",null),T.createElement("meshNormalMaterial",{wireframe:!0}),T.createElement("axesHelper",null)))})),Ue=t.forwardRef((function({src:r,skipFill:a,skipStrokes:i,fillMaterial:s,strokeMaterial:l,fillMeshProps:c,strokeMeshProps:u,...d},f){const p=o.useLoader(m.SVGLoader,r.startsWith("<svg")?`data:image/svg+xml;utf8,${r}`:r),h=t.useMemo((()=>i?[]:p.paths.map((e=>{var t;return void 0===(null==(t=e.userData)?void 0:t.style.stroke)||"none"===e.userData.style.stroke?null:e.subPaths.map((t=>m.SVGLoader.pointsToStroke(t.getPoints(),e.userData.style)))}))),[p,i]);return t.useEffect((()=>()=>h.forEach((e=>e&&e.map((e=>e.dispose()))))),[h]),T.createElement("object3D",e({ref:f},d),T.createElement("object3D",{scale:[1,-1,1]},p.paths.map(((r,o)=>{var d,f;return T.createElement(t.Fragment,{key:o},!a&&void 0!==(null==(d=r.userData)?void 0:d.style.fill)&&"none"!==r.userData.style.fill&&m.SVGLoader.createShapes(r).map(((t,o)=>T.createElement("mesh",e({key:o},c),T.createElement("shapeGeometry",{args:[t]}),T.createElement("meshBasicMaterial",e({color:r.userData.style.fill,opacity:r.userData.style.fillOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},s))))),!i&&void 0!==(null==(f=r.userData)?void 0:f.style.stroke)&&"none"!==r.userData.style.stroke&&r.subPaths.map(((t,a)=>T.createElement("mesh",e({key:a,geometry:h[o][a]},u),T.createElement("meshBasicMaterial",e({color:r.userData.style.stroke,opacity:r.userData.style.strokeOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},l))))))}))))}));let Oe=null;function Ne(e,t,r){return n=>{r&&r(n),e&&(Oe||(Oe=new m.DRACOLoader),Oe.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.5.5/"),n.setDRACOLoader(Oe)),t&&n.setMeshoptDecoder("function"==typeof m.MeshoptDecoder?m.MeshoptDecoder():m.MeshoptDecoder)}}function Ie(e,t=!0,r=!0,n){return o.useLoader(m.GLTFLoader,e,Ne(t,r,n))}Ie.preload=(e,t=!0,r=!0,n)=>o.useLoader.preload(m.GLTFLoader,e,Ne(t,r,n)),Ie.clear=e=>o.useLoader.clear(m.GLTFLoader,e);const Ve=T.forwardRef((({src:t,...r},n)=>{const{scene:o}=Ie(t);return T.createElement(De,e({ref:n},r,{object:o}))}));function je(e,t,r){const n=o.useThree((e=>e.size)),a=o.useThree((e=>e.viewport)),i="number"==typeof e?e:n.width*a.dpr,s="number"==typeof t?t:n.height*a.dpr,l=("number"==typeof e?r:e)||{},{samples:c=0,depth:u,...m}=l,d=T.useMemo((()=>{const e=new P.WebGLRenderTarget(i,s,{minFilter:P.LinearFilter,magFilter:P.LinearFilter,type:P.HalfFloatType,...m});return u&&(e.depthTexture=new P.DepthTexture(i,s,P.FloatType)),e.samples=c,e}),[]);return T.useLayoutEffect((()=>{d.setSize(i,s),c&&(d.samples=c)}),[c,d,i,s]),T.useEffect((()=>()=>d.dispose()),[]),d}const We=T.forwardRef((({envMap:t,resolution:r=256,frames:n=1/0,children:a,makeDefault:s,...l},c)=>{const u=o.useThree((({set:e})=>e)),m=o.useThree((({camera:e})=>e)),d=o.useThree((({size:e})=>e)),f=T.useRef(null),p=T.useRef(null),h=je(r);T.useLayoutEffect((()=>{l.manual||f.current.updateProjectionMatrix()}),[d,l]),T.useLayoutEffect((()=>{f.current.updateProjectionMatrix()})),T.useLayoutEffect((()=>{if(s){const e=m;return u((()=>({camera:f.current}))),()=>u((()=>({camera:e})))}}),[f,s,u]);let x=0,y=null;const v="function"==typeof a;return o.useFrame((e=>{v&&(n===1/0||x<n)&&(p.current.visible=!1,e.gl.setRenderTarget(h),y=e.scene.background,t&&(e.scene.background=t),e.gl.render(e.scene,f.current),e.scene.background=y,e.gl.setRenderTarget(null),p.current.visible=!0,x++)})),T.createElement(T.Fragment,null,T.createElement("orthographicCamera",e({left:d.width/-2,right:d.width/2,top:d.height/2,bottom:d.height/-2,ref:i([f,c])},l),!v&&a),T.createElement("group",{ref:p},v&&a(h.texture)))})),Ge=T.forwardRef((({envMap:t,resolution:r=256,frames:n=1/0,makeDefault:a,children:s,...l},c)=>{const u=o.useThree((({set:e})=>e)),m=o.useThree((({camera:e})=>e)),d=o.useThree((({size:e})=>e)),f=T.useRef(null),p=T.useRef(null),h=je(r);T.useLayoutEffect((()=>{l.manual||(f.current.aspect=d.width/d.height)}),[d,l]),T.useLayoutEffect((()=>{f.current.updateProjectionMatrix()}));let x=0,y=null;const v="function"==typeof s;return o.useFrame((e=>{v&&(n===1/0||x<n)&&(p.current.visible=!1,e.gl.setRenderTarget(h),y=e.scene.background,t&&(e.scene.background=t),e.gl.render(e.scene,f.current),e.scene.background=y,e.gl.setRenderTarget(null),p.current.visible=!0,x++)})),T.useLayoutEffect((()=>{if(a){const e=m;return u((()=>({camera:f.current}))),()=>u((()=>({camera:e})))}}),[f,a,u]),T.createElement(T.Fragment,null,T.createElement("perspectiveCamera",e({ref:i([f,c])},l),!v&&s),T.createElement("group",{ref:p},v&&s(h.texture)))}));function He({resolution:e=256,near:r=.1,far:a=1e3,envMap:i,fog:s}={}){const l=o.useThree((({gl:e})=>e)),c=o.useThree((({scene:e})=>e)),u=t.useMemo((()=>{const t=new n.WebGLCubeRenderTarget(e);return t.texture.type=n.HalfFloatType,t}),[e]);t.useEffect((()=>()=>{u.dispose()}),[u]);const m=t.useMemo((()=>new P.CubeCamera(r,a,u)),[r,a,u]);let d,f;const p=T.useCallback((()=>{d=c.fog,f=c.background,c.background=i||f,c.fog=s||d,m.update(l,c),c.fog=d,c.background=f}),[l,c,m]);return{fbo:u,camera:m,update:p}}const qe=T.forwardRef(((t,r)=>{const{camera:n,onChange:a,makeDefault:i,...s}=t,l=o.useThree((e=>e.camera)),c=o.useThree((e=>e.invalidate)),u=o.useThree((e=>e.get)),d=o.useThree((e=>e.set)),f=n||l,[p]=T.useState((()=>new m.DeviceOrientationControls(f)));return T.useEffect((()=>{const e=e=>{c(),a&&a(e)};return null==p||null==p.addEventListener||p.addEventListener("change",e),()=>null==p||null==p.removeEventListener?void 0:p.removeEventListener("change",e)}),[a,p,c]),o.useFrame((()=>null==p?void 0:p.update()),-1),T.useEffect((()=>{const e=p;return null==e||e.connect(),()=>null==e?void 0:e.dispose()}),[p]),T.useEffect((()=>{if(i){const e=u().controls;return d({controls:p}),()=>d({controls:e})}}),[i,p]),p?T.createElement("primitive",e({ref:r,object:p},s)):null})),$e=T.forwardRef((({domElement:t,...r},n)=>{const{onChange:a,makeDefault:i,...s}=r,l=o.useThree((e=>e.invalidate)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.gl)),d=o.useThree((e=>e.events)),f=o.useThree((e=>e.get)),p=o.useThree((e=>e.set)),h=t||d.connected||u.domElement,x=T.useMemo((()=>new m.FlyControls(c)),[c]);return T.useEffect((()=>(x.connect(h),()=>{x.dispose()})),[h,x,l]),T.useEffect((()=>{const e=e=>{l(),a&&a(e)};return null==x.addEventListener||x.addEventListener("change",e),()=>null==x.removeEventListener?void 0:x.removeEventListener("change",e)}),[a,l]),T.useEffect((()=>{if(i){const e=f().controls;return p({controls:x}),()=>p({controls:e})}}),[i,x]),o.useFrame(((e,t)=>x.update(t))),T.createElement("primitive",e({ref:n,object:x,args:[c,h]},s))})),Xe=T.forwardRef(((t={enableDamping:!0},r)=>{const{domElement:n,camera:a,makeDefault:i,onChange:s,onStart:l,onEnd:c,...u}=t,d=o.useThree((e=>e.invalidate)),f=o.useThree((e=>e.camera)),p=o.useThree((e=>e.gl)),h=o.useThree((e=>e.events)),x=o.useThree((e=>e.set)),y=o.useThree((e=>e.get)),v=n||h.connected||p.domElement,g=a||f,z=T.useMemo((()=>new m.MapControls(g)),[g]);return T.useEffect((()=>{z.connect(v);const e=e=>{d(),s&&s(e)};return z.addEventListener("change",e),l&&z.addEventListener("start",l),c&&z.addEventListener("end",c),()=>{z.dispose(),z.removeEventListener("change",e),l&&z.removeEventListener("start",l),c&&z.removeEventListener("end",c)}}),[s,l,c,z,d,v]),T.useEffect((()=>{if(i){const e=y().controls;return x({controls:z}),()=>x({controls:e})}}),[i,z]),o.useFrame((()=>z.update()),-1),T.createElement("primitive",e({ref:r,object:z,enableDamping:!0},u))})),Ye=T.forwardRef((({makeDefault:t,camera:r,regress:n,domElement:a,enableDamping:i=!0,keyEvents:s=!1,onChange:l,onStart:c,onEnd:u,...d},f)=>{const p=o.useThree((e=>e.invalidate)),h=o.useThree((e=>e.camera)),x=o.useThree((e=>e.gl)),y=o.useThree((e=>e.events)),v=o.useThree((e=>e.setEvents)),g=o.useThree((e=>e.set)),z=o.useThree((e=>e.get)),w=o.useThree((e=>e.performance)),b=r||h,E=a||y.connected||x.domElement,M=T.useMemo((()=>new m.OrbitControls(b)),[b]);return o.useFrame((()=>{M.enabled&&M.update()}),-1),T.useEffect((()=>(s&&M.connect(!0===s?E:s),M.connect(E),()=>{M.dispose()})),[s,E,n,M,p]),T.useEffect((()=>{const e=e=>{p(),n&&w.regress(),l&&l(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return M.addEventListener("change",e),M.addEventListener("start",t),M.addEventListener("end",r),()=>{M.removeEventListener("start",t),M.removeEventListener("end",r),M.removeEventListener("change",e)}}),[l,c,u,M,p,v]),T.useEffect((()=>{if(t){const e=z().controls;return g({controls:M}),()=>g({controls:e})}}),[t,M]),T.createElement("primitive",e({ref:f,object:M,enableDamping:i},d))})),Ke=T.forwardRef((({makeDefault:t,camera:r,domElement:n,regress:a,onChange:i,onStart:s,onEnd:l,...c},u)=>{const{invalidate:d,camera:f,gl:p,events:h,set:x,get:y,performance:v,viewport:g}=o.useThree(),z=r||f,w=n||h.connected||p.domElement,b=T.useMemo((()=>new m.TrackballControls(z)),[z]);return o.useFrame((()=>{b.enabled&&b.update()}),-1),T.useEffect((()=>(b.connect(w),()=>{b.dispose()})),[w,a,b,d]),T.useEffect((()=>{const e=e=>{d(),a&&v.regress(),i&&i(e)};return b.addEventListener("change",e),s&&b.addEventListener("start",s),l&&b.addEventListener("end",l),()=>{s&&b.removeEventListener("start",s),l&&b.removeEventListener("end",l),b.removeEventListener("change",e)}}),[i,s,l,b,d]),T.useEffect((()=>{b.handleResize()}),[g]),T.useEffect((()=>{if(t){const e=y().controls;return x({controls:b}),()=>x({controls:e})}}),[t,b]),T.createElement("primitive",e({ref:u,object:b},c))})),Ze=t.forwardRef((({camera:r,makeDefault:n,regress:a,domElement:i,onChange:s,onStart:l,onEnd:c,...u},d)=>{const f=o.useThree((e=>e.invalidate)),p=o.useThree((e=>e.camera)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.events)),y=o.useThree((e=>e.set)),v=o.useThree((e=>e.get)),g=o.useThree((e=>e.performance)),z=r||p,w=i||x.connected||h.domElement,b=t.useMemo((()=>new m.ArcballControls(z)),[z]);return o.useFrame((()=>{b.enabled&&b.update()}),-1),t.useEffect((()=>(b.connect(w),()=>{b.dispose()})),[w,a,b,f]),t.useEffect((()=>{const e=e=>{f(),a&&g.regress(),s&&s(e)};return b.addEventListener("change",e),l&&b.addEventListener("start",l),c&&b.addEventListener("end",c),()=>{b.removeEventListener("change",e),l&&b.removeEventListener("start",l),c&&b.removeEventListener("end",c)}}),[s,l,c]),t.useEffect((()=>{if(n){const e=v().controls;return y({controls:b}),()=>y({controls:e})}}),[n,b]),T.createElement("primitive",e({ref:d,object:b},u))})),Qe=T.forwardRef((({children:t,domElement:r,onChange:n,onMouseDown:a,onMouseUp:i,onObjectChange:s,object:l,makeDefault:c,...u},d)=>{const f=["enabled","axis","mode","translationSnap","rotationSnap","scaleSnap","space","size","showX","showY","showZ"],{camera:p,...h}=u,v=x(h,f),g=y(h,f),z=o.useThree((e=>e.controls)),w=o.useThree((e=>e.gl)),b=o.useThree((e=>e.events)),E=o.useThree((e=>e.camera)),M=o.useThree((e=>e.invalidate)),S=o.useThree((e=>e.get)),C=o.useThree((e=>e.set)),R=p||E,D=r||b.connected||w.domElement,F=T.useMemo((()=>new m.TransformControls(R,D)),[R,D]),k=T.useRef();T.useLayoutEffect((()=>(l?F.attach(l instanceof P.Object3D?l:l.current):k.current instanceof P.Object3D&&F.attach(k.current),()=>{F.detach()})),[l,t,F]),T.useEffect((()=>{if(z){const e=e=>z.enabled=!e.value;return F.addEventListener("dragging-changed",e),()=>F.removeEventListener("dragging-changed",e)}}),[F,z]);const _=T.useRef(),L=T.useRef(),A=T.useRef(),B=T.useRef();return T.useLayoutEffect((()=>{_.current=n}),[n]),T.useLayoutEffect((()=>{L.current=a}),[a]),T.useLayoutEffect((()=>{A.current=i}),[i]),T.useLayoutEffect((()=>{B.current=s}),[s]),T.useEffect((()=>{const e=e=>{M(),null==_.current||_.current(e)},t=e=>null==L.current?void 0:L.current(e),r=e=>null==A.current?void 0:A.current(e),n=e=>null==B.current?void 0:B.current(e);return F.addEventListener("change",e),F.addEventListener("mouseDown",t),F.addEventListener("mouseUp",r),F.addEventListener("objectChange",n),()=>{F.removeEventListener("change",e),F.removeEventListener("mouseDown",t),F.removeEventListener("mouseUp",r),F.removeEventListener("objectChange",n)}}),[M,F]),T.useEffect((()=>{if(c){const e=S().controls;return C({controls:F}),()=>C({controls:e})}}),[c,F]),F?T.createElement(T.Fragment,null,T.createElement("primitive",e({ref:d,object:F},v)),T.createElement("group",e({ref:k},g),t)):null})),Je=T.forwardRef((({domElement:t,selector:r,onChange:n,onLock:a,onUnlock:i,enabled:s=!0,makeDefault:l,...c},u)=>{const{camera:d,...f}=c,p=o.useThree((e=>e.setEvents)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.camera)),y=o.useThree((e=>e.invalidate)),v=o.useThree((e=>e.events)),g=o.useThree((e=>e.get)),z=o.useThree((e=>e.set)),w=d||x,b=t||v.connected||h.domElement,[E]=T.useState((()=>new m.PointerLockControls(w)));return T.useEffect((()=>{if(s){E.connect(b);const e=g().events.compute;return p({compute(e,t){const r=t.size.width/2,n=t.size.height/2;t.pointer.set(r/t.size.width*2-1,-n/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),()=>{E.disconnect(),p({compute:e})}}}),[s,E]),T.useEffect((()=>{const e=e=>{y(),n&&n(e)};E.addEventListener("change",e),a&&E.addEventListener("lock",a),i&&E.addEventListener("unlock",i);const t=()=>E.lock(),o=r?Array.from(document.querySelectorAll(r)):[document];return o.forEach((e=>e&&e.addEventListener("click",t))),()=>{E.removeEventListener("change",e),a&&E.addEventListener("lock",a),i&&E.addEventListener("unlock",i),o.forEach((e=>e?e.removeEventListener("click",t):void 0))}}),[n,a,i,r,E,y]),T.useEffect((()=>{if(l){const e=g().controls;return z({controls:E}),()=>z({controls:e})}}),[l,E]),T.createElement("primitive",e({ref:u,object:E},f))})),et=T.forwardRef((({domElement:t,makeDefault:r,...n},a)=>{const i=o.useThree((e=>e.camera)),s=o.useThree((e=>e.gl)),l=o.useThree((e=>e.events)),c=o.useThree((e=>e.get)),u=o.useThree((e=>e.set)),d=t||l.connected||s.domElement,[f]=T.useState((()=>new m.FirstPersonControls(i,d)));return T.useEffect((()=>{if(r){const e=c().controls;return u({controls:f}),()=>u({controls:e})}}),[r,f]),o.useFrame(((e,t)=>{f.update(t)}),-1),f?T.createElement("primitive",e({ref:a,object:f},n)):null})),tt=t.forwardRef(((r,a)=>{t.useMemo((()=>{const e={Box3:n.Box3,MathUtils:{clamp:n.MathUtils.clamp},Matrix4:n.Matrix4,Quaternion:n.Quaternion,Raycaster:n.Raycaster,Sphere:n.Sphere,Spherical:n.Spherical,Vector2:n.Vector2,Vector3:n.Vector3,Vector4:n.Vector4};v.install({THREE:e}),o.extend({CameraControlsImpl:v})}),[]);const{camera:i,domElement:s,makeDefault:l,onStart:c,onEnd:u,onChange:m,regress:d,...f}=r,p=o.useThree((e=>e.camera)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.invalidate)),y=o.useThree((e=>e.events)),g=o.useThree((e=>e.setEvents)),z=o.useThree((e=>e.set)),w=o.useThree((e=>e.get)),b=o.useThree((e=>e.performance)),E=i||p,M=s||y.connected||h.domElement,S=t.useMemo((()=>new v(E)),[E]);return o.useFrame(((e,t)=>{S.enabled&&S.update(t)}),-1),t.useEffect((()=>(S.connect(M),()=>{S.disconnect()})),[M,S]),t.useEffect((()=>{const e=e=>{x(),d&&b.regress(),m&&m(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return S.addEventListener("update",e),S.addEventListener("controlstart",t),S.addEventListener("controlend",r),S.addEventListener("control",e),S.addEventListener("transitionstart",e),S.addEventListener("wake",e),()=>{S.removeEventListener("update",e),S.removeEventListener("controlstart",t),S.removeEventListener("controlend",r),S.removeEventListener("control",e),S.removeEventListener("transitionstart",e),S.removeEventListener("wake",e)}}),[S,c,u,x,g,d,m]),t.useEffect((()=>{if(l){const e=w().controls;return z({controls:S}),()=>z({controls:e})}}),[l,S]),T.createElement("primitive",e({ref:a,object:S},f))}));function rt(e,r){const{unsuspend:n,start:a,crossOrigin:i,muted:s,loop:l,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...r},u=o.useThree((e=>e.gl)),m=p.suspend((()=>new Promise(((t,r)=>{const o=Object.assign(document.createElement("video"),{src:"string"==typeof e&&e||void 0,srcObject:e instanceof MediaStream&&e||void 0,crossOrigin:i,loop:l,muted:s,...c}),a=new P.VideoTexture(o);"colorSpace"in a?a.colorSpace=u.outputColorSpace:a.encoding=u.outputEncoding,o.addEventListener(n,(()=>t(a)))}))),[e]);return t.useEffect((()=>{a&&m.image.play()}),[m,a]),m}const nt=new P.Vector3(0,0,-1),ot=function(){const e=new P.Vector3,t=new P.Vector3,r=new P.Vector3,n=new P.Vector3,o=new P.Vector3;return function(a,i,s,l){return e.copy(a),t.copy(i),r.copy(s),n.copy(t).sub(e),o.copy(r).sub(e),l.crossVectors(o,n).normalize()}}();const at=T.forwardRef((({points:e=lt.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0],face:t,facialTransformationMatrix:r,faceBlendshapes:n,offset:a,offsetScalar:i=80,width:s,height:l,depth:c=1,verticalTri:u=[159,386,152],origin:m,eyes:d=!0,eyesAsOrigin:f=!1,debug:p=!1,children:h,...x},y)=>{var v;t&&(e=t.keypoints,console.warn("Facemesh `face` prop is deprecated: use `points` instead"));const g=T.useRef(null),z=T.useRef(null),w=T.useRef(null),b=T.useRef(null),E=T.useRef(null),M=T.useRef(null),S=T.useRef(null),[C]=T.useState((()=>new P.Vector3)),[R]=T.useState((()=>new P.Object3D)),[D]=T.useState((()=>new P.Quaternion)),[F]=T.useState((()=>new P.Vector3)),{invalidate:k}=o.useThree();T.useEffect((()=>{var e;null==(e=E.current)||e.geometry.setIndex(lt.TRIANGULATION)}),[]);const[_]=T.useState((()=>new P.Vector3));T.useEffect((()=>{var t,o;const h=null==(t=E.current)?void 0:t.geometry;if(!h)return;var x,y;(h.setFromPoints(e),h.setDrawRange(0,lt.TRIANGULATION.length),r)?(R.matrix.fromArray(r.data),R.matrix.decompose(R.position,R.quaternion,R.scale),R.rotation.y*=-1,R.rotation.z*=-1,D.setFromEuler(R.rotation),a?(R.position.y*=-1,R.position.z*=-1,null==(x=g.current)||x.position.copy(R.position.divideScalar(i))):null==(y=g.current)||y.position.set(0,0,0)):(ot(e[u[0]],e[u[1]],e[u[2]],C),D.setFromUnitVectors(nt,C));const v=D.clone().invert();if(h.computeBoundingBox(),p&&k(),h.center(),h.applyQuaternion(v),null==(o=b.current)||o.setRotationFromQuaternion(D),d)if(n){if(M.current&&S.current&&w.current)if(f){const e=M.current._computeSphere(h),t=S.current._computeSphere(h),r=function(e,t){return e.clone().add(t).multiplyScalar(.5)}(e.center,t.center);m=r.negate(),M.current._update(h,n,e),S.current._update(h,n,t)}else M.current._update(h,n),S.current._update(h,n)}else console.warn("Facemesh `eyes` option only works if `faceBlendshapes` is provided: skipping.");if(w.current){if(void 0!==m)if("number"==typeof m){const e=h.getAttribute("position");F.set(-e.getX(m),-e.getY(m),-e.getZ(m))}else m.isVector3&&F.copy(m);else F.setScalar(0);w.current.position.copy(F)}if(z.current){let e=1;(s||l||c)&&(h.boundingBox.getSize(_),s&&(e=s/_.x),l&&(e=l/_.y),c&&(e=c/_.z)),z.current.scale.setScalar(1!==e?e:1)}h.computeVertexNormals(),h.attributes.position.needsUpdate=!0}),[e,r,n,R,a,i,s,l,c,u,m,d,p,k,C,D,_,F]);const L=T.useMemo((()=>({outerRef:b,meshRef:E,eyeRightRef:M,eyeLeftRef:S})),[]);T.useImperativeHandle(y,(()=>L),[L]);const[A]=T.useState((()=>new P.Vector3)),B=null==(v=E.current)?void 0:v.geometry.boundingBox,U=(null==B?void 0:B.getSize(A).z)||1;return T.createElement("group",x,T.createElement("group",{ref:g},T.createElement("group",{ref:b},T.createElement("group",{ref:z},p?T.createElement(T.Fragment,null,T.createElement("axesHelper",{args:[U]}),T.createElement(re,{points:[[0,0,0],[0,0,-U]],color:65535})):null,T.createElement("group",{ref:w},d&&n&&T.createElement("group",{name:"eyes"},T.createElement(st,{side:"left",ref:M,debug:p}),T.createElement(st,{side:"right",ref:S,debug:p})),T.createElement("mesh",{ref:E,name:"face"},h,p?T.createElement(T.Fragment,null,B&&T.createElement("box3Helper",{args:[B]})):null))))))})),it={contourLandmarks:{right:[33,133,159,145,153],left:[263,362,386,374,380]},blendshapes:{right:[14,16,18,12],left:[13,15,17,11]},color:{right:"red",left:"#00ff00"},fov:{horizontal:100,vertical:90}},st=T.forwardRef((({side:e,debug:t=!0},r)=>{const n=T.useRef(null),o=T.useRef(null),[a]=T.useState((()=>new P.Sphere)),i=T.useCallback((t=>{const r=t.getAttribute("position"),n=it.contourLandmarks[e].map((e=>new P.Vector3(r.getX(e),r.getY(e),r.getZ(e))));return a.center.set(0,0,0),n.forEach((e=>a.center.add(e))),a.center.divideScalar(n.length),a.radius=n[0].sub(n[1]).length()/2,a}),[a,e]),[s]=T.useState((()=>new P.Euler)),l=T.useCallback(((t,r,a)=>{var l;n.current&&(null!==(l=a)&&void 0!==l||(a=i(t)),n.current.position.copy(a.center),n.current.scale.setScalar(a.radius));if(r&&o.current){const t=it.blendshapes[e],n=r.categories[t[0]].score,a=r.categories[t[1]].score,i=r.categories[t[2]].score,l=r.categories[t[3]].score,c=.5*(it.fov.horizontal*P.MathUtils.DEG2RAD)*(l-i),u=.5*(it.fov.vertical*P.MathUtils.DEG2RAD)*(n-a)*("left"===e?1:-1);s.set(c,u,0),o.current.setRotationFromEuler(s)}}),[i,e,s]),c=T.useMemo((()=>({eyeMeshRef:n,irisDirRef:o,_computeSphere:i,_update:l})),[i,l]);T.useImperativeHandle(r,(()=>c),[c]);const u=it.color[e];return T.createElement("group",null,T.createElement("group",{ref:n},t&&T.createElement("axesHelper",null),T.createElement("group",{ref:o},T.createElement(T.Fragment,null,t&&T.createElement(re,{points:[[0,0,0],[0,0,-2]],lineWidth:1,color:u})))))})),lt={TRIANGULATION:[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,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,173,155,133,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,246,33,7,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,163,161,246,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,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,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,384,398,382,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,382,398,362,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,263,466,249,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,390,249,466,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,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,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,173,157,155,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,7,163,246,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,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,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,381,384,382,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,388,390,466,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,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,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],SAMPLE_FACE:{keypoints:[{x:356.2804412841797,y:295.1960563659668,z:-23.786449432373047,name:"lips"},{x:354.8859405517578,y:264.69520568847656,z:-36.718435287475586},{x:355.2180862426758,y:275.3360366821289,z:-21.183712482452393},{x:347.349853515625,y:242.4400234222412,z:-25.093655586242676},{x:354.40135955810547,y:256.67933464050293,z:-38.23572635650635},{x:353.7689971923828,y:247.54886627197266,z:-34.5475435256958},{x:352.1288299560547,y:227.34312057495117,z:-13.095386028289795},{x:303.5013198852539,y:234.67002868652344,z:12.500141859054565,name:"rightEye"},{x:351.09378814697266,y:211.87547206878662,z:-6.413471698760986},{x:350.7115936279297,y:202.1251630783081,z:-6.413471698760986},{x:348.33667755126953,y:168.7741756439209,z:6.483500003814697,name:"faceOval"},{x:356.4806365966797,y:299.2995357513428,z:-23.144519329071045},{x:356.5511703491211,y:302.66146659851074,z:-21.020312309265137},{x:356.6239547729492,y:304.1536331176758,z:-18.137459754943848,name:"lips"},{x:356.5807342529297,y:305.1840591430664,z:-18.767719268798828,name:"lips"},{x:356.8241500854492,y:308.25711250305176,z:-20.16829490661621},{x:357.113037109375,y:312.26277351379395,z:-22.10575819015503},{x:357.34962463378906,y:317.1123218536377,z:-21.837315559387207,name:"lips"},{x:357.6658630371094,y:325.51036834716797,z:-16.27002477645874},{x:355.0201416015625,y:269.36279296875,z:-33.73054027557373},{x:348.5237503051758,y:270.33411026000977,z:-24.93025302886963},{x:279.97331619262695,y:213.24176788330078,z:47.759642601013184,name:"faceOval"},{x:322.66529083251953,y:238.5027265548706,z:5.535193085670471},{x:316.0983657836914,y:239.94489669799805,z:5.777376294136047},{x:309.9431610107422,y:240.24518966674805,z:7.510589361190796},{x:301.31994247436523,y:237.86138534545898,z:13.118728399276733},{x:328.14266204833984,y:235.80496788024902,z:6.646900177001953},{x:313.7326431274414,y:222.11161136627197,z:3.9887237548828125},{x:320.45196533203125,y:221.87729358673096,z:4.601476192474365},{x:307.35679626464844,y:223.63793849945068,z:5.932023525238037},{x:303.0031204223633,y:226.3743782043457,z:8.479321002960205},{x:296.80023193359375,y:242.94299125671387,z:15.931552648544312},{x:332.2352981567383,y:340.77341079711914,z:-10.165848731994629},{x:301.38587951660156,y:233.46447944641113,z:14.764405488967896,name:"rightEye"},{x:279.0147018432617,y:244.37155723571777,z:45.77549457550049},{x:289.60548400878906,y:239.1807460784912,z:23.191204071044922},{x:320.32257080078125,y:267.1292781829834,z:-4.954537749290466},{x:347.64583587646484,y:294.4955062866211,z:-23.062820434570312,name:"lips"},{x:349.28138732910156,y:303.1095886230469,z:-20.238323211669922},{x:338.9453125,y:298.19186210632324,z:-19.456336498260498,name:"lips"},{x:333.36788177490234,y:302.6706790924072,z:-14.776077270507812,name:"lips"},{x:342.89188385009766,y:304.3561363220215,z:-17.752301692962646},{x:337.7375030517578,y:306.0098361968994,z:-13.410515785217285},{x:325.6159210205078,y:316.22995376586914,z:-6.681914925575256},{x:349.0104675292969,y:264.9818515777588,z:-36.274919509887695},{x:347.7138900756836,y:257.5664806365967,z:-37.67549514770508},{x:291.79357528686523,y:218.88171672821045,z:11.578094959259033,name:"rightEyebrow"},{x:332.2689437866211,y:247.56946563720703,z:-3.3730539679527283},{x:332.0074462890625,y:267.1201229095459,z:-19.969879388809204},{x:331.27952575683594,y:263.6967658996582,z:-17.47218608856201},{x:301.04373931884766,y:269.56552505493164,z:3.61815482378006},{x:347.4863815307617,y:249.0706443786621,z:-32.633421421051025},{x:307.26118087768555,y:208.2646894454956,z:1.1591226607561111,name:"rightEyebrow"},{x:297.91919708251953,y:212.22604751586914,z:5.914516448974609,name:"rightEyebrow"},{x:285.1651382446289,y:197.98450469970703,z:36.391637325286865,name:"faceOval"},{x:337.04097747802734,y:211.25229835510254,z:-4.548954665660858},{x:326.5912628173828,y:223.16698551177979,z:6.670243740081787},{x:320.05664825439453,y:309.5834255218506,z:-4.055835008621216},{x:289.6866226196289,y:314.617395401001,z:53.875489234924316,name:"faceOval"},{x:337.4256896972656,y:270.8755302429199,z:-17.67060160636902},{x:343.69922637939453,y:273.0000400543213,z:-18.756048679351807},{x:327.4242401123047,y:309.22399520874023,z:-4.703601002693176,name:"lips"},{x:330.37220001220703,y:308.3323001861572,z:-6.442649960517883},{x:293.87027740478516,y:207.7961826324463,z:9.821539521217346,name:"rightEyebrow"},{x:332.11437225341797,y:271.22812271118164,z:-16.64351224899292},{x:320.1197814941406,y:207.40366458892822,z:-2.48164564371109,name:"rightEyebrow"},{x:318.59575271606445,y:201.07443809509277,z:-3.110446035861969,name:"rightEyebrow"},{x:310.72303771972656,y:175.75075149536133,z:13.328815698623657,name:"faceOval"},{x:289.67578887939453,y:202.29835510253906,z:21.370456218719482},{x:315.30879974365234,y:187.35260009765625,z:5.0304025411605835},{x:287.8936767578125,y:216.54793739318848,z:17.81065821647644,name:"rightEyebrow"},{x:283.9391899108887,y:215.01142501831055,z:32.04984903335571},{x:348.35330963134766,y:299.4155788421631,z:-22.47924566268921},{x:341.1790466308594,y:301.8221855163574,z:-18.977805376052856},{x:335.69713592529297,y:304.4266891479492,z:-14.682706594467163},{x:339.4615173339844,y:272.3654365539551,z:-16.38674020767212},{x:328.99600982666016,y:308.86685371398926,z:-5.616893768310547},{x:332.00313568115234,y:309.1875743865967,z:-10.335084199905396},{x:331.0068130493164,y:307.9274368286133,z:-6.681914925575256,name:"lips"},{x:341.13792419433594,y:266.4876937866211,z:-26.56425952911377},{x:339.02950286865234,y:305.6663703918457,z:-12.33674168586731,name:"lips"},{x:344.22935485839844,y:304.9452781677246,z:-15.161235332489014,name:"lips"},{x:350.1844024658203,y:304.374303817749,z:-17.5305438041687,name:"lips"},{x:348.52630615234375,y:325.9562301635742,z:-16.164982318878174},{x:348.6581802368164,y:317.1624183654785,z:-21.510512828826904,name:"lips"},{x:348.9766311645508,y:312.1923065185547,z:-21.708929538726807},{x:349.2427444458008,y:308.0660820007324,z:-19.643079042434692},{x:349.67491149902344,y:305.42747497558594,z:-18.16080331802368,name:"lips"},{x:337.95589447021484,y:306.6535949707031,z:-12.803598642349243,name:"lips"},{x:337.06878662109375,y:307.63169288635254,z:-14.274203777313232},{x:335.77449798583984,y:309.8449516296387,z:-15.698124170303345},{x:334.6099090576172,y:312.7997016906738,z:-14.764405488967896,name:"lips"},{x:327.2330856323242,y:293.80866050720215,z:-11.864047050476074},{x:280.97679138183594,y:279.79928970336914,z:68.90834331512451,name:"faceOval"},{x:355.13843536376953,y:271.7875671386719,z:-25.350427627563477},{x:334.7235870361328,y:307.4656391143799,z:-9.302158951759338,name:"lips"},{x:333.5293960571289,y:307.89782524108887,z:-10.200862884521484},{x:346.29688262939453,y:276.4256286621094,z:-19.748122692108154},{x:335.16246795654297,y:276.22097969055176,z:-12.313398122787476},{x:345.09132385253906,y:274.7082996368408,z:-19.304605722427368},{x:325.4267883300781,y:252.95130729675293,z:-1.6661019623279572},{x:315.347843170166,y:259.05200958251953,z:-.25604281574487686},{x:330.44933319091797,y:267.7570152282715,z:-14.017432928085327},{x:294.96768951416016,y:185.26001930236816,z:23.903164863586426,name:"faceOval"},{x:299.63531494140625,y:192.7913761138916,z:12.640198469161987},{x:304.5452117919922,y:202.4142837524414,z:3.244667649269104,name:"rightEyebrow"},{x:331.6915512084961,y:320.0467872619629,z:-10.632705688476562},{x:334.5911407470703,y:201.27566814422607,z:-6.133356094360352,name:"rightEyebrow"},{x:331.4815902709961,y:185.44180870056152,z:.6627205014228821},{x:328.05816650390625,y:170.8385467529297,z:7.358860373497009,name:"faceOval"},{x:304.49764251708984,y:239.76297855377197,z:10.387605428695679},{x:290.6382179260254,y:248.85257720947266,z:19.03616428375244},{x:331.5682601928711,y:233.20727348327637,z:7.837390303611755},{x:295.5115509033203,y:228.9834451675415,z:14.41426157951355},{x:336.94332122802734,y:241.8259334564209,z:-5.27842104434967},{x:336.2792205810547,y:262.7049922943115,z:-26.12074375152588},{x:284.4102478027344,y:255.3262710571289,z:25.467140674591064},{x:295.1420593261719,y:253.02655220031738,z:12.430112361907959},{x:303.5196113586426,y:254.20703887939453,z:6.139191389083862},{x:315.73450088500977,y:251.64799690246582,z:3.3788898587226868},{x:324.69661712646484,y:247.56494522094727,z:2.3328344523906708},{x:331.57970428466797,y:243.02241325378418,z:1.1423448473215103},{x:345.6210708618164,y:229.9976634979248,z:-10.825285911560059},{x:286.26644134521484,y:270.37991523742676,z:21.708929538726807},{x:290.2525520324707,y:228.4921360015869,z:17.71728754043579},{x:351.65367126464844,y:269.3400764465332,z:-33.450424671173096},{x:333.1378936767578,y:253.88388633728027,z:-7.230473756790161},{x:277.8318977355957,y:246.95331573486328,z:68.20805549621582,name:"faceOval"},{x:336.6680908203125,y:238.10003757476807,z:.7688578963279724},{x:329.95800018310547,y:269.18323516845703,z:-7.207130789756775},{x:299.17491912841797,y:234.13324356079102,z:15.95489501953125},{x:335.61729431152344,y:258.71752738952637,z:-23.016133308410645},{x:284.1079330444336,y:297.0343494415283,z:63.25934886932373,name:"faceOval"},{x:331.44542694091797,y:230.6892442703247,z:9.92658257484436,name:"rightEye"},{x:341.41536712646484,y:253.01264762878418,z:-29.038610458374023},{x:303.5472869873047,y:327.5896739959717,z:16.725212335586548},{x:304.7756576538086,y:337.4389457702637,z:27.38126277923584,name:"faceOval"},{x:280.80501556396484,y:275.32050132751465,z:45.0752067565918},{x:295.43582916259766,y:318.4501647949219,z:26.2608003616333},{x:281.4303207397461,y:228.7355661392212,z:40.94350814819336},{x:331.2549591064453,y:349.4216537475586,z:-7.376367449760437},{x:352.4247741699219,y:271.7330074310303,z:-24.953596591949463},{x:327.5672912597656,y:260.41900634765625,z:-5.456410646438599},{x:284.5432472229004,y:241.7647933959961,z:29.668869972229004},{x:310,y:235.66174507141113,z:8.502663969993591,name:"rightEye"},{x:315.7071113586426,y:235.7572603225708,z:6.938687562942505,name:"rightEye"},{x:330.41088104248047,y:311.04143142700195,z:-9.325502514839172,name:"lips"},{x:288.5377502441406,y:285.31983375549316,z:21.837315559387207},{x:344.55039978027344,y:359.4300842285156,z:-6.705257892608643,name:"faceOval"},{x:323.41880798339844,y:351.67362213134766,z:7.802375555038452,name:"faceOval"},{x:314.64088439941406,y:346.11894607543945,z:16.36339783668518,name:"faceOval"},{x:349.4945526123047,y:184.8434829711914,z:-.21847527474164963},{x:359.24694061279297,y:359.8348903656006,z:-8.403456211090088,name:"faceOval"},{x:321.26182556152344,y:234.64492321014404,z:6.90950870513916,name:"rightEye"},{x:326.318359375,y:232.90250301361084,z:8.029969334602356,name:"rightEye"},{x:329.6211624145508,y:231.6195774078369,z:9.722331762313843,name:"rightEye"},{x:285.9398078918457,y:228.2351303100586,z:24.650139808654785},{x:325.79288482666016,y:227.88007736206055,z:7.469738721847534,name:"rightEye"},{x:320.1699447631836,y:227.5934886932373,z:6.168370842933655,name:"rightEye"},{x:314.85408782958984,y:227.85282611846924,z:6.2675780057907104,name:"rightEye"},{x:309.3084907531738,y:229.1516876220703,z:7.7031683921813965,name:"rightEye"},{x:305.5621337890625,y:230.92366218566895,z:9.722331762313843,name:"rightEye"},{x:277.8681945800781,y:228.5354232788086,z:59.71122741699219,name:"faceOval"},{x:306.1444664001465,y:235.1954698562622,z:10.603528022766113,name:"rightEye"},{x:355.4478454589844,y:281.96210861206055,z:-20.565123558044434},{x:333.02661895751953,y:288.0105400085449,z:-14.72939133644104},{x:337.15728759765625,y:269.2059516906738,z:-19.8414945602417},{x:345.9898376464844,y:283.5453128814697,z:-20.4834246635437},{x:351.48963928222656,y:219.98916149139404,z:-7.0378947257995605},{x:312.39574432373047,y:336.50628089904785,z:8.671900033950806},{x:321.32152557373047,y:343.1755256652832,z:.9067271649837494},{x:343.78379821777344,y:353.2975959777832,z:-14.355905055999756},{x:296.8791389465332,y:327.91497230529785,z:41.01353645324707,name:"faceOval"},{x:329.6939468383789,y:229.27897453308105,z:8.934508562088013,name:"rightEye"},{x:341.6905212402344,y:241.4073657989502,z:-14.589333534240723},{x:359.03079986572266,y:353.48859786987305,z:-15.803166627883911},{x:333.1861877441406,y:356.43213272094727,z:-1.0234417766332626,name:"faceOval"},{x:283.97483825683594,y:291.4318656921387,z:41.94725513458252},{x:343.33770751953125,y:305.830135345459,z:-15.756480693817139,name:"lips"},{x:342.40283966064453,y:307.7453899383545,z:-17.4021577835083},{x:341.53621673583984,y:311.0595703125,z:-19.047834873199463},{x:340.9107208251953,y:315.4837703704834,z:-18.5576331615448,name:"lips"},{x:339.1478729248047,y:323.42233657836914,z:-14.367576837539673},{x:333.3201599121094,y:307.4406337738037,z:-9.617288708686829},{x:331.2411117553711,y:306.9811820983887,z:-9.669809937477112},{x:329.23255920410156,y:306.0508346557617,z:-9.582273960113525,name:"lips"},{x:322.4586486816406,y:301.33323669433594,z:-7.720675468444824},{x:297.1712112426758,y:286.9552803039551,z:8.240055441856384},{x:341.3060760498047,y:235.4432201385498,z:-7.504753470420837},{x:336.9318389892578,y:224.3451976776123,z:5.829898118972778},{x:332.65323638916016,y:226.70403957366943,z:8.105834126472473},{x:334.67357635498047,y:306.4397621154785,z:-8.981193900108337,name:"lips"},{x:297.4601936340332,y:306.29210472106934,z:15.476365089416504},{x:342.9119110107422,y:222.37077713012695,z:-2.754466235637665},{x:335.4629898071289,y:332.20250129699707,z:-11.823196411132812},{x:353.2412338256836,y:240.56339263916016,z:-27.147831916809082},{x:346.3080596923828,y:236.41446590423584,z:-18.452589511871338},{x:352.6475143432617,y:234.1420555114746,z:-19.748122692108154},{x:337.3209762573242,y:253.39937210083008,z:-16.024924516677856},{x:358.6122131347656,y:344.90861892700195,z:-18.592647314071655},{x:358.1117248535156,y:334.64990615844727,z:-17.49552845954895},{x:346.4450454711914,y:335.0321102142334,z:-16.32838249206543},{x:319.17640686035156,y:320.2833938598633,z:-3.276764452457428},{x:325.2540588378906,y:276.2369728088379,z:-6.460157036781311},{x:326.7214584350586,y:327.3939514160156,z:-7.417217493057251},{x:310.7190132141113,y:277.2265148162842,z:-3.5452082753181458},{x:319.78355407714844,y:284.8238182067871,z:-6.4543211460113525},{x:305.773983001709,y:290.83580017089844,z:.06907138042151928},{x:344.4001770019531,y:344.85408782958984,z:-16.946970224380493},{x:333.1879425048828,y:258.74256134033203,z:-11.90489649772644},{x:313.80598068237305,y:327.08919525146484,z:2.2277912497520447},{x:322.9637908935547,y:334.6819496154785,z:-3.3643004298210144},{x:313.4055519104004,y:311.2166690826416,z:-1.1175429821014404},{x:291.0865783691406,y:298.2831001281738,z:22.467575073242188},{x:305.6580924987793,y:313.3707904815674,z:5.561453700065613},{x:288.23760986328125,y:305.9941864013672,z:36.765122413635254},{x:315.10692596435547,y:296.26991271972656,z:-4.604393839836121},{x:337.50518798828125,y:247.5944423675537,z:-10.597691535949707},{x:338.8450622558594,y:265.47778129577637,z:-27.778091430664062},{x:334.25254821777344,y:269.0671920776367,z:-20.938611030578613},{x:341.64512634277344,y:259.6387195587158,z:-32.189905643463135},{x:331.44081115722656,y:219.0976095199585,z:4.207563698291779},{x:320.56339263916016,y:216.49658203125,z:2.930997312068939},{x:311.21912002563477,y:216.57853603363037,z:2.9674705862998962},{x:303.46256256103516,y:218.54614734649658,z:5.357203483581543},{x:297.99999237060547,y:222.505202293396,z:9.325502514839172},{x:294.93839263916016,y:236.39654159545898,z:18.534289598464966},{x:278.87489318847656,y:259.7095584869385,z:45.68212032318115},{x:300.3782653808594,y:245.38593292236328,z:12.278382778167725},{x:307.06348419189453,y:246.36857986450195,z:8.164191246032715},{x:315.5229187011719,y:245.3949737548828,z:5.503097176551819},{x:323.71395111083984,y:242.75178909301758,z:4.6335723996162415},{x:330.2785873413086,y:239.34658527374268,z:4.937030673027039},{x:334.6982192993164,y:236.0460376739502,z:4.823233783245087},{x:279.3412208557129,y:263.5196113586426,z:70.91583728790283,name:"faceOval"},{x:334.65972900390625,y:271.6648578643799,z:-17.775644063949585},{x:342.05677032470703,y:246.99846267700195,z:-20.84523916244507},{x:344.0357971191406,y:264.5701503753662,z:-32.936880588531494},{x:348.25531005859375,y:268.6645030975342,z:-30.695960521697998},{x:344.12227630615234,y:266.34212493896484,z:-29.808926582336426},{x:337.12318420410156,y:274.2556858062744,z:-15.768152475357056},{x:349.49047088623047,y:269.071683883667,z:-32.51670837402344},{x:350.1683044433594,y:271.4691352844238,z:-24.93025302886963},{x:333.9634704589844,y:230.56639194488525,z:8.89949381351471},{x:338.2147979736328,y:231.4807891845703,z:4.6715047955513},{x:340.4712677001953,y:231.74463272094727,z:-.34996166825294495},{x:303.28975677490234,y:232.24980354309082,z:11.916568279266357,name:"rightEye"},{x:299.4649124145508,y:229.53842639923096,z:12.325069904327393},{x:359.09618377685547,y:241.77349090576172,z:-24.650139808654785},{x:399.46216583251953,y:229.89503860473633,z:15.919880867004395,name:"leftEye"},{x:361.38919830322266,y:269.6129894256592,z:-24.510080814361572},{x:416.9973373413086,y:206.0895538330078,z:53.26857566833496,name:"faceOval"},{x:381.32179260253906,y:235.5476474761963,z:7.6214683055877686},{x:387.8068542480469,y:236.25958442687988,z:8.345099091529846},{x:393.95751953125,y:235.8660364151001,z:10.475142002105713},{x:401.84600830078125,y:232.77019500732422,z:16.760226488113403},{x:375.70568084716797,y:233.48456382751465,z:8.234220147132874},{x:388.17752838134766,y:218.94717693328857,z:6.810300946235657},{x:381.64928436279297,y:219.2656660079956,z:6.711093783378601},{x:394.4760513305664,y:219.66821193695068,z:9.173773527145386},{x:398.8843536376953,y:221.8837022781372,z:12.03328251838684},{x:406.5454864501953,y:237.12156772613525,z:19.7131085395813},{x:383.87447357177734,y:337.6932907104492,z:-8.631049990653992},{x:401.2682342529297,y:228.5916566848755,z:18.359217643737793,name:"leftEye"},{x:422.0449447631836,y:236.73934936523438,z:51.16771221160889},{x:412.69153594970703,y:232.80198097229004,z:27.52131938934326},{x:387.3497772216797,y:263.298397064209,z:-2.8609684109687805},{x:364.5124053955078,y:293.39221000671387,z:-22.397546768188477,name:"lips"},{x:363.62987518310547,y:302.1291446685791,z:-19.643079042434692},{x:373.2334518432617,y:295.8647060394287,z:-18.125789165496826,name:"lips"},{x:378.83365631103516,y:299.5177745819092,z:-13.153743743896484,name:"lips"},{x:369.91477966308594,y:302.5704002380371,z:-16.65518283843994},{x:374.9167251586914,y:303.5416603088379,z:-11.963253021240234},{x:387.58888244628906,y:312.2716999053955,z:-4.680258631706238},{x:360.6635284423828,y:264.31986808776855,z:-35.94811677932739},{x:361.04564666748047,y:256.8225860595703,z:-37.278664112091064},{x:408.3855438232422,y:213.52088928222656,z:15.756480693817139,name:"leftEyebrow"},{x:373.2946014404297,y:245.38101196289062,z:-1.9316278398036957},{x:376.83860778808594,y:264.3721103668213,z:-18.510947227478027},{x:376.9546127319336,y:261.0010528564453,z:-15.989909172058105},{x:406.1498260498047,y:263.5030174255371,z:7.072908878326416},{x:360.07205963134766,y:248.3631706237793,z:-32.16656446456909},{x:393.11119079589844,y:205.10473251342773,z:3.7786373496055603,name:"leftEyebrow"},{x:402.12791442871094,y:207.89000988006592,z:9.383859634399414,name:"leftEyebrow"},{x:410.8693313598633,y:191.6182279586792,z:41.27030849456787,name:"faceOval"},{x:364.9509811401367,y:210.40483474731445,z:-3.758212625980377},{x:375.94444274902344,y:221.1331844329834,z:8.368442058563232},{x:392.1904754638672,y:305.0360298156738,z:-1.752179116010666},{x:419.50225830078125,y:307.25592613220215,z:58.96425247192383,name:"faceOval"},{x:372.0027160644531,y:268.7212657928467,z:-16.631840467453003},{x:366.1614227294922,y:271.6237449645996,z:-18.219159841537476},{x:385.00938415527344,y:305.3863334655762,z:-2.567722797393799},{x:381.99771881103516,y:304.9723720550537,z:-4.575215280056},{x:405.078125,y:203.21216583251953,z:13.713973760604858,name:"leftEyebrow"},{x:377.13207244873047,y:268.4710121154785,z:-15.266278982162476},{x:380.9713363647461,y:205.36980628967285,z:-.7250899076461792,name:"leftEyebrow"},{x:381.7788314819336,y:198.9268398284912,z:-1.184653863310814,name:"leftEyebrow"},{x:385.5204772949219,y:172.1484375,z:16.04826807975769,name:"faceOval"},{x:407.94189453125,y:196.76236152648926,z:25.723915100097656},{x:383.03890228271484,y:184.5157527923584,z:7.393874526023865},{x:411.61781311035156,y:210.79241752624512,z:22.315845489501953,name:"leftEyebrow"},{x:414.30870056152344,y:208.4643030166626,z:37.021894454956055},{x:364.28722381591797,y:298.35777282714844,z:-21.86065673828125},{x:371.3682556152344,y:299.78848457336426,z:-17.834001779556274},{x:376.88201904296875,y:301.6696071624756,z:-13.153743743896484},{x:370.2193832397461,y:270.49095153808594,z:-15.569736957550049},{x:383.5081100463867,y:305.2726364135742,z:-3.673594295978546},{x:380.73760986328125,y:305.96869468688965,z:-8.660228252410889},{x:381.2334442138672,y:304.63574409484863,z:-4.820316135883331,name:"lips"},{x:368.1698989868164,y:264.8884963989258,z:-25.653886795043945},{x:373.5087203979492,y:303.4233856201172,z:-10.95950722694397,name:"lips"},{x:368.4544372558594,y:303.29601287841797,z:-14.169161319732666,name:"lips"},{x:362.76554107666016,y:303.5735607147217,z:-16.911956071853638,name:"lips"},{x:366.60980224609375,y:324.8870658874512,z:-15.616422891616821},{x:365.7067108154297,y:315.95678329467773,z:-20.903596878051758,name:"lips"},{x:365.0083923339844,y:311.2232208251953,z:-21.066999435424805},{x:364.1508102416992,y:307.0583438873291,z:-18.907777070999146},{x:363.37512969970703,y:304.5721435546875,z:-17.42550015449524,name:"lips"},{x:374.580078125,y:304.3059539794922,z:-11.40302300453186,name:"lips"},{x:375.55362701416016,y:305.0998020172119,z:-12.861957550048828},{x:377.2437286376953,y:307.1674346923828,z:-14.215847253799438},{x:378.68587493896484,y:309.9015712738037,z:-13.223772048950195,name:"lips"},{x:383.8992691040039,y:290.29629707336426,z:-9.97326910495758},{x:423.3871841430664,y:271.91688537597656,z:74.37058925628662,name:"faceOval"},{x:377.68043518066406,y:304.62209701538086,z:-7.603961229324341,name:"lips"},{x:379.00428771972656,y:304.9314594268799,z:-8.57852816581726},{x:364.00279998779297,y:275.2813911437988,z:-19.25792098045349},{x:374.68231201171875,y:273.82555961608887,z:-11.28047227859497},{x:365.0354766845703,y:273.4548568725586,z:-18.791062831878662},{x:380.61901092529297,y:249.8848056793213,z:.15501167625188828},{x:391.14158630371094,y:254.7934627532959,z:2.0906515419483185},{x:378.1761169433594,y:264.9612236022949,z:-12.605184316635132},{x:400.9540557861328,y:179.99592304229736,z:27.82477855682373,name:"faceOval"},{x:398.0038833618164,y:188.50656509399414,z:16.094952821731567},{x:394.8717498779297,y:199.0359592437744,z:6.226727366447449,name:"leftEyebrow"},{x:382.10926055908203,y:316.83926582336426,z:-8.946179747581482},{x:366.51588439941406,y:200.32583713531494,z:-5.24632453918457,name:"leftEyebrow"},{x:367.4893569946289,y:183.87210845947266,z:1.9039081037044525},{x:368.6243438720703,y:168.8127565383911,z:8.736093044281006,name:"faceOval"},{x:398.96175384521484,y:234.9675178527832,z:13.713973760604858},{x:412.9645538330078,y:242.23042488098145,z:23.272905349731445},{x:372.05257415771484,y:231.41919136047363,z:9.226294755935669},{x:406.0722351074219,y:223.58965873718262,z:18.370890617370605},{x:368.27442169189453,y:240.2039337158203,z:-4.166713654994965},{x:372.3575210571289,y:260.66442489624023,z:-24.976940155029297},{x:419.2244338989258,y:247.9079246520996,z:30.299127101898193},{x:409.43885803222656,y:246.60913467407227,z:16.398411989212036},{x:401.69139862060547,y:248.76328468322754,z:9.395531415939331},{x:389.7608184814453,y:247.56915092468262,z:5.841569304466248},{x:380.5461883544922,y:244.55984115600586,z:4.263003468513489},{x:373.25817108154297,y:240.80214500427246,z:2.5356262922286987},{x:358.77086639404297,y:229.35615062713623,z:-10.387605428695679},{x:419.5793914794922,y:262.8478717803955,z:26.5175724029541},{x:410.8808898925781,y:222.51372814178467,z:22.199130058288574},{x:358.45714569091797,y:268.91467094421387,z:-33.17030906677246},{x:373.4129333496094,y:251.6385841369629,z:-5.771540403366089},{x:422.5408172607422,y:239.23919677734375,z:74.04378890991211,name:"faceOval"},{x:367.8171920776367,y:236.58040523529053,z:1.820748895406723},{x:378.51959228515625,y:266.2532329559326,z:-5.74819803237915},{x:403.3472442626953,y:229.05112266540527,z:19.689764976501465},{x:372.34840393066406,y:256.6451168060303,z:-21.872329711914062},{x:422.54566192626953,y:289.1587829589844,z:68.67491245269775,name:"faceOval"},{x:371.9297409057617,y:228.90116214752197,z:11.432201862335205,name:"leftEye"},{x:366.21360778808594,y:251.6158962249756,z:-28.19826364517212},{x:409.1571807861328,y:321.3156223297119,z:20.2266526222229},{x:408.52943420410156,y:331.44238471984863,z:31.09278917312622,name:"faceOval"},{x:424.2788314819336,y:267.1992301940918,z:50.467424392700195},{x:415.60352325439453,y:311.6528606414795,z:30.579242706298828},{x:418.12793731689453,y:221.59927368164062,z:46.26569747924805},{x:385.68286895751953,y:346.0184955596924,z:-5.70151150226593},{x:357.82936096191406,y:271.3758373260498,z:-24.836881160736084},{x:379.588623046875,y:257.5071716308594,z:-3.755294680595398},{x:417.4592590332031,y:234.71948146820068,z:34.5475435256958},{x:393.4684371948242,y:231.58967971801758,z:11.408859491348267,name:"leftEye"},{x:387.8864288330078,y:232.14245796203613,z:9.51808214187622,name:"leftEye"},{x:382.4981689453125,y:307.5654888153076,z:-7.522260546684265,name:"lips"},{x:419.00169372558594,y:277.8332805633545,z:26.424202919006348},{x:373.62953186035156,y:357.6375102996826,z:-5.75986921787262,name:"faceOval"},{x:392.8708267211914,y:347.72446632385254,z:10.154176950454712,name:"faceOval"},{x:400.3953552246094,y:341.0005187988281,z:19.39797878265381,name:"faceOval"},{x:382.25440979003906,y:231.66935920715332,z:8.998700976371765,name:"leftEye"},{x:377.14550018310547,y:230.4228687286377,z:9.804032444953918,name:"leftEye"},{x:373.8358688354492,y:229.64950561523438,z:11.292144060134888,name:"leftEye"},{x:414.5794677734375,y:221.67891025543213,z:29.412097930908203},{x:377.00672149658203,y:225.66201210021973,z:9.360517263412476,name:"leftEye"},{x:382.29530334472656,y:224.8431158065796,z:8.32175612449646,name:"leftEye"},{x:387.5133514404297,y:224.49507236480713,z:8.917000889778137,name:"leftEye"},{x:393.15906524658203,y:225.24795055389404,z:10.737749338150024,name:"leftEye"},{x:397.05554962158203,y:226.55359268188477,z:13.002015352249146,name:"leftEye"},{x:420.5299377441406,y:221.014666557312,z:65.40690422058105,name:"faceOval"},{x:397.06920623779297,y:230.6661558151245,z:13.807345628738403,name:"leftEye"},{x:377.94647216796875,y:285.1647090911865,z:-13.305472135543823},{x:372.1118927001953,y:267.1267318725586,z:-18.83774757385254},{x:364.9968719482422,y:282.24411964416504,z:-19.818150997161865},{x:401.973876953125,y:331.20131492614746,z:11.566424369812012},{x:394.3083190917969,y:338.86693954467773,z:3.142542541027069},{x:373.9820861816406,y:351.4504623413086,z:-13.50388765335083},{x:414.3888854980469,y:321.24735832214355,z:45.51872253417969,name:"faceOval"},{x:373.44234466552734,y:227.33163356781006,z:10.626870393753052,name:"leftEye"},{x:364.0731430053711,y:240.31539916992188,z:-13.807345628738403},{x:384.2658233642578,y:353.3793067932129,z:.7385850697755814,name:"faceOval"},{x:423.20526123046875,y:283.5176181793213,z:47.152724266052246},{x:369.42798614501953,y:304.0898895263672,z:-14.647691249847412,name:"lips"},{x:370.63812255859375,y:305.90051651000977,z:-16.211668252944946},{x:371.91192626953125,y:309.0167713165283,z:-17.84567356109619},{x:373.0583953857422,y:313.3545398712158,z:-17.378815412521362,name:"lips"},{x:375.39905548095703,y:321.09289169311523,z:-13.118728399276733},{x:379.2567825317383,y:304.3582534790039,z:-7.924926280975342},{x:381.18797302246094,y:303.7031364440918,z:-7.843226194381714},{x:383.0918502807617,y:302.4884605407715,z:-7.6506465673446655,name:"lips"},{x:389.09461975097656,y:297.1475315093994,z:-5.5497825145721436},{x:411.6408920288086,y:280.24898529052734,z:12.02161192893982},{x:363.3110809326172,y:234.27620887756348,z:-6.775286793708801},{x:366.0474395751953,y:223.29872131347656,z:6.827808618545532},{x:370.34427642822266,y:225.1457118988037,z:9.558931589126587},{x:377.5371551513672,y:303.60079765319824,z:-7.358860373497009,name:"lips"},{x:412.9557800292969,y:299.53579902648926,z:19.39797878265381},{x:360.0810241699219,y:221.72012329101562,z:-2.153385728597641},{x:379.82784271240234,y:329.47723388671875,z:-10.48097848892212},{x:359.08477783203125,y:235.7911491394043,z:-18.079102039337158},{x:369.6688461303711,y:251.5407943725586,z:-14.962821006774902},{x:369.5555114746094,y:333.5307312011719,z:-15.67478060722351},{x:394.0193176269531,y:315.6973171234131,z:-.9920747578144073},{x:383.78997802734375,y:272.7268695831299,z:-4.689012169837952},{x:387.67765045166016,y:323.6722755432129,z:-5.640236139297485},{x:397.8769302368164,y:272.1331214904785,z:-.9395531564950943},{x:389.87476348876953,y:280.5630111694336,z:-4.29218202829361},{x:403.83888244628906,y:285.1167869567871,z:3.0229100584983826},{x:372.5467300415039,y:343.1070327758789,z:-16.153310537338257},{x:374.1112518310547,y:256.3721466064453,z:-10.574349164962769},{x:399.73785400390625,y:321.77515983581543,z:4.849494695663452},{x:392.03365325927734,y:330.56447982788086,z:-1.3407598435878754},{x:398.59134674072266,y:305.93902587890625,z:1.517290621995926},{x:417.95997619628906,y:290.9716987609863,z:26.89105987548828},{x:406.04541778564453,y:307.35154151916504,z:8.666064143180847},{x:420.75328826904297,y:298.40752601623535,z:41.78385257720947},{x:395.4522705078125,y:291.4153575897217,z:-2.1752697229385376},{x:368.6452102661133,y:245.8882999420166,z:-9.453888535499573},{x:370.34900665283203,y:263.56690406799316,z:-26.75100326538086},{x:374.98477935791016,y:266.6126346588135,z:-19.77146625518799},{x:366.99840545654297,y:258.12140464782715,z:-31.372904777526855},{x:371.00616455078125,y:217.63479709625244,z:5.60522198677063},{x:381.30577087402344,y:214.14087295532227,z:4.983716309070587},{x:390.1496124267578,y:213.38221549987793,z:5.593550801277161},{x:397.7696990966797,y:214.3659782409668,z:8.57852816581726},{x:403.1652069091797,y:217.65509605407715,z:13.013685941696167},{x:407.3551940917969,y:230.72525024414062,z:22.444231510162354},{x:424.0876770019531,y:251.7839241027832,z:51.16771221160889},{x:403.50196838378906,y:239.88757610321045,z:15.803166627883911},{x:397.31719970703125,y:241.49806022644043,z:11.233787536621094},{x:388.99425506591797,y:241.4366912841797,z:7.948269248008728},{x:380.7804489135742,y:239.78078842163086,z:6.600214838981628},{x:374.01336669921875,y:237.11946487426758,z:6.349278092384338},{x:369.39125061035156,y:234.35351371765137,z:5.987462401390076},{x:422.9730987548828,y:255.76455116271973,z:76.61150932312012,name:"faceOval"},{x:374.73915100097656,y:269.24214363098145,z:-16.608498096466064},{x:364.61681365966797,y:245.71088790893555,z:-20.02823829650879},{x:365.3834533691406,y:263.34174156188965,z:-32.32996463775635},{x:361.58252716064453,y:267.8273677825928,z:-30.345816612243652},{x:365.37208557128906,y:265.0249671936035,z:-29.178667068481445},{x:372.72605895996094,y:272.05135345458984,z:-14.834434986114502},{x:360.48614501953125,y:268.34827423095703,z:-32.189905643463135},{x:359.9516296386719,y:270.8049201965332,z:-24.650139808654785},{x:369.5049285888672,y:229.01945114135742,z:10.107489824295044},{x:365.5447769165039,y:230.24096488952637,z:5.593550801277161},{x:363.50669860839844,y:230.6208372116089,z:.43622106313705444},{x:399.3529510498047,y:227.65677452087402,z:15.35965085029602,name:"leftEye"},{x:402.5693130493164,y:224.60190296173096,z:15.931552648544312}],box:{xMin:277.8318977355957,yMin:168.7741756439209,xMax:424.2788314819336,yMax:359.8348903656006,width:146.4469337463379,height:191.0607147216797}},SAMPLE_FACELANDMARKER_RESULT:{faceLandmarks:[[{x:.5760777592658997,y:.8639070391654968,z:-.030997956171631813},{x:.572094738483429,y:.7886289358139038,z:-.07189624011516571},{x:.5723551511764526,y:.8075382709503174,z:-.03578168898820877},{x:.5548420548439026,y:.7188365459442139,z:-.057787876576185226},{x:.5706077814102173,y:.7674974799156189,z:-.07740399986505508},{x:.5681378245353699,y:.7387768030166626,z:-.07356284558773041},{x:.5621535181999207,y:.6681165099143982,z:-.04189874976873398},{x:.46613582968711853,y:.6679812073707581,z:.011289681307971478},{x:.5579932928085327,y:.6174106597900391,z:-.03502821549773216},{x:.5563451647758484,y:.5905600190162659,z:-.03928658738732338},{x:.5487832427024841,y:.4900572597980499,z:-.029898937791585922},{x:.5765544176101685,y:.8692144751548767,z:-.02831427752971649},{x:.5771114230155945,y:.873644232749939,z:-.02345779910683632},{x:.5771905779838562,y:.877016007900238,z:-.016658689826726913},{x:.5778058767318726,y:.8770116567611694,z:-.014505492523312569},{x:.5783766508102417,y:.8835000991821289,z:-.015996402129530907},{x:.5792440176010132,y:.8913810849189758,z:-.01924579218029976},{x:.5796768069267273,y:.8996334671974182,z:-.018261712044477463},{x:.5817288160324097,y:.9255813956260681,z:-.007126849144697189},{x:.5726592540740967,y:.7992473244667053,z:-.0643521398305893},{x:.5579419136047363,y:.7996989488601685,z:-.04566684365272522},{x:.4216199815273285,y:.5958762764930725,z:.06776496022939682},{x:.5052269697189331,y:.6796539425849915,z:-.0010737782577052712},{x:.49243026971817017,y:.6838865876197815,z:-.0005227324436418712},{x:.4796970784664154,y:.6856290102005005,z:.002684245817363262},{x:.4618356227874756,y:.6764569878578186,z:.013439622707664967},{x:.5160380601882935,y:.6737282276153564,z:-17607348127057776e-21},{x:.48070961236953735,y:.6255870461463928,z:-.008339674212038517},{x:.49719780683517456,y:.6256808042526245,z:-.008027955889701843},{x:.46674346923828125,y:.6317623853683472,z:-.004460199736058712},{x:.4582492709159851,y:.641118049621582,z:.0011905613355338573},{x:.45408669114112854,y:.6911458969116211,z:.020514748990535736},{x:.535312294960022,y:.9619986414909363,z:.012499462813138962},{x:.4608460068702698,y:.6628725528717041,z:.01517564244568348},{x:.4206731915473938,y:.6828458309173584,z:.07848648726940155},{x:.4390624463558197,y:.6796106696128845,z:.03283142298460007},{x:.5029968619346619,y:.7701570391654968,z:-.009734481573104858},{x:.5595027208328247,y:.8607323169708252,z:-.030043255537748337},{x:.5621269941329956,y:.8738374710083008,z:-.021709579974412918},{x:.5451499819755554,y:.865527331829071,z:-.022014077752828598},{x:.5351184010505676,y:.8705098032951355,z:-.011602800339460373},{x:.5495014190673828,y:.8744956254959106,z:-.016490943729877472},{x:.5395170450210571,y:.8759440779685974,z:-.007333362940698862},{x:.5183624029159546,y:.8959754705429077,z:.010520773939788342},{x:.5604349374771118,y:.7895449995994568,z:-.07082037627696991},{x:.557381272315979,y:.7687489986419678,z:-.07590588927268982},{x:.4432901442050934,y:.6308897733688354,z:.0027153254486620426},{x:.5258325338363647,y:.7151225805282593,z:-.014676518738269806},{x:.5271827578544617,y:.7833116054534912,z:-.037643320858478546},{x:.5257382988929749,y:.7717816233634949,z:-.03401920944452286},{x:.46516409516334534,y:.7705106735229492,z:.0065747760236263275},{x:.5558893084526062,y:.7420997619628906,z:-.0694495290517807},{x:.4720408320426941,y:.6066038608551025,z:-.021204356104135513},{x:.45432573556900024,y:.6158540844917297,z:-.011054684408009052},{x:.4305151402950287,y:.5608053803443909,z:.0396830290555954},{x:.5310865640640259,y:.6157484650611877,z:-.03081176057457924},{x:.5114666223526001,y:.6329749226570129,z:-.00335998204536736},{x:.506435751914978,y:.8786543607711792,z:.012980876490473747},{x:.4480472207069397,y:.8640613555908203,z:.12569651007652283},{x:.5372058153152466,y:.7942581176757812,z:-.03168361634016037},{x:.5488379597663879,y:.8001630306243896,z:-.03280917927622795},{x:.5213388204574585,y:.8794381618499756,z:.011892606504261494},{x:.5242055654525757,y:.8789222240447998,z:.008370225317776203},{x:.4477175176143646,y:.6039950251579285,z:-.0050799972377717495},{x:.526964008808136,y:.7916748523712158,z:-.02968614175915718},{x:.4971255660057068,y:.6050706505775452,z:-.028175678104162216},{x:.4938119053840637,y:.5882453918457031,z:-.03210941329598427},{x:.4757143557071686,y:.5094879865646362,z:-.01300730835646391},{x:.43947282433509827,y:.5816648006439209,z:.01415177434682846},{x:.485664039850235,y:.5477864146232605,z:-.023685332387685776},{x:.43635931611061096,y:.6226438283920288,z:.013606148771941662},{x:.42910251021385193,y:.6102726459503174,z:.03926564007997513},{x:.5605402588844299,y:.8680099248886108,z:-.027318159118294716},{x:.5474816560745239,y:.8702861070632935,z:-.019686367362737656},{x:.5373021364212036,y:.8728838562965393,z:-.010484928265213966},{x:.540735125541687,y:.7979167103767395,z:-.029073253273963928},{x:.5228585004806519,y:.87913578748703,z:.009915109723806381},{x:.530497670173645,y:.8815253973007202,z:.0020524784922599792},{x:.5259912610054016,y:.8790552616119385,z:.007895970717072487},{x:.5433906316757202,y:.7882310748100281,z:-.05121905356645584},{x:.541388213634491,y:.8777219653129578,z:-.00466804439201951},{x:.5515822172164917,y:.8767023086547852,z:-.010475946590304375},{x:.5637003779411316,y:.877059817314148,z:-.015273625031113625},{x:.5640299320220947,y:.9263423085212708,z:-.00658724969252944},{x:.5642300248146057,y:.8993074893951416,z:-.017653480172157288},{x:.5637336373329163,y:.8910360932350159,z:-.01852807030081749},{x:.5637134313583374,y:.8837276697158813,z:-.01482592523097992},{x:.564205527305603,y:.8768964409828186,z:-.01331155002117157},{x:.5419867634773254,y:.8778373599052429,z:-.0037720394320786},{x:.5404468774795532,y:.880696177482605,z:-.005610354244709015},{x:.5392338633537292,y:.8845721483230591,z:-.007352025713771582},{x:.538469672203064,y:.8891173601150513,z:-.005154991988092661},{x:.5189250111579895,y:.8452741503715515,z:-.009755070321261883},{x:.4258975088596344,y:.7662280797958374,z:.1387351155281067},{x:.5725725293159485,y:.8041572570800781,z:-.04583907872438431},{x:.5342061519622803,y:.8785833120346069,z:.002659974154084921},{x:.5324031114578247,y:.8804071545600891,z:.0017832003068178892},{x:.5538818836212158,y:.8078407645225525,z:-.03254539892077446},{x:.5325431823730469,y:.8026832938194275,z:-.019140373915433884},{x:.5514076948165894,y:.8043903112411499,z:-.03313535451889038},{x:.5131856203079224,y:.7284771800041199,z:-.009399853646755219},{x:.49331504106521606,y:.7443980574607849,z:-.005225230939686298},{x:.5239617824554443,y:.7807451486587524,z:-.025881027802824974},{x:.4473606050014496,y:.5315827131271362,z:.011164786294102669},{x:.45718759298324585,y:.5604941248893738,z:-.005943301599472761},{x:.4670005738735199,y:.5909327268600464,z:-.019681761041283607},{x:.5311570167541504,y:.9076261520385742,z:.00389476353302598},{x:.5249923467636108,y:.5893563628196716,z:-.037981919944286346},{x:.5166932344436646,y:.5429551005363464,z:-.03319704160094261},{x:.5085030198097229,y:.49676206707954407,z:-.02691275253891945},{x:.4687720239162445,y:.6834565997123718,z:.008113506250083447},{x:.4426414966583252,y:.7069531679153442,z:.028577271848917007},{x:.5230373740196228,y:.6675713658332825,z:.001773772411979735},{x:.4481240212917328,y:.6527872085571289,z:.012414850294589996},{x:.5339856743812561,y:.7012367844581604,z:-.020220188423991203},{x:.5347223281860352,y:.7761190533638,z:-.05141595005989075},{x:.4315067231655121,y:.7211957573890686,z:.04381405934691429},{x:.45203351974487305,y:.7206180095672607,z:.017288070172071457},{x:.46892452239990234,y:.7265436053276062,z:.005602988880127668},{x:.49314674735069275,y:.7202282547950745,z:-.0006408205372281373},{x:.5104925632476807,y:.7091827392578125,z:-.00362918758764863},{x:.5232142210006714,y:.698553740978241,z:-.00787867046892643},{x:.5497883558273315,y:.6743605136871338,z:-.036349106580019},{x:.43658503890037537,y:.7627100348472595,z:.042555369436740875},{x:.4397648870944977,y:.6528646349906921,z:.017956094816327095},{x:.5653332471847534,y:.7992802858352661,z:-.06365057826042175},{x:.5285563468933105,y:.736810564994812,z:-.018836988136172295},{x:.4180678725242615,y:.6792560815811157,z:.12284679710865021},{x:.5328429937362671,y:.6865872144699097,z:-.010484723374247551},{x:.5230283141136169,y:.7809416055679321,z:-.011922398582100868},{x:.4551771283149719,y:.6650775074958801,z:.01774493046104908},{x:.5337203741073608,y:.7618928551673889,z:-.04697106033563614},{x:.43463975191116333,y:.8133478164672852,z:.1354849934577942},{x:.5225707292556763,y:.6605283617973328,z:.004980515688657761},{x:.5441933870315552,y:.7497199773788452,z:-.06091512367129326},{x:.4774007797241211,y:.9159183502197266,z:.059622734785079956},{x:.48068761825561523,y:.9364941716194153,z:.08404944837093353},{x:.4268292486667633,y:.7657528519630432,z:.09051097184419632},{x:.46051913499832153,y:.8880485892295837,z:.0738474428653717},{x:.4243420660495758,y:.6434382200241089,z:.06230505183339119},{x:.5342157483100891,y:.9835634231567383,z:.021662971004843712},{x:.5668109655380249,y:.8042187094688416,z:-.044937074184417725},{x:.5176341533660889,y:.7530587315559387,z:-.012967454269528389},{x:.430206298828125,y:.6835605502128601,z:.04612284153699875},{x:.4794231951236725,y:.6732114553451538,z:.003970044665038586},{x:.49073347449302673,y:.6722435355186462,z:.0008692514384165406},{x:.5294116139411926,y:.884677529335022,z:.004413890186697245},{x:.4430122375488281,y:.80235356092453,z:.04987282305955887},{x:.5603825449943542,y:1.0092442035675049,z:.026417359709739685},{x:.5186598300933838,y:.9828659892082214,z:.0513598807156086},{x:.5010536909103394,y:.9640932679176331,z:.06591596454381943},{x:.5524769425392151,y:.539441704750061,z:-.035816047340631485},{x:.5879997611045837,y:1.0091472864151,z:.02285068854689598},{x:.5016193985939026,y:.6684437990188599,z:.00028415941051207483},{x:.511952817440033,y:.6642197370529175,z:.0021144719794392586},{x:.5194343328475952,y:.6623469591140747,z:.004674181342124939},{x:.4321230351924896,y:.6496355533599854,z:.03124697133898735},{x:.508686363697052,y:.6479565501213074,z:-.00044765998609364033},{x:.4963986277580261,y:.6431032419204712,z:-.0032507688738405704},{x:.4845542013645172,y:.6430778503417969,z:-.002903624437749386},{x:.4733612537384033,y:.647506833076477,z:.00023347247042693198},{x:.4668654501438141,y:.653346598148346,z:.004762572236359119},{x:.41815051436424255,y:.633708119392395,z:.09809435904026031},{x:.47159942984580994,y:.6711485385894775,z:.007849935442209244},{x:.5734396576881409,y:.8256140351295471,z:-.03155219927430153},{x:.5306524038314819,y:.8337990641593933,z:-.018351426348090172},{x:.5371729135513306,y:.7910830974578857,z:-.037286680191755295},{x:.5549534559249878,y:.8275275826454163,z:-.030664825811982155},{x:.5597432255744934,y:.6418541669845581,z:-.03318847343325615},{x:.4958484172821045,y:.9429569244384766,z:.048340678215026855},{x:.5140507817268372,y:.9634028077125549,z:.03589847311377525},{x:.5587693452835083,y:.9951097369194031,z:.00908728688955307},{x:.46411189436912537,y:.9051855206489563,z:.10601935535669327},{x:.5181609392166138,y:.6554316878318787,z:.002546071307733655},{x:.5436590909957886,y:.7085841298103333,z:-.03844436630606651},{x:.5872187614440918,y:.9960382580757141,z:.0063423276878893375},{x:.5379653573036194,y:.9989125728607178,z:.03636329993605614},{x:.4350326955318451,y:.8088565468788147,z:.09147704392671585},{x:.5523084998130798,y:.8773422837257385,z:-.009068487212061882},{x:.5510149598121643,y:.8816931843757629,z:-.011043853126466274},{x:.5503793954849243,y:.88776695728302,z:-.01348799467086792},{x:.5501549243927002,y:.8954370617866516,z:-.012142189778387547},{x:.546072781085968,y:.9192524552345276,z:-.003157563041895628},{x:.5314661860466003,y:.8771666884422302,z:.0005075141089037061},{x:.5293324589729309,y:.8762547969818115,z:.00039177737198770046},{x:.5275698900222778,y:.8750609755516052,z:47732755774632096e-21},{x:.5104271173477173,y:.8607332110404968,z:.0012934643309563398},{x:.45938700437545776,y:.8134918212890625,z:.023569690063595772},{x:.5418947339057922,y:.6864100694656372,z:-.027333909645676613},{x:.531914234161377,y:.6456130743026733,z:-.005434140563011169},{x:.523697018623352,y:.647885262966156,z:-.0002466466394253075},{x:.5338191390037537,y:.8783687353134155,z:.002268768846988678},{x:.46226605772972107,y:.8610277771949768,z:.04718952998518944},{x:.5434442758560181,y:.6456181406974792,z:-.02327350154519081},{x:.5399754643440247,y:.940219521522522,z:.005075343884527683},{x:.5661457777023315,y:.71457839012146,z:-.06242101639509201},{x:.5523148775100708,y:.6974870562553406,z:-.04863070324063301},{x:.5639959573745728,y:.6923378109931946,z:-.05180761218070984},{x:.5367592573165894,y:.7423217296600342,z:-.03623027727007866},{x:.5853689908981323,y:.9752064943313599,z:-.002361974213272333},{x:.5835235118865967,y:.9493685960769653,z:-.003941743168979883},{x:.5615018606185913,y:.949194610118866,z:-.0015953965485095978},{x:.5068561434745789,y:.9048219323158264,z:.01862684078514576},{x:.5134067535400391,y:.7971825003623962,z:-.008485661819577217},{x:.5223897099494934,y:.925589919090271,z:.01249657291918993},{x:.48500555753707886,y:.7959478497505188,z:-.0032065745908766985},{x:.5037734508514404,y:.8184596300125122,z:-.004932103678584099},{x:.4766361117362976,y:.828806459903717,z:.01027688942849636},{x:.5589827299118042,y:.974656343460083,z:.0009666886180639267},{x:.5294582843780518,y:.7541216611862183,z:-.025603046640753746},{x:.4973002076148987,y:.9208990931510925,z:.031931452453136444},{x:.5163551568984985,y:.9432790875434875,z:.024321340024471283},{x:.49399662017822266,y:.8814862370491028,z:.018687399104237556},{x:.44948166608810425,y:.836137592792511,z:.05702034756541252},{x:.47898444533348083,y:.8836610913276672,z:.03150695189833641},{x:.4454479217529297,y:.8499438166618347,z:.08868525922298431},{x:.49572959542274475,y:.8452823758125305,z:.0036111653316766024},{x:.5362502336502075,y:.7222585678100586,z:-.027912352234125137},{x:.5393770337104797,y:.7850722074508667,z:-.05415399745106697},{x:.531399667263031,y:.7898418307304382,z:-.03883346915245056},{x:.5451627373695374,y:.7717036604881287,z:-.06480253487825394},{x:.5206395983695984,y:.6287745833396912,z:-.010521138086915016},{x:.4974782466888428,y:.6191938519477844,z:-.014098240062594414},{x:.4774145185947418,y:.6193130612373352,z:-.013643337413668633},{x:.4616098403930664,y:.6259890198707581,z:-.008448202162981033},{x:.4516478478908539,y:.6368461847305298,z:9050309745362028e-20},{x:.4485096037387848,y:.6719120740890503,z:.022984720766544342},{x:.42177659273147583,y:.7240667343139648,z:.08511673659086227},{x:.4616215229034424,y:.6988231539726257,z:.014238474890589714},{x:.4755798876285553,y:.7034608721733093,z:.00625590980052948},{x:.4924992024898529,y:.7005885243415833,z:.0009391739731654525},{x:.5082254409790039,y:.693384051322937,z:-.0009464038303121924},{x:.5203112959861755,y:.6849707961082458,z:-.0022114769089967012},{x:.52867591381073,y:.6779075860977173,z:-.002962538506835699},{x:.4213953912258148,y:.7219811677932739,z:.1350894570350647},{x:.5320829749107361,y:.794858992099762,z:-.03181503340601921},{x:.5452795028686523,y:.7286570072174072,z:-.04771539941430092},{x:.5496407747268677,y:.7866933345794678,z:-.06452003121376038},{x:.557040274143219,y:.7962084412574768,z:-.05837344378232956},{x:.549176812171936,y:.7895247936248779,z:-.057761140167713165},{x:.5362890362739563,y:.8005836606025696,z:-.026903774589300156},{x:.560200035572052,y:.7983731031417847,z:-.06172555685043335},{x:.5616944432258606,y:.8022753596305847,z:-.045200999826192856},{x:.5273328423500061,y:.6611284017562866,z:.0029021520167589188},{x:.534850537776947,y:.6660012006759644,z:-.005215510260313749},{x:.5394860506057739,y:.6701375246047974,z:-.014931917190551758},{x:.4634307324886322,y:.658291757106781,z:.009295716881752014},{x:.4538393020629883,y:.6519932150840759,z:.00930330716073513},{x:.5776031613349915,y:.7159298658370972,z:-.057365912944078445},{x:.6504855155944824,y:.6461779475212097,z:.014184834435582161},{x:.5860154032707214,y:.7962266206741333,z:-.04522843658924103},{x:.6842049360275269,y:.5631637573242188,z:.07207967340946198},{x:.6152560710906982,y:.6674962639808655,z:.0007529259892180562},{x:.6280948519706726,y:.6684326529502869,z:.0016892586136236787},{x:.6408625245094299,y:.6663892269134521,z:.005331226624548435},{x:.6557814478874207,y:.6534678936004639,z:.01646413467824459},{x:.6035663485527039,y:.6639701724052429,z:.0013799630105495453},{x:.6329053044319153,y:.608010470867157,z:-.006195899099111557},{x:.6167260408401489,y:.6117533445358276,z:-.006319951266050339},{x:.6471013426780701,y:.6112449765205383,z:-.0017843559617176652},{x:.6560901999473572,y:.6185776591300964,z:.004047257360070944},{x:.6666946411132812,y:.6651176810264587,z:.023647578433156013},{x:.6311345100402832,y:.9495396018028259,z:.014004078693687916},{x:.6544655561447144,y:.6397901773452759,z:.01809609681367874},{x:.6965808868408203,y:.6482675075531006,z:.08304904401302338},{x:.679817259311676,y:.650188148021698,z:.03632688894867897},{x:.6336516737937927,y:.7541458010673523,z:-.007742783520370722},{x:.5921701192855835,y:.8567668199539185,z:-.029399123042821884},{x:.591663658618927,y:.870215654373169,z:-.02103729173541069},{x:.6068367958068848,y:.8584195375442505,z:-.020668085664510727},{x:.6176617741584778,y:.860965371131897,z:-.009790095500648022},{x:.6040634512901306,y:.8686612844467163,z:-.015289564616978168},{x:.6143736839294434,y:.8671170473098755,z:-.005712216719985008},{x:.6373105049133301,y:.8815656900405884,z:.012672550976276398},{x:.5832505822181702,y:.7866312861442566,z:-.07051534950733185},{x:.5836675763130188,y:.7658692598342896,z:-.07566110789775848},{x:.6709531545639038,y:.604898989200592,z:.005951565690338612},{x:.6029891967773438,y:.705652117729187,z:-.013388276100158691},{x:.6131622195243835,y:.7728396058082581,z:-.036248479038476944},{x:.6123163104057312,y:.7612020373344421,z:-.03264721855521202},{x:.6696187853813171,y:.744706928730011,z:.009673702530562878},{x:.5803102254867554,y:.7385968565940857,z:-.0689152330160141},{x:.6404349207878113,y:.5877999663352966,z:-.01929756999015808},{x:.6588467955589294,y:.5929454565048218,z:-.008487257175147533},{x:.6720337867736816,y:.530631422996521,z:.043437421321868896},{x:.584305465221405,y:.6099005341529846,z:-.030301367864012718},{x:.6034283638000488,y:.6217452883720398,z:-.001970183802768588},{x:.6460927724838257,y:.8608663082122803,z:.015541625209152699},{x:.6957815289497375,y:.8326103091239929,z:.13015234470367432},{x:.6043362617492676,y:.7861682772636414,z:-.030476901680231094},{x:.594293475151062,y:.7942103147506714,z:-.032218821346759796},{x:.6324057579040527,y:.8665139675140381,z:.014255806803703308},{x:.6296147704124451,y:.8667733669281006,z:.010388285852968693},{x:.663644552230835,y:.5798642635345459,z:-.0022301070857793093},{x:.6140630841255188,y:.7809288501739502,z:-.02835679054260254},{x:.615908145904541,y:.5921698212623596,z:-.026804860681295395},{x:.617181122303009,y:.5748661756515503,z:-.03060605563223362},{x:.6222207546234131,y:.49137672781944275,z:-.011151673272252083},{x:.6669357419013977,y:.5541607141494751,z:.017466170713305473},{x:.6182981729507446,y:.5320425629615784,z:-.021793590858578682},{x:.6760554313659668,y:.595052182674408,z:.017115700989961624},{x:.6801463961601257,y:.5800720453262329,z:.043127160519361496},{x:.5922210812568665,y:.8644017577171326,z:-.02662893570959568},{x:.6054555177688599,y:.8637874722480774,z:-.018363753333687782},{x:.6161889433860779,y:.8641164898872375,z:-.008808949030935764},{x:.6017249822616577,y:.7901403307914734,z:-.028126630932092667},{x:.631446123123169,y:.8664817810058594,z:.012112865224480629},{x:.6249198913574219,y:.8716511130332947,z:.003882825840264559},{x:.6281915903091431,y:.867301881313324,z:.009891441091895103},{x:.5986843109130859,y:.7813931703567505,z:-.050227612257003784},{x:.6126407384872437,y:.869275689125061,z:-.0031255714129656553},{x:.6027271151542664,y:.8711842894554138,z:-.009324162267148495},{x:.59088134765625,y:.8742044568061829,z:-.014608660712838173},{x:.5984604358673096,y:.9216185212135315,z:-.005981989670544863},{x:.5950398445129395,y:.8964707255363464,z:-.01703473925590515},{x:.5941568613052368,y:.8882410526275635,z:-.017784785479307175},{x:.5928806662559509,y:.8803883194923401,z:-.014153128489851952},{x:.5909661054611206,y:.8748103976249695,z:-.012609979137778282},{x:.6128016710281372,y:.8702545762062073,z:-.0022550546564161777},{x:.6150846481323242,y:.8726804256439209,z:-.00414019962772727},{x:.6173093914985657,y:.8770190477371216,z:-.005970994010567665},{x:.619335412979126,y:.8814800977706909,z:-.0036864024586975574},{x:.6292637586593628,y:.8314558267593384,z:-.007714875973761082},{x:.702275276184082,y:.7320667505264282,z:.1433621346950531},{x:.6204835176467896,y:.8689177632331848,z:.0044869170524179935},{x:.6223508715629578,y:.8704851269721985,z:.00352082890458405},{x:.590448260307312,y:.8029727935791016,z:-.03200828656554222},{x:.6097423434257507,y:.7933741211891174,z:-.018042555078864098},{x:.59229576587677,y:.7993767261505127,z:-.032564569264650345},{x:.6171364188194275,y:.7153720259666443,z:-.007672437466681004},{x:.6389747858047485,y:.726390540599823,z:-.002999067772179842},{x:.6151940226554871,y:.769412100315094,z:-.024427521973848343},{x:.6526776552200317,y:.505868136882782,z:.01412637997418642},{x:.6475822329521179,y:.5375454425811768,z:-.0033899128902703524},{x:.6433356404304504,y:.5714520215988159,z:-.017428796738386154},{x:.626949667930603,y:.8962116837501526,z:.005602736957371235},{x:.5868416428565979,y:.5829002261161804,z:-.03727729618549347},{x:.5877229571342468,y:.5345035791397095,z:-.032396964728832245},{x:.5887066125869751,y:.48655083775520325,z:-.025856535881757736},{x:.6507197618484497,y:.6612282991409302,z:.011114613153040409},{x:.6803066730499268,y:.677992045879364,z:.032125361263751984},{x:.5963194370269775,y:.6598632335662842,z:.002976928371936083},{x:.667536199092865,y:.6274255514144897,z:.015618261881172657},{x:.5930740833282471,y:.6940041780471802,z:-.019217798486351967},{x:.6053346395492554,y:.7676517963409424,z:-.050308309495449066},{x:.6934473514556885,y:.6884298920631409,z:.04794462397694588},{x:.6738007664680481,y:.6934011578559875,z:.020697161555290222},{x:.6588084697723389,y:.7033141851425171,z:.008462334051728249},{x:.6346072554588318,y:.7029502391815186,z:.001542167621664703},{x:.6157816648483276,y:.6966525912284851,z:-.002009218093007803},{x:.6015574336051941,y:.688928484916687,z:-.006588225718587637},{x:.5746836066246033,y:.6711069345474243,z:-.03597589209675789},{x:.6947521567344666,y:.7309479117393494,z:.046707939356565475},{x:.6759101152420044,y:.6249120831489563,z:.021654341369867325},{x:.5794773101806641,y:.7971615195274353,z:-.06339326500892639},{x:.6041849851608276,y:.727514922618866,z:-.017512541264295578},{x:.6968844532966614,y:.6440950036048889,z:.12727996706962585},{x:.5910853147506714,y:.679325520992279,z:-.009497715160250664},{x:.6157375574111938,y:.7695677280426025,z:-.010624290443956852},{x:.6606494784355164,y:.6410489678382874,z:.0208158977329731},{x:.6040687561035156,y:.7531470656394958,z:-.045887019485235214},{x:.7012156248092651,y:.780247151851654,z:.14028730988502502},{x:.595149576663971,y:.6527782678604126,z:.006308757700026035},{x:.5925500392913818,y:.7436665892601013,z:-.060151755809783936},{x:.6780198812484741,y:.8905693888664246,z:.0626060739159584},{x:.676746666431427,y:.9113880395889282,z:.08726003766059875},{x:.7030686140060425,y:.7312687635421753,z:.09529774636030197},{x:.688987135887146,y:.8588417172431946,z:.07752864807844162},{x:.6883691549301147,y:.6109960675239563,z:.06669612973928452},{x:.6358906030654907,y:.9702065587043762,z:.023120900616049767},{x:.5781539678573608,y:.8023634552955627,z:-.044763918966054916},{x:.6170316934585571,y:.7408350706100464,z:-.011375460773706436},{x:.688542366027832,y:.6516284346580505,z:.050206027925014496},{x:.6385149359703064,y:.6540714502334595,z:.006462941411882639},{x:.6279382109642029,y:.6563615798950195,z:.003062846139073372},{x:.6268895268440247,y:.8736732006072998,z:.00627936702221632},{x:.6944946050643921,y:.7709181308746338,z:.053824134171009064},{x:.614617109298706,y:1.0022112131118774,z:.02719894051551819},{x:.6493719220161438,y:.9665167927742004,z:.053563784807920456},{x:.6624587178230286,y:.943530797958374,z:.068605437874794},{x:.6162528991699219,y:.6558693051338196,z:.002187855076044798},{x:.6058168411254883,y:.654328465461731,z:.0036193584091961384},{x:.5987918972969055,y:.6536934971809387,z:.006134530063718557},{x:.6831037402153015,y:.6195642948150635,z:.03511790186166763},{x:.6062582731246948,y:.6356398463249207,z:.001280312892049551},{x:.6174948811531067,y:.62776118516922,z:-.0013642468256875873},{x:.6297246217727661,y:.6253792643547058,z:-.0007034156005829573},{x:.6407091617584229,y:.627578616142273,z:.0028144705574959517},{x:.6479622721672058,y:.6322650909423828,z:.00750273372977972},{x:.6915091276168823,y:.5990704298019409,z:.10270945727825165},{x:.6457163095474243,y:.6504453420639038,z:.010696077719330788},{x:.6164222955703735,y:.8231936097145081,z:-.016772059723734856},{x:.6042401194572449,y:.7830976843833923,z:-.03630910441279411},{x:.5922216773033142,y:.8228387236595154,z:-.029992375522851944},{x:.6646111011505127,y:.92097008228302,z:.050967294722795486},{x:.651232898235321,y:.9460107088088989,z:.038000158965587616},{x:.6140977144241333,y:.9882472157478333,z:.009882091544568539},{x:.6870781183242798,y:.8768675327301025,z:.10980932414531708},{x:.5986856818199158,y:.6456438899040222,z:.003999010659754276},{x:.585981547832489,y:.7034481763839722,z:-.0377722829580307},{x:.6342031359672546,y:.9867448806762695,z:.03786521404981613},{x:.7013950943946838,y:.776049017906189,z:.09598205983638763},{x:.6030206680297852,y:.8719133138656616,z:-.007931148633360863},{x:.6050592064857483,y:.8767156004905701,z:-.009791925549507141},{x:.6073468923568726,y:.8831382393836975,z:-.012361008673906326},{x:.6087977290153503,y:.890143632888794,z:-.01098148338496685},{x:.6147705316543579,y:.9110084772109985,z:-.0018823575228452682},{x:.622577965259552,y:.8670604825019836,z:.002609190298244357},{x:.6241236329078674,y:.8651344180107117,z:.0025534380692988634},{x:.6257084608078003,y:.8638408184051514,z:.0023300074972212315},{x:.639931321144104,y:.8449671268463135,z:.0038123116828501225},{x:.6810906529426575,y:.7856625318527222,z:.02717764675617218},{x:.583532452583313,y:.6811994910240173,z:-.026588857173919678},{x:.5855660438537598,y:.6393819451332092,z:-.004512844607234001},{x:.5932201743125916,y:.6398029327392578,z:.0008020466193556786},{x:.6200879812240601,y:.8683351874351501,z:.00417016725987196},{x:.6842559576034546,y:.8330534100532532,z:.050836317241191864},{x:.5754412412643433,y:.6418221592903137,z:-.022838059812784195},{x:.6232790350914001,y:.9295297265052795,z:.006339520215988159},{x:.5764067769050598,y:.694546639919281,z:-.04825803264975548},{x:.59778892993927,y:.7343927621841431,z:-.035004377365112305},{x:.6042810678482056,y:.9441440105438232,z:-.0010970570147037506},{x:.6496372222900391,y:.8869078159332275,z:.021036235615611076},{x:.6274012327194214,y:.7830310463905334,z:-.006658440921455622},{x:.637792706489563,y:.9104999899864197,z:.014290250837802887},{x:.6549934148788452,y:.7748609185218811,z:-.0006672973395325243},{x:.6404005289077759,y:.801220715045929,z:-.0026642554439604282},{x:.6671456694602966,y:.8045546412467957,z:.013180811889469624},{x:.6107483506202698,y:.9680658578872681,z:.001778992242179811},{x:.6060343980789185,y:.744587242603302,z:-.024382334202528},{x:.6602751612663269,y:.8998945355415344,z:.0344940721988678},{x:.6463775038719177,y:.9262562394142151,z:.02617623284459114},{x:.6579852104187012,y:.8602304458618164,z:.021586716175079346},{x:.6926165223121643,y:.8053340315818787,z:.061075080186128616},{x:.6724731922149658,y:.8594399690628052,z:.03457934781908989},{x:.6975721716880798,y:.8183245062828064,z:.09300774335861206},{x:.6512877941131592,y:.8258221745491028,z:.006324059329926968},{x:.594887375831604,y:.7148372530937195,z:-.026898479089140892},{x:.6017440557479858,y:.7773507833480835,z:-.05312420800328255},{x:.6096571683883667,y:.7806998491287231,z:-.037646256387233734},{x:.5952993035316467,y:.7654367685317993,z:-.06398405134677887},{x:.5950021147727966,y:.6201304793357849,z:-.009297547861933708},{x:.6165438890457153,y:.6052900552749634,z:-.012455573305487633},{x:.6362661719322205,y:.6015968918800354,z:-.011649220250546932},{x:.6522727608680725,y:.6046400666236877,z:-.005903332494199276},{x:.6625409722328186,y:.6128141283988953,z:.0030042496509850025},{x:.6688099503517151,y:.6457712054252625,z:.026322703808546066},{x:.7013440728187561,y:.6893666386604309,z:.08984331786632538},{x:.6608623266220093,y:.6749406456947327,z:.0172116681933403},{x:.6482325196266174,y:.6823726296424866,z:.008881398476660252},{x:.6313265562057495,y:.6842025518417358,z:.0031308617908507586},{x:.6147016286849976,y:.6809731721878052,z:.0007630771724507213},{x:.6018834114074707,y:.6755372285842896,z:-.0008834321051836014},{x:.5925027132034302,y:.670681357383728,z:-.001968748401850462},{x:.700127363204956,y:.6871103644371033,z:.13980500400066376},{x:.6095665693283081,y:.7853189706802368,z:-.03074747882783413},{x:.5880423784255981,y:.7229287028312683,z:-.04691500961780548},{x:.5930182337760925,y:.7811514139175415,z:-.06398335844278336},{x:.5867722034454346,y:.7922660112380981,z:-.05794971063733101},{x:.5933279991149902,y:.7842848896980286,z:-.05714067071676254},{x:.6063535809516907,y:.7920218706130981,z:-.02590685710310936},{x:.5839452743530273,y:.794978141784668,z:-.0615212507545948},{x:.5828126072883606,y:.8000800013542175,z:-.0449722595512867},{x:.5909603834152222,y:.6541213393211365,z:.003991890233010054},{x:.5852181911468506,y:.6602938771247864,z:-.004428438376635313},{x:.5825737714767456,y:.6651063561439514,z:-.014345290139317513},{x:.6517343521118164,y:.6362385153770447,z:.012151890434324741},{x:.6615052819252014,y:.6281577944755554,z:.0123682152479887},{x:.4856873154640198,y:.6568945646286011,z:.000720038078725338},{x:.49988406896591187,y:.6547410488128662,z:.0006949726957827806},{x:.48438939452171326,y:.6392973065376282,z:.000705525919329375},{x:.47143134474754333,y:.6589511632919312,z:.0006980331381782889},{x:.48704618215560913,y:.6752797961235046,z:.0006921177846379578},{x:.6243702173233032,y:.640461802482605,z:-6592126737814397e-20},{x:.6390967965126038,y:.6385173797607422,z:-.00016105435497593135},{x:.6230536699295044,y:.6224825382232666,z:-.00016136496560648084},{x:.6095397472381592,y:.641917884349823,z:-.0001803556369850412},{x:.6250996589660645,y:.6586247682571411,z:-.0001785515050869435}]],faceBlendshapes:[{categories:[{index:0,score:5187174338061595e-21,categoryName:"_neutral",displayName:""},{index:1,score:.24521504342556,categoryName:"browDownLeft",displayName:""},{index:2,score:.1987743377685547,categoryName:"browDownRight",displayName:""},{index:3,score:.013400448486208916,categoryName:"browInnerUp",displayName:""},{index:4,score:.012361560948193073,categoryName:"browOuterUpLeft",displayName:""},{index:5,score:.019305096939206123,categoryName:"browOuterUpRight",displayName:""},{index:6,score:28426356948330067e-21,categoryName:"cheekPuff",displayName:""},{index:7,score:3.4500112633395474e-7,categoryName:"cheekSquintLeft",displayName:""},{index:8,score:4.83789051486383e-7,categoryName:"cheekSquintRight",displayName:""},{index:9,score:.07650448381900787,categoryName:"eyeBlinkLeft",displayName:""},{index:10,score:.05070012807846069,categoryName:"eyeBlinkRight",displayName:""},{index:11,score:.13978900015354156,categoryName:"eyeLookDownLeft",displayName:""},{index:12,score:.14198613166809082,categoryName:"eyeLookDownRight",displayName:""},{index:13,score:.2177766114473343,categoryName:"eyeLookInLeft",displayName:""},{index:14,score:.014739357866346836,categoryName:"eyeLookInRight",displayName:""},{index:15,score:.02361512929201126,categoryName:"eyeLookOutLeft",displayName:""},{index:16,score:.19679604470729828,categoryName:"eyeLookOutRight",displayName:""},{index:17,score:.04874616861343384,categoryName:"eyeLookUpLeft",displayName:""},{index:18,score:.049392376095056534,categoryName:"eyeLookUpRight",displayName:""},{index:19,score:.34944331645965576,categoryName:"eyeSquintLeft",displayName:""},{index:20,score:.2939716875553131,categoryName:"eyeSquintRight",displayName:""},{index:21,score:.005955042317509651,categoryName:"eyeWideLeft",displayName:""},{index:22,score:.006776117719709873,categoryName:"eyeWideRight",displayName:""},{index:23,score:16942436559475027e-21,categoryName:"jawForward",displayName:""},{index:24,score:.0045165494084358215,categoryName:"jawLeft",displayName:""},{index:25,score:.07803940027952194,categoryName:"jawOpen",displayName:""},{index:26,score:2090057751047425e-20,categoryName:"jawRight",displayName:""},{index:27,score:.06032035872340202,categoryName:"mouthClose",displayName:""},{index:28,score:.00228882092051208,categoryName:"mouthDimpleLeft",displayName:""},{index:29,score:.00781762320548296,categoryName:"mouthDimpleRight",displayName:""},{index:30,score:.0017093931091949344,categoryName:"mouthFrownLeft",displayName:""},{index:31,score:.0019319106359034777,categoryName:"mouthFrownRight",displayName:""},{index:32,score:8485237776767462e-20,categoryName:"mouthFunnel",displayName:""},{index:33,score:.0009051355300471187,categoryName:"mouthLeft",displayName:""},{index:34,score:.0003630454302765429,categoryName:"mouthLowerDownLeft",displayName:""},{index:35,score:.00017601238505449146,categoryName:"mouthLowerDownRight",displayName:""},{index:36,score:.12865161895751953,categoryName:"mouthPressLeft",displayName:""},{index:37,score:.20137207210063934,categoryName:"mouthPressRight",displayName:""},{index:38,score:.0022203284315764904,categoryName:"mouthPucker",displayName:""},{index:39,score:.0009096377179957926,categoryName:"mouthRight",displayName:""},{index:40,score:.34189721941947937,categoryName:"mouthRollLower",displayName:""},{index:41,score:.11409689486026764,categoryName:"mouthRollUpper",displayName:""},{index:42,score:.17172536253929138,categoryName:"mouthShrugLower",displayName:""},{index:43,score:.004038424696773291,categoryName:"mouthShrugUpper",displayName:""},{index:44,score:.00023205230536404997,categoryName:"mouthSmileLeft",displayName:""},{index:45,score:.00019313619122840464,categoryName:"mouthSmileRight",displayName:""},{index:46,score:.0018571305554360151,categoryName:"mouthStretchLeft",displayName:""},{index:47,score:.0023813238367438316,categoryName:"mouthStretchRight",displayName:""},{index:48,score:24323100660694763e-21,categoryName:"mouthUpperUpLeft",displayName:""},{index:49,score:3161552012898028e-20,categoryName:"mouthUpperUpRight",displayName:""},{index:50,score:1.08198406678639e-7,categoryName:"noseSneerLeft",displayName:""},{index:51,score:12652527630052646e-22,categoryName:"noseSneerRight",displayName:""}],headIndex:-1,headName:""}],facialTransformationMatrixes:[{rows:4,columns:4,data:[.9947517514228821,.10230544209480286,.0013679931871592999,0,-.10230997204780579,.9947447776794434,.003816320328041911,0,-.000970348424743861,-.0039362297393381596,.9999914169311523,0,2.8888821601867676,-7.808934211730957,-30.52109146118164,1]}]}},ct=t.createContext({}),ut={basePath:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.2-rc2/wasm",options:{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0}};function mt(){return t.useContext(ct)}function dt(e,t){return e.clone().add(t).multiplyScalar(.5)}function ft(e,t,r){const n=e.localToWorld(t);return r.worldToLocal(n)}const pt=t.createContext({}),ht=t.forwardRef((({camera:r,autostart:n=!0,webcam:a=!0,webcamVideoTextureSrc:i,manualUpdate:l=!1,manualDetect:c=!1,onVideoFrame:u,smoothTime:m=.25,offset:d=!0,offsetScalar:f=80,eyes:p=!1,eyesAsOrigin:h=!0,depth:x=.15,debug:y=!1,facemesh:v,makeDefault:g},z)=>{var w,b;const E=o.useThree((e=>e.scene)),M=o.useThree((e=>e.camera)),S=o.useThree((e=>e.set)),C=o.useThree((e=>e.get)),R=r||M,D=t.useRef(null),F=t.useRef(null),[k]=t.useState((()=>new P.Object3D)),[_]=t.useState((()=>new P.Vector3)),[L]=t.useState((()=>new P.Vector3)),[A]=t.useState((()=>new P.Vector3)),[B]=t.useState((()=>new P.Vector3)),U=t.useCallback((()=>{k.parent=R.parent;const e=F.current;if(e){const{outerRef:t,eyeRightRef:r,eyeLeftRef:n}=e;if(r.current&&n.current){const{irisDirRef:e}=r.current,{irisDirRef:o}=n.current;e.current&&o.current&&t.current&&(_.copy(ft(e.current,new P.Vector3(0,0,0),t.current)),L.copy(ft(o.current,new P.Vector3(0,0,0),t.current)),k.position.copy(ft(t.current,dt(_,L),R.parent||E)),A.copy(ft(e.current,new P.Vector3(0,0,1),t.current)),B.copy(ft(o.current,new P.Vector3(0,0,1),t.current)),k.lookAt(t.current.localToWorld(dt(A,B))))}else t.current&&(k.position.copy(ft(t.current,new P.Vector3(0,0,0),R.parent||E)),k.lookAt(t.current.localToWorld(new P.Vector3(0,0,1))))}return k}),[R,L,B,_,A,E,k]),[O]=t.useState((()=>new P.Object3D)),N=t.useCallback((function(e,t){if(R){var r;if(null!==(r=t)&&void 0!==r||(t=U()),m>0){const r=1e-9;s.easing.damp3(O.position,t.position,m,e,void 0,void 0,r),s.easing.dampE(O.rotation,t.rotation,m,e,void 0,void 0,r)}else O.position.copy(t.position),O.rotation.copy(t.rotation);R.position.copy(O.position),R.rotation.copy(O.rotation)}}),[R,U,m,O.position,O.rotation]),[I,V]=t.useState(),j=mt(),W=t.useCallback(((e,t)=>{const r=null==j?void 0:j.detectForVideo(e,t);V(r)}),[j]);o.useFrame(((e,t)=>{l||N(t)}));const G=t.useMemo((()=>Object.assign(Object.create(P.EventDispatcher.prototype),{detect:W,computeTarget:U,update:N,facemeshApiRef:F,webcamApiRef:D,play:()=>{var e,t;null==(e=D.current)||null==(t=e.videoTextureApiRef.current)||t.texture.source.data.play()},pause:()=>{var e,t;null==(e=D.current)||null==(t=e.videoTextureApiRef.current)||t.texture.source.data.pause()}})),[W,U,N]);t.useImperativeHandle(z,(()=>G),[G]),t.useEffect((()=>{const e=e=>{c||W(e.texture.source.data,e.time),u&&u(e)};return G.addEventListener("videoFrame",e),()=>{G.removeEventListener("videoFrame",e)}}),[G,W,j,c,u]),t.useEffect((()=>{if(g){const e=C().controls;return S({controls:G}),()=>S({controls:e})}}),[g,G,C,S]);const H=null==I?void 0:I.faceLandmarks[0],q=null==I||null==(w=I.facialTransformationMatrixes)?void 0:w[0],$=null==I||null==(b=I.faceBlendshapes)?void 0:b[0];return T.createElement(pt.Provider,{value:G},a&&T.createElement(t.Suspense,{fallback:null},T.createElement(yt,{ref:D,autostart:n,videoTextureSrc:i})),T.createElement(at,e({ref:F},v,{points:H,depth:x,facialTransformationMatrix:q,faceBlendshapes:$,eyes:p,eyesAsOrigin:h,offset:d,offsetScalar:f,debug:y,"rotation-z":Math.PI,visible:y}),T.createElement("meshBasicMaterial",{side:P.DoubleSide})))})),xt=()=>t.useContext(pt),yt=t.forwardRef((({videoTextureSrc:e,autostart:r=!0},n)=>{const o=t.useRef(null),a=xt(),i=p.suspend((async()=>e?Promise.resolve(null):await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"user"}})),[e]);t.useEffect((()=>(a.dispatchEvent({type:"stream",stream:i}),()=>{null==i||i.getTracks().forEach((e=>e.stop())),p.clear([e])})),[i,a,e]);const s=t.useMemo((()=>({videoTextureApiRef:o})),[]);return t.useImperativeHandle(n,(()=>s),[s]),T.createElement(t.Suspense,{fallback:null},T.createElement(vt,{ref:o,src:e||i,start:r}))})),vt=t.forwardRef((({src:e,start:r},n)=>{const o=rt(e,{start:r}),a=o.source.data,i=xt(),s=t.useCallback((e=>{i.dispatchEvent({type:"videoFrame",texture:o,time:e})}),[o,i]);gt(a,s);const l=t.useMemo((()=>({texture:o})),[o]);return t.useImperativeHandle(n,(()=>l),[l]),T.createElement(T.Fragment,null)})),gt=(e,r)=>{t.useEffect((()=>{if(!e||!e.requestVideoFrameCallback)return;let t;return e.requestVideoFrameCallback((function n(...o){r(...o),t=e.requestVideoFrameCallback(n)})),()=>e.cancelVideoFrameCallback(t)}),[e,r])};function zt({defaultScene:e,defaultCamera:t,renderPriority:r=1}){const{gl:n,scene:a,camera:i}=o.useThree();let s;return o.useFrame((()=>{s=n.autoClear,1===r&&(n.autoClear=!0,n.render(e,t)),n.autoClear=!1,n.clearDepth(),n.render(a,i),n.autoClear=s}),r),T.createElement("group",{onPointerOver:()=>null})}function wt({children:e,renderPriority:t=1}){const{scene:r,camera:n}=o.useThree(),[a]=T.useState((()=>new P.Scene));return T.createElement(T.Fragment,null,o.createPortal(T.createElement(T.Fragment,null,e,T.createElement(zt,{defaultScene:r,defaultCamera:n,renderPriority:t})),a,{events:{priority:t+1}}))}const bt=T.createContext({}),Et=()=>T.useContext(bt),Mt=2*Math.PI,St=new n.Object3D,Tt=new n.Matrix4,[Ct,Pt]=[new n.Quaternion,new n.Quaternion],Rt=new n.Vector3,Dt=new n.Vector3,Ft="#f0f0f0",kt="#999",_t="black",Lt="black",At=["Right","Left","Top","Bottom","Front","Back"],Bt=e=>new n.Vector3(...e).multiplyScalar(.38),Ut=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]].map(Bt),Ot=[.25,.25,.25],Nt=[[1,1,0],[1,0,1],[1,0,-1],[1,-1,0],[0,1,1],[0,1,-1],[0,-1,1],[0,-1,-1],[-1,1,0],[-1,0,1],[-1,0,-1],[-1,-1,0]].map(Bt),It=Nt.map((e=>e.toArray().map((e=>0==e?.5:.25)))),Vt=({hover:e,index:t,font:r="20px Inter var, Arial, sans-serif",faces:a=At,color:i=Ft,hoverColor:s=kt,textColor:l=_t,strokeColor:c=Lt,opacity:u=1})=>{const m=o.useThree((e=>e.gl)),d=T.useMemo((()=>{const e=document.createElement("canvas");e.width=128,e.height=128;const o=e.getContext("2d");return o.fillStyle=i,o.fillRect(0,0,e.width,e.height),o.strokeStyle=c,o.strokeRect(0,0,e.width,e.height),o.font=r,o.textAlign="center",o.fillStyle=l,o.fillText(a[t].toUpperCase(),64,76),new n.CanvasTexture(e)}),[t,a,r,i,l,c]);return T.createElement("meshBasicMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,attach:`material-${t}`,color:e?s:"white",transparent:!0,opacity:u})},jt=t=>{const{tweenCamera:r}=Et(),[n,o]=T.useState(null);return T.createElement("mesh",{onPointerOut:e=>{e.stopPropagation(),o(null)},onPointerMove:e=>{e.stopPropagation(),o(Math.floor(e.faceIndex/2))},onClick:t.onClick||(e=>{e.stopPropagation(),r(e.face.normal)})},[...Array(6)].map(((r,o)=>T.createElement(Vt,e({key:o,index:o,hover:n===o},t)))),T.createElement("boxGeometry",null))},Wt=({onClick:e,dimensions:t,position:r,hoverColor:n=kt})=>{const{tweenCamera:o}=Et(),[a,i]=T.useState(!1);return T.createElement("mesh",{scale:1.01,position:r,onPointerOver:e=>{e.stopPropagation(),i(!0)},onPointerOut:e=>{e.stopPropagation(),i(!1)},onClick:e||(e=>{e.stopPropagation(),o(r)})},T.createElement("meshBasicMaterial",{color:a?n:"white",transparent:!0,opacity:.6,visible:a}),T.createElement("boxGeometry",{args:t}))};function Gt({scale:e=[.8,.05,.05],color:t,rotation:r}){return T.createElement("group",{rotation:r},T.createElement("mesh",{position:[.4,0,0]},T.createElement("boxGeometry",{args:e}),T.createElement("meshBasicMaterial",{color:t,toneMapped:!1})))}function Ht({onClick:t,font:r,disabled:a,arcStyle:i,label:s,labelColor:l,axisHeadScale:c=1,...u}){const m=o.useThree((e=>e.gl)),d=T.useMemo((()=>{const e=document.createElement("canvas");e.width=64,e.height=64;const t=e.getContext("2d");return t.beginPath(),t.arc(32,32,16,0,2*Math.PI),t.closePath(),t.fillStyle=i,t.fill(),s&&(t.font=r,t.textAlign="center",t.fillStyle=l,t.fillText(s,32,41)),new n.CanvasTexture(e)}),[i,s,l,r]),[f,p]=T.useState(!1),h=(s?1:.75)*(f?1.2:1)*c;return T.createElement("sprite",e({scale:h,onPointerOver:a?void 0:e=>{e.stopPropagation(),p(!0)},onPointerOut:a?void 0:t||(e=>{e.stopPropagation(),p(!1)})},u),T.createElement("spriteMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:s?1:.75,toneMapped:!1}))}const qt=xe({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new P.Color,sectionColor:new P.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new P.Vector3,worldPlanePosition:new P.Vector3},"\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform vec3 worldPlanePosition;\n uniform float fadeDistance;\n uniform bool infiniteGrid;\n uniform bool followCamera;\n\n void main() {\n localPosition = position.xzy;\n if (infiniteGrid) localPosition *= 1.0 + fadeDistance;\n \n worldPosition = modelMatrix * vec4(localPosition, 1.0);\n if (followCamera) {\n worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);\n localPosition = (inverse(modelMatrix) * worldPosition).xyz;\n }\n\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n }\n ","\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n\n float getGrid(float size, float thickness) {\n vec2 r = localPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1.0 - thickness;\n return 1.0 - min(line, 1.0);\n }\n\n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n\n float dist = distance(worldCamProjPosition, worldPosition.xyz);\n float d = 1.0 - min(dist / fadeDistance, 1.0);\n vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));\n\n gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }\n "),$t=T.forwardRef((({args:t,cellColor:r="#000000",sectionColor:n="#2080ff",cellSize:a=.5,sectionSize:s=1,followCamera:l=!1,infiniteGrid:c=!1,fadeDistance:u=100,fadeStrength:m=1,cellThickness:d=.5,sectionThickness:f=1,side:p=P.BackSide,...h},x)=>{o.extend({GridMaterial:qt});const y=T.useRef(null);o.useFrame((e=>{const t=(new P.Plane).setFromNormalAndCoplanarPoint(new P.Vector3(0,1,0),new P.Vector3(0,0,0)).applyMatrix4(y.current.matrixWorld),r=y.current.material,n=r.uniforms.worldCamProjPosition,o=r.uniforms.worldPlanePosition;t.projectPoint(e.camera.position,n.value),o.value.set(0,0,0).applyMatrix4(y.current.matrixWorld)}));const v={cellSize:a,sectionSize:s,cellColor:r,sectionColor:n,cellThickness:d,sectionThickness:f},g={fadeDistance:u,fadeStrength:m,infiniteGrid:c,followCamera:l};return T.createElement("mesh",e({ref:i([y,x]),frustumCulled:!1},h),T.createElement("gridMaterial",e({transparent:!0,"extensions-derivatives":!0,side:p},v,g)),T.createElement("planeGeometry",{args:t}))}));function Xt(e,{path:t}){const[r]=o.useLoader(n.CubeTextureLoader,[e],(e=>e.setPath(t)));return r}function Yt(e){return o.useLoader(m.FBXLoader,e)}Xt.preload=(e,{path:t})=>o.useLoader.preload(n.CubeTextureLoader,[e],(e=>e.setPath(t))),Yt.preload=e=>o.useLoader.preload(m.FBXLoader,e),Yt.clear=e=>o.useLoader.clear(m.FBXLoader,e);const Kt="https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master";function Zt(e,r=`${Kt}/basis/`){const n=o.useThree((e=>e.gl)),a=o.useLoader(m.KTX2Loader,ye(e)?Object.values(e):e,(e=>{e.detectSupport(n),e.setTranscoderPath(r)}));if(t.useEffect((()=>{(Array.isArray(a)?a:[a]).forEach(n.initTexture)}),[n,a]),ye(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:a[t.indexOf(e)]}))),r}return a}function Qt(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}Zt.preload=(e,t=`${Kt}/basis/`)=>o.useLoader.preload(m.KTX2Loader,e,(e=>{e.setTranscoderPath(t)})),Zt.clear=e=>o.useLoader.clear(m.KTX2Loader,e);function Jt(e,t,...r){const n=T.useRef(),a=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>{let o;if(e&&null!=e&&e.current&&t&&(n.current=o=new t(e.current,...r)),o)return o.traverse((e=>e.raycast=()=>null)),a.add(o),()=>{n.current=void 0,a.remove(o),null==o.dispose||o.dispose()}}),[a,t,e,...r]),o.useFrame((()=>{var e;null==(e=n.current)||null==e.update||e.update()})),n}const er=e=>e.isMesh;const tr=T.forwardRef((({enabled:t=!0,firstHitOnly:r=!1,children:a,strategy:i=b.SAH,verbose:s=!1,setBoundingBox:l=!0,maxDepth:c=40,maxLeafTris:u=10,...m},d)=>{const f=T.useRef(null),p=o.useThree((e=>e.raycaster));return T.useImperativeHandle(d,(()=>f.current),[]),T.useEffect((()=>{if(t){const e={strategy:i,verbose:s,setBoundingBox:l,maxDepth:c,maxLeafTris:u},t=f.current;return p.firstHitOnly=r,t.traverse((t=>{er(t)&&!t.geometry.boundsTree&&t.raycast===n.Mesh.prototype.raycast&&(t.raycast=b.acceleratedRaycast,t.geometry.computeBoundsTree=b.computeBoundsTree,t.geometry.disposeBoundsTree=b.disposeBoundsTree,t.geometry.computeBoundsTree(e))})),()=>{delete p.firstHitOnly,t.traverse((e=>{er(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=n.Mesh.prototype.raycast)}))}}})),T.createElement("group",e({ref:f},m),a)}));function rr(e){const t=T.useRef(null),r=T.useRef(!1),n=T.useRef(!1),a=T.useRef(e);return T.useLayoutEffect((()=>{a.current=e}),[e]),T.useEffect((()=>{const e=t.current;if(e){const t=o.addEffect((()=>(r.current=!1,!0))),i=e.onBeforeRender;e.onBeforeRender=()=>r.current=!0;const s=o.addAfterEffect((()=>(r.current!==n.current&&(null==a.current||a.current(n.current=r.current)),!0)));return()=>{e.onBeforeRender=i,t(),s()}}}),[]),t}const nr="\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n #ifdef BOX_PROJECTED_ENV_MAP\n vWorldPosition = worldPosition.xyz;\n #endif\n#endif\n",or="\n#ifdef BOX_PROJECTED_ENV_MAP\n uniform vec3 envMapSize;\n uniform vec3 envMapPosition;\n varying vec3 vWorldPosition;\n \n vec3 parallaxCorrectNormal( vec3 v, vec3 cubeSize, vec3 cubePos ) {\n vec3 nDir = normalize( v );\n vec3 rbmax = ( .5 * cubeSize + cubePos - vWorldPosition ) / nDir;\n vec3 rbmin = ( -.5 * cubeSize + cubePos - vWorldPosition ) / nDir;\n vec3 rbminmax;\n rbminmax.x = ( nDir.x > 0. ) ? rbmax.x : rbmin.x;\n rbminmax.y = ( nDir.y > 0. ) ? rbmax.y : rbmin.y;\n rbminmax.z = ( nDir.z > 0. ) ? rbmax.z : rbmin.z;\n float correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z );\n vec3 boxIntersection = vWorldPosition + nDir * correction; \n return boxIntersection - cubePos;\n }\n#endif\n",ar="\n#ifdef BOX_PROJECTED_ENV_MAP\n worldNormal = parallaxCorrectNormal( worldNormal, envMapSize, envMapPosition );\n#endif\n",ir="\n#ifdef BOX_PROJECTED_ENV_MAP\n reflectVec = parallaxCorrectNormal( reflectVec, envMapSize, envMapPosition );\n#endif\n";const sr=new P.Box3,lr=new P.Vector3;const cr=e=>Math.sqrt(1-Math.pow(e-1,2));class ur{constructor({size:e=256,maxAge:t=750,radius:r=.3,intensity:n=.2,interpolate:o=0,smoothing:a=0,minForce:i=.3,blend:s="screen",ease:l=cr}={}){this.size=e,this.maxAge=t,this.radius=r,this.intensity=n,this.ease=l,this.interpolate=o,this.smoothing=a,this.minForce=i,this.blend=s,this.trail=[],this.force=0,this.initTexture()}initTexture(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=this.size,this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.texture=new n.Texture(this.canvas),this.canvas.id="touchTexture",this.canvas.style.width=this.canvas.style.height=`${this.canvas.width}px`}update(e){this.clear(),this.trail.forEach(((t,r)=>{t.age+=1e3*e,t.age>this.maxAge&&this.trail.splice(r,1)})),this.trail.length||(this.force=0),this.trail.forEach((e=>{this.drawTouch(e)})),this.texture.needsUpdate=!0}clear(){this.ctx.globalCompositeOperation="source-over",this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}addTouch(e){const t=this.trail[this.trail.length-1];if(t){const r=t.x-e.x,n=t.y-e.y,o=r*r+n*n,a=Math.max(this.minForce,Math.min(1e4*o,1));if(this.force=function(e,t,r=.9){return t*r+e*(1-r)}(a,this.force,this.smoothing),this.interpolate){const e=Math.ceil(o/Math.pow(.5*this.radius/this.interpolate,2));if(e>1)for(let o=1;o<e;o++)this.trail.push({x:t.x-r/e*o,y:t.y-n/e*o,age:0,force:a})}}this.trail.push({x:e.x,y:e.y,age:0,force:this.force})}drawTouch(e){const t={x:e.x*this.size,y:(1-e.y)*this.size};let r=1;r=e.age<.3*this.maxAge?this.ease(e.age/(.3*this.maxAge)):this.ease(1-(e.age-.3*this.maxAge)/(.7*this.maxAge)),r*=e.force,this.ctx.globalCompositeOperation=this.blend;const n=this.size*this.radius*r,o=this.ctx.createRadialGradient(t.x,t.y,Math.max(0,.25*n),t.x,t.y,Math.max(0,n));o.addColorStop(0,`rgba(255, 255, 255, ${this.intensity})`),o.addColorStop(1,"rgba(0, 0, 0, 0.0)"),this.ctx.beginPath(),this.ctx.fillStyle=o,this.ctx.arc(t.x,t.y,Math.max(0,n),0,2*Math.PI),this.ctx.fill()}}const mr=T.forwardRef((function({children:t,disable:r,disableX:o,disableY:a,disableZ:i,left:s,right:l,top:c,bottom:u,front:m,back:d,onCentered:f,precise:p=!0,cacheKey:h=0,...x},y){const v=T.useRef(null),g=T.useRef(null),z=T.useRef(null);return T.useLayoutEffect((()=>{g.current.matrixWorld.identity();const e=(new n.Box3).setFromObject(z.current,p),t=new n.Vector3,h=new n.Sphere,x=e.max.x-e.min.x,y=e.max.y-e.min.y,w=e.max.z-e.min.z;e.getCenter(t),e.getBoundingSphere(h);const b=c?y/2:u?-y/2:0,E=s?-x/2:l?x/2:0,M=m?w/2:d?-w/2:0;g.current.position.set(r||o?0:-t.x+E,r||a?0:-t.y+b,r||i?0:-t.z+M),void 0!==f&&f({parent:v.current.parent,container:v.current,width:x,height:y,depth:w,boundingBox:e,boundingSphere:h,center:t,verticalAlignment:b,horizontalAlignment:E,depthAlignment:M})}),[h,f,c,s,m,r,o,a,i,p,l,u,d]),T.useImperativeHandle(y,(()=>v.current),[]),T.createElement("group",e({ref:v},x),T.createElement("group",{ref:g},T.createElement("group",{ref:z},t)))})),dr=T.forwardRef((({font:e,color:t="#cbcbcb",bevelSize:r=.04,debug:n=!1,children:o,...a},i)=>{const[s,l]=T.useState(0),c=T.useCallback(((e=1)=>l(s+e)),[s]),u=T.useCallback(((e=1)=>l(s-e)),[s]),m=T.useMemo((()=>({incr:c,decr:u})),[c,u]);return T.useImperativeHandle(i,(()=>m),[m]),T.createElement("group",a,T.createElement(T.Suspense,{fallback:null},T.createElement(mr,{top:!0,cacheKey:JSON.stringify({counter:s,font:e})},T.createElement(fe,{bevelEnabled:!0,bevelSize:r,font:e},n?T.createElement("meshNormalMaterial",{wireframe:!0}):T.createElement("meshStandardMaterial",{color:t}),s))),o)})),fr=T.forwardRef((({children:e,curve:t},r)=>{const[n]=T.useState((()=>new P.Scene)),[a,i]=T.useState(),s=T.useRef();return T.useEffect((()=>{s.current=new m.Flow(n.children[0]),i(s.current.object3D)}),[e]),T.useEffect((()=>{var e;t&&(null==(e=s.current)||e.updateCurve(0,t))}),[t]),T.useImperativeHandle(r,(()=>({moveAlongCurve:e=>{var t;null==(t=s.current)||t.moveAlongCurve(e)}}))),T.createElement(T.Fragment,null,o.createPortal(e,n),a&&T.createElement("primitive",{object:a}))}));class pr extends n.MeshPhysicalMaterial{constructor(e={}){super(e),this.setValues(e),this._time={value:0},this._distort={value:.4},this._radius={value:1}}onBeforeCompile(e){e.uniforms.time=this._time,e.uniforms.radius=this._radius,e.uniforms.distort=this._distort,e.vertexShader=`\n uniform float time;\n uniform float radius;\n uniform float distort;\n #define GLSLIFY 1\nvec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 permute(vec4 x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float snoise(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}\n ${e.vertexShader}\n `,e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n float updateTime = time / 50.0;\n float noise = snoise(vec3(position / 2.0 + updateTime * 5.0));\n vec3 transformed = vec3(position * (noise * pow(distort, 2.0) + radius));\n ")}get time(){return this._time.value}set time(e){this._time.value=e}get distort(){return this._distort.value}set distort(e){this._distort.value=e}get radius(){return this._radius.value}set radius(e){this._radius.value=e}}const hr=T.forwardRef((({speed:t=1,...r},n)=>{const[a]=T.useState((()=>new pr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),T.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class xr extends n.MeshStandardMaterial{constructor(e={}){super(e),this.setValues(e),this._time={value:0},this._factor={value:1}}onBeforeCompile(e){e.uniforms.time=this._time,e.uniforms.factor=this._factor,e.vertexShader=`\n uniform float time;\n uniform float factor;\n ${e.vertexShader}\n `,e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","float theta = sin( time + position.y ) / 2.0 * factor;\n float c = cos( theta );\n float s = sin( theta );\n mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );\n vec3 transformed = vec3( position ) * m;\n vNormal = vNormal * m;")}get time(){return this._time.value}set time(e){this._time.value=e}get factor(){return this._factor.value}set factor(e){this._factor.value=e}}const yr=T.forwardRef((({speed:t=1,...r},n)=>{const[a]=T.useState((()=>new xr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),T.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class vr extends n.ShaderMaterial{constructor(e=new n.Vector2){super({uniforms:{inputBuffer:new n.Uniform(null),depthBuffer:new n.Uniform(null),resolution:new n.Uniform(new n.Vector2),texelSize:new n.Uniform(new n.Vector2),halfTexelSize:new n.Uniform(new n.Vector2),kernel:new n.Uniform(0),scale:new n.Uniform(1),cameraNear:new n.Uniform(0),cameraFar:new n.Uniform(1),minDepthThreshold:new n.Uniform(0),maxDepthThreshold:new n.Uniform(1),depthScale:new n.Uniform(0),depthToBlurRatioBias:new n.Uniform(.25)},fragmentShader:"#include <common>\n #include <dithering_pars_fragment> \n uniform sampler2D inputBuffer;\n uniform sampler2D depthBuffer;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n float depthFactor = 0.0;\n \n #ifdef USE_DEPTH\n vec4 depth = texture2D(depthBuffer, vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0, min(1.0, depthFactor + 0.25));\n #endif\n \n vec4 sum = texture2D(inputBuffer, mix(vUv0, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv1, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv2, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv3, vUv, depthFactor));\n gl_FragColor = sum * 0.25 ;\n\n #include <dithering_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }",vertexShader:"uniform vec2 texelSize;\n uniform vec2 halfTexelSize;\n uniform float kernel;\n uniform float scale;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n vec2 uv = position.xy * 0.5 + 0.5;\n vUv = uv;\n\n vec2 dUv = (texelSize * vec2(kernel) + halfTexelSize) * scale;\n vUv0 = vec2(uv.x - dUv.x, uv.y + dUv.y);\n vUv1 = vec2(uv.x + dUv.x, uv.y + dUv.y);\n vUv2 = vec2(uv.x + dUv.x, uv.y - dUv.y);\n vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y);\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n }",blending:n.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setTexelSize(e.x,e.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}setResolution(e){this.uniforms.resolution.value.copy(e)}}class gr{constructor({gl:e,resolution:t,width:r=500,height:o=500,minDepthThreshold:a=0,maxDepthThreshold:i=1,depthScale:s=0,depthToBlurRatioBias:l=.25}){this.renderToScreen=!1,this.renderTargetA=new n.WebGLRenderTarget(t,t,{minFilter:n.LinearFilter,magFilter:n.LinearFilter,stencilBuffer:!1,depthBuffer:!1,type:n.HalfFloatType}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new vr,this.convolutionMaterial.setTexelSize(1/r,1/o),this.convolutionMaterial.setResolution(new n.Vector2(r,o)),this.scene=new n.Scene,this.camera=new n.Camera,this.convolutionMaterial.uniforms.minDepthThreshold.value=a,this.convolutionMaterial.uniforms.maxDepthThreshold.value=i,this.convolutionMaterial.uniforms.depthScale.value=s,this.convolutionMaterial.uniforms.depthToBlurRatioBias.value=l,this.convolutionMaterial.defines.USE_DEPTH=s>0;const c=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),u=new Float32Array([0,0,2,0,0,2]),m=new n.BufferGeometry;m.setAttribute("position",new n.BufferAttribute(c,3)),m.setAttribute("uv",new n.BufferAttribute(u,2)),this.screen=new n.Mesh(m,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(e,t,r){const n=this.scene,o=this.camera,a=this.renderTargetA,i=this.renderTargetB;let s=this.convolutionMaterial,l=s.uniforms;l.depthBuffer.value=t.depthTexture;const c=s.kernel;let u,m,d,f=t;for(m=0,d=c.length-1;m<d;++m)u=0==(1&m)?a:i,l.kernel.value=c[m],l.inputBuffer.value=f.texture,e.setRenderTarget(u),e.render(n,o),f=u;l.kernel.value=c[m],l.inputBuffer.value=f.texture,e.setRenderTarget(this.renderToScreen?null:r),e.render(n,o)}}let zr=class extends n.MeshStandardMaterial{constructor(e={}){super(e),this._tDepth={value:null},this._distortionMap={value:null},this._tDiffuse={value:null},this._tDiffuseBlur={value:null},this._textureMatrix={value:null},this._hasBlur={value:!1},this._mirror={value:0},this._mixBlur={value:0},this._blurStrength={value:.5},this._minDepthThreshold={value:.9},this._maxDepthThreshold={value:1},this._depthScale={value:0},this._depthToBlurRatioBias={value:.25},this._distortion={value:1},this._mixContrast={value:1},this.setValues(e)}onBeforeCompile(e){var t;null!=(t=e.defines)&&t.USE_UV||(e.defines.USE_UV=""),e.uniforms.hasBlur=this._hasBlur,e.uniforms.tDiffuse=this._tDiffuse,e.uniforms.tDepth=this._tDepth,e.uniforms.distortionMap=this._distortionMap,e.uniforms.tDiffuseBlur=this._tDiffuseBlur,e.uniforms.textureMatrix=this._textureMatrix,e.uniforms.mirror=this._mirror,e.uniforms.mixBlur=this._mixBlur,e.uniforms.mixStrength=this._blurStrength,e.uniforms.minDepthThreshold=this._minDepthThreshold,e.uniforms.maxDepthThreshold=this._maxDepthThreshold,e.uniforms.depthScale=this._depthScale,e.uniforms.depthToBlurRatioBias=this._depthToBlurRatioBias,e.uniforms.distortion=this._distortion,e.uniforms.mixContrast=this._mixContrast,e.vertexShader=`\n uniform mat4 textureMatrix;\n varying vec4 my_vUv;\n ${e.vertexShader}`,e.vertexShader=e.vertexShader.replace("#include <project_vertex>","#include <project_vertex>\n my_vUv = textureMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );"),e.fragmentShader=`\n uniform sampler2D tDiffuse;\n uniform sampler2D tDiffuseBlur;\n uniform sampler2D tDepth;\n uniform sampler2D distortionMap;\n uniform float distortion;\n uniform float cameraNear;\n\t\t\t uniform float cameraFar;\n uniform bool hasBlur;\n uniform float mixBlur;\n uniform float mirror;\n uniform float mixStrength;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float mixContrast;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec4 my_vUv;\n ${e.fragmentShader}`,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>","#include <emissivemap_fragment>\n\n float distortionFactor = 0.0;\n #ifdef USE_DISTORTION\n distortionFactor = texture2D(distortionMap, vUv).r * distortion;\n #endif\n\n vec4 new_vUv = my_vUv;\n new_vUv.x += distortionFactor;\n new_vUv.y += distortionFactor;\n\n vec4 base = texture2DProj(tDiffuse, new_vUv);\n vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);\n\n vec4 merge = base;\n\n #ifdef USE_NORMALMAP\n vec2 normal_uv = vec2(0.0);\n vec4 normalColor = texture2D(normalMap, vUv * normalScale);\n vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );\n vec3 coord = new_vUv.xyz / new_vUv.w;\n normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;\n vec4 base_normal = texture2D(tDiffuse, normal_uv);\n vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);\n merge = base_normal;\n blur = blur_normal;\n #endif\n\n float depthFactor = 0.0001;\n float blurFactor = 0.0;\n\n #ifdef USE_DEPTH\n vec4 depth = texture2DProj(tDepth, new_vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0001, min(1.0, depthFactor));\n\n #ifdef USE_BLUR\n blur = blur * min(1.0, depthFactor + depthToBlurRatioBias);\n merge = merge * min(1.0, depthFactor + 0.5);\n #else\n merge = merge * depthFactor;\n #endif\n\n #endif\n\n float reflectorRoughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv );\n reflectorRoughnessFactor *= reflectorTexelRoughness.g;\n #endif\n\n #ifdef USE_BLUR\n blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor);\n merge = mix(merge, blur, blurFactor);\n #endif\n\n vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0);\n newMerge.r = (merge.r - 0.5) * mixContrast + 0.5;\n newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;\n newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;\n\n diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);\n ")}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(e){this._tDiffuse.value=e}get tDepth(){return this._tDepth.value}set tDepth(e){this._tDepth.value=e}get distortionMap(){return this._distortionMap.value}set distortionMap(e){this._distortionMap.value=e}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(e){this._tDiffuseBlur.value=e}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(e){this._textureMatrix.value=e}get hasBlur(){return this._hasBlur.value}set hasBlur(e){this._hasBlur.value=e}get mirror(){return this._mirror.value}set mirror(e){this._mirror.value=e}get mixBlur(){return this._mixBlur.value}set mixBlur(e){this._mixBlur.value=e}get mixStrength(){return this._blurStrength.value}set mixStrength(e){this._blurStrength.value=e}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(e){this._minDepthThreshold.value=e}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(e){this._maxDepthThreshold.value=e}get depthScale(){return this._depthScale.value}set depthScale(e){this._depthScale.value=e}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(e){this._depthToBlurRatioBias.value=e}get distortion(){return this._distortion.value}set distortion(e){this._distortion.value=e}get mixContrast(){return this._mixContrast.value}set mixContrast(e){this._mixContrast.value=e}};o.extend({MeshReflectorMaterialImpl:zr});const wr=T.forwardRef((({mixBlur:t=0,mixStrength:r=1,resolution:a=256,blur:s=[0,0],minDepthThreshold:l=.9,maxDepthThreshold:c=1,depthScale:u=0,depthToBlurRatioBias:m=.25,mirror:d=0,distortion:f=1,mixContrast:p=1,distortionMap:h,reflectorOffset:x=0,...y},v)=>{const g=o.useThree((({gl:e})=>e)),z=o.useThree((({camera:e})=>e)),w=o.useThree((({scene:e})=>e)),b=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,E=T.useRef(null),[M]=T.useState((()=>new n.Plane)),[S]=T.useState((()=>new n.Vector3)),[C]=T.useState((()=>new n.Vector3)),[P]=T.useState((()=>new n.Vector3)),[R]=T.useState((()=>new n.Matrix4)),[D]=T.useState((()=>new n.Vector3(0,0,-1))),[F]=T.useState((()=>new n.Vector4)),[k]=T.useState((()=>new n.Vector3)),[_]=T.useState((()=>new n.Vector3)),[L]=T.useState((()=>new n.Vector4)),[A]=T.useState((()=>new n.Matrix4)),[B]=T.useState((()=>new n.PerspectiveCamera)),U=T.useCallback((()=>{var e;const t=E.current.parent||(null==(e=E.current)?void 0:e.__r3f.parent);if(!t)return;if(C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(z.matrixWorld),R.extractRotation(t.matrixWorld),S.set(0,0,1),S.applyMatrix4(R),C.addScaledVector(S,x),k.subVectors(C,P),k.dot(S)>0)return;k.reflect(S).negate(),k.add(C),R.extractRotation(z.matrixWorld),D.set(0,0,-1),D.applyMatrix4(R),D.add(P),_.subVectors(C,D),_.reflect(S).negate(),_.add(C),B.position.copy(k),B.up.set(0,1,0),B.up.applyMatrix4(R),B.up.reflect(S),B.lookAt(_),B.far=z.far,B.updateMatrixWorld(),B.projectionMatrix.copy(z.projectionMatrix),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(B.projectionMatrix),A.multiply(B.matrixWorldInverse),A.multiply(t.matrixWorld),M.setFromNormalAndCoplanarPoint(S,C),M.applyMatrix4(B.matrixWorldInverse),F.set(M.normal.x,M.normal.y,M.normal.z,M.constant);const r=B.projectionMatrix;L.x=(Math.sign(F.x)+r.elements[8])/r.elements[0],L.y=(Math.sign(F.y)+r.elements[9])/r.elements[5],L.z=-1,L.w=(1+r.elements[10])/r.elements[14],F.multiplyScalar(2/F.dot(L)),r.elements[2]=F.x,r.elements[6]=F.y,r.elements[10]=F.z+1,r.elements[14]=F.w}),[z,x]),[O,N,I,V]=T.useMemo((()=>{const e={minFilter:n.LinearFilter,magFilter:n.LinearFilter,type:n.HalfFloatType},o=new n.WebGLRenderTarget(a,a,e);o.depthBuffer=!0,o.depthTexture=new n.DepthTexture(a,a),o.depthTexture.format=n.DepthFormat,o.depthTexture.type=n.UnsignedShortType;const i=new n.WebGLRenderTarget(a,a,e);return[o,i,new gr({gl:g,resolution:a,width:s[0],height:s[1],minDepthThreshold:l,maxDepthThreshold:c,depthScale:u,depthToBlurRatioBias:m}),{mirror:d,textureMatrix:A,mixBlur:t,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:i.texture,hasBlur:b,mixStrength:r,minDepthThreshold:l,maxDepthThreshold:c,depthScale:u,depthToBlurRatioBias:m,distortion:f,distortionMap:h,mixContrast:p,"defines-USE_BLUR":b?"":void 0,"defines-USE_DEPTH":u>0?"":void 0,"defines-USE_DISTORTION":h?"":void 0}]}),[g,s,A,a,d,b,t,r,l,c,u,m,f,h,p]);return o.useFrame((()=>{var e;const t=E.current.parent||(null==(e=E.current)?void 0:e.__r3f.parent);if(!t)return;t.visible=!1;const r=g.xr.enabled,n=g.shadowMap.autoUpdate;U(),g.xr.enabled=!1,g.shadowMap.autoUpdate=!1,g.setRenderTarget(O),g.state.buffers.depth.setMask(!0),g.autoClear||g.clear(),g.render(w,B),b&&I.render(g,O,N),g.xr.enabled=r,g.shadowMap.autoUpdate=n,t.visible=!0,g.setRenderTarget(null)})),T.createElement("meshReflectorMaterialImpl",e({attach:"material",key:"key"+V["defines-USE_BLUR"]+V["defines-USE_DEPTH"]+V["defines-USE_DISTORTION"],ref:i([E,v])},V,y))})),br=xe({envMap:null,bounces:3,ior:2.4,correctMips:!0,aberrationStrength:.01,fresnel:0,bvh:new b.MeshBVHUniformStruct,color:new P.Color("white"),resolution:new P.Vector2,viewMatrixInverse:new P.Matrix4,projectionMatrixInverse:new P.Matrix4},"\n uniform mat4 viewMatrixInverse;\n\n varying vec3 vWorldPosition; \n varying vec3 vNormal;\n varying mat4 vModelMatrixInverse;\n\n #ifdef USE_INSTANCING_COLOR\n varying vec3 vInstanceColor;\n #endif\n\n void main() { \n vec4 transformedNormal = vec4(normal, 0.0);\n vec4 transformedPosition = vec4(position, 1.0);\n #ifdef USE_INSTANCING\n transformedNormal = instanceMatrix * transformedNormal;\n transformedPosition = instanceMatrix * transformedPosition;\n #endif\n\n #ifdef USE_INSTANCING\n vModelMatrixInverse = inverse(modelMatrix * instanceMatrix);\n #else\n vModelMatrixInverse = inverse(modelMatrix);\n #endif\n\n #ifdef USE_INSTANCING_COLOR\n vInstanceColor = instanceColor.rgb;\n #endif\n\n vWorldPosition = (modelMatrix * transformedPosition).xyz;\n vNormal = normalize((viewMatrixInverse * vec4(normalMatrix * transformedNormal.xyz, 0.0)).xyz);\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * transformedPosition;\n }",`\n #define ENVMAP_TYPE_CUBE_UV\n precision highp isampler2D;\n precision highp usampler2D;\n varying vec3 vWorldPosition;\n varying vec3 vNormal;\n varying mat4 vModelMatrixInverse;\n\n #ifdef USE_INSTANCING_COLOR\n varying vec3 vInstanceColor;\n #endif\n \n #ifdef ENVMAP_TYPE_CUBEM\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n uniform float bounces;\n ${b.shaderStructs}\n ${b.shaderIntersectFunction}\n uniform BVH bvh;\n uniform float ior;\n uniform bool correctMips;\n uniform vec2 resolution;\n uniform float fresnel;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrixInverse;\n uniform mat4 viewMatrixInverse;\n uniform float aberrationStrength;\n uniform vec3 color;\n \n float fresnelFunc(vec3 viewDirection, vec3 worldNormal) {\n return pow( 1.0 + dot( viewDirection, worldNormal), 10.0 );\n }\n \n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 normal, float ior, mat4 modelMatrixInverse) {\n vec3 rayOrigin = ro;\n vec3 rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = vWorldPosition + rayDirection * 0.001;\n rayOrigin = (modelMatrixInverse * vec4(rayOrigin, 1.0)).xyz;\n rayDirection = normalize((modelMatrixInverse * vec4(rayDirection, 0.0)).xyz);\n for(float i = 0.0; i < bounces; i++) {\n uvec4 faceIndices = uvec4( 0u );\n vec3 faceNormal = vec3( 0.0, 0.0, 1.0 );\n vec3 barycoord = vec3( 0.0 );\n float side = 1.0;\n float dist = 0.0;\n bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist );\n vec3 hitPos = rayOrigin + rayDirection * max(dist - 0.001, 0.0); \n vec3 tempDir = refract(rayDirection, faceNormal, ior);\n if (length(tempDir) != 0.0) {\n rayDirection = tempDir;\n break;\n }\n rayDirection = reflect(rayDirection, faceNormal);\n rayOrigin = hitPos + rayDirection * 0.01;\n }\n rayDirection = normalize((modelMatrix * vec4(rayDirection, 0.0)).xyz);\n return rayDirection;\n }\n \n #include <common>\n #include <cube_uv_reflection_fragment>\n \n #ifdef ENVMAP_TYPE_CUBEM\n vec4 textureGradient(samplerCube envMap, vec3 rayDirection, vec3 directionCamPerfect) {\n return textureGrad(envMap, rayDirection, dFdx(correctMips ? directionCamPerfect: rayDirection), dFdy(correctMips ? directionCamPerfect: rayDirection));\n }\n #else\n vec4 textureGradient(sampler2D envMap, vec3 rayDirection, vec3 directionCamPerfect) {\n vec2 uvv = equirectUv( rayDirection );\n vec2 smoothUv = equirectUv( directionCamPerfect );\n return textureGrad(envMap, uvv, dFdx(correctMips ? smoothUv : uvv), dFdy(correctMips ? smoothUv : uvv));\n }\n #endif\n \n void main() {\n vec2 uv = gl_FragCoord.xy / resolution;\n vec3 directionCamPerfect = (projectionMatrixInverse * vec4(uv * 2.0 - 1.0, 0.0, 1.0)).xyz;\n directionCamPerfect = (viewMatrixInverse * vec4(directionCamPerfect, 0.0)).xyz;\n directionCamPerfect = normalize(directionCamPerfect);\n vec3 normal = vNormal;\n vec3 rayOrigin = cameraPosition;\n vec3 rayDirection = normalize(vWorldPosition - cameraPosition);\n vec3 finalColor;\n #ifdef CHROMATIC_ABERRATIONS\n vec3 rayDirectionG = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse);\n #ifdef FAST_CHROMA \n vec3 rayDirectionR = normalize(rayDirectionG + 1.0 * vec3(aberrationStrength / 2.0));\n vec3 rayDirectionB = normalize(rayDirectionG - 1.0 * vec3(aberrationStrength / 2.0));\n #else\n vec3 rayDirectionR = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 - aberrationStrength), 1.0), vModelMatrixInverse);\n vec3 rayDirectionB = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 + aberrationStrength), 1.0), vModelMatrixInverse);\n #endif\n float finalColorR = textureGradient(envMap, rayDirectionR, directionCamPerfect).r;\n float finalColorG = textureGradient(envMap, rayDirectionG, directionCamPerfect).g;\n float finalColorB = textureGradient(envMap, rayDirectionB, directionCamPerfect).b;\n finalColor = vec3(finalColorR, finalColorG, finalColorB);\n #else\n rayDirection = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse);\n finalColor = textureGradient(envMap, rayDirection, directionCamPerfect).rgb; \n #endif\n\n finalColor *= color;\n #ifdef USE_INSTANCING_COLOR\n finalColor *= vInstanceColor;\n #endif\n\n vec3 viewDirection = normalize(vWorldPosition - cameraPosition);\n float nFresnel = fresnelFunc(viewDirection, normal) * fresnel;\n gl_FragColor = vec4(mix(finalColor, vec3(1.0), nFresnel), 1.0); \n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }`);const Er=xe({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class Mr extends P.MeshPhysicalMaterial{constructor(e=6,t=!1){super(),this.uniforms={chromaticAberration:{value:.05},transmission:{value:0},_transmission:{value:1},transmissionMap:{value:null},roughness:{value:0},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:1/0},attenuationColor:{value:new P.Color("white")},anisotropicBlur:{value:.1},time:{value:0},distortion:{value:0},distortionScale:{value:.5},temporalDistortion:{value:0},buffer:{value:null}},this.onBeforeCompile=r=>{r.uniforms={...r.uniforms,...this.uniforms},t?r.defines.USE_SAMPLER="":r.defines.USE_TRANSMISSION="",r.fragmentShader="\n uniform float chromaticAberration; \n uniform float anisotropicBlur; \n uniform float time;\n uniform float distortion;\n uniform float distortionScale;\n uniform float temporalDistortion;\n uniform sampler2D buffer;\n\n vec3 random3(vec3 c) {\n float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n vec3 r;\n r.z = fract(512.0*j);\n j *= .125;\n r.x = fract(512.0*j);\n j *= .125;\n r.y = fract(512.0*j);\n return r-0.5;\n }\n\n float seed = 0.0;\n uint hash( uint x ) {\n x += ( x << 10u );\n x ^= ( x >> 6u );\n x += ( x << 3u );\n x ^= ( x >> 11u );\n x += ( x << 15u );\n return x;\n }\n\n // Compound versions of the hashing algorithm I whipped together.\n uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }\n uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }\n uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }\n\n // Construct a float with half-open range [0:1] using low 23 bits.\n // All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.\n float floatConstruct( uint m ) {\n const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask\n const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32\n m &= ieeeMantissa; // Keep only mantissa bits (fractional part)\n m |= ieeeOne; // Add fractional part to 1.0\n float f = uintBitsToFloat( m ); // Range [1:2]\n return f - 1.0; // Range [0:1]\n }\n\n // Pseudo-random value in half-open range [0:1].\n float random( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }\n float random( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float random( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float random( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n\n float rand() {\n float result = random(vec3(gl_FragCoord.xy, seed));\n seed += 1.0;\n return result;\n }\n\n const float F3 = 0.3333333;\n const float G3 = 0.1666667;\n\n float snoise(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n vec3 x = p - s + dot(s, vec3(G3));\n vec3 e = step(vec3(0.0), x - x.yzx);\n vec3 i1 = e*(1.0 - e.zxy);\n vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n vec3 x1 = x - i1 + G3;\n vec3 x2 = x - i2 + 2.0*G3;\n vec3 x3 = x - 1.0 + 3.0*G3;\n vec4 w, d;\n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n w = max(0.6 - w, 0.0);\n d.x = dot(random3(s), x);\n d.y = dot(random3(s + i1), x1);\n d.z = dot(random3(s + i2), x2);\n d.w = dot(random3(s + 1.0), x3);\n w *= w;\n w *= w;\n d *= w;\n return dot(d, vec4(52.0));\n }\n\n float snoiseFractal(vec3 m) {\n return 0.5333333* snoise(m)\n +0.2666667* snoise(2.0*m)\n +0.1333333* snoise(4.0*m)\n +0.0666667* snoise(8.0*m);\n }\n"+r.fragmentShader,r.fragmentShader=r.fragmentShader.replace("#include <transmission_pars_fragment>","\n #ifdef USE_TRANSMISSION\n // Transmission code is based on glTF-Sampler-Viewer\n // https://github.com/KhronosGroup/glTF-Sample-Viewer\n uniform float _transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n // Direction of refracted light.\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n // Compute rotation-independant scaling of the model matrix.\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n // The thickness is specified in local space.\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n // an IOR of 1.5 results in the default amount of microfacet refraction.\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); \n #ifdef USE_SAMPLER\n #ifdef texture2DLodEXT\n return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #else\n return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #endif\n #else\n return texture2D(buffer, fragCoord.xy);\n #endif\n }\n vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n // Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.\n return radiance;\n } else {\n // Compute light attenuation using Beer's law.\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law\n return transmittance * radiance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n // Sample framebuffer to get pixel the refracted ray hits.\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n // Get the specular component.\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n }\n #endif\n"),r.fragmentShader=r.fragmentShader.replace("#include <transmission_fragment>",` \n // Improve the refraction to use the world pos\n material.transmission = _transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vUv ).g;\n #endif\n \n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec3 transmission = vec3(0.0);\n float transmissionR, transmissionB, transmissionG;\n float randomCoords = rand();\n float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur);\n vec3 distortionNormal = vec3(0.0);\n vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;\n if (distortion > 0.0) {\n distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));\n }\n for (float i = 0.0; i < ${e}.0; i ++) {\n vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand() - 0.5, rand() - 0.5, rand() - 0.5)) * pow(rand(), 0.33) + distortionNormal);\n transmissionR = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).r;\n transmissionG = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${e})) , material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).g;\n transmissionB = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${e})), material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).b;\n transmission.r += transmissionR;\n transmission.g += transmissionG;\n transmission.b += transmissionB;\n }\n transmission /= ${e}.0;\n totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n`)},Object.keys(this.uniforms).forEach((e=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t})))}}const Sr=T.forwardRef((({buffer:t,transmissionSampler:r=!1,backside:n=!1,side:a=P.FrontSide,transmission:i=1,thickness:s=0,backsideThickness:l=0,samples:c=10,resolution:u,backsideResolution:m,background:d,anisotropy:f,anisotropicBlur:p,...h},x)=>{o.extend({MeshTransmissionMaterial:Mr});const y=T.useRef(null),[v]=T.useState((()=>new Er)),g=je(m||u),z=je(u);let w,b,E;return o.useFrame((e=>{y.current.time=e.clock.getElapsedTime(),y.current.buffer!==z.texture||r||(E=y.current.__r3f.parent,E&&(b=e.gl.toneMapping,w=e.scene.background,e.gl.toneMapping=P.NoToneMapping,d&&(e.scene.background=d),E.material=v,n&&(e.gl.setRenderTarget(g),e.gl.render(e.scene,e.camera),E.material=y.current,E.material.buffer=g.texture,E.material.thickness=l,E.material.side=P.BackSide),e.gl.setRenderTarget(z),e.gl.render(e.scene,e.camera),E.material.thickness=s,E.material.side=a,E.material.buffer=z.texture,e.scene.background=w,e.gl.setRenderTarget(null),E.material=y.current,e.gl.toneMapping=b))})),T.useImperativeHandle(x,(()=>y.current),[]),T.createElement("meshTransmissionMaterial",e({args:[c,r],ref:y},h,{buffer:t||z.texture,_transmission:i,anisotropicBlur:null!=p?p:f,transmission:r?i:0,thickness:s,side:a}))})),Tr=T.forwardRef(((t,r)=>(o.extend({DiscardMaterialImpl:Er}),T.createElement("discardMaterialImpl",e({ref:r},t)))));class Cr extends P.PointsMaterial{constructor(e){super(e),this.onBeforeCompile=(e,t)=>{const{isWebGL2:r}=t.capabilities;e.fragmentShader=e.fragmentShader.replace("#include <output_fragment>",`\n ${r?"#include <output_fragment>":"#extension GL_OES_standard_derivatives : enable\n#include <output_fragment>"}\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n float r = dot(cxy, cxy);\n float delta = fwidth(r); \n float mask = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n gl_FragColor = vec4(gl_FragColor.rgb, mask * gl_FragColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n `)}}}const Pr=T.forwardRef(((t,r)=>{const[n]=T.useState((()=>new Cr(null)));return T.createElement("primitive",e({},t,{object:n,ref:r,attach:"material"}))}));function Rr(e,t,r){t.traverse((t=>{t.material&&(e.properties.remove(t.material),null==t.material.dispose||t.material.dispose())})),e.info.programs.length=0,e.compile(t,r)}function Dr(t,r){const n=t+"Geometry";return T.forwardRef((({args:t,children:o,...a},i)=>{const s=T.useRef(null);return T.useImperativeHandle(i,(()=>s.current)),T.useLayoutEffect((()=>{null==r||r(s.current)})),T.createElement("mesh",e({ref:s},a),T.createElement(n,{attach:"geometry",args:t}),o)}))}const Fr=Dr("box"),kr=Dr("circle"),_r=Dr("cone"),Lr=Dr("cylinder"),Ar=Dr("sphere"),Br=Dr("plane"),Ur=Dr("tube"),Or=Dr("torus"),Nr=Dr("torusKnot"),Ir=Dr("tetrahedron"),Vr=Dr("ring"),jr=Dr("polyhedron"),Wr=Dr("icosahedron"),Gr=Dr("octahedron"),Hr=Dr("dodecahedron"),qr=Dr("extrude"),$r=Dr("lathe"),Xr=Dr("capsule"),Yr=Dr("shape",(({geometry:e})=>{const t=e.attributes.position,r=(new P.Box3).setFromBufferAttribute(t),n=new P.Vector3;r.getSize(n);const o=[];let a=0,i=0,s=0,l=0;for(let e=0;e<t.count;e++)a=t.getX(e),i=t.getY(e),s=(a-r.min.x)/n.x,l=(i-r.min.y)/n.y,o.push(s,l);e.setAttribute("uv",new P.Float32BufferAttribute(o,2))})),Kr=1e-5;const Zr=T.forwardRef((function({args:[t=1,r=1,o=1]=[],radius:a=.05,steps:i=1,smoothness:s=4,creaseAngle:l=.4,children:c,...u},d){const f=T.useMemo((()=>function(e,t,r){const o=new n.Shape,a=r-Kr;return o.absarc(Kr,Kr,Kr,-Math.PI/2,-Math.PI,!0),o.absarc(Kr,t-2*a,Kr,Math.PI,Math.PI/2,!0),o.absarc(e-2*a,t-2*a,Kr,Math.PI/2,0,!0),o.absarc(e-2*a,Kr,Kr,0,-Math.PI/2,!0),o}(t,r,a)),[t,r,a]),p=T.useMemo((()=>({depth:o-2*a,bevelEnabled:!0,bevelSegments:2*s,steps:i,bevelSize:a-Kr,bevelThickness:a,curveSegments:s})),[o,a,s]),h=T.useRef();return T.useLayoutEffect((()=>{h.current&&(h.current.center(),m.toCreasedNormals(h.current,l))}),[f,p]),T.createElement("mesh",e({ref:d},u),T.createElement("extrudeGeometry",{ref:h,args:[f,p]}),c)}));function Qr(){const e=new P.BufferGeometry,t=new Float32Array([-1,-1,3,-1,-1,3]);return e.setAttribute("position",new P.BufferAttribute(t,2)),e}const Jr=T.forwardRef((function({children:t,...r},n){const o=T.useMemo(Qr,[]);return T.createElement("mesh",e({ref:n,geometry:o,frustumCulled:!1},r),t)})),en=T.forwardRef((({children:t,width:r,height:n,depth:o,box3:a,precise:i=!0,...s},l)=>{const c=T.useRef(null),u=T.useRef(null),m=T.useRef(null);return T.useLayoutEffect((()=>{u.current.matrixWorld.identity();let e=a||(new P.Box3).setFromObject(m.current,i);const t=e.max.x-e.min.x,s=e.max.y-e.min.y,l=e.max.z-e.min.z;let c=Math.max(t,s,l);r&&(c=t),n&&(c=s),o&&(c=l),u.current.scale.setScalar(1/c)}),[r,n,o,a,i]),T.useImperativeHandle(l,(()=>c.current),[]),T.createElement("group",e({ref:c},s),T.createElement("group",{ref:u},T.createElement("group",{ref:m},t)))})),tn=e=>e&&e.isOrthographicCamera,rn=e=>e&&e.isBox3,nn=T.createContext(null);function on({children:e,damping:t=6,fit:r,clip:n,observe:a,margin:i=1.2,eps:s=.01,onFit:l}){const c=T.useRef(null),{camera:u,invalidate:m,size:d,controls:f}=o.useThree(),p=f,h=T.useRef(l);function x(e,t){return Math.abs(e.x-t.x)<s&&Math.abs(e.y-t.y)<s&&Math.abs(e.z-t.z)<s}function y(e,t,r,n){e.x=P.MathUtils.damp(e.x,t.x,r,n),e.y=P.MathUtils.damp(e.y,t.y,r,n),e.z=P.MathUtils.damp(e.z,t.z,r,n)}h.current=l;const[v]=T.useState((()=>({animating:!1,focus:new P.Vector3,camera:new P.Vector3,zoom:1}))),[g]=T.useState((()=>({focus:new P.Vector3,camera:new P.Vector3,zoom:1}))),[z]=T.useState((()=>new P.Box3)),w=T.useMemo((()=>{function e(){const e=z.getSize(new P.Vector3),t=z.getCenter(new P.Vector3),r=Math.max(e.x,e.y,e.z),n=tn(u)?4*r:r/(2*Math.atan(Math.PI*u.fov/360)),o=tn(u)?4*r:n/u.aspect,a=i*Math.max(n,o);return{box:z,size:e,center:t,distance:a}}return{getSize:e,refresh(t){if(rn(t))z.copy(t);else{const e=t||c.current;e.updateWorldMatrix(!0,!0),z.setFromObject(e)}if(z.isEmpty()){const e=u.position.length()||10;z.setFromCenterAndSize(new P.Vector3,new P.Vector3(e,e,e))}if("OrthographicTrackballControls"===(null==p?void 0:p.constructor.name)){const{distance:t}=e(),r=u.position.clone().sub(p.target).normalize().multiplyScalar(t),n=p.target.clone().add(r);u.position.copy(n)}return this},clip(){const{distance:t}=e();return p&&(p.maxDistance=10*t),u.near=t/100,u.far=100*t,u.updateProjectionMatrix(),p&&p.update(),m(),this},to({position:r,target:n}){v.camera.copy(u.position);const{center:o}=e();return g.camera.set(...r),n?g.focus.set(...n):g.focus.copy(o),t?v.animating=!0:u.position.set(...r),this},fit(){v.camera.copy(u.position),p&&v.focus.copy(p.target);const{center:r,distance:n}=e(),o=r.clone().sub(u.position).normalize().multiplyScalar(n);if(g.camera.copy(r).sub(o),g.focus.copy(r),tn(u)){v.zoom=u.zoom;let e=0,n=0;const o=[new P.Vector3(z.min.x,z.min.y,z.min.z),new P.Vector3(z.min.x,z.max.y,z.min.z),new P.Vector3(z.min.x,z.min.y,z.max.z),new P.Vector3(z.min.x,z.max.y,z.max.z),new P.Vector3(z.max.x,z.max.y,z.max.z),new P.Vector3(z.max.x,z.max.y,z.min.z),new P.Vector3(z.max.x,z.min.y,z.max.z),new P.Vector3(z.max.x,z.min.y,z.min.z)];r.applyMatrix4(u.matrixWorldInverse);for(const t of o)t.applyMatrix4(u.matrixWorldInverse),e=Math.max(e,Math.abs(t.y-r.y)),n=Math.max(n,Math.abs(t.x-r.x));e*=2,n*=2;const a=(u.top-u.bottom)/e,s=(u.right-u.left)/n;g.zoom=Math.min(a,s)/i,t||(u.zoom=g.zoom,u.updateProjectionMatrix())}return t?v.animating=!0:(u.position.copy(g.camera),u.lookAt(g.focus),p&&(p.target.copy(g.focus),p.update())),h.current&&h.current(this.getSize()),m(),this}}}),[z,u,p,i,t,m]);T.useLayoutEffect((()=>{if(p){const e=()=>v.animating=!1;return p.addEventListener("start",e),()=>p.removeEventListener("start",e)}}),[p]);const b=T.useRef(0);return T.useLayoutEffect((()=>{(a||0==b.current++)&&(w.refresh(),r&&w.fit(),n&&w.clip())}),[d,n,r,a,u,p]),o.useFrame(((e,r)=>{if(v.animating){if(y(v.focus,g.focus,t,r),y(v.camera,g.camera,t,r),v.zoom=P.MathUtils.damp(v.zoom,g.zoom,t,r),u.position.copy(v.camera),tn(u)&&(u.zoom=v.zoom,u.updateProjectionMatrix()),p?(p.target.copy(v.focus),p.update()):u.lookAt(v.focus),m(),tn(u)&&!(Math.abs(v.zoom-g.zoom)<s))return;if(!tn(u)&&!x(v.camera,g.camera))return;if(p&&!x(v.focus,g.focus))return;v.animating=!1}})),T.createElement("group",{ref:c},T.createElement(nn.Provider,{value:w},e))}function an(){return T.useContext(nn)}const sn=T.forwardRef((({intensity:e=1,decay:t,decayRate:r=.65,maxYaw:n=.1,maxPitch:a=.1,maxRoll:i=.1,yawFrequency:s=.1,pitchFrequency:l=.1,rollFrequency:c=.1},u)=>{const d=o.useThree((e=>e.camera)),f=o.useThree((e=>e.controls)),p=T.useRef(e),h=T.useRef(d.rotation.clone()),[x]=T.useState((()=>new m.SimplexNoise)),[y]=T.useState((()=>new m.SimplexNoise)),[v]=T.useState((()=>new m.SimplexNoise)),g=()=>{(p.current<0||p.current>1)&&(p.current=p.current<0?0:1)};return T.useImperativeHandle(u,(()=>({getIntensity:()=>p.current,setIntensity:e=>{p.current=e,g()}})),[]),T.useEffect((()=>{if(f){const e=()=>{h.current=d.rotation.clone()};return f.addEventListener("change",e),e(),()=>{f.removeEventListener("change",e)}}}),[d,f]),o.useFrame(((e,o)=>{const u=Math.pow(p.current,2),m=n*u*x.noise(e.clock.elapsedTime*s,1),f=a*u*y.noise(e.clock.elapsedTime*l,1),z=i*u*v.noise(e.clock.elapsedTime*c,1);d.rotation.set(h.current.x+f,h.current.y+m,h.current.z+z),t&&p.current>0&&(p.current-=r*o,g())})),null})),ln=T.forwardRef((({children:e,enabled:t=!0,speed:r=1,rotationIntensity:n=1,floatIntensity:a=1,floatingRange:s=[-.1,.1],...l},c)=>{const u=T.useRef(null),m=T.useRef(1e4*Math.random());return o.useFrame((e=>{var o,i;if(!t||0===r)return;const l=m.current+e.clock.getElapsedTime();u.current.rotation.x=Math.cos(l/4*r)/8*n,u.current.rotation.y=Math.sin(l/4*r)/8*n,u.current.rotation.z=Math.sin(l/4*r)/20*n;let c=Math.sin(l/4*r)/10;c=P.MathUtils.mapLinear(c,-.1,.1,null!==(o=null==s?void 0:s[0])&&void 0!==o?o:-.1,null!==(i=null==s?void 0:s[1])&&void 0!==i?i:.1),u.current.position.y=c*a,u.current.updateMatrix()})),T.createElement("group",l,T.createElement("group",{ref:i([u,c]),matrixAutoUpdate:!1},e))})),cn={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},un="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",mn=e=>Array.isArray(e);function dn({files:e=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:t="",preset:r,encoding:a,extensions:i}={}){var s;let l,c=null,u=!1;if(r){if(!(r in cn))throw new Error("Preset must be one of: "+Object.keys(cn).join(", "));e=cn[r],t=un}if(u=mn(e),l=mn(e)?"cube":e.startsWith("data:application/exr")?"exr":e.startsWith("data:application/hdr")?"hdr":null==(s=e.split(".").pop())?void 0:s.toLowerCase(),c=u?n.CubeTextureLoader:"hdr"===l?m.RGBELoader:"exr"===l?m.EXRLoader:null,!c)throw new Error("useEnvironment: Unrecognized file extension: "+e);const d=o.useLoader(c,u?[e]:e,(e=>{null==e.setPath||e.setPath(t),i&&i(e)})),f=u?d[0]:d;f.mapping=u?n.CubeReflectionMapping:n.EquirectangularReflectionMapping;return"colorSpace"in f?f.colorSpace=(null!=a?a:u)?"srgb":"srgb-linear":f.encoding=(null!=a?a:u)?3001:3e3,f}const fn=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function pn(e,t,r,n,o=0){const a=fn(t||r),i=a.background,s=a.environment,l=a.backgroundBlurriness||0;return"only"!==e&&(a.environment=n),e&&(a.background=n),e&&void 0!==a.backgroundBlurriness&&(a.backgroundBlurriness=o),()=>{"only"!==e&&(a.environment=s),e&&(a.background=i),e&&void 0!==a.backgroundBlurriness&&(a.backgroundBlurriness=l)}}function hn({scene:e,background:t=!1,blur:r,map:n}){const a=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>{if(n)return pn(t,e,a,n,r)}),[a,e,n,t,r]),null}function xn({background:e=!1,scene:t,blur:r,...n}){const a=dn(n),i=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>pn(e,t,i,a,r)),[a,e,t,i,r]),null}function yn({children:e,near:t=1,far:r=1e3,resolution:a=256,frames:i=1,map:s,background:l=!1,blur:c,scene:u,files:m,path:d,preset:f,extensions:p}){const h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.scene)),y=T.useRef(null),[v]=T.useState((()=>new n.Scene)),g=T.useMemo((()=>{const e=new n.WebGLCubeRenderTarget(a);return e.texture.type=n.HalfFloatType,e}),[a]);T.useLayoutEffect((()=>(1===i&&y.current.update(h,v),pn(l,u,x,g.texture,c))),[e,v,g.texture,u,x,l,i,h]);let z=1;return o.useFrame((()=>{(i===1/0||z<i)&&(y.current.update(h,v),z++)})),T.createElement(T.Fragment,null,o.createPortal(T.createElement(T.Fragment,null,e,T.createElement("cubeCamera",{ref:y,args:[t,r,g]}),m||f?T.createElement(xn,{background:!0,files:m,preset:f,path:d,extensions:p}):s?T.createElement(hn,{background:!0,map:s,extensions:p}):null),v))}function vn(t){var r,n,a,i;const s=dn(t),l=t.map||s;T.useMemo((()=>o.extend({GroundProjectedEnvImpl:m.GroundProjectedEnv})),[]);const c=T.useMemo((()=>[l]),[l]),u=null==(r=t.ground)?void 0:r.height,d=null==(n=t.ground)?void 0:n.radius,f=null!==(a=null==(i=t.ground)?void 0:i.scale)&&void 0!==a?a:1e3;return T.createElement(T.Fragment,null,T.createElement(hn,e({},t,{map:l})),T.createElement("groundProjectedEnvImpl",{args:c,scale:f,height:u,radius:d}))}function gn(e){return e.ground?T.createElement(vn,e):e.map?T.createElement(hn,e):e.children?T.createElement(yn,e):T.createElement(xn,e)}const zn=T.forwardRef((({scale:t=10,frames:r=1/0,opacity:n=1,width:a=1,height:i=1,blur:s=1,near:l=0,far:c=10,resolution:u=512,smooth:d=!0,color:f="#000000",depthWrite:p=!1,renderOrder:h,...x},y)=>{const v=T.useRef(null),g=o.useThree((e=>e.scene)),z=o.useThree((e=>e.gl)),w=T.useRef(null);a*=Array.isArray(t)?t[0]:t||1,i*=Array.isArray(t)?t[1]:t||1;const[b,E,M,S,C,R,D]=T.useMemo((()=>{const e=new P.WebGLRenderTarget(u,u),t=new P.WebGLRenderTarget(u,u);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const r=new P.PlaneGeometry(a,i).rotateX(Math.PI/2),n=new P.Mesh(r),o=new P.MeshDepthMaterial;o.depthTest=o.depthWrite=!1,o.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new P.Color(f)}},e.fragmentShader=e.fragmentShader.replace("void main() {","uniform vec3 ucolor;\n void main() {\n "),e.fragmentShader=e.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")};const s=new P.ShaderMaterial(m.HorizontalBlurShader),l=new P.ShaderMaterial(m.VerticalBlurShader);return l.depthTest=s.depthTest=!1,[e,r,o,n,s,l,t]}),[u,a,i,t,f]),F=e=>{S.visible=!0,S.material=C,C.uniforms.tDiffuse.value=b.texture,C.uniforms.h.value=1*e/256,z.setRenderTarget(D),z.render(S,w.current),S.material=R,R.uniforms.tDiffuse.value=D.texture,R.uniforms.v.value=1*e/256,z.setRenderTarget(b),z.render(S,w.current),S.visible=!1};let k,_,L=0;return o.useFrame((()=>{w.current&&(r===1/0||L<r)&&(L++,k=g.background,_=g.overrideMaterial,v.current.visible=!1,g.background=null,g.overrideMaterial=M,z.setRenderTarget(b),z.render(g,w.current),F(s),d&&F(.4*s),z.setRenderTarget(null),v.current.visible=!0,g.overrideMaterial=_,g.background=k)})),T.useImperativeHandle(y,(()=>v.current),[]),T.createElement("group",e({"rotation-x":Math.PI/2},x,{ref:v}),T.createElement("mesh",{renderOrder:h,geometry:E,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},T.createElement("meshBasicMaterial",{transparent:!0,map:b.texture,opacity:n,depthWrite:p})),T.createElement("orthographicCamera",{ref:w,args:[-a/2,a/2,i/2,-i/2,l,c]}))}));const wn=T.createContext(null),bn=xe({color:new P.Color,blend:2,alphaTest:.75,opacity:0,map:null},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }","varying vec2 vUv;\n uniform sampler2D map;\n uniform vec3 color;\n uniform float opacity;\n uniform float alphaTest;\n uniform float blend;\n void main() {\n vec4 sampledDiffuseColor = texture2D(map, vUv);\n gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),En=T.forwardRef((({children:e,temporal:t,frames:r=40,limit:n=1/0,blend:a=20,scale:i=10,opacity:s=1,alphaTest:l=.75,color:c="black",colorBlend:u=2,resolution:m=1024,toneMapped:d=!0,...f},p)=>{o.extend({SoftShadowMaterial:bn});const h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.scene)),y=o.useThree((e=>e.camera)),v=o.useThree((e=>e.invalidate)),g=T.useRef(null),z=T.useRef(null),[w]=T.useState((()=>new Sn(h,x,m)));T.useLayoutEffect((()=>{w.configure(g.current)}),[]);const b=T.useMemo((()=>({lights:new Map,temporal:!!t,frames:Math.max(2,r),blend:Math.max(2,r===1/0?a:r),count:0,getMesh:()=>g.current,reset:()=>{w.clear();const e=g.current.material;e.opacity=0,e.alphaTest=0,b.count=0},update:(e=1)=>{const t=g.current.material;b.temporal?(t.opacity=Math.min(s,t.opacity+s/b.blend),t.alphaTest=Math.min(l,t.alphaTest+l/b.blend)):(t.opacity=s,t.alphaTest=l),z.current.visible=!0,w.prepare();for(let t=0;t<e;t++)b.lights.forEach((e=>e.update())),w.update(y,b.blend);z.current.visible=!1,w.finish()}})),[w,y,x,t,r,a,s,l]);return T.useLayoutEffect((()=>{b.reset(),b.temporal||b.frames===1/0||b.update(b.blend)})),T.useImperativeHandle(p,(()=>b),[b]),o.useFrame((()=>{(b.temporal||b.frames===1/0)&&b.count<b.frames&&b.count<n&&(v(),b.update(),b.count++)})),T.createElement("group",f,T.createElement("group",{traverse:()=>null,ref:z},T.createElement(wn.Provider,{value:b},e)),T.createElement("mesh",{receiveShadow:!0,ref:g,scale:i,rotation:[-Math.PI/2,0,0]},T.createElement("planeGeometry",null),T.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:d,color:c,blend:u,map:w.progressiveLightMap2.texture})))})),Mn=T.forwardRef((({castShadow:t=!0,bias:r=.001,mapSize:n=512,size:o=5,near:a=.5,far:i=500,frames:s=1,position:l=[0,0,0],radius:c=1,amount:u=8,intensity:m=1,ambient:d=.5,...f},p)=>{const h=T.useRef(null),x=new P.Vector3(...l).length(),y=T.useContext(wn),v=T.useCallback((()=>{let e;if(h.current)for(let t=0;t<h.current.children.length;t++)if(e=h.current.children[t],Math.random()>d)e.position.set(l[0]+P.MathUtils.randFloatSpread(c),l[1]+P.MathUtils.randFloatSpread(c),l[2]+P.MathUtils.randFloatSpread(c));else{let t=Math.acos(2*Math.random()-1)-Math.PI/2,r=2*Math.PI*Math.random();e.position.set(Math.cos(t)*Math.cos(r)*x,Math.abs(Math.cos(t)*Math.sin(r)*x),Math.sin(t)*x)}}),[c,d,x,...l]),g=T.useMemo((()=>({update:v})),[v]);return T.useImperativeHandle(p,(()=>g),[g]),T.useLayoutEffect((()=>{const e=h.current;return y&&y.lights.set(e.uuid,g),()=>{y.lights.delete(e.uuid)}}),[y,g]),T.createElement("group",e({ref:h},f),Array.from({length:u},((e,s)=>T.createElement("directionalLight",{key:s,castShadow:t,"shadow-bias":r,"shadow-mapSize":[n,n],intensity:m/u},T.createElement("orthographicCamera",{attach:"shadow-camera",args:[-o,o,o,-o,a,i]})))))}));class Sn{constructor(e,t,r=1024){this.renderer=e,this.res=r,this.scene=t,this.buffer1Active=!1,this.lights=[],this.meshes=[],this.object=null,this.clearColor=new P.Color,this.clearAlpha=0;const n=/(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent)?P.HalfFloatType:P.FloatType;this.progressiveLightMap1=new P.WebGLRenderTarget(this.res,this.res,{type:n}),this.progressiveLightMap2=new P.WebGLRenderTarget(this.res,this.res,{type:n}),this.discardMat=new Er,this.targetMat=new P.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:100},this.targetMat.onBeforeCompile=e=>{e.vertexShader="varying vec2 vUv;\n"+e.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const t=e.fragmentShader.indexOf("void main() {");e.fragmentShader="varying vec2 vUv;\n"+e.fragmentShader.slice(0,t)+"uniform sampler2D previousShadowMap;\n\tuniform float averagingWindow;\n"+e.fragmentShader.slice(t-1,-1)+"\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;\n gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);\n }",e.uniforms.previousShadowMap=this.previousShadowMap,e.uniforms.averagingWindow=this.averagingWindow}}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.lights=[],this.meshes=[],this.scene.traverse((e=>{!function(e){return!!e.geometry}(e)?function(e){return e.isLight}(e)&&this.lights.push({object:e,intensity:e.intensity}):this.meshes.push({object:e,material:e.material})}))}prepare(){this.lights.forEach((e=>e.object.intensity=0)),this.meshes.forEach((e=>e.object.material=this.discardMat))}finish(){this.lights.forEach((e=>e.object.intensity=e.intensity)),this.meshes.forEach((e=>e.object.material=e.material))}configure(e){this.object=e}update(e,t=100){if(!this.object)return;this.averagingWindow.value=t,this.object.material=this.targetMat;const r=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,n=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1,o=this.scene.background;this.scene.background=null,this.renderer.setRenderTarget(r),this.previousShadowMap.value=n.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.renderer.setRenderTarget(null),this.scene.background=o}}const Tn={rembrandt:{main:[1,2,1],fill:[-2,-.5,-2]},portrait:{main:[-1,2,.5],fill:[-1,.5,-1.5]},upfront:{main:[0,2,1],fill:[-1,.5,-1.5]},soft:{main:[-2,4,4],fill:[-1,.5,-1.5]}};function Cn({radius:e,adjustCamera:t}){const r=an();return T.useEffect((()=>{t&&r.refresh().clip().fit()}),[e,t]),null}const Pn=e=>0===e?0:Math.pow(2,10*e-10);const Rn=T.forwardRef((({fog:t=!1,renderOrder:r,depthWrite:o=!1,colorStop:a=0,color:i="black",opacity:s=.5,...l},c)=>{const u=T.useMemo((()=>{const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d"),r=t.createRadialGradient(e.width/2,e.height/2,0,e.width/2,e.height/2,e.width/2);return r.addColorStop(a,new n.Color(i).getStyle()),r.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height),e}),[i,a]);return T.createElement("mesh",e({renderOrder:r,ref:c,"rotation-x":-Math.PI/2},l),T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,opacity:s,fog:t,depthWrite:o,side:n.DoubleSide},T.createElement("canvasTexture",{attach:"map",args:[u]})))}));function Dn(e=P.FrontSide){const t={value:new P.Matrix4};return Object.assign(new P.MeshNormalMaterial({side:e}),{viewMatrix:t,onBeforeCompile:e=>{e.uniforms.viewMatrix=t,e.fragmentShader="vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n }\n"+e.fragmentShader.replace("#include <normal_fragment_maps>","#include <normal_fragment_maps>\n normal = inverseTransformDirection( normal, viewMatrix );\n")}})}const Fn=xe({causticsTexture:null,causticsTextureB:null,color:new P.Color,lightProjMatrix:new P.Matrix4,lightViewMatrix:new P.Matrix4},"varying vec3 vWorldPosition; \n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vec4 worldPosition = modelMatrix * vec4(position, 1.);\n vWorldPosition = worldPosition.xyz;\n }","varying vec3 vWorldPosition;\n uniform vec3 color;\n uniform sampler2D causticsTexture; \n uniform sampler2D causticsTextureB; \n uniform mat4 lightProjMatrix;\n uniform mat4 lightViewMatrix;\n void main() {\n // Apply caustics \n vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);\n lightSpacePos.xyz /= lightSpacePos.w;\n lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5; \n vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;\n vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;\n gl_FragColor = vec4((front + back) * color, 1.0);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),kn=xe({cameraMatrixWorld:new P.Matrix4,cameraProjectionMatrixInv:new P.Matrix4,normalTexture:null,depthTexture:null,lightDir:new P.Vector3(0,1,0),lightPlaneNormal:new P.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new P.Matrix4,worldRadius:1/40,ior:1.1,bounces:0,resolution:1024,size:10,intensity:.5},"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }"," \n uniform mat4 cameraMatrixWorld;\n uniform mat4 cameraProjectionMatrixInv;\n uniform vec3 lightDir;\n uniform vec3 lightPlaneNormal;\n uniform float lightPlaneConstant;\n uniform float near;\n uniform float far;\n uniform float time;\n uniform float worldRadius;\n uniform float resolution;\n uniform float size;\n uniform float intensity;\n uniform float ior;\n precision highp isampler2D;\n precision highp usampler2D;\n uniform sampler2D normalTexture;\n uniform sampler2D depthTexture;\n uniform float bounces;\n varying vec2 vUv;\n vec3 WorldPosFromDepth(float depth, vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;\n // Perspective division\n viewSpacePosition /= viewSpacePosition.w;\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n return worldSpacePosition.xyz;\n } \n float sdPlane( vec3 p, vec3 n, float h ) {\n // n must be normalized\n return dot(p,n) + h;\n }\n float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {\n return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);\n }\n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {\n rayOrigin = ro;\n rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = pos + rayDirection * 0.1;\n return rayDirection;\n }\n void main() {\n // Each sample consists of random offset in the x and y direction\n float caustic = 0.0;\n float causticTexelSize = (1.0 / resolution) * size * 2.0;\n float texelsNeeded = worldRadius / causticTexelSize;\n float sampleRadius = texelsNeeded / resolution;\n float sum = 0.0;\n if (texture2D(depthTexture, vUv).x == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 uv1 = vUv + offset1 * sampleRadius;\n vec2 uv2 = vUv + offset2 * sampleRadius;\n vec2 uv3 = vUv + offset3 * sampleRadius;\n vec2 uv4 = vUv + offset4 * sampleRadius;\n vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;\n vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;\n vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;\n vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;\n float depth1 = texture2D(depthTexture, uv1, -10.0).x;\n float depth2 = texture2D(depthTexture, uv2, -10.0).x;\n float depth3 = texture2D(depthTexture, uv3, -10.0).x;\n float depth4 = texture2D(depthTexture, uv4, -10.0).x;\n // Sanity check the depths\n if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec3 pos1 = WorldPosFromDepth(depth1, uv1);\n vec3 pos2 = WorldPosFromDepth(depth2, uv2);\n vec3 pos3 = WorldPosFromDepth(depth3, uv3);\n vec3 pos4 = WorldPosFromDepth(depth4, uv4);\n vec3 originPos1 = WorldPosFromDepth(0.0, uv1);\n vec3 originPos2 = WorldPosFromDepth(0.0, uv2);\n vec3 originPos3 = WorldPosFromDepth(0.0, uv3);\n vec3 originPos4 = WorldPosFromDepth(0.0, uv4);\n vec3 endPos1, endPos2, endPos3, endPos4;\n vec3 endDir1, endDir2, endDir3, endDir4;\n totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);\n totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);\n totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);\n totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);\n float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));\n float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));\n float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));\n float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));\n float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));\n vec3 finalPos1 = endPos1 + endDir1 * t1;\n vec3 finalPos2 = endPos2 + endDir2 * t2;\n vec3 finalPos3 = endPos3 + endDir3 * t3;\n vec3 finalPos4 = endPos4 + endDir4 * t4;\n float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));\n caustic += intensity * (lightPosArea / finalArea);\n // Calculate the area of the triangle in light spaces\n gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);\n }"),_n={depth:!0,minFilter:P.LinearFilter,magFilter:P.LinearFilter,type:P.UnsignedByteType},Ln={minFilter:P.LinearMipmapLinearFilter,magFilter:P.LinearFilter,type:P.FloatType,generateMipmaps:!0},An=T.forwardRef((({debug:t,children:r,frames:n=1,ior:a=1.1,color:i="white",causticsOnly:s=!1,backside:l=!1,backsideIOR:c=1.1,worldRadius:u=.3125,intensity:d=.05,resolution:f=2024,lightSource:p=[5,5,5],...h},x)=>{o.extend({CausticsProjectionMaterial:Fn});const y=T.useRef(null),v=T.useRef(null),g=T.useRef(null),z=T.useRef(null),w=o.useThree((e=>e.gl)),b=Jt(t&&v,P.CameraHelper),E=je(f,f,_n),M=je(f,f,_n),S=je(f,f,Ln),C=je(f,f,Ln),[R]=T.useState((()=>Dn())),[D]=T.useState((()=>Dn(P.BackSide))),[F]=T.useState((()=>new kn)),[k]=T.useState((()=>new m.FullScreenQuad(F)));T.useLayoutEffect((()=>{y.current.updateWorldMatrix(!1,!0)}));let _=0;const L=new P.Vector3,A=new P.Frustum,B=new P.Matrix4,U=new P.Plane,O=new P.Vector3,N=new P.Vector3,I=new P.Box3,V=new P.Vector3,j=[],W=[],G=[],H=[],q=new P.Vector3;for(let e=0;e<8;e++)j.push(new P.Vector3),W.push(new P.Vector3),G.push(new P.Vector3),H.push(new P.Vector3);return o.useFrame((()=>{if(n===1/0||_++<n){var e,r;Array.isArray(p)?O.fromArray(p).normalize():O.copy(y.current.worldToLocal(p.current.getWorldPosition(L)).normalize()),N.copy(O).multiplyScalar(-1),null==(e=g.current.parent)||e.matrixWorld.identity(),I.setFromObject(g.current,!0),j[0].set(I.min.x,I.min.y,I.min.z),j[1].set(I.min.x,I.min.y,I.max.z),j[2].set(I.min.x,I.max.y,I.min.z),j[3].set(I.min.x,I.max.y,I.max.z),j[4].set(I.max.x,I.min.y,I.min.z),j[5].set(I.max.x,I.min.y,I.max.z),j[6].set(I.max.x,I.max.y,I.min.z),j[7].set(I.max.x,I.max.y,I.max.z);for(let e=0;e<8;e++)W[e].copy(j[e]);I.getCenter(V),j.map((e=>e.sub(V)));const n=U.set(N,0);j.map(((e,t)=>n.projectPoint(e,G[t])));const o=G.reduce(((e,t)=>e.add(t)),L.set(0,0,0)).divideScalar(G.length),i=G.map((e=>e.distanceTo(o))).reduce(((e,t)=>Math.max(e,t))),m=j.map((e=>e.dot(O))).reduce(((e,t)=>Math.max(e,t)));v.current.position.copy(q.copy(O).multiplyScalar(m).add(V)),v.current.lookAt(g.current.localToWorld(V));const h=B.lookAt(v.current.position,V,L.set(0,1,0));v.current.left=-i,v.current.right=i,v.current.top=i,v.current.bottom=-i;const x=L.set(0,i,0).applyMatrix4(h),T=(v.current.position.y+x.y)/O.y;v.current.near=.1,v.current.far=T,v.current.updateProjectionMatrix(),v.current.updateMatrixWorld();const P=W.map(((e,t)=>e.add(H[t].copy(O).multiplyScalar(-e.y/O.y)))),_=P.reduce(((e,t)=>e.add(t)),L.set(0,0,0)).divideScalar(P.length),$=2*P.map((e=>Math.hypot(e.x-_.x,e.z-_.z))).reduce(((e,t)=>Math.max(e,t)));z.current.scale.setScalar($),z.current.position.copy(_),t&&(null==(r=b.current)||r.update()),D.viewMatrix.value=R.viewMatrix.value=v.current.matrixWorldInverse;const X=A.setFromProjectionMatrix(B.multiplyMatrices(v.current.projectionMatrix,v.current.matrixWorldInverse)).planes[4];F.cameraMatrixWorld=v.current.matrixWorld,F.cameraProjectionMatrixInv=v.current.projectionMatrixInverse,F.lightDir=N,F.lightPlaneNormal=X.normal,F.lightPlaneConstant=X.constant,F.near=v.current.near,F.far=v.current.far,F.resolution=f,F.size=i,F.intensity=d,F.worldRadius=u,g.current.visible=!0,w.setRenderTarget(E),w.clear(),g.current.overrideMaterial=R,w.render(g.current,v.current),w.setRenderTarget(M),w.clear(),l&&(g.current.overrideMaterial=D,w.render(g.current,v.current)),g.current.overrideMaterial=null,F.ior=a,z.current.material.lightProjMatrix=v.current.projectionMatrix,z.current.material.lightViewMatrix=v.current.matrixWorldInverse,F.normalTexture=E.texture,F.depthTexture=E.depthTexture,w.setRenderTarget(S),w.clear(),k.render(w),F.ior=c,F.normalTexture=M.texture,F.depthTexture=M.depthTexture,w.setRenderTarget(C),w.clear(),l&&k.render(w),w.setRenderTarget(null),s&&(g.current.visible=!1)}})),T.useImperativeHandle(x,(()=>y.current),[]),T.createElement("group",e({ref:y},h),T.createElement("scene",{ref:g},T.createElement("orthographicCamera",{ref:v,up:[0,1,0]}),r),T.createElement("mesh",{renderOrder:2,ref:z,"rotation-x":-Math.PI/2},T.createElement("planeGeometry",null),T.createElement("causticsProjectionMaterial",{transparent:!0,color:i,causticsTexture:S.texture,causticsTextureB:C.texture,blending:P.CustomBlending,blendSrc:P.OneFactor,blendDst:P.SrcAlphaFactor,depthWrite:!1}),t&&T.createElement(Me,null,T.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))}));o.extend({MeshReflectorMaterial:zr});const Bn=T.forwardRef((({mixBlur:t=0,mixStrength:r=.5,resolution:a=256,blur:s=[0,0],args:l=[1,1],minDepthThreshold:c=.9,maxDepthThreshold:u=1,depthScale:m=0,depthToBlurRatioBias:d=.25,mirror:f=0,children:p,debug:h=0,distortion:x=1,mixContrast:y=1,distortionMap:v,...g},z)=>{T.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const w=o.useThree((({gl:e})=>e)),b=o.useThree((({camera:e})=>e)),E=o.useThree((({scene:e})=>e)),M=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,S=T.useRef(null),[C]=T.useState((()=>new n.Plane)),[P]=T.useState((()=>new n.Vector3)),[R]=T.useState((()=>new n.Vector3)),[D]=T.useState((()=>new n.Vector3)),[F]=T.useState((()=>new n.Matrix4)),[k]=T.useState((()=>new n.Vector3(0,0,-1))),[_]=T.useState((()=>new n.Vector4)),[L]=T.useState((()=>new n.Vector3)),[A]=T.useState((()=>new n.Vector3)),[B]=T.useState((()=>new n.Vector4)),[U]=T.useState((()=>new n.Matrix4)),[O]=T.useState((()=>new n.PerspectiveCamera)),N=T.useCallback((()=>{if(R.setFromMatrixPosition(S.current.matrixWorld),D.setFromMatrixPosition(b.matrixWorld),F.extractRotation(S.current.matrixWorld),P.set(0,0,1),P.applyMatrix4(F),L.subVectors(R,D),L.dot(P)>0)return;L.reflect(P).negate(),L.add(R),F.extractRotation(b.matrixWorld),k.set(0,0,-1),k.applyMatrix4(F),k.add(D),A.subVectors(R,k),A.reflect(P).negate(),A.add(R),O.position.copy(L),O.up.set(0,1,0),O.up.applyMatrix4(F),O.up.reflect(P),O.lookAt(A),O.far=b.far,O.updateMatrixWorld(),O.projectionMatrix.copy(b.projectionMatrix),U.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),U.multiply(O.projectionMatrix),U.multiply(O.matrixWorldInverse),U.multiply(S.current.matrixWorld),C.setFromNormalAndCoplanarPoint(P,R),C.applyMatrix4(O.matrixWorldInverse),_.set(C.normal.x,C.normal.y,C.normal.z,C.constant);const e=O.projectionMatrix;B.x=(Math.sign(_.x)+e.elements[8])/e.elements[0],B.y=(Math.sign(_.y)+e.elements[9])/e.elements[5],B.z=-1,B.w=(1+e.elements[10])/e.elements[14],_.multiplyScalar(2/_.dot(B)),e.elements[2]=_.x,e.elements[6]=_.y,e.elements[10]=_.z+1,e.elements[14]=_.w}),[]),[I,V,j,W]=T.useMemo((()=>{const e={type:n.HalfFloatType,minFilter:n.LinearFilter,magFilter:n.LinearFilter},o=new n.WebGLRenderTarget(a,a,e);o.depthBuffer=!0,o.depthTexture=new n.DepthTexture(a,a),o.depthTexture.format=n.DepthFormat,o.depthTexture.type=n.UnsignedShortType;const i=new n.WebGLRenderTarget(a,a,e);return[o,i,new gr({gl:w,resolution:a,width:s[0],height:s[1],minDepthThreshold:c,maxDepthThreshold:u,depthScale:m,depthToBlurRatioBias:d}),{mirror:f,textureMatrix:U,mixBlur:t,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:i.texture,hasBlur:M,mixStrength:r,minDepthThreshold:c,maxDepthThreshold:u,depthScale:m,depthToBlurRatioBias:d,transparent:!0,debug:h,distortion:x,distortionMap:v,mixContrast:y,"defines-USE_BLUR":M?"":void 0,"defines-USE_DEPTH":m>0?"":void 0,"defines-USE_DISTORTION":v?"":void 0}]}),[w,s,U,a,f,M,t,r,c,u,m,d,h,x,v,y]);return o.useFrame((()=>{if(null==S||!S.current)return;S.current.visible=!1;const e=w.xr.enabled,t=w.shadowMap.autoUpdate;N(),w.xr.enabled=!1,w.shadowMap.autoUpdate=!1,w.setRenderTarget(I),w.state.buffers.depth.setMask(!0),w.autoClear||w.clear(),w.render(E,O),M&&j.render(w,I,V),w.xr.enabled=e,w.shadowMap.autoUpdate=t,S.current.visible=!0,w.setRenderTarget(null)})),T.createElement("mesh",e({ref:i([S,z])},g),T.createElement("planeGeometry",{args:l}),p?p("meshReflectorMaterial",W):T.createElement("meshReflectorMaterial",W))}));class Un extends n.ShaderMaterial{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new n.Vector3(0,0,0)},lightColor:{value:new n.Color("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new n.Vector2(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation; \n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity; \n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",fragmentShader:"\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}var On="#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D uShadowMap;uniform float uTime;void main(){vec3 color=texture2D(uShadowMap,vUv).xyz;gl_FragColor=vec4(color,1.);}";const Nn=e=>null==e?void 0:e.isSpotLight;function In({opacity:e=1,radiusTop:t,radiusBottom:r,depthBuffer:a,color:i="white",distance:s=5,angle:l=.15,attenuation:c=5,anglePower:u=5}){const m=T.useRef(null),d=o.useThree((e=>e.size)),f=o.useThree((e=>e.camera)),p=o.useThree((e=>e.viewport.dpr)),[h]=T.useState((()=>new Un)),[x]=T.useState((()=>new n.Vector3));t=void 0===t?.1:t,r=void 0===r?7*l:r,o.useFrame((()=>{h.uniforms.spotPosition.value.copy(m.current.getWorldPosition(x)),m.current.lookAt(m.current.parent.target.getWorldPosition(x))}));const y=T.useMemo((()=>{const e=new n.CylinderGeometry(t,r,s,128,64,!0);return e.applyMatrix4((new n.Matrix4).makeTranslation(0,-s/2,0)),e.applyMatrix4((new n.Matrix4).makeRotationX(-Math.PI/2)),e}),[s,t,r]);return T.createElement(T.Fragment,null,T.createElement("mesh",{ref:m,geometry:y,raycast:()=>null},T.createElement("primitive",{object:h,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":i,"uniforms-attenuation-value":c,"uniforms-anglePower-value":u,"uniforms-depth-value":a,"uniforms-cameraNear-value":f.near,"uniforms-cameraFar-value":f.far,"uniforms-resolution-value":a?[d.width*p,d.height*p]:[0,0]})))}function Vn(e,t,r,a,i){const[[s,l]]=T.useState((()=>[new n.Vector3,new n.Vector3]));T.useLayoutEffect((()=>{if(!Nn(e.current))throw new Error("SpotlightShadow must be a child of a SpotLight");e.current.shadow.mapSize.set(r,a),e.current.shadow.needsUpdate=!0}),[e,r,a]),o.useFrame((()=>{if(!e.current)return;const r=e.current.position,n=e.current.target.position;l.copy(n).sub(r);var o=l.length();l.normalize().multiplyScalar(o*i),s.copy(r).add(l),t.current.position.copy(s),t.current.lookAt(e.current.target.position)}))}function jn({distance:e=.4,alphaTest:t=.5,map:r,shader:a=On,width:i=512,height:s=512,scale:l=1,children:c,...u}){const d=T.useRef(null),f=u.spotlightRef,p=u.debug;Vn(f,d,i,s,e);const h=T.useMemo((()=>new n.WebGLRenderTarget(i,s,{format:n.RGBAFormat,encoding:n.LinearEncoding,stencilBuffer:!1})),[i,s]),x=T.useRef({uShadowMap:{value:r},uTime:{value:0}});T.useEffect((()=>{x.current.uShadowMap.value=r}),[r]);const y=T.useMemo((()=>new m.FullScreenQuad(new n.ShaderMaterial({uniforms:x.current,vertexShader:"\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:a}))),[a]);return T.useEffect((()=>()=>{y.material.dispose(),y.dispose()}),[y]),T.useEffect((()=>()=>h.dispose()),[h]),o.useFrame((({gl:e},t)=>{x.current.uTime.value+=t,e.setRenderTarget(h),y.render(e),e.setRenderTarget(null)})),T.createElement(T.Fragment,null,T.createElement("mesh",{ref:d,scale:l,castShadow:!0},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,side:n.DoubleSide,alphaTest:t,alphaMap:h.texture,"alphaMap-wrapS":n.RepeatWrapping,"alphaMap-wrapT":n.RepeatWrapping,opacity:p?1:0},c)))}function Wn({distance:e=.4,alphaTest:t=.5,map:r,width:o=512,height:a=512,scale:i,children:s,...l}){const c=T.useRef(null),u=l.spotlightRef,m=l.debug;return Vn(u,c,o,a,e),T.createElement(T.Fragment,null,T.createElement("mesh",{ref:c,scale:i,castShadow:!0},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,side:n.DoubleSide,alphaTest:t,alphaMap:r,"alphaMap-wrapS":n.RepeatWrapping,"alphaMap-wrapT":n.RepeatWrapping,opacity:m?1:0},s)))}const Gn=T.forwardRef((({opacity:t=1,radiusTop:r,radiusBottom:n,depthBuffer:o,color:a="white",distance:s=5,angle:l=.15,attenuation:c=5,anglePower:u=5,volumetric:m=!0,debug:d=!1,children:f,...p},h)=>{const x=T.useRef(null);return T.createElement("group",null,d&&x.current&&T.createElement("spotLightHelper",{args:[x.current]}),T.createElement("spotLight",e({ref:i([h,x]),angle:l,color:a,distance:s,castShadow:!0},p),m&&T.createElement(In,{debug:d,opacity:t,radiusTop:r,radiusBottom:n,depthBuffer:o,color:a,distance:s,angle:l,attenuation:c,anglePower:u})),f&&T.cloneElement(f,{spotlightRef:x,debug:d}))})),Hn=T.forwardRef((({args:t,map:r,toneMapped:n=!1,color:a="white",form:s="rect",intensity:l=1,scale:c=1,target:u,children:m,...d},f)=>{const p=T.useRef(null);return T.useLayoutEffect((()=>{m||d.material||(o.applyProps(p.current.material,{color:a}),p.current.material.color.multiplyScalar(l))}),[a,l,m,d.material]),T.useLayoutEffect((()=>{u&&p.current.lookAt(Array.isArray(u)?new P.Vector3(...u):u)}),[u]),c=Array.isArray(c)&&2===c.length?[c[0],c[1],1]:c,T.createElement("mesh",e({ref:i([p,f]),scale:c},d),"circle"===s?T.createElement("ringGeometry",{args:[0,1,64]}):"ring"===s?T.createElement("ringGeometry",{args:[.5,1,64]}):"rect"===s?T.createElement("planeGeometry",null):T.createElement(s,{args:t}),m||(d.material?null:T.createElement("meshBasicMaterial",{toneMapped:n,map:r,side:P.DoubleSide})))}));function qn(e,t,r=new n.Vector3){const o=Math.PI*(e-.5),a=2*Math.PI*(t-.5);return r.x=Math.cos(a),r.y=Math.sin(o),r.z=Math.sin(a),r}const $n=T.forwardRef((({inclination:t=.6,azimuth:r=.1,distance:o=1e3,mieCoefficient:a=.005,mieDirectionalG:i=.8,rayleigh:s=.5,turbidity:l=10,sunPosition:c=qn(t,r),...u},d)=>{const f=T.useMemo((()=>(new n.Vector3).setScalar(o)),[o]),[p]=T.useState((()=>new m.Sky));return T.createElement("primitive",e({object:p,ref:d,"material-uniforms-mieCoefficient-value":a,"material-uniforms-mieDirectionalG-value":i,"material-uniforms-rayleigh-value":s,"material-uniforms-sunPosition-value":c,"material-uniforms-turbidity-value":l,scale:f},u))}));class Xn extends n.ShaderMaterial{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:"\n uniform float time;\n attribute float size;\n varying vec3 vColor;\n void main() {\n vColor = color;\n vec4 mvPosition = modelViewMatrix * vec4(position, 0.5);\n gl_PointSize = size * (30.0 / -mvPosition.z) * (3.0 + sin(time + 100.0));\n gl_Position = projectionMatrix * mvPosition;\n }",fragmentShader:"\n uniform sampler2D pointTexture;\n uniform float fade;\n varying vec3 vColor;\n void main() {\n float opacity = 1.0;\n if (fade == 1.0) {\n float d = distance(gl_PointCoord, vec2(0.5, 0.5));\n opacity = 1.0 / (1.0 + exp(16.0 * (d - 0.25)));\n }\n gl_FragColor = vec4(vColor, opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}const Yn=e=>(new n.Vector3).setFromSpherical(new n.Spherical(e,Math.acos(1-2*Math.random()),2*Math.random()*Math.PI)),Kn=T.forwardRef((({radius:e=100,depth:t=50,count:r=5e3,saturation:a=0,factor:i=4,fade:s=!1,speed:l=1},c)=>{const u=T.useRef(),[m,d,f]=T.useMemo((()=>{const o=[],s=[],l=Array.from({length:r},(()=>(.5+.5*Math.random())*i)),c=new n.Color;let u=e+t;const m=t/r;for(let e=0;e<r;e++)u-=m*Math.random(),o.push(...Yn(u).toArray()),c.setHSL(e/r,a,.9),s.push(c.r,c.g,c.b);return[new Float32Array(o),new Float32Array(s),new Float32Array(l)]}),[r,t,i,e,a]);o.useFrame((e=>u.current&&(u.current.uniforms.time.value=e.clock.getElapsedTime()*l)));const[p]=T.useState((()=>new Xn));return T.createElement("points",{ref:c},T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",args:[m,3]}),T.createElement("bufferAttribute",{attach:"attributes-color",args:[d,3]}),T.createElement("bufferAttribute",{attach:"attributes-size",args:[f,1]})),T.createElement("primitive",{ref:u,object:p,attach:"material",blending:n.AdditiveBlending,"uniforms-fade-value":s,depthWrite:!1,transparent:!0,vertexColors:!0}))}));const Zn=xe({time:0,pixelRatio:1}," uniform float pixelRatio;\n uniform float time;\n attribute float size; \n attribute float speed; \n attribute float opacity;\n attribute vec3 noise;\n attribute vec3 color;\n varying vec3 vColor;\n varying float vOpacity;\n void main() {\n vec4 modelPosition = modelMatrix * vec4(position, 1.0);\n modelPosition.y += sin(time * speed + modelPosition.x * noise.x * 100.0) * 0.2;\n modelPosition.z += cos(time * speed + modelPosition.x * noise.y * 100.0) * 0.2;\n modelPosition.x += cos(time * speed + modelPosition.x * noise.z * 100.0) * 0.2;\n vec4 viewPosition = viewMatrix * modelPosition;\n vec4 projectionPostion = projectionMatrix * viewPosition;\n gl_Position = projectionPostion;\n gl_PointSize = size * 25. * pixelRatio;\n gl_PointSize *= (1.0 / - viewPosition.z);\n vColor = color;\n vOpacity = opacity;\n }"," varying vec3 vColor;\n varying float vOpacity;\n void main() {\n float distanceToCenter = distance(gl_PointCoord, vec2(0.5));\n float strength = 0.05 / distanceToCenter - 0.1;\n gl_FragColor = vec4(vColor, strength * vOpacity);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),Qn=e=>e&&e.constructor===Float32Array,Jn=e=>e instanceof P.Vector2||e instanceof P.Vector3||e instanceof P.Vector4,eo=e=>Array.isArray(e)?e:Jn(e)?e.toArray():[e,e,e];function to(e,t,r){return T.useMemo((()=>{if(void 0!==t){if(Qn(t))return t;if(t instanceof P.Color){const r=Array.from({length:3*e},(()=>(e=>[e.r,e.g,e.b])(t))).flat();return Float32Array.from(r)}if(Jn(t)||Array.isArray(t)){const r=Array.from({length:3*e},(()=>eo(t))).flat();return Float32Array.from(r)}return Float32Array.from({length:e},(()=>t))}return Float32Array.from({length:e},r)}),[t])}const ro=T.forwardRef((({noise:t=1,count:r=100,speed:n=1,opacity:a=1,scale:i=1,size:s,color:l,children:c,...u},m)=>{T.useMemo((()=>o.extend({SparklesImplMaterial:Zn})),[]);const d=T.useRef(null),f=o.useThree((e=>e.viewport.dpr)),p=T.useMemo((()=>Float32Array.from(Array.from({length:r},(()=>eo(i).map(P.MathUtils.randFloatSpread))).flat())),[r,i]),h=to(r,s,Math.random),x=to(r,a),y=to(r,n),v=to(3*r,t),g=to(void 0===l?3*r:r,Qn(l)?l:new P.Color(l),(()=>1));return o.useFrame((e=>{d.current&&d.current.material&&(d.current.material.time=e.clock.elapsedTime)})),T.useImperativeHandle(m,(()=>d.current),[]),T.createElement("points",e({key:`particle-${r}-${JSON.stringify(i)}`},u,{ref:d}),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",args:[p,3]}),T.createElement("bufferAttribute",{attach:"attributes-size",args:[h,1]}),T.createElement("bufferAttribute",{attach:"attributes-opacity",args:[x,1]}),T.createElement("bufferAttribute",{attach:"attributes-speed",args:[y,1]}),T.createElement("bufferAttribute",{attach:"attributes-color",args:[g,3]}),T.createElement("bufferAttribute",{attach:"attributes-noise",args:[v,3]})),c||T.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:f,depthWrite:!1}))}));const no={uniforms:{strokeOpacity:1,fillOpacity:.25,fillMix:0,thickness:.05,colorBackfaces:!1,dashInvert:!0,dash:!1,dashRepeats:4,dashLength:.5,squeeze:!1,squeezeMin:.2,squeezeMax:1,stroke:new P.Color("#ff0000"),backfaceStroke:new P.Color("#0000ff"),fill:new P.Color("#00ff00")},vertex:"\n\t attribute vec3 barycentric;\n\t\n\t\tvarying vec3 v_edges_Barycentric;\n\t\tvarying vec3 v_edges_Position;\n\n\t\tvoid initWireframe() {\n\t\t\tv_edges_Barycentric = barycentric;\n\t\t\tv_edges_Position = position.xyz;\n\t\t}\n\t ",fragment:"\n\t\t#ifndef PI\n\t \t#define PI 3.1415926535897932384626433832795\n\t\t#endif\n \n\t varying vec3 v_edges_Barycentric;\n\t varying vec3 v_edges_Position;\n \n\t uniform float strokeOpacity;\n\t uniform float fillOpacity;\n\t uniform float fillMix;\n\t uniform float thickness;\n\t uniform bool colorBackfaces;\n \n\t // Dash\n\t uniform bool dashInvert;\n\t uniform bool dash;\n\t uniform bool dashOnly;\n\t uniform float dashRepeats;\n\t uniform float dashLength;\n \n\t // Squeeze\n\t uniform bool squeeze;\n\t uniform float squeezeMin;\n\t uniform float squeezeMax;\n \n\t // Colors\n\t uniform vec3 stroke;\n\t uniform vec3 backfaceStroke;\n\t uniform vec3 fill;\n \n\t // This is like\n\t float wireframe_aastep(float threshold, float dist) {\n\t\t float afwidth = fwidth(dist) * 0.5;\n\t\t return smoothstep(threshold - afwidth, threshold + afwidth, dist);\n\t }\n \n\t float wireframe_map(float value, float min1, float max1, float min2, float max2) {\n\t\t return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n\t }\n \n\t float getWireframe() {\n\t\t\tvec3 barycentric = v_edges_Barycentric;\n\t\t\n\t\t\t// Distance from center of each triangle to its edges.\n\t\t\tfloat d = min(min(barycentric.x, barycentric.y), barycentric.z);\n\n\t\t\t// for dashed rendering, we can use this to get the 0 .. 1 value of the line length\n\t\t\tfloat positionAlong = max(barycentric.x, barycentric.y);\n\t\t\tif (barycentric.y < barycentric.x && barycentric.y < barycentric.z) {\n\t\t\t\tpositionAlong = 1.0 - positionAlong;\n\t\t\t}\n\n\t\t\t// the thickness of the stroke\n\t\t\tfloat computedThickness = wireframe_map(thickness, 0.0, 1.0, 0.0, 0.34);\n\n\t\t\t// if we want to shrink the thickness toward the center of the line segment\n\t\t\tif (squeeze) {\n\t\t\t\tcomputedThickness *= mix(squeezeMin, squeezeMax, (1.0 - sin(positionAlong * PI)));\n\t\t\t}\n\n\t\t\t// Create dash pattern\n\t\t\tif (dash) {\n\t\t\t\t// here we offset the stroke position depending on whether it\n\t\t\t\t// should overlap or not\n\t\t\t\tfloat offset = 1.0 / dashRepeats * dashLength / 2.0;\n\t\t\t\tif (!dashInvert) {\n\t\t\t\t\toffset += 1.0 / dashRepeats / 2.0;\n\t\t\t\t}\n\n\t\t\t\t// if we should animate the dash or not\n\t\t\t\t// if (dashAnimate) {\n\t\t\t\t// \toffset += time * 0.22;\n\t\t\t\t// }\n\n\t\t\t\t// create the repeating dash pattern\n\t\t\t\tfloat pattern = fract((positionAlong + offset) * dashRepeats);\n\t\t\t\tcomputedThickness *= 1.0 - wireframe_aastep(dashLength, pattern);\n\t\t\t}\n\n\t\t\t// compute the anti-aliased stroke edge \n\t\t\tfloat edge = 1.0 - wireframe_aastep(computedThickness, d);\n\n\t\t\treturn edge;\n\t }\n\t "},oo=xe(no.uniforms,no.vertex+"\n \tvoid main() {\n\t\tinitWireframe();\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n\t}\n ",no.fragment+"\n void main () {\n\t\t// Compute color\n\n\t\tfloat edge = getWireframe();\n\t\tvec4 colorStroke = vec4(stroke, edge);\n\n\t\t#ifdef FLIP_SIDED\n\t\t\tcolorStroke.rgb = backfaceStroke;\n\t\t#endif\n \n\t\tvec4 colorFill = vec4(fill, fillOpacity);\n\t\tvec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);\n\n\t\tgl_FragColor = outColor;\n\t}\n ");function ao(e){return void 0!==(null==e?void 0:e.current)}function io(e){return"WireframeGeometry"===e.type}function so(e){const t=null!=(r=e)&&r.current?e.current:e;var r;if(function(e){return!(null==e||!e.isBufferGeometry)}(t))return t;{if(io(t))throw new Error("Wireframe: WireframeGeometry is not supported.");const e=t.parent;if(function(e){return!(null==e||!e.geometry)}(e)){if(io(e.geometry))throw new Error("Wireframe: WireframeGeometry is not supported.");return e.geometry}}}function lo(e,t){if(e.index){console.warn("Wireframe: Requires non-indexed geometry, converting to non-indexed geometry.");const t=e.toNonIndexed();e.copy(t),e.setIndex(null)}const r=function(e,t){const r=e.getAttribute("position").count,n=[];for(let e=0;e<r;e++){const r=t?1:0;e%2==0?n.push(0,0,1,0,1,0,1,0,r):n.push(0,1,0,0,0,1,1,0,r)}return new P.BufferAttribute(Float32Array.from(n),3)}(e,t);e.setAttribute("barycentric",r)}function co({geometry:t,simplify:r=!1,...n}){const[o,a]=T.useState(null);T.useLayoutEffect((()=>{const e=so(t);if(!e)throw new Error("Wireframe: geometry prop must be a BufferGeometry or a ref to a BufferGeometry.");lo(e,r),ao(t)&&a(e)}),[r,t]);const i=ao(t)?o:t;return T.createElement(T.Fragment,null,i&&T.createElement("mesh",{geometry:i},T.createElement("meshWireframeMaterial",e({attach:"material",transparent:!0,side:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-4},n,{extensions:{derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1}}))))}function uo({simplify:e=!1,...t}){const r=T.useRef(null),n=T.useMemo((()=>function(){const e={};for(const t in no.uniforms)e[t]={value:no.uniforms[t]};return e}()),[no.uniforms]);return function(e,t){T.useEffect((()=>{var r;e.fillOpacity.value=null!==(r=t.fillOpacity)&&void 0!==r?r:e.fillOpacity.value}),[t.fillOpacity]),T.useEffect((()=>{var r;e.fillMix.value=null!==(r=t.fillMix)&&void 0!==r?r:e.fillMix.value}),[t.fillMix]),T.useEffect((()=>{var r;e.strokeOpacity.value=null!==(r=t.strokeOpacity)&&void 0!==r?r:e.strokeOpacity.value}),[t.strokeOpacity]),T.useEffect((()=>{var r;e.thickness.value=null!==(r=t.thickness)&&void 0!==r?r:e.thickness.value}),[t.thickness]),T.useEffect((()=>{e.colorBackfaces.value=!!t.colorBackfaces}),[t.colorBackfaces]),T.useEffect((()=>{e.dash.value=!!t.dash}),[t.dash]),T.useEffect((()=>{e.dashInvert.value=!!t.dashInvert}),[t.dashInvert]),T.useEffect((()=>{var r;e.dashRepeats.value=null!==(r=t.dashRepeats)&&void 0!==r?r:e.dashRepeats.value}),[t.dashRepeats]),T.useEffect((()=>{var r;e.dashLength.value=null!==(r=t.dashLength)&&void 0!==r?r:e.dashLength.value}),[t.dashLength]),T.useEffect((()=>{e.squeeze.value=!!t.squeeze}),[t.squeeze]),T.useEffect((()=>{var r;e.squeezeMin.value=null!==(r=t.squeezeMin)&&void 0!==r?r:e.squeezeMin.value}),[t.squeezeMin]),T.useEffect((()=>{var r;e.squeezeMax.value=null!==(r=t.squeezeMax)&&void 0!==r?r:e.squeezeMax.value}),[t.squeezeMax]),T.useEffect((()=>{e.stroke.value=t.stroke?new P.Color(t.stroke):e.stroke.value}),[t.stroke]),T.useEffect((()=>{e.fill.value=t.fill?new P.Color(t.fill):e.fill.value}),[t.fill]),T.useEffect((()=>{e.backfaceStroke.value=t.backfaceStroke?new P.Color(t.backfaceStroke):e.backfaceStroke.value}),[t.backfaceStroke])}(n,t),T.useLayoutEffect((()=>{const t=so(r);if(!t)throw new Error("Wireframe: Must be a child of a Mesh, Line or Points object or specify a geometry prop.");const n=t.clone();return lo(t,e),()=>{t.copy(n),n.dispose()}}),[e]),T.useLayoutEffect((()=>{const e=r.current.parent,t=e.material.clone();return function(e,t){e.onBeforeCompile=e=>{e.uniforms={...e.uniforms,...t},e.vertexShader=e.vertexShader.replace("void main() {",`\n\t\t ${no.vertex}\n\t\t void main() {\n\t\t\tinitWireframe();\n\t\t`),e.fragmentShader=e.fragmentShader.replace("void main() {",`\n\t\t ${no.fragment}\n\t\t void main() {\n\t\t`),e.fragmentShader=e.fragmentShader.replace("#include <color_fragment>","\n\t\t #include <color_fragment>\n\t\t\t float edge = getWireframe();\n\t\t vec4 colorStroke = vec4(stroke, edge);\n\t\t #ifdef FLIP_SIDED\n\t\t\tcolorStroke.rgb = backfaceStroke;\n\t\t #endif\n\t\t vec4 colorFill = vec4(mix(diffuseColor.rgb, fill, fillMix), mix(diffuseColor.a, fillOpacity, fillMix));\n\t\t vec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);\n\n\t\t diffuseColor.rgb = outColor.rgb;\n\t\t diffuseColor.a *= outColor.a;\n\t\t")},e.side=P.DoubleSide,e.transparent=!0}(e.material,n),()=>{e.material.dispose(),e.material=t}}),[]),T.createElement("object3D",{ref:r})}R.extend({MeshWireframeMaterial:oo});const mo=new P.Matrix4,fo=new P.Ray,po=new P.Sphere,ho=new P.Vector3;class xo extends P.Group{constructor(){super(),this.size=0,this.color=new P.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){var r,n;const o=this.instance.current;if(!o||!o.geometry)return;const a=o.userData.instances.indexOf(this.instanceKey);if(-1===a||a>o.geometry.drawRange.count)return;const i=null!==(r=null==(n=e.params.Points)?void 0:n.threshold)&&void 0!==r?r:1;if(po.set(this.getWorldPosition(ho),i),!1===e.ray.intersectsSphere(po))return;mo.copy(o.matrixWorld).invert(),fo.copy(e.ray).applyMatrix4(mo);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),l=s*s,c=fo.distanceSqToPoint(this.position);if(c<l){const r=new P.Vector3;fo.closestPointToPoint(this.position,r),r.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(r);if(n<e.near||n>e.far)return;t.push({distance:n,distanceToRay:Math.sqrt(c),point:r,index:a,face:null,object:this})}}}let yo,vo;const go=T.createContext(null),zo=new P.Matrix4,wo=new P.Vector3,bo=T.forwardRef((({children:t,range:r,limit:n=1e3,...a},s)=>{const l=T.useRef(null),[c,u]=T.useState([]),[[m,d,f]]=T.useState((()=>[new Float32Array(3*n),Float32Array.from({length:3*n},(()=>1)),Float32Array.from({length:n},(()=>1))]));T.useEffect((()=>{l.current.geometry.attributes.position.needsUpdate=!0})),o.useFrame((()=>{for(l.current.updateMatrix(),l.current.updateMatrixWorld(),zo.copy(l.current.matrixWorld).invert(),l.current.geometry.drawRange.count=Math.min(n,void 0!==r?r:n,c.length),yo=0;yo<c.length;yo++)vo=c[yo].current,vo.getWorldPosition(wo).applyMatrix4(zo),wo.toArray(m,3*yo),l.current.geometry.attributes.position.needsUpdate=!0,vo.matrixWorldNeedsUpdate=!0,vo.color.toArray(d,3*yo),l.current.geometry.attributes.color.needsUpdate=!0,f.set([vo.size],yo),l.current.geometry.attributes.size.needsUpdate=!0}));const p=T.useMemo((()=>({getParent:()=>l,subscribe:e=>(u((t=>[...t,e])),()=>u((t=>t.filter((t=>t.current!==e.current)))))})),[]);return T.createElement("points",e({userData:{instances:c},matrixAutoUpdate:!1,ref:i([s,l]),raycast:()=>null},a),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",count:m.length/3,array:m,itemSize:3,usage:P.DynamicDrawUsage}),T.createElement("bufferAttribute",{attach:"attributes-color",count:d.length/3,array:d,itemSize:3,usage:P.DynamicDrawUsage}),T.createElement("bufferAttribute",{attach:"attributes-size",count:f.length,array:f,itemSize:1,usage:P.DynamicDrawUsage})),T.createElement(go.Provider,{value:p},t))})),Eo=T.forwardRef((({children:t,...r},n)=>{T.useMemo((()=>o.extend({PositionPoint:xo})),[]);const a=T.useRef(),{subscribe:s,getParent:l}=T.useContext(go);return T.useLayoutEffect((()=>s(a)),[]),T.createElement("positionPoint",e({instance:l(),instanceKey:a,ref:i([n,a])},r),t)})),Mo=T.forwardRef((({children:t,positions:r,colors:n,sizes:a,stride:s=3,...l},c)=>{const u=T.useRef(null);return o.useFrame((()=>{const e=u.current.geometry.attributes;e.position.needsUpdate=!0,n&&(e.color.needsUpdate=!0),a&&(e.size.needsUpdate=!0)})),T.createElement("points",e({ref:i([c,u])},l),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",count:r.length/s,array:r,itemSize:s,usage:P.DynamicDrawUsage}),n&&T.createElement("bufferAttribute",{attach:"attributes-color",count:n.length/s,array:n,itemSize:3,usage:P.DynamicDrawUsage}),a&&T.createElement("bufferAttribute",{attach:"attributes-size",count:a.length/s,array:a,itemSize:1,usage:P.DynamicDrawUsage})),t)})),So=T.forwardRef(((t,r)=>t.positions instanceof Float32Array?T.createElement(Mo,e({},t,{ref:r})):T.createElement(bo,e({},t,{ref:r})))),To=new P.Matrix4,Co=new P.Matrix4,Po=[],Ro=new P.Mesh;class Do extends P.Group{constructor(){super(),this.color=new P.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){const r=this.instance.current;if(!r)return;if(!r.geometry||!r.material)return;Ro.geometry=r.geometry;const n=r.matrixWorld,o=r.userData.instances.indexOf(this.instanceKey);if(!(-1===o||o>r.count)){r.getMatrixAt(o,To),Co.multiplyMatrices(n,To),Ro.matrixWorld=Co,r.material instanceof P.Material?Ro.material.side=r.material.side:Ro.material.side=r.material[0].side,Ro.raycast(e,Po);for(let e=0,r=Po.length;e<r;e++){const r=Po[e];r.instanceId=o,r.object=this,t.push(r)}Po.length=0}}}const Fo=T.createContext(null),ko=new P.Matrix4,_o=new P.Matrix4,Lo=new P.Matrix4,Ao=new P.Vector3,Bo=new P.Quaternion,Uo=new P.Vector3,Oo=T.forwardRef((({context:t,children:r,...n},a)=>{T.useMemo((()=>o.extend({PositionMesh:Do})),[]);const s=T.useRef(),{subscribe:l,getParent:c}=T.useContext(t||Fo);return T.useLayoutEffect((()=>l(s)),[]),T.createElement("positionMesh",e({instance:c(),instanceKey:s,ref:i([a,s])},n),r)})),No=T.forwardRef((({children:t,range:r,limit:n=1e3,frames:a=1/0,...s},l)=>{const[{context:c,instance:u}]=T.useState((()=>{const t=T.createContext(null);return{context:t,instance:T.forwardRef(((r,n)=>T.createElement(Oo,e({context:t},r,{ref:n}))))}})),m=T.useRef(null),[d,f]=T.useState([]),[[p,h]]=T.useState((()=>{const e=new Float32Array(16*n);for(let t=0;t<n;t++)Lo.identity().toArray(e,16*t);return[e,new Float32Array([...new Array(3*n)].map((()=>1)))]}));T.useEffect((()=>{m.current.instanceMatrix.needsUpdate=!0}));let x=0,y=0;o.useFrame((()=>{if(a===1/0||x<a){m.current.updateMatrix(),m.current.updateMatrixWorld(),ko.copy(m.current.matrixWorld).invert(),y=Math.min(n,void 0!==r?r:n,d.length),m.current.count=y,m.current.instanceMatrix.updateRange.count=16*y,m.current.instanceColor.updateRange.count=3*y;for(let e=0;e<d.length;e++){const t=d[e].current;t.matrixWorld.decompose(Ao,Bo,Uo),_o.compose(Ao,Bo,Uo).premultiply(ko),_o.toArray(p,16*e),m.current.instanceMatrix.needsUpdate=!0,t.color.toArray(h,3*e),m.current.instanceColor.needsUpdate=!0}x++}}));const v=T.useMemo((()=>({getParent:()=>m,subscribe:e=>(f((t=>[...t,e])),()=>f((t=>t.filter((t=>t.current!==e.current)))))})),[]);return T.createElement("instancedMesh",e({userData:{instances:d},matrixAutoUpdate:!1,ref:i([l,m]),args:[null,null,0],raycast:()=>null},s),T.createElement("instancedBufferAttribute",{attach:"instanceMatrix",count:p.length/16,array:p,itemSize:16,usage:P.DynamicDrawUsage}),T.createElement("instancedBufferAttribute",{attach:"instanceColor",count:h.length/3,array:h,itemSize:3,usage:P.DynamicDrawUsage}),"function"==typeof t?T.createElement(c.Provider,{value:v},t(u)):T.createElement(Fo.Provider,{value:v},t))})),Io=T.forwardRef((function({meshes:t,children:r,...n},o){const a=Array.isArray(t);if(!a)for(const e of Object.keys(t))t[e].isMesh||delete t[e];return T.createElement("group",{ref:o},T.createElement(E,{components:(a?t:Object.values(t)).map((({geometry:t,material:r})=>T.createElement(No,e({key:t.uuid,geometry:t,material:r},n))))},(e=>a?r(...e):r(Object.keys(t).filter((e=>t[e].isMesh)).reduce(((t,r,n)=>({...t,[r]:e[n]})),{})))))})),Vo=T.createContext(null),jo=T.forwardRef(((t,r)=>{T.useMemo((()=>o.extend({SegmentObject:Wo})),[]);const{limit:n=1e3,lineWidth:a=1,children:i,...s}=t,[l,c]=T.useState([]),[u]=T.useState((()=>new m.Line2)),[d]=T.useState((()=>new m.LineMaterial)),[f]=T.useState((()=>new m.LineSegmentsGeometry)),[p]=T.useState((()=>new P.Vector2(512,512))),[h]=T.useState((()=>Array(6*n).fill(0))),[x]=T.useState((()=>Array(6*n).fill(0))),y=T.useMemo((()=>({subscribe:e=>(c((t=>[...t,e])),()=>c((t=>t.filter((t=>t.current!==e.current)))))})),[]);return o.useFrame((()=>{for(let t=0;t<n;t++){var e;const r=null==(e=l[t])?void 0:e.current;r&&(h[6*t+0]=r.start.x,h[6*t+1]=r.start.y,h[6*t+2]=r.start.z,h[6*t+3]=r.end.x,h[6*t+4]=r.end.y,h[6*t+5]=r.end.z,x[6*t+0]=r.color.r,x[6*t+1]=r.color.g,x[6*t+2]=r.color.b,x[6*t+3]=r.color.r,x[6*t+4]=r.color.g,x[6*t+5]=r.color.b)}f.setColors(x),f.setPositions(h),u.computeLineDistances()})),T.createElement("primitive",{object:u,ref:r},T.createElement("primitive",{object:f,attach:"geometry"}),T.createElement("primitive",e({object:d,attach:"material",vertexColors:!0,resolution:p,linewidth:a},s)),T.createElement(Vo.Provider,{value:y},i))}));class Wo{constructor(){this.color=new P.Color("white"),this.start=new P.Vector3(0,0,0),this.end=new P.Vector3(0,0,0)}}const Go=e=>e instanceof P.Vector3?e:new P.Vector3(..."number"==typeof e?[e,e,e]:e),Ho=T.forwardRef((({color:e,start:t,end:r},n)=>{const o=T.useContext(Vo);if(!o)throw"Segment must used inside Segments component.";const a=T.useRef(null);return T.useLayoutEffect((()=>o.subscribe(a)),[]),T.createElement("segmentObject",{ref:i([a,n]),color:e,start:Go(t),end:Go(r)})})),qo=T.forwardRef((({children:t,hysteresis:r=0,distances:n,...a},s)=>{const l=T.useRef(null);return T.useLayoutEffect((()=>{const{current:e}=l;e.levels.length=0,e.children.forEach(((t,o)=>e.levels.push({object:t,hysteresis:r,distance:n[o]})))})),o.useFrame((e=>{var t;return null==(t=l.current)?void 0:t.update(e.camera)})),T.createElement("lOD",e({ref:i([l,s])},a),t)}));const $o=new n.Matrix4,Xo=new n.Ray,Yo=new n.Sphere,Ko=new n.Vector3;const Zo=t.createContext(null);const Qo=T.forwardRef((({children:t,compute:r,width:n,height:a,samples:i=8,renderPriority:s=0,eventPriority:l=0,frames:c=1/0,stencilBuffer:u=!1,depthBuffer:m=!0,generateMipmaps:d=!1,...f},p)=>{const{size:h,viewport:x}=o.useThree(),y=je((n||h.width)*x.dpr,(a||h.height)*x.dpr,{samples:i,stencilBuffer:u,depthBuffer:m,generateMipmaps:d}),[v]=T.useState((()=>new P.Scene)),g=T.useCallback(((e,t,r)=>{var n,o;let a=null==(n=y.texture)?void 0:n.__r3f.parent;for(;a&&!(a instanceof P.Object3D);)a=a.__r3f.parent;if(!a)return!1;r.raycaster.camera||r.events.compute(e,r,null==(o=r.previousRoot)?void 0:o.getState());const[i]=r.raycaster.intersectObject(a);if(!i)return!1;const s=i.uv;if(!s)return!1;t.raycaster.setFromCamera(t.pointer.set(2*s.x-1,2*s.y-1),t.camera)}),[]);return T.useImperativeHandle(p,(()=>y.texture),[y]),T.createElement(T.Fragment,null,o.createPortal(T.createElement(Jo,{renderPriority:s,frames:c,fbo:y},t,T.createElement("group",{onPointerOver:()=>null})),v,{events:{compute:r||g,priority:l}}),T.createElement("primitive",e({object:y.texture},f)))}));function Jo({frames:e,renderPriority:t,children:r,fbo:n}){let a,i=0;return o.useFrame((t=>{(e===1/0||i<e)&&(a=t.gl.autoClear,t.gl.autoClear=!0,t.gl.setRenderTarget(n),t.gl.render(t.scene,t.camera),t.gl.setRenderTarget(null),t.gl.autoClear=a,i++)}),t),T.createElement(T.Fragment,null,r)}const ea=T.forwardRef((({id:t=1,colorWrite:r=!1,depthWrite:n=!1,...o},a)=>{const i=T.useRef(null),s=T.useMemo((()=>({colorWrite:r,depthWrite:n,stencilWrite:!0,stencilRef:t,stencilFunc:P.AlwaysStencilFunc,stencilFail:P.ReplaceStencilOp,stencilZFail:P.ReplaceStencilOp,stencilZPass:P.ReplaceStencilOp})),[t,r,n]);return T.useLayoutEffect((()=>{Object.assign(i.current.material,s)})),T.useImperativeHandle(a,(()=>i.current),[]),T.createElement("mesh",e({ref:i,renderOrder:-t},o))}));const ta=xe({blur:0,map:null,sdf:null,blend:0,size:0,resolution:new P.Vector2},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vUv = uv;\n }","uniform sampler2D sdf;\n uniform sampler2D map;\n uniform float blur;\n uniform float size;\n uniform float time;\n uniform vec2 resolution;\n varying vec2 vUv;\n #include <packing>\n void main() {\n vec2 uv = gl_FragCoord.xy / resolution.xy;\n vec4 t = texture2D(map, uv);\n float k = blur;\n float d = texture2D(sdf, vUv).r/size;\n float alpha = 1.0 - smoothstep(0.0, 1.0, clamp(d/k + 1.0, 0.0, 1.0));\n gl_FragColor = vec4(t.rgb, blur == 0.0 ? t.a : t.a * alpha);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),ra=T.forwardRef((({children:t,events:r,blur:n=0,eventPriority:a=0,renderPriority:i=0,worldUnits:s=!1,resolution:l=512,...c},u)=>{o.extend({PortalMaterialImpl:ta});const m=T.useRef(null),{scene:d,gl:f,size:p,viewport:h,setEvents:x}=o.useThree(),y=je(l,l),[v,g]=T.useState(0);o.useFrame((()=>{const e=m.current.blend>0?Math.max(1,i):0;v!==e&&g(e)})),T.useEffect((()=>{void 0!==r&&x({enabled:!r})}),[r]);const[z,w]=T.useState(!0),b=rr(w);T.useLayoutEffect((()=>{var e;b.current=null==(e=m.current)?void 0:e.__r3f.parent}),[]),T.useLayoutEffect((()=>{if(b.current&&n&&null===m.current.sdf){const e=new P.Mesh(b.current.geometry,new P.MeshBasicMaterial),t=(new P.Box3).setFromBufferAttribute(e.geometry.attributes.position),r=new P.OrthographicCamera(t.min.x*(1+2/l),t.max.x*(1+2/l),t.max.y*(1+2/l),t.min.y*(1+2/l),.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0),f.setRenderTarget(y),f.render(e,r);const n=oa(l,l,f)(y.texture),o=new Float32Array(l*l);f.readRenderTargetPixels(n,0,0,l,l,o);let a=1/0;for(let e=0;e<o.length;e++)o[e]<a&&(a=o[e]);a=-a,m.current.size=a,m.current.sdf=n.texture,f.setRenderTarget(null)}}),[l,n]),T.useImperativeHandle(u,(()=>m.current));const E=T.useCallback(((e,t,r)=>{var n;if(!b.current)return!1;if(t.pointer.set(e.offsetX/t.size.width*2-1,-e.offsetY/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera),0===(null==(n=m.current)?void 0:n.blend)){const[e]=t.raycaster.intersectObject(b.current);if(!e)return t.raycaster.camera=void 0,!1}}),[]);return T.createElement("portalMaterialImpl",e({ref:m,blur:n,blend:0,resolution:[p.width*h.dpr,p.height*h.dpr],toneMapped:!1,attach:"material"},c),T.createElement(Qo,{attach:"map",frames:z?1/0:0,eventPriority:a,renderPriority:i,compute:E},t,T.createElement(na,{events:r,rootScene:d,priority:v,material:m,worldUnits:s})))}));function na({events:e,rootScene:t,material:r,priority:n,worldUnits:a}){const i=o.useThree((e=>e.scene)),s=o.useThree((e=>e.setEvents)),l=je(),c=je();T.useLayoutEffect((()=>{i.matrixAutoUpdate=!1}),[]),T.useEffect((()=>{void 0!==e&&s({enabled:e})}),[e]);const[u,d]=T.useMemo((()=>{const e={value:0};return[new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{a:{value:l.texture},b:{value:c.texture},blend:e},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D a;\n uniform sampler2D b;\n uniform float blend;\n varying vec2 vUv;\n #include <packing>\n void main() {\n vec4 ta = texture2D(a, vUv);\n vec4 tb = texture2D(b, vUv);\n gl_FragColor = mix(tb, ta, blend);\n #include <encodings_fragment>\n }"})),e]}),[]);return o.useFrame((e=>{var o;let s=null==r||null==(o=r.current)?void 0:o.__r3f.parent;if(s){var m,f,p,h;if(a)i.matrixWorld.identity();else n&&1===(null==(m=r.current)?void 0:m.blend)&&s.updateWorldMatrix(!0,!1),i.matrixWorld.copy(s.matrixWorld);if(n)(null==(f=r.current)?void 0:f.blend)>0&&(null==(p=r.current)?void 0:p.blend)<1?(d.value=r.current.blend,e.gl.setRenderTarget(l),e.gl.render(i,e.camera),e.gl.setRenderTarget(c),e.gl.render(t,e.camera),e.gl.setRenderTarget(null),u.render(e.gl)):1===(null==(h=r.current)?void 0:h.blend)&&e.gl.render(i,e.camera)}}),n),T.createElement(T.Fragment,null)}const oa=(e,t,r)=>{let n=new P.WebGLRenderTarget(e,t,{minFilter:P.LinearMipmapLinearFilter,magFilter:P.LinearFilter,type:P.FloatType,format:P.RedFormat,generateMipmaps:!0}),o=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),a=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),i=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),s=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),l=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter,type:P.FloatType,format:P.RedFormat}),c=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter,type:P.FloatType,format:P.RedFormat});const u=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D tex;\n varying vec2 vUv;\n #include <packing>\n void main() {\n gl_FragColor = pack2HalfToRGBA(vUv * (round(texture2D(tex, vUv).x)));\n }"})),d=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D tex;\n varying vec2 vUv;\n #include <packing>\n void main() {\n gl_FragColor = pack2HalfToRGBA(vUv * (1.0 - round(texture2D(tex, vUv).x)));\n }"})),f=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null},offset:{value:0},level:{value:0},maxSteps:{value:0}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:`\n varying vec2 vUv;\n uniform sampler2D tex;\n uniform float offset;\n uniform float level;\n uniform float maxSteps;\n #include <packing>\n void main() {\n float closestDist = 9999999.9;\n vec2 closestPos = vec2(0.0);\n for (float x = -1.0; x <= 1.0; x += 1.0) {\n for (float y = -1.0; y <= 1.0; y += 1.0) {\n vec2 voffset = vUv;\n voffset += vec2(x, y) * vec2(${1/e}, ${1/t}) * offset;\n vec2 pos = unpackRGBATo2Half(texture2D(tex, voffset));\n float dist = distance(pos.xy, vUv);\n if(pos.x != 0.0 && pos.y != 0.0 && dist < closestDist) {\n closestDist = dist;\n closestPos = pos;\n }\n }\n }\n gl_FragColor = pack2HalfToRGBA(closestPos);\n }`})),p=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null},size:{value:new P.Vector2(e,t)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D tex;\n uniform vec2 size;\n #include <packing>\n void main() {\n gl_FragColor = vec4(distance(size * unpackRGBATo2Half(texture2D(tex, vUv)), size * vUv), 0.0, 0.0, 0.0);\n }"})),h=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{inside:{value:c.texture},outside:{value:l.texture},tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D inside;\n uniform sampler2D outside;\n uniform sampler2D tex;\n #include <packing>\n void main() {\n float i = texture2D(inside, vUv).x;\n float o =texture2D(outside, vUv).x;\n if (texture2D(tex, vUv).x == 0.0) {\n gl_FragColor = vec4(o, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = vec4(-i, 0.0, 0.0, 0.0);\n }\n }"}));return m=>{let x=n;m.minFilter=P.NearestFilter,m.magFilter=P.NearestFilter,u.material.uniforms.tex.value=m,r.setRenderTarget(o),u.render(r);const y=Math.ceil(Math.log(Math.max(e,t))/Math.log(2));let v=o,g=null;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===o?i:o,f.material.uniforms.level.value=e,f.material.uniforms.maxSteps.value=y,f.material.uniforms.offset.value=t,f.material.uniforms.tex.value=v.texture,r.setRenderTarget(g),f.render(r),v=g}r.setRenderTarget(l),p.material.uniforms.tex.value=g.texture,p.render(r),d.material.uniforms.tex.value=m,r.setRenderTarget(a),d.render(r),v=a;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===a?s:a,f.material.uniforms.level.value=e,f.material.uniforms.maxSteps.value=y,f.material.uniforms.offset.value=t,f.material.uniforms.tex.value=v.texture,r.setRenderTarget(g),f.render(r),v=g}return r.setRenderTarget(c),p.material.uniforms.tex.value=g.texture,p.render(r),r.setRenderTarget(x),h.material.uniforms.tex.value=m,h.render(r),r.setRenderTarget(null),x}},aa=new P.Color;function ia(e){return"top"in e}function sa({canvasSize:e,scene:t,index:r,children:n,frames:a,rect:i,track:s}){const l=o.useThree((e=>e.get)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.scene)),m=o.useThree((e=>e.setEvents));let d=0;return o.useFrame((r=>{var o,l;(a===1/0||d<=a)&&(i.current=null==(o=s.current)?void 0:o.getBoundingClientRect(),d++);if(i.current){const{position:{left:o,bottom:a,width:s,height:m},isOffscreen:d}=function(e,t){const{right:r,top:n,left:o,bottom:a,width:i,height:s}=t,l=t.bottom<0||n>e.height||r<0||t.left>e.width;if(ia(e)){const t=e.top+e.height-a;return{position:{width:i,height:s,left:o-e.left,top:n,bottom:t,right:r},isOffscreen:l}}return{position:{width:i,height:s,top:n,left:o,bottom:e.height-a,right:r},isOffscreen:l}}(e,i.current),f=s/m;(l=c)&&l.isOrthographicCamera?c.left===s/-2&&c.right===s/2&&c.top===m/2&&c.bottom===m/-2||(Object.assign(c,{left:s/-2,right:s/2,top:m/2,bottom:m/-2}),c.updateProjectionMatrix()):c.aspect!==f&&(c.aspect=f,c.updateProjectionMatrix()),r.gl.setViewport(o,a,s,m),r.gl.setScissor(o,a,s,m),r.gl.setScissorTest(!0),d?(r.gl.getClearColor(aa),r.gl.setClearColor(aa,r.gl.getClearAlpha()),r.gl.clear(!0,!0)):r.gl.render(n?u:t,c),r.gl.setScissorTest(!0)}}),r),T.useEffect((()=>{const e=l().events.connected;return m({connected:s.current}),()=>m({connected:e})}),[]),T.useEffect((()=>{ia(e)||console.warn("Detected @react-three/fiber canvas size does not include position information. <View /> may not work as expected. Upgrade to @react-three/fiber ^8.1.0 for support.\n See https://github.com/pmndrs/drei/issues/944")}),[]),T.createElement(T.Fragment,null,n)}const la=T.createContext(null),ca=new P.Vector3,ua=new P.Vector3,ma=new P.Vector3(0,1,0),da=new P.Matrix4,fa=({direction:e,axis:t})=>{const{translation:r,translationLimits:n,annotations:a,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:m,hoveredColor:d,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=T.useContext(la),v=o.useThree((e=>e.controls)),g=T.useRef(null),z=T.useRef(null),w=T.useRef(null),b=T.useRef(0),[E,M]=T.useState(!1),S=T.useCallback((n=>{a&&(g.current.innerText=`${r.current[t].toFixed(2)}`,g.current.style.display="block"),n.stopPropagation();const o=(new P.Matrix4).extractRotation(z.current.matrixWorld),i=n.point.clone(),s=(new P.Vector3).setFromMatrixPosition(z.current.matrixWorld),l=e.clone().applyMatrix4(o).normalize();w.current={clickPoint:i,dir:l},b.current=r.current[t],p({component:"Arrow",axis:t,origin:s,directions:[l]}),v&&(v.enabled=!1),n.target.setPointerCapture(n.pointerId)}),[a,e,v,p,r,t]),C=T.useCallback((e=>{if(e.stopPropagation(),E||M(!0),w.current){const{clickPoint:o,dir:i}=w.current,[s,l]=(null==n?void 0:n[t])||[void 0,void 0];let c=((e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);return 0===i?-a/o:(ca.copy(n).multiplyScalar(o/i).sub(t),ua.copy(n).multiplyScalar(a/i).add(r).sub(e),-ca.dot(ua)/ca.dot(ca))})(o,i,e.ray.origin,e.ray.direction);void 0!==s&&(c=Math.max(c,s-b.current)),void 0!==l&&(c=Math.min(c,l-b.current)),r.current[t]=b.current+c,a&&(g.current.innerText=`${r.current[t].toFixed(2)}`),da.makeTranslation(i.x*c,i.y*c,i.z*c),h(da)}}),[a,h,E,r,n,t]),R=T.useCallback((e=>{a&&(g.current.style.display="none"),e.stopPropagation(),w.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[a,v,x]),D=T.useCallback((e=>{e.stopPropagation(),M(!1)}),[]),{cylinderLength:F,coneWidth:k,coneLength:_,matrixL:L}=T.useMemo((()=>{const t=u?c/l*1.6:l/20,r=u?.2:l/5,n=u?1-r:l-r,o=(new P.Quaternion).setFromUnitVectors(ma,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new P.Matrix4).makeRotationFromQuaternion(o)}}),[e,l,c,u]),A=E?d:m[t];return T.createElement("group",{ref:z},T.createElement("group",{matrix:L,matrixAutoUpdate:!1,onPointerDown:S,onPointerMove:C,onPointerUp:R,onPointerOut:D},a&&T.createElement(N,{position:[0,-_,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),T.createElement("mesh",{visible:!1,position:[0,(F+_)/2,0],userData:y},T.createElement("cylinderGeometry",{args:[1.4*k,1.4*k,F+_,8,1]})),T.createElement(re,{transparent:!0,raycast:()=>null,depthTest:s,points:[0,0,0,0,F,0],lineWidth:c,color:A,opacity:f,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),T.createElement("mesh",{raycast:()=>null,position:[0,F+_/2,0],renderOrder:500},T.createElement("coneGeometry",{args:[k,_,24,1]}),T.createElement("meshBasicMaterial",{transparent:!0,depthTest:s,color:A,opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},pa=new P.Ray,ha=new P.Vector3,xa=new P.Matrix4,ya=({dir1:e,dir2:t,axis:r})=>{const{translation:n,translationLimits:a,annotations:i,annotationsClass:s,depthTest:l,scale:c,lineWidth:u,fixed:m,axisColors:d,hoveredColor:f,opacity:p,onDragStart:h,onDrag:x,onDragEnd:y,userData:v}=T.useContext(la),g=o.useThree((e=>e.controls)),z=T.useRef(null),w=T.useRef(null),b=T.useRef(null),E=T.useRef(0),M=T.useRef(0),[S,C]=T.useState(!1),R=T.useCallback((e=>{i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`,z.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),o=(new P.Vector3).setFromMatrixPosition(w.current.matrixWorld),a=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,0).normalize(),s=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,1).normalize(),l=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,2).normalize(),c=(new P.Plane).setFromNormalAndCoplanarPoint(l,o);b.current={clickPoint:t,e1:a,e2:s,plane:c},E.current=n.current[(r+1)%3],M.current=n.current[(r+2)%3],h({component:"Slider",axis:r,origin:o,directions:[a,s,l]}),g&&(g.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[i,g,h,r]),D=T.useCallback((e=>{if(e.stopPropagation(),S||C(!0),b.current){const{clickPoint:t,e1:o,e2:s,plane:l}=b.current,[c,u]=(null==a?void 0:a[(r+1)%3])||[void 0,void 0],[m,d]=(null==a?void 0:a[(r+2)%3])||[void 0,void 0];pa.copy(e.ray),pa.intersectPlane(l,ha),pa.direction.negate(),pa.intersectPlane(l,ha),ha.sub(t);let[f,p]=((e,t,r)=>{const n=Math.abs(e.x)>=Math.abs(e.y)&&Math.abs(e.x)>=Math.abs(e.z)?0:Math.abs(e.y)>=Math.abs(e.x)&&Math.abs(e.y)>=Math.abs(e.z)?1:2,o=[0,1,2].sort(((e,r)=>Math.abs(t.getComponent(r))-Math.abs(t.getComponent(e)))),a=n===o[0]?o[1]:o[0],i=e.getComponent(n),s=e.getComponent(a),l=t.getComponent(n),c=t.getComponent(a),u=r.getComponent(n),m=(r.getComponent(a)-u*(s/i))/(c-l*(s/i));return[(u-m*l)/i,m]})(o,s,ha);void 0!==c&&(f=Math.max(f,c-E.current)),void 0!==u&&(f=Math.min(f,u-E.current)),void 0!==m&&(p=Math.max(p,m-M.current)),void 0!==d&&(p=Math.min(p,d-M.current)),n.current[(r+1)%3]=E.current+f,n.current[(r+2)%3]=M.current+p,i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`),xa.makeTranslation(f*o.x+p*s.x,f*o.y+p*s.y,f*o.z+p*s.z),x(xa)}}),[i,x,S,n,a,r]),F=T.useCallback((e=>{i&&(z.current.style.display="none"),e.stopPropagation(),b.current=null,y(),g&&(g.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[i,g,y]),k=T.useCallback((e=>{e.stopPropagation(),C(!1)}),[]),_=T.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new P.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),L=m?1/7:c/7,A=m?.225:.225*c,B=S?f:d[r],U=T.useMemo((()=>[new P.Vector3(0,0,0),new P.Vector3(0,A,0),new P.Vector3(A,A,0),new P.Vector3(A,0,0),new P.Vector3(0,0,0)]),[A]);return T.createElement("group",{ref:w,matrix:_,matrixAutoUpdate:!1},i&&T.createElement(N,{position:[0,0,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:s,ref:z})),T.createElement("group",{position:[1.7*L,1.7*L,0]},T.createElement("mesh",{visible:!0,onPointerDown:R,onPointerMove:D,onPointerUp:F,onPointerOut:k,scale:A,userData:v},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,depthTest:l,color:B,polygonOffset:!0,polygonOffsetFactor:-10,side:P.DoubleSide,fog:!1})),T.createElement(re,{position:[-A/2,-A/2,0],transparent:!0,depthTest:l,points:U,lineWidth:u,color:B,opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,userData:v,fog:!1})))},va=new P.Vector3,ga=new P.Vector3,za=e=>180*e/Math.PI,wa=e=>{let t=((e,t)=>{let r=Math.floor(e/t);return r=r<0?r+1:r,e-r*t})(e,2*Math.PI);return Math.abs(t)<1e-6?0:(t<0&&(t+=2*Math.PI),t)},ba=new P.Matrix4,Ea=new P.Vector3,Ma=new P.Ray,Sa=new P.Vector3,Ta=({dir1:e,dir2:t,axis:r})=>{const{rotationLimits:n,annotations:a,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:m,hoveredColor:d,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=T.useContext(la),v=o.useThree((e=>e.controls)),g=T.useRef(null),z=T.useRef(null),w=T.useRef(0),b=T.useRef(0),E=T.useRef(null),[S,C]=T.useState(!1),R=T.useCallback((e=>{a&&(g.current.innerText=`${za(b.current).toFixed(0)}º`,g.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),n=(new P.Vector3).setFromMatrixPosition(z.current.matrixWorld),o=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,0).normalize(),i=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,1).normalize(),s=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,2).normalize(),l=(new P.Plane).setFromNormalAndCoplanarPoint(s,n);E.current={clickPoint:t,origin:n,e1:o,e2:i,normal:s,plane:l},p({component:"Rotator",axis:r,origin:n,directions:[o,i,s]}),v&&(v.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[a,v,p,r]),D=T.useCallback((e=>{if(e.stopPropagation(),S||C(!0),E.current){const{clickPoint:t,origin:o,e1:i,e2:s,normal:l,plane:c}=E.current,[u,m]=(null==n?void 0:n[r])||[void 0,void 0];Ma.copy(e.ray),Ma.intersectPlane(c,Sa),Ma.direction.negate(),Ma.intersectPlane(c,Sa);let d=((e,t,r,n,o)=>{va.copy(e).sub(r),ga.copy(t).sub(r);const a=n.dot(n),i=o.dot(o),s=va.dot(n)/a,l=va.dot(o)/i,c=ga.dot(n)/a,u=ga.dot(o)/i,m=Math.atan2(l,s);return Math.atan2(u,c)-m})(t,Sa,o,i,s),f=za(d);e.shiftKey&&(f=10*Math.round(f/10),d=(e=>e*Math.PI/180)(f)),void 0!==u&&void 0!==m&&m-u<2*Math.PI?(d=wa(d),d=d>Math.PI?d-2*Math.PI:d,d=M(d,u-w.current,m-w.current),b.current=w.current+d):(b.current=wa(w.current+d),b.current=b.current>Math.PI?b.current-2*Math.PI:b.current),a&&(f=za(b.current),g.current.innerText=`${f.toFixed(0)}º`),ba.makeRotationAxis(l,d),Ea.copy(o).applyMatrix4(ba).sub(o).negate(),ba.setPosition(Ea),h(ba)}}),[a,h,S,n,r]),F=T.useCallback((e=>{a&&(g.current.style.display="none"),e.stopPropagation(),w.current=b.current,E.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[a,v,x]),k=T.useCallback((e=>{e.stopPropagation(),C(!1)}),[]),_=T.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new P.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),L=u?.65:.65*l,A=T.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new P.Vector3(Math.cos(r)*L,Math.sin(r)*L,0))}return e}),[L]);return T.createElement("group",{ref:z,onPointerDown:R,onPointerMove:D,onPointerUp:F,onPointerOut:k,matrix:_,matrixAutoUpdate:!1},a&&T.createElement(N,{position:[L,L,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),T.createElement(re,{points:A,lineWidth:4*c,visible:!1,userData:y}),T.createElement(re,{transparent:!0,raycast:()=>null,depthTest:s,points:A,lineWidth:c,color:S?d:m[r],opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))},Ca=new P.Vector3,Pa=new P.Vector3,Ra=new P.Vector3,Da=(e,t,r,n=1)=>{const o=Ca.set(e.x/r.width*2-1,-e.y/r.height*2+1,n);return o.unproject(t),o},Fa=(e,t,r,n)=>{const o=((e,t,r)=>{const n=r.width/2,o=r.height/2;t.updateMatrixWorld(!1);const a=e.project(t);return a.x=a.x*n+n,a.y=-a.y*o+o,a})(Ra.copy(e),r,n);let a=0;for(let i=0;i<2;++i){const s=Pa.copy(o).setComponent(i,o.getComponent(i)+t),l=Da(s,r,n,s.z);a=Math.max(a,e.distanceTo(l))}return a},ka=new P.Matrix4,_a=new P.Matrix4,La=new P.Matrix4,Aa=new P.Matrix4,Ba=new P.Matrix4,Ua=new P.Matrix4,Oa=new P.Matrix4,Na=new P.Matrix4,Ia=new P.Box3,Va=new P.Box3,ja=new P.Vector3,Wa=new P.Vector3,Ga=new P.Vector3,Ha=new P.Vector3,qa=new P.Vector3(1,0,0),$a=new P.Vector3(0,1,0),Xa=new P.Vector3(0,0,1),Ya=T.forwardRef((({matrix:t,onDragStart:r,onDrag:n,onDragEnd:a,autoTransform:i=!0,anchor:s,disableAxes:l=!1,disableSliders:c=!1,disableRotations:u=!1,activeAxes:m=[!0,!0,!0],offset:d=[0,0,0],rotation:f=[0,0,0],scale:p=1,lineWidth:h=4,fixed:x=!1,translationLimits:y,rotationLimits:v,depthTest:g=!0,axisColors:z=["#ff2060","#20df80","#2080ff"],hoveredColor:w="#ffff40",annotations:b=!1,annotationsClass:E,opacity:M=1,visible:S=!0,userData:C,children:R,...D},F)=>{const k=o.useThree((e=>e.invalidate)),_=T.useRef(null),L=T.useRef(null),A=T.useRef(null),B=T.useRef(null),U=T.useRef([0,0,0]);T.useLayoutEffect((()=>{s&&(B.current.updateWorldMatrix(!0,!0),Aa.copy(B.current.matrixWorld).invert(),Ia.makeEmpty(),B.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),Ua.copy(e.matrixWorld).premultiply(Aa),Va.copy(e.geometry.boundingBox),Va.applyMatrix4(Ua),Ia.union(Va))})),ja.copy(Ia.max).add(Ia.min).multiplyScalar(.5),Wa.copy(Ia.max).sub(Ia.min).multiplyScalar(.5),Ga.copy(Wa).multiply(new P.Vector3(...s)).add(ja),Ha.set(...d).add(Ga),A.current.position.copy(Ha),k())}));const O=T.useMemo((()=>({onDragStart:e=>{ka.copy(L.current.matrix),_a.copy(L.current.matrixWorld),r&&r(e),k()},onDrag:e=>{La.copy(_.current.matrixWorld),Aa.copy(La).invert(),Ba.copy(_a).premultiply(e),Ua.copy(Ba).premultiply(Aa),Oa.copy(ka).invert(),Na.copy(Ua).multiply(Oa),i&&L.current.matrix.copy(Ua),n&&n(Ua,Na,Ba,e),k()},onDragEnd:()=>{a&&a(),k()},translation:U,translationLimits:y,rotationLimits:v,axisColors:z,hoveredColor:w,opacity:M,scale:p,lineWidth:h,fixed:x,depthTest:g,userData:C,annotations:b,annotationsClass:E})),[r,n,a,U,y,v,g,p,h,x,...z,w,M,C,i,b,E]),N=new P.Vector3;return o.useFrame((e=>{if(x){const o=Fa(A.current.getWorldPosition(N),p,e.camera,e.size);var t,r,n;if(A.current)(null==(t=A.current)?void 0:t.scale.x)===o&&(null==(r=A.current)?void 0:r.scale.y)===o&&(null==(n=A.current)?void 0:n.scale.z)===o||(A.current.scale.setScalar(o),e.invalidate())}})),T.useImperativeHandle(F,(()=>L.current),[]),T.useLayoutEffect((()=>{t&&t instanceof P.Matrix4&&(L.current.matrix=t)}),[t]),T.createElement(la.Provider,{value:O},T.createElement("group",{ref:_},T.createElement("group",e({ref:L,matrix:t,matrixAutoUpdate:!1},D),T.createElement("group",{visible:S,ref:A,position:d,rotation:f},!l&&m[0]&&T.createElement(fa,{axis:0,direction:qa}),!l&&m[1]&&T.createElement(fa,{axis:1,direction:$a}),!l&&m[2]&&T.createElement(fa,{axis:2,direction:Xa}),!c&&m[0]&&m[1]&&T.createElement(ya,{axis:2,dir1:qa,dir2:$a}),!c&&m[0]&&m[2]&&T.createElement(ya,{axis:1,dir1:Xa,dir2:qa}),!c&&m[2]&&m[1]&&T.createElement(ya,{axis:0,dir1:$a,dir2:Xa}),!u&&m[0]&&m[1]&&T.createElement(Ta,{axis:2,dir1:qa,dir2:$a}),!u&&m[0]&&m[2]&&T.createElement(Ta,{axis:1,dir1:Xa,dir2:qa}),!u&&m[2]&&m[1]&&T.createElement(Ta,{axis:0,dir1:$a,dir2:Xa})),T.createElement("group",{ref:B},R))))}));exports.AccumulativeShadows=En,exports.AdaptiveDpr=function({pixelated:e}){const t=o.useThree((e=>e.gl)),r=o.useThree((e=>e.internal.active)),n=o.useThree((e=>e.performance.current)),a=o.useThree((e=>e.viewport.initialDpr)),i=o.useThree((e=>e.setDpr));return T.useEffect((()=>{const n=t.domElement;return()=>{r&&i(a),e&&n&&(n.style.imageRendering="auto")}}),[]),T.useEffect((()=>{i(n*a),e&&t.domElement&&(t.domElement.style.imageRendering=1===n?"auto":"pixelated")}),[n]),null},exports.AdaptiveEvents=function(){const e=o.useThree((e=>e.get)),t=o.useThree((e=>e.setEvents)),r=o.useThree((e=>e.performance.current));return T.useEffect((()=>{const r=e().events.enabled;return()=>t({enabled:r})}),[]),T.useEffect((()=>t({enabled:1===r})),[r]),null},exports.ArcballControls=Ze,exports.AsciiRenderer=function({renderIndex:e=1,bgColor:t="black",fgColor:r="white",characters:n=" .:-+*=%@#",invert:a=!0,color:i=!1,resolution:s=.15}){const{size:l,gl:c,scene:u,camera:d}=o.useThree(),f=T.useMemo((()=>{const e=new m.AsciiEffect(c,n,{invert:a,color:i,resolution:s});return e.domElement.style.position="absolute",e.domElement.style.top="0px",e.domElement.style.left="0px",e.domElement.style.pointerEvents="none",e}),[n,a,i,s]);return T.useLayoutEffect((()=>{f.domElement.style.color=r,f.domElement.style.backgroundColor=t}),[r,t]),T.useEffect((()=>(c.domElement.style.opacity="0",c.domElement.parentNode.appendChild(f.domElement),()=>{c.domElement.style.opacity="1",c.domElement.parentNode.removeChild(f.domElement)})),[f]),T.useEffect((()=>{f.setSize(l.width,l.height)}),[f,l]),o.useFrame((e=>{f.render(u,d)}),e),T.createElement(T.Fragment,null)},exports.BBAnchor=({anchor:t,...r})=>{const n=T.useRef(null),a=T.useRef(null);return T.useEffect((()=>{var e,t;null!=(e=n.current)&&null!=(t=e.parent)&&t.parent&&(a.current=n.current.parent,n.current.parent.parent.add(n.current))}),[]),o.useFrame((()=>{a.current&&(sr.setFromObject(a.current),sr.getSize(lr),n.current.position.set(a.current.position.x+lr.x*t[0]/2,a.current.position.y+lr.y*t[1]/2,a.current.position.z+lr.z*t[2]/2))})),T.createElement("group",e({ref:n},r))},exports.Backdrop=function({children:e,floor:t=.25,segments:r=20,receiveShadow:n,...o}){const a=T.useRef(null);return T.useLayoutEffect((()=>{let e=0;const n=r/r/2,o=a.current.attributes.position;for(let a=0;a<r+1;a++)for(let i=0;i<r+1;i++)o.setXYZ(e++,a/r-n+(0===a?-t:0),i/r-n,Pn(a/r));o.needsUpdate=!0,a.current.computeVertexNormals()}),[r,t]),T.createElement("group",o,T.createElement("mesh",{receiveShadow:n,rotation:[-Math.PI/2,0,Math.PI/2]},T.createElement("planeGeometry",{ref:a,args:[1,1,r,r]}),e))},exports.BakeShadows=function(){const e=o.useThree((e=>e.gl));return t.useEffect((()=>(e.shadowMap.autoUpdate=!1,e.shadowMap.needsUpdate=!0,()=>{e.shadowMap.autoUpdate=e.shadowMap.needsUpdate=!0})),[e.shadowMap]),null},exports.Billboard=ee,exports.Bounds=on,exports.Box=Fr,exports.Bvh=tr,exports.CameraControls=tt,exports.CameraShake=sn,exports.Capsule=Xr,exports.CatmullRomLine=ie,exports.Caustics=An,exports.Center=mr,exports.Circle=kr,exports.Clone=De,exports.Cloud=function({opacity:e=.5,speed:t=.4,width:r=10,depth:n=1.5,segments:a=20,texture:i="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",color:s="#ffffff",depthTest:l=!0,...c}){const u=T.useRef(),m=ve(i),d=T.useMemo((()=>[...new Array(a)].map(((e,n)=>({x:r/2-Math.random()*r,y:r/2-Math.random()*r,scale:.4+Math.sin((n+1)/a*Math.PI)*(10*(.2+Math.random())),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*t})))),[r,a,t]);return o.useFrame((e=>{var t;return null==(t=u.current)?void 0:t.children.forEach(((t,r)=>{t.children[0].rotation.z+=d[r].rotation,t.children[0].scale.setScalar(d[r].scale+(1+Math.sin(e.clock.getElapsedTime()/10))/2*r/10)}))})),T.createElement("group",c,T.createElement("group",{position:[0,0,a/2*n],ref:u},d.map((({x:t,y:r,scale:o,density:a},i)=>T.createElement(ee,{key:i,position:[t,r,-i*n]},T.createElement(Br,{scale:o,rotation:[0,0,0]},T.createElement("meshStandardMaterial",{map:m,transparent:!0,opacity:o/6*a*e,depthTest:l,color:s})))))))},exports.ComputedAttribute=({compute:t,name:r,...o})=>{const[a]=T.useState((()=>new n.BufferAttribute(new Float32Array(0),1))),i=T.useRef(null);return T.useLayoutEffect((()=>{if(i.current){var e;const r=null!==(e=i.current.parent)&&void 0!==e?e:i.current.__r3f.parent,n=t(r);i.current.copy(n)}}),[t]),T.createElement("primitive",e({ref:i,object:a,attach:`attributes-${r}`},o))},exports.Cone=_r,exports.ContactShadows=zn,exports.CubeCamera=function({children:e,frames:t=1/0,resolution:r,near:n,far:a,envMap:i,fog:s,...l}){const c=T.useRef(),{fbo:u,camera:m,update:d}=He({resolution:r,near:n,far:a,envMap:i,fog:s});let f=0;return o.useFrame((()=>{c.current&&(t===1/0||f<t)&&(c.current.visible=!1,d(),c.current.visible=!0,f++)})),T.createElement("group",l,T.createElement("primitive",{object:m}),T.createElement("group",{ref:c},e(u.texture)))},exports.CubicBezierLine=ae,exports.CurveModifier=fr,exports.CycleRaycast=function({onChanged:e,portal:t,preventDefault:r=!0,scroll:n=!0,keyCode:a=9}){const i=T.useRef(0),s=o.useThree((e=>e.setEvents)),l=o.useThree((e=>e.get)),c=o.useThree((e=>e.gl));return T.useEffect((()=>{var o;let u,m=[];const d=l().events.filter,f=null!==(o=null==t?void 0:t.current)&&void 0!==o?o:c.domElement.parentNode,p=()=>f&&e&&e(m,Math.round(i.current)%m.length);s({filter:(e,t)=>{let r=[...e];r.length===m.length&&m.every((e=>r.map((e=>e.object.uuid)).includes(e.object.uuid)))||(i.current=0,m=r,p()),d&&(r=d(r,t));for(let e=0;e<Math.round(i.current)%r.length;e++){const e=r.shift();r=[...r,e]}return r}});const h=e=>{var t,r;i.current=e(i.current),null==(t=l().events.handlers)||t.onPointerCancel(void 0),null==(r=l().events.handlers)||r.onPointerMove(u),p()},x=e=>{(e.keyCode||e.which===a)&&(r&&e.preventDefault(),m.length>1&&h((e=>e+1)))},y=e=>{r&&e.preventDefault();let t=0;e||(e=window.event),e.wheelDelta?t=e.wheelDelta/120:e.detail&&(t=-e.detail/3),m.length>1&&h((e=>Math.abs(e-t)))},v=e=>u=e;return document.addEventListener("pointermove",v,{passive:!0}),n&&document.addEventListener("wheel",y),void 0!==a&&document.addEventListener("keydown",x),()=>{s({filter:d}),void 0!==a&&document.removeEventListener("keydown",x),n&&document.removeEventListener("wheel",y),document.removeEventListener("pointermove",v)}}),[c,l,s,r,n,a]),null},exports.Cylinder=Lr,exports.Decal=Be,exports.Detailed=qo,exports.DeviceOrientationControls=qe,exports.Dodecahedron=Hr,exports.Edges=Me,exports.Effects=pe,exports.Environment=gn,exports.EnvironmentCube=xn,exports.EnvironmentMap=hn,exports.EnvironmentPortal=yn,exports.Example=dr,exports.Extrude=qr,exports.FaceControls=ht,exports.FaceLandmarker=function({basePath:e=ut.basePath,options:r=ut.options,children:n}){const o=JSON.stringify(r),a=p.suspend((async()=>await g.FilesetResolver.forVisionTasks(e).then((e=>g.FaceLandmarker.createFromOptions(e,r)))),[e,o]);return t.useEffect((()=>()=>{null==a||a.close(),p.clear([e,o])}),[a,e,o]),T.createElement(ct.Provider,{value:a},n)},exports.FaceLandmarkerDefaults=ut,exports.Facemesh=at,exports.FacemeshDatas=lt,exports.FacemeshEye=st,exports.FacemeshEyeDefaults=it,exports.FirstPersonControls=et,exports.Float=ln,exports.FlyControls=$e,exports.GizmoHelper=({alignment:e="bottom-right",margin:t=[80,80],renderPriority:r=1,onUpdate:a,onTarget:i,children:s})=>{const l=o.useThree((e=>e.size)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.controls)),m=o.useThree((e=>e.invalidate)),d=T.useRef(),f=T.useRef(null),p=T.useRef(!1),h=T.useRef(0),x=T.useRef(new n.Vector3(0,0,0)),y=T.useRef(new n.Vector3(0,0,0));T.useEffect((()=>{y.current.copy(c.up)}),[c]);const v=T.useCallback((e=>{p.current=!0,(u||i)&&(x.current=(null==u?void 0:u.target)||(null==i?void 0:i())),h.current=c.position.distanceTo(Rt),Ct.copy(c.quaternion),Dt.copy(e).multiplyScalar(h.current).add(Rt),St.lookAt(Dt),St.up.copy(c.up),Pt.copy(St.quaternion),m()}),[u,c,i,m]);o.useFrame(((e,t)=>{if(f.current&&d.current){var r;if(p.current)if(Ct.angleTo(Pt)<.01)p.current=!1,"minPolarAngle"in u&&c.up.copy(y.current);else{const e=t*Mt;Ct.rotateTowards(Pt,e),c.position.set(0,0,1).applyQuaternion(Ct).multiplyScalar(h.current).add(x.current),c.up.set(0,1,0).applyQuaternion(Ct).normalize(),c.quaternion.copy(Ct),a?a():u&&u.update(),m()}Tt.copy(c.matrix).invert(),null==(r=d.current)||r.quaternion.setFromRotationMatrix(Tt)}}));const g=T.useMemo((()=>({tweenCamera:v})),[v]),[z,w]=t,b=e.endsWith("-center")?0:e.endsWith("-left")?-l.width/2+z:l.width/2-z,E=e.startsWith("center-")?0:e.startsWith("top-")?l.height/2-w:-l.height/2+w;return T.createElement(wt,{renderPriority:r},T.createElement(bt.Provider,{value:g},T.createElement(We,{makeDefault:!0,ref:f,position:[0,0,200]}),T.createElement("group",{ref:d,position:[b,E,0]},s)))},exports.GizmoViewcube=t=>T.createElement("group",{scale:[60,60,60]},T.createElement(jt,t),Nt.map(((r,n)=>T.createElement(Wt,e({key:n,position:r,dimensions:It[n]},t)))),Ut.map(((r,n)=>T.createElement(Wt,e({key:n,position:r,dimensions:Ot},t))))),exports.GizmoViewport=({hideNegativeAxes:t,hideAxisHeads:r,disabled:n,font:o="18px Inter var, Arial, sans-serif",axisColors:a=["#ff2060","#20df80","#2080ff"],axisHeadScale:i=1,axisScale:s,labels:l=["X","Y","Z"],labelColor:c="#000",onClick:u,...m})=>{const[d,f,p]=a,{tweenCamera:h}=Et(),x={font:o,disabled:n,labelColor:c,onClick:u,axisHeadScale:i,onPointerDown:n?void 0:e=>{h(e.object.position),e.stopPropagation()}};return T.createElement("group",e({scale:40},m),T.createElement(Gt,{color:d,rotation:[0,0,0],scale:s}),T.createElement(Gt,{color:f,rotation:[0,0,Math.PI/2],scale:s}),T.createElement(Gt,{color:p,rotation:[0,-Math.PI/2,0],scale:s}),!r&&T.createElement(T.Fragment,null,T.createElement(Ht,e({arcStyle:d,position:[1,0,0],label:l[0]},x)),T.createElement(Ht,e({arcStyle:f,position:[0,1,0],label:l[1]},x)),T.createElement(Ht,e({arcStyle:p,position:[0,0,1],label:l[2]},x)),!t&&T.createElement(T.Fragment,null,T.createElement(Ht,e({arcStyle:d,position:[-1,0,0]},x)),T.createElement(Ht,e({arcStyle:f,position:[0,-1,0]},x)),T.createElement(Ht,e({arcStyle:p,position:[0,0,-1]},x)))))},exports.Gltf=Ve,exports.GradientTexture=function({stops:t,colors:r,size:n=1024,width:a=16,type:i=he.Linear,innerCircleRadius:s=0,outerCircleRadius:l="auto",...c}){const u=o.useThree((e=>e.gl)),m=T.useMemo((()=>{const e=document.createElement("canvas"),o=e.getContext("2d");let c;if(e.width=a,e.height=n,i===he.Linear)c=o.createLinearGradient(0,0,0,n);else{const t=e.width/2,r=e.height/2,n="auto"!==l?Math.abs(Number(l)):Math.sqrt(t**2+r**2);c=o.createRadialGradient(t,r,Math.abs(s),t,r,n)}let u=t.length;for(;u--;)c.addColorStop(t[u],r[u]);return o.save(),o.fillStyle=c,o.fillRect(0,0,a,n),o.restore(),e}),[t]);return T.createElement("canvasTexture",e({colorSpace:u.outputColorSpace,args:[m],attach:"map"},c))},exports.GradientType=he,exports.Grid=$t,exports.Html=N,exports.Hud=wt,exports.Icosahedron=Wr,exports.Image=Ee,exports.Instance=Oo,exports.Instances=No,exports.IsObject=ye,exports.KeyboardControls=function({map:e,children:t,onChange:r,domElement:n}){const o=e.map((e=>e.name+e.keys)).join("-"),a=T.useMemo((()=>K(u.subscribeWithSelector((()=>e.reduce(((e,t)=>({...e,[t.name]:!1})),{}))))),[o]),i=T.useMemo((()=>[a.subscribe,a.getState,a]),[o]),s=a.setState;return T.useEffect((()=>{const t=e.map((({name:e,keys:t,up:n})=>({keys:t,up:n,fn:t=>{s({[e]:t}),r&&r(e,t,i[1]())}}))).reduce(((e,{keys:t,fn:r,up:n=!0})=>(t.forEach((t=>e[t]={fn:r,pressed:!1,up:n})),e)),{}),o=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:o,pressed:a,up:i}=n;n.pressed=!0,!i&&a||o(!0)},a=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:o,up:a}=n;n.pressed=!1,a&&o(!1)},l=n||window;return l.addEventListener("keydown",o,{passive:!0}),l.addEventListener("keyup",a,{passive:!0}),()=>{l.removeEventListener("keydown",o),l.removeEventListener("keyup",a)}}),[n,o]),T.createElement(Z.Provider,{value:i,children:t})},exports.Lathe=$r,exports.Lightformer=Hn,exports.Line=re,exports.Loader=function({containerStyles:e,innerStyles:t,barStyles:r,dataStyles:n,dataInterpolation:o=W,initialState:a=(e=>e)}){const{active:i,progress:s}=j(),l=T.useRef(0),c=T.useRef(0),u=T.useRef(null),[m,d]=T.useState(a(i));T.useEffect((()=>{let e;return i!==m&&(e=setTimeout((()=>d(i)),300)),()=>clearTimeout(e)}),[m,i]);const f=T.useCallback((()=>{u.current&&(l.current+=(s-l.current)/2,(l.current>.95*s||100===s)&&(l.current=s),u.current.innerText=o(l.current),l.current<s&&(c.current=requestAnimationFrame(f)))}),[o,s]);return T.useEffect((()=>(f(),()=>cancelAnimationFrame(c.current))),[f]),m?T.createElement("div",{style:{...G.container,opacity:i?1:0,...e}},T.createElement("div",null,T.createElement("div",{style:{...G.inner,...t}},T.createElement("div",{style:{...G.bar,transform:`scaleX(${s/100})`,...r}}),T.createElement("span",{ref:u,style:{...G.data,...n}})))):null},exports.MapControls=Xe,exports.MarchingCube=_e,exports.MarchingCubes=ke,exports.MarchingPlane=Le,exports.Mask=ea,exports.Merged=Io,exports.MeshDiscardMaterial=Tr,exports.MeshDistortMaterial=hr,exports.MeshPortalMaterial=ra,exports.MeshReflectorMaterial=wr,exports.MeshRefractionMaterial=function({aberrationStrength:r=0,fastChroma:n=!0,envMap:a,...i}){o.extend({MeshRefractionMaterial:br});const s=t.useRef(),{size:l}=o.useThree(),c=t.useMemo((()=>{var e,t;const o={},i=(s=a)&&s.isCubeTexture;var s;const l=(null!==(e=i?null==(t=a.image[0])?void 0:t.width:a.image.width)&&void 0!==e?e:1024)/4,c=Math.floor(Math.log2(l)),u=Math.pow(2,c),m=3*Math.max(u,112),d=4*u;return i&&(o.ENVMAP_TYPE_CUBEM=""),o.CUBEUV_TEXEL_WIDTH=""+1/m,o.CUBEUV_TEXEL_HEIGHT=""+1/d,o.CUBEUV_MAX_MIP=`${c}.0`,r>0&&(o.CHROMATIC_ABERRATIONS=""),n&&(o.FAST_CHROMA=""),o}),[r,n]);return t.useLayoutEffect((()=>{var e,t,r;const n=null==(e=s.current)||null==(t=e.__r3f)||null==(r=t.parent)?void 0:r.geometry;n&&(s.current.bvh=new b.MeshBVHUniformStruct,s.current.bvh.updateFrom(new b.MeshBVH(n.clone().toNonIndexed(),{lazyGeneration:!1,strategy:b.SAH})))}),[]),o.useFrame((({camera:e})=>{s.current.viewMatrixInverse=e.matrixWorld,s.current.projectionMatrixInverse=e.projectionMatrixInverse})),T.createElement("meshRefractionMaterial",e({key:JSON.stringify(c),defines:c,ref:s,resolution:[l.width,l.height],aberrationStrength:r,envMap:a},i))},exports.MeshTransmissionMaterial=Sr,exports.MeshWobbleMaterial=yr,exports.Octahedron=Gr,exports.OrbitControls=Ye,exports.OrthographicCamera=We,exports.PerformanceMonitor=function({iterations:e=10,ms:r=250,threshold:n=.75,step:a=.1,factor:i=.5,flipflops:s=1/0,bounds:l=(e=>e>100?[60,100]:[40,60]),onIncline:c,onDecline:u,onChange:m,onFallback:d,children:f}){const p=Math.pow(10,0),[h,x]=t.useState((()=>({fps:0,index:0,factor:i,flipped:0,refreshrate:0,fallback:!1,frames:[],averages:[],subscriptions:new Map,subscribe:e=>{const t=Symbol();return h.subscriptions.set(t,e.current),()=>{h.subscriptions.delete(t)}}})));let y=0;return o.useFrame((()=>{const{frames:t,averages:o}=h;if(!h.fallback&&o.length<e){t.push(performance.now());const i=t[t.length-1]-t[0];if(i>=r){if(h.fps=Math.round(t.length/i*1e3*p)/p,h.refreshrate=Math.max(h.refreshrate,h.fps),o[h.index++%e]=h.fps,o.length===e){const[t,r]=l(h.refreshrate),i=o.filter((e=>e>=r)),f=o.filter((e=>e<t));i.length>e*n&&(h.factor=Math.min(1,h.factor+a),h.flipped++,c&&c(h),h.subscriptions.forEach((e=>e.onIncline&&e.onIncline(h)))),f.length>e*n&&(h.factor=Math.max(0,h.factor-a),h.flipped++,u&&u(h),h.subscriptions.forEach((e=>e.onDecline&&e.onDecline(h)))),y!==h.factor&&(y=h.factor,m&&m(h),h.subscriptions.forEach((e=>e.onChange&&e.onChange(h)))),h.flipped>s&&!h.fallback&&(h.fallback=!0,d&&d(h),h.subscriptions.forEach((e=>e.onFallback&&e.onFallback(h)))),h.averages=[]}h.frames=[]}}})),T.createElement(Zo.Provider,{value:h},f)},exports.PerspectiveCamera=Ge,exports.PivotControls=Ya,exports.Plane=Br,exports.Point=Eo,exports.PointMaterial=Pr,exports.PointMaterialImpl=Cr,exports.PointerLockControls=Je,exports.Points=So,exports.PointsBuffer=Mo,exports.Polyhedron=jr,exports.PositionPoint=xo,exports.PositionalAudio=se,exports.Preload=function({all:e,scene:t,camera:r}){const a=o.useThree((({gl:e})=>e)),i=o.useThree((({camera:e})=>e)),s=o.useThree((({scene:e})=>e));return T.useLayoutEffect((()=>{const o=[];e&&(t||s).traverse((e=>{!1===e.visible&&(o.push(e),e.visible=!0)})),a.compile(t||s,r||i);const l=new n.WebGLCubeRenderTarget(128);new n.CubeCamera(.01,1e5,l).update(a,t||s),l.dispose(),o.forEach((e=>e.visible=!1))}),[]),null},exports.PresentationControls=function({enabled:t=!0,snap:r,global:a,domElement:i,cursor:s=!0,children:u,speed:m=1,rotation:d=[0,0,0],zoom:f=1,polar:p=[0,Math.PI/2],azimuth:h=[-1/0,1/0],config:x={mass:1,tension:170,friction:26}}){const y=o.useThree((e=>e.events)),v=o.useThree((e=>e.gl)),g=i||y.connected||v.domElement,{size:z}=o.useThree(),w=T.useMemo((()=>[d[0]+p[0],d[0]+p[1]]),[d[0],p[0],p[1]]),b=T.useMemo((()=>[d[1]+h[0],d[1]+h[1]]),[d[1],h[0],h[1]]),E=T.useMemo((()=>[n.MathUtils.clamp(d[0],...w),n.MathUtils.clamp(d[1],...b),d[2]]),[d[0],d[1],d[2],w,b]),[M,S]=l.useSpring((()=>({scale:1,rotation:E,config:x})));T.useEffect((()=>{S.start({scale:1,rotation:E,config:x})}),[E]),T.useEffect((()=>{if(a&&s&&t)return g.style.cursor="grab",v.domElement.style.cursor="",()=>{g.style.cursor="default",v.domElement.style.cursor="default"}}),[a,s,g,t]);const C=c.useGesture({onHover:({last:e})=>{s&&!a&&t&&(g.style.cursor=e?"auto":"grab")},onDrag:({down:e,delta:[o,a],memo:[i,l]=M.rotation.animation.to||E})=>{if(!t)return[a,o];s&&(g.style.cursor=e?"grabbing":"grab"),o=n.MathUtils.clamp(l+o/z.width*Math.PI*m,...b),a=n.MathUtils.clamp(i+a/z.height*Math.PI*m,...w);const c=r&&!e&&"boolean"!=typeof r?r:x;return S.start({scale:e&&a>w[1]/2?f:1,rotation:r&&!e?E:[a,o,0],config:e=>"scale"===e?{...c,friction:3*c.friction}:c}),[a,o]}},{target:a?g:void 0});return T.createElement(l.a.group,e({},null==C?void 0:C(),M),u)},exports.QuadraticBezierLine=oe,exports.RandomizedLight=Mn,exports.Reflector=Bn,exports.RenderTexture=Qo,exports.Resize=en,exports.Ring=Vr,exports.RoundedBox=Zr,exports.Sampler=function({children:t,weight:r,transform:n,instances:o,mesh:a,count:i=16,...s}){const l=T.useRef(null),c=T.useRef(null),u=T.useRef(null);return T.useLayoutEffect((()=>{var e,t;c.current=null!==(e=null==o?void 0:o.current)&&void 0!==e?e:l.current.children.find((e=>e.hasOwnProperty("instanceMatrix"))),u.current=null!==(t=null==a?void 0:a.current)&&void 0!==t?t:l.current.children.find((e=>"Mesh"===e.type))}),[t,null==a?void 0:a.current,null==o?void 0:o.current]),Re(u,i,n,r,c),T.createElement("group",e({ref:l},s),t)},exports.ScreenQuad=Jr,exports.ScreenSpace=te,exports.Scroll=Y,exports.ScrollControls=function({eps:e=1e-5,enabled:t=!0,infinite:r,horizontal:n,pages:a=1,distance:i=1,damping:l=.25,maxSpeed:c=1/0,style:u={},children:m}){const{get:d,setEvents:f,gl:p,size:h,invalidate:x,events:y}=o.useThree(),[v]=T.useState((()=>document.createElement("div"))),[g]=T.useState((()=>document.createElement("div"))),[z]=T.useState((()=>document.createElement("div"))),w=p.domElement.parentNode,b=T.useRef(0),E=T.useMemo((()=>{const t={el:v,eps:e,fill:g,fixed:z,horizontal:n,damping:l,offset:0,delta:0,scroll:b,pages:a,range(e,t,r=0){const n=e-r,o=n+t+2*r;return this.offset<n?0:this.offset>o?1:(this.offset-n)/(o-n)},curve(e,t,r=0){return Math.sin(this.range(e,t,r)*Math.PI)},visible(e,t,r=0){const n=e-r,o=n+t+2*r;return this.offset>=n&&this.offset<=o}};return t}),[e,l,n,a]);T.useEffect((()=>{v.style.position="absolute",v.style.width="100%",v.style.height="100%",v.style[n?"overflowX":"overflowY"]="auto",v.style[n?"overflowY":"overflowX"]="hidden",v.style.top="0px",v.style.left="0px";for(const e in u)v.style[e]=u[e];z.style.position="sticky",z.style.top="0px",z.style.left="0px",z.style.width="100%",z.style.height="100%",z.style.overflow="hidden",v.appendChild(z),g.style.height=n?"100%":a*i*100+"%",g.style.width=n?a*i*100+"%":"100%",g.style.pointerEvents="none",v.appendChild(g),w.appendChild(v),v[n?"scrollLeft":"scrollTop"]=1;const e=y.connected||p.domElement;requestAnimationFrame((()=>null==y.connect?void 0:y.connect(v)));const t=d().events.compute;return f({compute(e,t){const{left:r,top:n}=w.getBoundingClientRect(),o=e.clientX-r,a=e.clientY-n;t.pointer.set(o/t.size.width*2-1,-a/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),()=>{w.removeChild(v),f({compute:t}),null==y.connect||y.connect(e)}}),[a,i,n,v,g,z,w]),T.useEffect((()=>{if(y.connected===v){const e=h[n?"width":"height"],o=v[n?"scrollWidth":"scrollHeight"],a=o-e;let i=0,s=!0,l=!0;const c=()=>{if(t&&!l&&(x(),i=v[n?"scrollLeft":"scrollTop"],b.current=i/a,r)){if(!s)if(i>=a){const e=1-E.offset;v[n?"scrollLeft":"scrollTop"]=1,b.current=E.offset=-e,s=!0}else if(i<=0){const e=1+E.offset;v[n?"scrollLeft":"scrollTop"]=o,b.current=E.offset=e,s=!0}s&&setTimeout((()=>s=!1),40)}};v.addEventListener("scroll",c,{passive:!0}),requestAnimationFrame((()=>l=!1));const u=e=>v.scrollLeft+=e.deltaY/2;return n&&v.addEventListener("wheel",u,{passive:!0}),()=>{v.removeEventListener("scroll",c),n&&v.removeEventListener("wheel",u)}}}),[v,y,h,r,E,x,n,t]);let M=0;return o.useFrame(((t,r)=>{M=E.offset,s.easing.damp(E,"offset",b.current,l,r,c,void 0,e),s.easing.damp(E,"delta",Math.abs(M-E.offset),l,r,c,void 0,e),E.delta>e&&x()})),T.createElement(H.Provider,{value:E},m)},exports.Segment=Ho,exports.SegmentObject=Wo,exports.Segments=jo,exports.Select=function({box:t,multiple:r,children:n,onChange:a,onChangePointerUp:i,border:s="1px solid #55aaff",backgroundColor:l="rgba(75, 160, 255, 0.1)",filter:c=(e=>e),...u}){const[d,f]=T.useState(!1),{setEvents:p,camera:h,raycaster:x,gl:y,controls:v,size:g,get:z}=o.useThree(),[w,b]=T.useState(!1),[E,M]=T.useReducer(((e,{object:t,shift:r})=>void 0===t?[]:Array.isArray(t)?t:r?e.includes(t)?e.filter((e=>e!==t)):[t,...e]:e[0]===t?[]:[t]),[]);T.useEffect((()=>{d?null==a||a(E):null==i||i(E)}),[E,d]);const S=T.useCallback((e=>{e.stopPropagation(),M({object:c([e.object])[0],shift:r&&e.shiftKey})}),[]),C=T.useCallback((e=>!w&&M({})),[w]),R=T.useRef(null);return T.useEffect((()=>{if(!t||!r)return;const e=new m.SelectionBox(h,R.current),n=document.createElement("div");n.style.pointerEvents="none",n.style.border=s,n.style.backgroundColor=l,n.style.position="fixed";const o=new P.Vector2,a=new P.Vector2,i=new P.Vector2,u=z().events.enabled,d=null==v?void 0:v.enabled;let x=!1;function w(e,t){const{offsetX:r,offsetY:n}=e,{width:o,height:a}=g;t.set(r/o*2-1,-n/a*2+1)}function b(t){t.shiftKey&&(!function(e){var t;v&&(v.enabled=!1),p({enabled:!1}),f(x=!0),null==(t=y.domElement.parentElement)||t.appendChild(n),n.style.left=`${e.clientX}px`,n.style.top=`${e.clientY}px`,n.style.width="0px",n.style.height="0px",o.x=e.clientX,o.y=e.clientY}(t),w(t,e.startPoint))}let E=[];function S(t){if(x){!function(e){i.x=Math.max(o.x,e.clientX),i.y=Math.max(o.y,e.clientY),a.x=Math.min(o.x,e.clientX),a.y=Math.min(o.y,e.clientY),n.style.left=`${a.x}px`,n.style.top=`${a.y}px`,n.style.width=i.x-a.x+"px",n.style.height=i.y-a.y+"px"}(t),w(t,e.endPoint);const r=e.select().sort((e=>e.uuid)).filter((e=>e.isMesh));Q(r,E)||(E=r,M({object:c(r)}))}}function T(e){var t;x&&x&&(v&&(v.enabled=d),p({enabled:u}),f(x=!1),null==(t=n.parentElement)||t.removeChild(n))}return document.addEventListener("pointerdown",b,{passive:!0}),document.addEventListener("pointermove",S,{passive:!0,capture:!0}),document.addEventListener("pointerup",T,{passive:!0}),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",T)}}),[g.width,g.height,x,h,v,y]),T.createElement("group",e({ref:R,onClick:S,onPointerOver:()=>b(!0),onPointerOut:()=>b(!1),onPointerMissed:C},u),T.createElement(J.Provider,{value:E},n))},exports.Shadow=Rn,exports.Shape=Yr,exports.Sky=$n,exports.SoftShadows=function({focus:e=0,samples:t=10,size:r=25}){const n=o.useThree((e=>e.gl)),a=o.useThree((e=>e.scene)),i=o.useThree((e=>e.camera));return T.useEffect((()=>{const o=P.ShaderChunk.shadowmap_pars_fragment;return P.ShaderChunk.shadowmap_pars_fragment=P.ShaderChunk.shadowmap_pars_fragment.replace("#ifdef USE_SHADOWMAP","#ifdef USE_SHADOWMAP\n"+(({focus:e=0,size:t=25,samples:r=10}={})=>`\n#define PENUMBRA_FILTER_SIZE float(${t})\n#define RGB_NOISE_FUNCTION(uv) (randRGB(uv))\nvec3 randRGB(vec2 uv) {\n return vec3(\n fract(sin(dot(uv, vec2(12.75613, 38.12123))) * 13234.76575),\n fract(sin(dot(uv, vec2(19.45531, 58.46547))) * 43678.23431),\n fract(sin(dot(uv, vec2(23.67817, 78.23121))) * 93567.23423)\n );\n}\n\nvec3 lowPassRandRGB(vec2 uv) {\n // 3x3 convolution (average)\n // can be implemented as separable with an extra buffer for a total of 6 samples instead of 9\n vec3 result = vec3(0);\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, +1.0));\n result *= 0.111111111; // 1.0 / 9.0\n return result;\n}\nvec3 highPassRandRGB(vec2 uv) {\n // by subtracting the low-pass signal from the original signal, we're being left with the high-pass signal\n // hp(x) = x - lp(x)\n return RGB_NOISE_FUNCTION(uv) - lowPassRandRGB(uv) + 0.5;\n}\n\n\nvec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; // radians\n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n}\nfloat penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation\n return (zReceiver - zBlocker) / zBlocker;\n}\nfloat findBlocker(sampler2D shadowMap, vec2 uv, float compare, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float blockerDepthSum = float(${e});\n float blockers = 0.0;\n\n int j = 0;\n vec2 offset = vec2(0.);\n float depth = 0.;\n\n #pragma unroll_loop_start\n for(int i = 0; i < ${r}; i ++) {\n offset = (vogelDiskSample(j, ${r}, angle) * texelSize) * 2.0 * PENUMBRA_FILTER_SIZE;\n depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset));\n if (depth < compare) {\n blockerDepthSum += depth;\n blockers++;\n }\n j++;\n }\n #pragma unroll_loop_end\n\n if (blockers > 0.0) {\n return blockerDepthSum / blockers;\n }\n return -1.0;\n}\n\n \nfloat vogelFilter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float shadow = 0.0f;\n int j = 0;\n vec2 vogelSample = vec2(0.0);\n vec2 offset = vec2(0.0);\n #pragma unroll_loop_start\n for (int i = 0; i < ${r}; i++) {\n vogelSample = vogelDiskSample(j, ${r}, angle) * texelSize;\n offset = vogelSample * (1.0 + filterRadius * float(${t}));\n shadow += step( zReceiver, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );\n j++;\n }\n #pragma unroll_loop_end\n return shadow * 1.0 / ${r}.0;\n}\n\nfloat PCSS (sampler2D shadowMap, vec4 coords) {\n vec2 uv = coords.xy;\n float zReceiver = coords.z; // Assumed to be eye-space z in this code\n float angle = highPassRandRGB(gl_FragCoord.xy).r * PI2;\n float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver, angle);\n if (avgBlockerDepth == -1.0) {\n return 1.0;\n }\n float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth);\n return vogelFilter(shadowMap, uv, zReceiver, 1.25 * penumbraRatio, angle);\n}`)({size:r,samples:t,focus:e})).replace("#if defined( SHADOWMAP_TYPE_PCF )","\nreturn PCSS(shadowMap, shadowCoord);\n#if defined( SHADOWMAP_TYPE_PCF )"),Rr(n,a,i),()=>{P.ShaderChunk.shadowmap_pars_fragment=o,Rr(n,a,i)}}),[e,r,t]),null},exports.Sparkles=ro,exports.Sphere=Ar,exports.SpotLight=Gn,exports.SpotLightShadow=function(e){return e.shader?T.createElement(jn,e):T.createElement(Wn,e)},exports.SpriteAnimator=({startFrame:e,endFrame:t,fps:r,frameName:n,textureDataURL:a,textureImageURL:i,loop:s,numberOfFrames:l,autoPlay:c,animationNames:u,onStart:m,onEnd:d,onLoopEnd:f,onFrame:p,play:h,pause:x,flipX:y,alphaTest:v,children:g,...z},w)=>{o.useThree((e=>e.viewport));const b=T.useRef(null),[E,M]=T.useState(!1),S=T.useRef(),C=T.useRef(),R=T.useRef(window.performance.now()),D=T.useRef(),F=T.useRef(e||0),k=T.useRef(n||""),_=1e3/(r||30),[L,A]=T.useState(new P.Texture),B=T.useRef(0),[U,O]=T.useState([1,1,1]),N=y?-1:1;const I=(e,t)=>{const r=t/e;return C.current.scale.set(1,r,1),[1,r,1]};T.useEffect((()=>{if(a&&i)!function(e,t,r){const n=new P.TextureLoader,o=fetch(e).then((e=>e.json())),a=new Promise((e=>{n.load(t,e)}));Promise.all([o,a]).then((e=>{r(e[0],e[1])}))}(a,i,V);else if(i){const e=new P.TextureLoader;new Promise((t=>{e.load(i,t)})).then((e=>{V(null,e)}))}}),[]),T.useLayoutEffect((()=>{W()}),[L,y]),T.useEffect((()=>{}),[x]),T.useEffect((()=>{k.current!==n&&n&&(F.current=0,k.current=n)}),[n]);const V=(e,t)=>{if(null===e){if(t&&l){const e=t.image.width,r=t.image.height,n=e/l,o=r;if(D.current=t,B.current=l,b.current={frames:[],meta:{version:"1.0",size:{w:e,h:r},scale:"1"}},parseInt(n.toString(),10)===n)for(let e=0;e<l;e++)b.current.frames.push({frame:{x:e*n,y:0,w:n,h:o},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:n,h:o},sourceSize:{w:n,h:r}})}}else if(t){b.current=e,b.current.frames=Array.isArray(e.frames)?e.frames:j(),B.current=Array.isArray(e.frames)?e.frames.length:Object.keys(e.frames).length,D.current=t;const{w:r,h:n}=G(e.frames).sourceSize,o=I(r,n);O(o),S.current&&(S.current.map=t)}t.premultiplyAlpha=!1,A(t)},j=()=>{const e={},t=b.current,r=u;if(r)for(let n=0;n<r.length;n++){e[r[n]]=[];for(let o in t.frames){const a=t.frames[o],i=a.frame,s=i.x,l=i.y,c=i.w,u=i.h,m=a.sourceSize.w,d=a.sourceSize.h;"string"==typeof o&&-1!==o.toLowerCase().indexOf(r[n].toLowerCase())&&e[r[n]].push({x:s,y:l,w:c,h:u,frame:i,sourceSize:{w:m,h:d}})}}return e},W=()=>{if(!b.current)return;const{meta:{size:e},frames:t}=b.current,{w:r,h:o}=Array.isArray(t)?t[0].sourceSize:n&&t[n]?t[n][0].sourceSize:{w:0,h:0};S.current.map.wrapS=S.current.map.wrapT=P.RepeatWrapping,S.current.map.center.set(0,0),S.current.map.repeat.set(1*N/(e.w/r),1/(e.h/o));const a=1/((e.h-1)/o);S.current.map.offset.x=0,S.current.map.offset.y=1-a,M(!0),m&&m({currentFrameName:n,currentFrame:F.current})};o.useFrame(((r,o)=>{var a,i;null!=(a=b.current)&&a.frames&&null!=(i=S.current)&&i.map&&(x||(c||h)&&((()=>{const r=window.performance.now(),o=r-R.current,{meta:{size:a},frames:i}=b.current,{w:l,h:c}=G(i).sourceSize,u=Array.isArray(i)?i:n?i[n]:[];let m=0,p=0;const h=t||u.length-1;if(F.current>h&&(F.current=s&&null!=e?e:0,s?null==f||f({currentFrameName:n,currentFrame:F.current}):null==d||d({currentFrameName:n,currentFrame:F.current}),!s))return;if(o<=_)return;R.current=r-o%_,I(l,c);const x=(a.w-1)/l,y=(a.h-1)/c,{frame:{x:v,y:g},sourceSize:{w:z,h:w}}=u[F.current],E=1/x,M=1/y;m=N>0?E*(v/z):E*(v/z)-S.current.map.repeat.x,p=Math.abs(1-M)-M*(g/w),S.current.map.offset.x=m,S.current.map.offset.y=p,F.current+=1})(),p&&p({currentFrameName:k.current,currentFrame:F.current})))}));const G=e=>{if(Array.isArray(e))return e[0];if("object"==typeof e&&null!==e){return e[Object.keys(e)[0]][0]}return{w:0,h:0}};return T.createElement("group",z,T.createElement(T.Suspense,{fallback:null},T.createElement("sprite",{ref:C,scale:U},T.createElement("spriteMaterial",{toneMapped:!1,ref:S,map:L,transparent:!0,alphaTest:null!=v?v:0}))),g)},exports.Stage=function({children:t,center:r,adjustCamera:n=!0,intensity:o=.5,shadows:a="contact",environment:i="city",preset:s="rembrandt",...l}){var c,u,m,d,f,p,h,x;const y="string"==typeof s?Tn[s]:s,[{radius:v,height:g},z]=T.useState({radius:0,width:0,height:0,depth:0}),w=null!==(c=null==a?void 0:a.bias)&&void 0!==c?c:-1e-4,b=null!==(u=null==a?void 0:a.normalBias)&&void 0!==u?u:0,E=null!==(m=null==a?void 0:a.size)&&void 0!==m?m:1024,M=null!==(d=null==a?void 0:a.offset)&&void 0!==d?d:0,S="contact"===a||"contact"===(null==a?void 0:a.type),C="accumulative"===a||"accumulative"===(null==a?void 0:a.type),P={..."object"==typeof a?a:{}},R=i?"string"==typeof i?{preset:i}:i:null,D=T.useCallback((e=>{const{width:t,height:n,depth:o,boundingSphere:a}=e;z({radius:a.radius,width:t,height:n,depth:o}),null!=r&&r.onCentered&&r.onCentered(e)}),[]);return T.createElement(T.Fragment,null,T.createElement("ambientLight",{intensity:o/3}),T.createElement("spotLight",{penumbra:1,position:[y.main[0]*v,y.main[1]*v,y.main[2]*v],intensity:2*o,castShadow:!!a,"shadow-bias":w,"shadow-normalBias":b,"shadow-mapSize":E}),T.createElement("pointLight",{position:[y.fill[0]*v,y.fill[1]*v,y.fill[2]*v],intensity:o}),T.createElement(on,e({fit:!!n,clip:!!n,margin:Number(n),observe:!0},l),T.createElement(Cn,{radius:v,adjustCamera:n}),T.createElement(mr,e({},r,{position:[0,M/2,0],onCentered:D}),t)),T.createElement("group",{position:[0,-g/2-M/2,0]},S&&T.createElement(zn,e({scale:4*v,far:v,blur:2},P)),C&&T.createElement(En,e({temporal:!0,frames:100,alphaTest:.9,toneMapped:!0,scale:4*v},P),T.createElement(Mn,{amount:null!==(f=P.amount)&&void 0!==f?f:8,radius:null!==(p=P.radius)&&void 0!==p?p:v,ambient:null!==(h=P.ambient)&&void 0!==h?h:.5,intensity:null!==(x=P.intensity)&&void 0!==x?x:1,position:[y.main[0]*v,y.main[1]*v,y.main[2]*v],size:4*v,bias:-w,mapSize:E}))),i&&T.createElement(gn,R))},exports.Stars=Kn,exports.Stats=function({showPanel:e=0,className:t,parent:r}){const n=function(e,t=[],r){const[n,o]=T.useState();return T.useLayoutEffect((()=>{const t=e();return o(t),Qt(r,t),()=>Qt(r,null)}),t),n}((()=>new z),[]);return T.useEffect((()=>{if(n){const a=r&&r.current||document.body;n.showPanel(e),null==a||a.appendChild(n.dom),t&&n.dom.classList.add(...t.split(" ").filter((e=>e)));const i=o.addEffect((()=>n.begin())),s=o.addAfterEffect((()=>n.end()));return()=>{null==a||a.removeChild(n.dom),i(),s()}}}),[r,n,t,e]),null},exports.Svg=Ue,exports.Tetrahedron=Ir,exports.Text=le,exports.Text3D=fe,exports.Torus=Or,exports.TorusKnot=Nr,exports.TrackballControls=Ke,exports.Trail=Pe,exports.TransformControls=Qe,exports.Tube=Ur,exports.View=({track:e,index:t=1,frames:r=1/0,children:n})=>{var a,i;const s=T.useRef(null),{size:l,scene:c}=o.useThree(),[u]=T.useState((()=>new P.Scene)),m=T.useCallback(((t,r)=>{if(s.current&&e.current&&t.target===e.current){const{width:e,height:n,left:o,top:a}=s.current,i=t.clientX-o,l=t.clientY-a;r.pointer.set(i/e*2-1,-l/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[s,e]),[d,f]=T.useReducer((()=>!0),!1);return T.useEffect((()=>{var t;s.current=null==(t=e.current)?void 0:t.getBoundingClientRect(),f()}),[e]),T.createElement(T.Fragment,null,d&&o.createPortal(T.createElement(sa,{canvasSize:l,frames:r,scene:c,track:e,rect:s,index:t},n,T.createElement("group",{onPointerOver:()=>null})),u,{events:{compute:m,priority:t},size:{width:null==(a=s.current)?void 0:a.width,height:null==(i=s.current)?void 0:i.height}}))},exports.Wireframe=function({geometry:t,...r}){return t?T.createElement(co,e({geometry:t},r)):T.createElement(uo,r)},exports.accumulativeContext=wn,exports.calcPosFromAngles=qn,exports.calculateScaleFactor=Fa,exports.isWebGL2Available=()=>{try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},exports.meshBounds=function(e,t){const r=this.geometry,n=this.material,o=this.matrixWorld;void 0!==n&&(null===r.boundingSphere&&r.computeBoundingSphere(),Yo.copy(r.boundingSphere),Yo.applyMatrix4(o),!1!==e.ray.intersectsSphere(Yo)&&($o.copy(o).invert(),Xo.copy(e.ray).applyMatrix4($o),null!==r.boundingBox&&null===Xo.intersectBox(r.boundingBox,Ko)||t.push({distance:Ko.distanceTo(e.ray.origin),point:Ko.clone(),object:this})))},exports.shaderMaterial=xe,exports.useAnimations=function(e,t){const r=T.useRef(),[a]=T.useState((()=>t?t instanceof n.Object3D?{current:t}:t:r)),[i]=T.useState((()=>new n.AnimationMixer(void 0)));T.useLayoutEffect((()=>{i._root=a.current}),[i,t]);const s=T.useRef({}),[l]=T.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(a.current)return s.current[e.name]||(s.current[e.name]=i.clipAction(e,a.current))},configurable:!0}))),{ref:a,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}));return o.useFrame(((e,t)=>i.update(t))),T.useEffect((()=>{const e=a.current;return()=>{s.current={},Object.values(l.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),T.useEffect((()=>()=>{i.stopAllAction()}),[i]),l},exports.useAspect=function(e,t,r=1){const n=o.useThree((e=>e.viewport)),a=t*(n.aspect>e/t?n.width/e:n.height/t);return[e*(n.aspect>e/t?n.width/e:n.height/t)*r,a*r,1]},exports.useBVH=function(e,t){t={strategy:b.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,...t},T.useEffect((()=>{if(e.current){e.current.raycast=b.acceleratedRaycast;const r=e.current.geometry;return r.computeBoundsTree=b.computeBoundsTree,r.disposeBoundsTree=b.disposeBoundsTree,r.computeBoundsTree(t),()=>{r.boundsTree&&r.disposeBoundsTree()}}}),[e,JSON.stringify(t)])},exports.useBounds=an,exports.useBoxProjectedEnv=function(e=new P.Vector3,t=new P.Vector3){const[r]=T.useState((()=>({position:new P.Vector3,size:new P.Vector3})));o.applyProps(r,{position:e,size:t});const n=T.useRef(null),a=T.useMemo((()=>({ref:n,onBeforeCompile:e=>function(e,t,r){e.defines.BOX_PROJECTED_ENV_MAP=!0,e.uniforms.envMapPosition={value:t},e.uniforms.envMapSize={value:r},e.vertexShader=`\n varying vec3 vWorldPosition;\n ${e.vertexShader.replace("#include <worldpos_vertex>",nr)}`,e.fragmentShader=`\n ${or}\n ${e.fragmentShader.replace("#include <envmap_physical_pars_fragment>",P.ShaderChunk.envmap_physical_pars_fragment).replace("vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",`vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n ${ar}\n `).replace("reflectVec = inverseTransformDirection( reflectVec, viewMatrix );",`reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n ${ir}\n `)}`}(e,r.position,r.size),customProgramCacheKey:()=>JSON.stringify(r.position.toArray())+JSON.stringify(r.size.toArray())})),[...r.position.toArray(),...r.size.toArray()]);return T.useLayoutEffect((()=>{n.current.needsUpdate=!0}),[r]),a},exports.useCamera=function(e,t){const r=o.useThree((e=>e.pointer)),[a]=T.useState((()=>{const a=new n.Raycaster;return t&&o.applyProps(a,t,{}),function(t,o){a.setFromCamera(r,e instanceof n.Camera?e:e.current);const i=this.constructor.prototype.raycast.bind(this);i&&i(a,o)}}));return a},exports.useContextBridge=function(...e){const t=T.useRef([]);return t.current=e.map((e=>T.useContext(e))),T.useMemo((()=>({children:r})=>e.reduceRight(((e,r,n)=>T.createElement(r.Provider,{value:t.current[n],children:e})),r)),[])},exports.useCubeCamera=He,exports.useCubeTexture=Xt,exports.useCursor=function(e,t="pointer",r="auto"){T.useEffect((()=>{if(e)return document.body.style.cursor=t,()=>{document.body.style.cursor=r}}),[e])},exports.useDepthBuffer=function({size:e=256,frames:t=1/0}={}){const r=o.useThree((e=>e.viewport.dpr)),{width:a,height:i}=o.useThree((e=>e.size)),s=e||a*r,l=e||i*r,c=T.useMemo((()=>{const e=new n.DepthTexture(s,l);return e.format=n.DepthFormat,e.type=n.UnsignedShortType,{depthTexture:e}}),[s,l]);let u=0;const m=je(s,l,c);return o.useFrame((e=>{(t===1/0||u<t)&&(e.gl.setRenderTarget(m),e.gl.render(e.scene,e.camera),e.gl.setRenderTarget(null),u++)})),m.depthTexture},exports.useDetectGPU=e=>p.suspend((()=>w.getGPUTier(e)),["useDetectGPU"]),exports.useEnvironment=dn,exports.useFBO=je,exports.useFBX=Yt,exports.useFaceControls=xt,exports.useFaceLandmarker=mt,exports.useFont=me,exports.useGLTF=Ie,exports.useGizmoContext=Et,exports.useHelper=Jt,exports.useIntersect=rr,exports.useKTX2=Zt,exports.useKeyboardControls=function(e){const[t,r,n]=T.useContext(Z);return e?n(e):[t,r]},exports.useMask=function(e,t=!1){return{stencilWrite:!0,stencilRef:e,stencilFunc:t?P.NotEqualStencilFunc:P.EqualStencilFunc,stencilFail:P.KeepStencilOp,stencilZFail:P.KeepStencilOp,stencilZPass:P.KeepStencilOp}},exports.useMatcapTexture=function(e=0,t=1024,r){const n=p.suspend((()=>fetch("https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/matcaps.json").then((e=>e.json()))),["matcapList"]),o=n[0],a=T.useMemo((()=>Object.keys(n).length),[]),i=`${T.useMemo((()=>"string"==typeof e?e:"number"==typeof e?n[e]:null),[e])||o}${function(e){switch(e){case 64:return"-64px";case 128:return"-128px";case 256:return"-256px";case 512:return"-512px";default:return""}}(t)}.png`,s=`https://rawcdn.githack.com/emmelleppi/matcaps/9b36ccaaf0a24881a39062d05566c9e92be4aa0d/${t}/${i}`;return[ve(s,r),s,a]},exports.useNormalTexture=function(e=0,t={},r){const{repeat:o=[1,1],anisotropy:a=1,offset:i=[0,0]}=t,s=p.suspend((()=>fetch("https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/normals/normals.json").then((e=>e.json()))),["normalsList"]),l=T.useMemo((()=>Object.keys(s).length),[]),c=s[0],u=`https://rawcdn.githack.com/pmndrs/drei-assets/7a3104997e1576f83472829815b00880d88b32fb/normals/${s[e]||c}`,m=ve(u,r);return T.useLayoutEffect((()=>{m&&(m.wrapS=m.wrapT=n.RepeatWrapping,m.repeat=new n.Vector2(o[0],o[1]),m.offset=new n.Vector2(i[0],i[1]),m.anisotropy=a)}),[m,a,o,i]),[m,u,l]},exports.usePerformanceMonitor=function({onIncline:e,onDecline:r,onChange:n,onFallback:o}){const a=t.useContext(Zo),i=t.useRef({onIncline:e,onDecline:r,onChange:n,onFallback:o});t.useLayoutEffect((()=>{i.current.onIncline=e,i.current.onDecline=r,i.current.onChange=n,i.current.onFallback=o}),[e,r,n,o]),t.useLayoutEffect((()=>a.subscribe(i)),[a])},exports.useProgress=j,exports.useScroll=q,exports.useSelect=function(){return T.useContext(J)},exports.useSurfaceSampler=Re,exports.useTexture=ve,exports.useTrail=Ce,exports.useTrailTexture=function(e={}){const{size:r,maxAge:n,radius:a,intensity:i,interpolate:s,smoothing:l,minForce:c,blend:u,ease:m}=e,d=t.useMemo((()=>new ur(e)),[r,n,a,i,s,l,c,u,m]);o.useFrame(((e,t)=>{d.update(t)}));const f=t.useCallback((e=>d.addTouch(e.uv)),[d]);return[d.texture,f]},exports.useVideoTexture=rt;
1
+ "use strict";var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("react-dom/client"),n=require("three"),o=require("@react-three/fiber"),a=require("zustand"),i=require("react-merge-refs"),s=require("maath"),l=require("@react-spring/three"),c=require("@use-gesture/react"),u=require("zustand/middleware"),m=require("three-stdlib"),d=require("zustand/shallow"),f=require("troika-three-text"),p=require("suspend-react"),h=require("meshline"),x=require("lodash.pick"),y=require("lodash.omit"),v=require("camera-controls"),g=require("@mediapipe/tasks-vision"),z=require("stats.js"),w=require("detect-gpu"),b=require("three-mesh-bvh"),E=require("react-composer"),M=require("lodash.clamp");function S(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var T=S(t),C=S(r),P=S(n),R=S(o);const D=new n.Vector3,F=new n.Vector3,k=new n.Vector3;function _(e,t,r){const n=D.setFromMatrixPosition(e.matrixWorld);n.project(t);const o=r.width/2,a=r.height/2;return[n.x*o+o,-n.y*a+a]}const L=e=>Math.abs(e)<1e-10?0:e;function A(e,t,r=""){let n="matrix3d(";for(let r=0;16!==r;r++)n+=L(t[r]*e.elements[r])+(15!==r?",":")");return r+n}const B=(U=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>A(e,U));var U;const O=(e,t)=>{return A(e,[1/(r=t),1/r,1/r,1,-1/r,-1/r,-1/r,-1,1/r,1/r,1/r,1,1,1,1,1],"translate(-50%,-50%)");var r};const N=T.forwardRef((({children:t,eps:r=.001,style:a,className:i,prepend:s,center:l,fullscreen:c,portal:u,distanceFactor:m,sprite:d=!1,transform:f=!1,occlude:p,onOcclude:h,castShadow:x,receiveShadow:y,material:v,geometry:g,zIndexRange:z=[16777271,0],calculatePosition:w=_,as:b="div",wrapperClass:E,pointerEvents:M="auto",...S},P)=>{const{gl:R,camera:A,scene:U,size:N,raycaster:I,events:V,viewport:j}=o.useThree(),[W]=T.useState((()=>document.createElement(b))),G=T.useRef(),H=T.useRef(null),q=T.useRef(0),$=T.useRef([0,0]),X=T.useRef(null),Y=T.useRef(null),K=(null==u?void 0:u.current)||V.connected||R.domElement.parentNode,Z=T.useRef(null),Q=T.useRef(!1),J=T.useMemo((()=>p&&"blending"!==p||Array.isArray(p)&&p.length&&function(e){return e&&"object"==typeof e&&"current"in e}(p[0])),[p]);T.useLayoutEffect((()=>{const e=R.domElement;p&&"blending"===p?(e.style.zIndex=`${Math.floor(z[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)}),[p]),T.useLayoutEffect((()=>{if(H.current){const e=G.current=C.createRoot(W);if(U.updateMatrixWorld(),f)W.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=w(H.current,A,N);W.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return K&&(s?K.prepend(W):K.appendChild(W)),()=>{K&&K.removeChild(W),e.unmount()}}}),[K,f]),T.useLayoutEffect((()=>{E&&(W.className=E)}),[E]);const ee=T.useMemo((()=>f?{position:"absolute",top:0,left:0,width:N.width,height:N.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:l?"translate3d(-50%,-50%,0)":"none",...c&&{top:-N.height/2,left:-N.width/2,width:N.width,height:N.height},...a}),[a,l,c,N,f]),te=T.useMemo((()=>({position:"absolute",pointerEvents:M})),[M]);T.useLayoutEffect((()=>{var e,r;(Q.current=!1,f)?null==(e=G.current)||e.render(T.createElement("div",{ref:X,style:ee},T.createElement("div",{ref:Y,style:te},T.createElement("div",{ref:P,className:i,style:a,children:t})))):null==(r=G.current)||r.render(T.createElement("div",{ref:P,style:ee,className:i,children:t}))}));const re=T.useRef(!0);o.useFrame((e=>{if(H.current){A.updateMatrixWorld(),H.current.updateWorldMatrix(!0,!1);const e=f?$.current:w(H.current,A,N);if(f||Math.abs(q.current-A.zoom)>r||Math.abs($.current[0]-e[0])>r||Math.abs($.current[1]-e[1])>r){const t=function(e,t){const r=D.setFromMatrixPosition(e.matrixWorld),n=F.setFromMatrixPosition(t.matrixWorld),o=r.sub(n),a=t.getWorldDirection(k);return o.angleTo(a)>Math.PI/2}(H.current,A);let r=!1;J&&("blending"!==p?r=[U]:Array.isArray(p)&&(r=p.map((e=>e.current))));const o=re.current;if(r){const e=function(e,t,r,n){const o=D.setFromMatrixPosition(e.matrixWorld),a=o.clone();a.project(t),r.setFromCamera(a,t);const i=r.intersectObjects(n,!0);if(i.length){const e=i[0].distance;return o.distanceTo(r.ray.origin)<e}return!0}(H.current,A,I,r);re.current=e&&!t}else re.current=!t;o!==re.current&&(h?h(!re.current):W.style.display=re.current?"block":"none");const a=Math.floor(z[0]/2),i=p?J?[z[0],a]:[a-1,0]:z;if(W.style.zIndex=`${function(e,t,r){if(t instanceof n.PerspectiveCamera||t instanceof n.OrthographicCamera){const n=D.setFromMatrixPosition(e.matrixWorld),o=F.setFromMatrixPosition(t.matrixWorld),a=n.distanceTo(o),i=(r[1]-r[0])/(t.far-t.near),s=r[1]-i*t.far;return Math.round(i*a+s)}}(H.current,A,i)}`,f){const[e,t]=[N.width/2,N.height/2],r=A.projectionMatrix.elements[5]*t,{isOrthographicCamera:n,top:o,left:a,bottom:i,right:s}=A,l=B(A.matrixWorldInverse),c=n?`scale(${r})translate(${L(-(s+a)/2)}px,${L((o+i)/2)}px)`:`translateZ(${r}px)`;let u=H.current.matrixWorld;d&&(u=A.matrixWorldInverse.clone().transpose().copyPosition(u).scale(H.current.scale),u.elements[3]=u.elements[7]=u.elements[11]=0,u.elements[15]=1),W.style.width=N.width+"px",W.style.height=N.height+"px",W.style.perspective=n?"":`${r}px`,X.current&&Y.current&&(X.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,Y.current.style.transform=O(u,1/((m||10)/400)))}else{const t=void 0===m?1:function(e,t){if(t instanceof n.OrthographicCamera)return t.zoom;if(t instanceof n.PerspectiveCamera){const r=D.setFromMatrixPosition(e.matrixWorld),n=F.setFromMatrixPosition(t.matrixWorld),o=t.fov*Math.PI/180,a=r.distanceTo(n);return 1/(2*Math.tan(o/2)*a)}return 1}(H.current,A)*m;W.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}$.current=e,q.current=A.zoom}}if(!J&&Z.current&&!Q.current)if(f){if(X.current){const e=X.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){const{isOrthographicCamera:t}=A;if(t||g)S.scale&&(Array.isArray(S.scale)?S.scale instanceof n.Vector3?Z.current.scale.copy(S.scale.clone().divideScalar(1)):Z.current.scale.set(1/S.scale[0],1/S.scale[1],1/S.scale[2]):Z.current.scale.setScalar(1/S.scale));else{const t=(m||10)/400,r=e.clientWidth*t,n=e.clientHeight*t;Z.current.scale.set(r,n,1)}Q.current=!0}}}else{const t=W.children[0];if(null!=t&&t.clientWidth&&null!=t&&t.clientHeight){const e=1/j.factor,r=t.clientWidth*e,n=t.clientHeight*e;Z.current.scale.set(r,n,1),Q.current=!0}Z.current.lookAt(e.camera.position)}}));const ne=T.useMemo((()=>({vertexShader:f?void 0:'\n /*\n This shader is from the THREE\'s SpriteMaterial.\n We need to turn the backing plane into a Sprite\n (make it always face the camera) if "transfrom" \n is false. \n */\n #include <common>\n\n void main() {\n vec2 center = vec2(0., 1.);\n float rotation = 0.0;\n \n // This is somewhat arbitrary, but it seems to work well\n // Need to figure out how to derive this dynamically if it even matters\n float size = 0.03;\n\n vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n vec2 scale;\n scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n\n gl_Position = projectionMatrix * mvPosition;\n }\n ',fragmentShader:"\n void main() {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n }\n "})),[f]);return T.createElement("group",e({},S,{ref:H}),p&&!J&&T.createElement("mesh",{castShadow:x,receiveShadow:y,ref:Z},g||T.createElement("planeGeometry",null),v||T.createElement("shaderMaterial",{side:n.DoubleSide,vertexShader:ne.vertexShader,fragmentShader:ne.fragmentShader})))}));const I=a.default||a;let V=0;const j=I((e=>(n.DefaultLoadingManager.onStart=(t,r,n)=>{e({active:!0,item:t,loaded:r,total:n,progress:(r-V)/(n-V)*100})},n.DefaultLoadingManager.onLoad=()=>{e({active:!1})},n.DefaultLoadingManager.onError=t=>e((e=>({errors:[...e.errors,t]}))),n.DefaultLoadingManager.onProgress=(t,r,n)=>{r===n&&(V=n),e({active:!0,item:t,loaded:r,total:n,progress:(r-V)/(n-V)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0}))),W=e=>`Loading ${e.toFixed(2)}%`;const G={container:{position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"#171717",display:"flex",alignItems:"center",justifyContent:"center",transition:"opacity 300ms ease",zIndex:1e3},inner:{width:100,height:3,background:"#272727",textAlign:"center"},bar:{height:3,width:"100%",background:"white",transition:"transform 200ms",transformOrigin:"left center"},data:{display:"inline-block",position:"relative",fontVariantNumeric:"tabular-nums",marginTop:"0.8em",color:"#f0f0f0",fontSize:"0.6em",fontFamily:'-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Helvetica, Arial, Roboto, Ubuntu, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',whiteSpace:"nowrap"}},H=T.createContext(null);function q(){return T.useContext(H)}const $=T.forwardRef((({children:e},t)=>{const r=T.useRef(null),n=q(),{width:a,height:s}=o.useThree((e=>e.viewport));return o.useFrame((()=>{r.current.position.x=n.horizontal?-a*(n.pages-1)*n.offset:0,r.current.position.y=n.horizontal?0:s*(n.pages-1)*n.offset})),T.createElement("group",{ref:i([t,r])},e)})),X=T.forwardRef((({children:t,style:r,...n},a)=>{const s=q(),l=T.useRef(null),{width:c,height:u}=o.useThree((e=>e.size)),m=T.useContext(o.context),d=T.useMemo((()=>C.createRoot(s.fixed)),[s.fixed]);return o.useFrame((()=>{s.delta>s.eps&&(l.current.style.transform=`translate3d(${s.horizontal?-c*(s.pages-1)*s.offset:0}px,${s.horizontal?0:u*(s.pages-1)*-s.offset}px,0)`)})),d.render(T.createElement("div",e({ref:i([a,l]),style:{...r,position:"absolute",top:0,left:0,willChange:"transform"}},n),T.createElement(H.Provider,{value:s},T.createElement(o.context.Provider,{value:m},t)))),null})),Y=T.forwardRef((({html:t,...r},n)=>{const o=t?X:$;return T.createElement(o,e({ref:n},r))}));const K=a.default||a,Z=T.createContext(null);const Q=d.default||d,J=T.createContext([]);const ee=T.forwardRef((function({follow:t=!0,lockX:r=!1,lockY:n=!1,lockZ:a=!1,...s},l){const c=T.useRef();return o.useFrame((({camera:e})=>{if(!t||!c.current)return;const o=c.current.rotation.clone();e.getWorldQuaternion(c.current.quaternion),r&&(c.current.rotation.x=o.x),n&&(c.current.rotation.y=o.y),a&&(c.current.rotation.z=o.z)})),T.createElement("group",e({ref:i([c,l])},s))})),te=T.forwardRef((({children:t,depth:r=-1,...n},a)=>{const s=T.useRef(null);return o.useFrame((({camera:e})=>{s.current.quaternion.copy(e.quaternion),s.current.position.copy(e.position)})),T.createElement("group",e({ref:i([a,s])},n),T.createElement("group",{"position-z":-r},t))})),re=T.forwardRef((function({points:t,color:r="black",vertexColors:a,linewidth:i,lineWidth:s,segments:l,dashed:c,...u},d){const f=o.useThree((e=>e.size)),p=T.useMemo((()=>l?new m.LineSegments2:new m.Line2),[l]),[h]=T.useState((()=>new m.LineMaterial)),x=T.useMemo((()=>{const e=l?new m.LineSegmentsGeometry:new m.LineGeometry,r=t.map((e=>{const t=Array.isArray(e);return e instanceof n.Vector3?[e.x,e.y,e.z]:e instanceof n.Vector2?[e.x,e.y,0]:t&&3===e.length?[e[0],e[1],e[2]]:t&&2===e.length?[e[0],e[1],0]:e}));if(e.setPositions(r.flat()),a){const t=a.map((e=>e instanceof n.Color?e.toArray():e));e.setColors(t.flat())}return e}),[t,l,a]);return T.useLayoutEffect((()=>{p.computeLineDistances()}),[t,p]),T.useLayoutEffect((()=>{c?h.defines.USE_DASH="":delete h.defines.USE_DASH,h.needsUpdate=!0}),[c,h]),T.useEffect((()=>()=>x.dispose()),[x]),T.createElement("primitive",e({object:p,ref:d},u),T.createElement("primitive",{object:x,attach:"geometry"}),T.createElement("primitive",e({object:h,attach:"material",color:r,vertexColors:Boolean(a),resolution:[f.width,f.height],linewidth:null!=i?i:s,dashed:c},u)))})),ne=new n.Vector3,oe=T.forwardRef((function({start:t=[0,0,0],end:r=[0,0,0],mid:o,segments:a=20,...s},l){const c=T.useRef(null),[u]=T.useState((()=>new n.QuadraticBezierCurve3(void 0,void 0,void 0))),m=T.useCallback(((e,t,r,o=20)=>(e instanceof n.Vector3?u.v0.copy(e):u.v0.set(...e),t instanceof n.Vector3?u.v2.copy(t):u.v2.set(...t),r instanceof n.Vector3?u.v1.copy(r):Array.isArray(r)?u.v1.set(...r):u.v1.copy(u.v0.clone().add(u.v2.clone().sub(u.v0)).add(ne.set(0,u.v0.y-u.v2.y,0))),u.getPoints(o))),[]);T.useLayoutEffect((()=>{c.current.setPoints=(e,t,r)=>{const n=m(e,t,r);c.current.geometry&&c.current.geometry.setPositions(n.map((e=>e.toArray())).flat())}}),[]);const d=T.useMemo((()=>m(t,r,o,a)),[t,r,o,a]);return T.createElement(re,e({ref:i([c,l]),points:d},s))})),ae=T.forwardRef((function({start:t,end:r,midA:o,midB:a,segments:i=20,...s},l){const c=T.useMemo((()=>{const e=t instanceof n.Vector3?t:new n.Vector3(...t),s=r instanceof n.Vector3?r:new n.Vector3(...r),l=o instanceof n.Vector3?o:new n.Vector3(...o),c=a instanceof n.Vector3?a:new n.Vector3(...a);return new n.CubicBezierCurve3(e,l,c,s).getPoints(i)}),[t,r,o,a,i]);return T.createElement(re,e({ref:l,points:c},s))})),ie=T.forwardRef((function({points:t,closed:r=!1,curveType:o="centripetal",tension:a=.5,segments:i=20,vertexColors:s,...l},c){const u=T.useMemo((()=>{const e=t.map((e=>e instanceof n.Vector3?e:new n.Vector3(...e)));return new n.CatmullRomCurve3(e,r,o,a)}),[t,r,o,a]),m=T.useMemo((()=>u.getPoints(i)),[u,i]),d=T.useMemo((()=>{if(!s||s.length<2)return;if(s.length===i+1)return s;const e=s.map((e=>e instanceof n.Color?e:new n.Color(...e)));r&&e.push(e[0].clone());const t=[e[0]],o=i/(e.length-1);for(let r=1;r<i;r++){const n=r%o/o,a=Math.floor(r/o);t.push(e[a].clone().lerp(e[a+1],n))}return t.push(e[e.length-1]),t}),[s,i]);return T.createElement(re,e({ref:c,points:m,vertexColors:d},l))})),se=T.forwardRef((({url:t,distance:r=1,loop:a=!0,autoplay:s,...l},c)=>{const u=T.useRef(),m=o.useThree((({camera:e})=>e)),[d]=T.useState((()=>new n.AudioListener)),f=o.useLoader(n.AudioLoader,t);return T.useEffect((()=>{const e=u.current;e&&(e.setBuffer(f),e.setRefDistance(r),e.setLoop(a),s&&!e.isPlaying&&e.play())}),[f,m,r,a]),T.useEffect((()=>{const e=u.current;return m.add(d),()=>{m.remove(d),e&&(e.isPlaying&&e.stop(),e.source&&e.source._connected&&e.disconnect())}}),[]),T.createElement("positionalAudio",e({ref:i([u,c]),args:[d]},l))})),le=T.forwardRef((({sdfGlyphSize:t=64,anchorX:r="center",anchorY:n="middle",font:a,fontSize:i=1,children:s,characters:l,onSync:c,...u},m)=>{const d=o.useThree((({invalidate:e})=>e)),[h]=T.useState((()=>new f.Text)),[x,y]=T.useMemo((()=>{const e=[];let t="";return T.Children.forEach(s,(r=>{"string"==typeof r||"number"==typeof r?t+=r:e.push(r)})),[e,t]}),[s]);return p.suspend((()=>new Promise((e=>f.preloadFont({font:a,characters:l},e)))),["troika-text",a,l]),T.useLayoutEffect((()=>{h.sync((()=>{d(),c&&c(h)}))})),T.useEffect((()=>()=>h.dispose()),[h]),T.createElement("primitive",e({object:h,ref:m,font:a,text:y,anchorX:r,anchorY:n,fontSize:i,sdfGlyphSize:t},u),x)}));let ce=null;async function ue(e){ce||(ce=new m.FontLoader);let t="string"==typeof e?await(await fetch(e)).json():e;return ce.parse(t)}function me(e){return p.suspend(ue,[e])}me.preload=e=>p.preload(ue,[e]),me.clear=e=>p.clear([e]);const de=["string","number"],fe=T.forwardRef((({font:r,letterSpacing:n=0,lineHeight:a=1,size:i=1,height:s=.2,bevelThickness:l=.1,bevelSize:c=.01,bevelEnabled:u=!1,bevelOffset:d=0,bevelSegments:f=4,curveSegments:p=8,smooth:h,children:x,...y},v)=>{T.useMemo((()=>o.extend({RenamedTextGeometry:m.TextGeometry})),[]);const g=T.useRef(null),z=me(r),w=t.useMemo((()=>({font:z,size:i,height:s,bevelThickness:l,bevelSize:c,bevelEnabled:u,bevelSegments:f,bevelOffset:d,curveSegments:p,letterSpacing:n,lineHeight:a})),[z,i,s,l,c,u,f,d,p,n,a]),[b,...E]=t.useMemo((()=>(e=>{let t="";const r=[];return T.Children.forEach(e,(e=>{de.includes(typeof e)?t+=e+"":r.push(e)})),[t,...r]})(x)),[x]),M=T.useMemo((()=>[b,w]),[b,w]);return T.useLayoutEffect((()=>{h&&(g.current.geometry=m.mergeVertices(g.current.geometry,h),g.current.geometry.computeVertexNormals())}),[M,h]),T.useImperativeHandle(v,(()=>g.current),[]),T.createElement("mesh",e({},y,{ref:g}),T.createElement("renamedTextGeometry",{args:M}),E)})),pe=T.forwardRef((({children:t,multisamping:r=8,renderIndex:a=1,disableRender:s,disableGamma:l,disableRenderPass:c,depthBuffer:u=!0,stencilBuffer:d=!1,anisotropy:f=1,encoding:p,type:h,...x},y)=>{T.useMemo((()=>o.extend({EffectComposer:m.EffectComposer,RenderPass:m.RenderPass,ShaderPass:m.ShaderPass})),[]);const v=T.useRef(),{scene:g,camera:z,gl:w,size:b,viewport:E}=o.useThree(),[M]=T.useState((()=>{const e=new n.WebGLRenderTarget(b.width,b.height,{type:h||n.HalfFloatType,format:n.RGBAFormat,depthBuffer:u,stencilBuffer:d,anisotropy:f});return h===n.UnsignedByteType&&null!=p&&("colorSpace"in e?e.texture.colorSpace=p:e.texture.encoding=p),e.samples=r,e}));T.useEffect((()=>{var e,t;null==(e=v.current)||e.setSize(b.width,b.height),null==(t=v.current)||t.setPixelRatio(E.dpr)}),[w,b,E.dpr]),o.useFrame((()=>{var e;s||null==(e=v.current)||e.render()}),a);const S=[];return c||S.push(T.createElement("renderPass",{key:"renderpass",attach:`passes-${S.length}`,args:[g,z]})),l||S.push(T.createElement("shaderPass",{attach:`passes-${S.length}`,key:"gammapass",args:[m.GammaCorrectionShader]})),T.Children.forEach(t,(e=>{e&&S.push(T.cloneElement(e,{key:S.length,attach:`passes-${S.length}`}))})),T.createElement("effectComposer",e({ref:i([y,v]),args:[w,M]},x),S)}));let he=function(e){return e.Linear="linear",e.Radial="radial",e}({});function xe(e,t,r,n){const o=class extends P.ShaderMaterial{constructor(o={}){const a=Object.entries(e);super({uniforms:a.reduce(((e,[t,r])=>({...e,...P.UniformsUtils.clone({[t]:{value:r}})})),{}),vertexShader:t,fragmentShader:r}),this.key="",a.forEach((([e])=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t}))),Object.assign(this,o),n&&n(this)}};return o.key=P.MathUtils.generateUUID(),o}const ye=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function ve(e,r){const a=o.useThree((e=>e.gl)),i=o.useLoader(n.TextureLoader,ye(e)?Object.values(e):e);if(t.useLayoutEffect((()=>{null==r||r(i)}),[r]),t.useEffect((()=>{(Array.isArray(i)?i:[i]).forEach(a.initTexture)}),[a,i]),ye(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:i[t.indexOf(e)]}))),r}return i}ve.preload=e=>o.useLoader.preload(n.TextureLoader,e),ve.clear=e=>o.useLoader.clear(n.TextureLoader,e);const ge=xe({color:new P.Color("white"),scale:[1,1],imageBounds:[1,1],map:null,zoom:1,grayscale:0,opacity:1},"\n varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }\n","\n // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44\n varying vec2 vUv;\n uniform vec2 scale;\n uniform vec2 imageBounds;\n uniform vec3 color;\n uniform sampler2D map;\n uniform float zoom;\n uniform float grayscale;\n uniform float opacity;\n const vec3 luma = vec3(.299, 0.587, 0.114);\n vec4 toGrayscale(vec4 color, float intensity) {\n return vec4(mix(color.rgb, vec3(dot(color.rgb, luma)), intensity), color.a);\n }\n vec2 aspect(vec2 size) {\n return size / min(size.x, size.y);\n }\n void main() {\n vec2 s = aspect(scale);\n vec2 i = aspect(imageBounds);\n float rs = s.x / s.y;\n float ri = i.x / i.y;\n vec2 new = rs < ri ? vec2(i.x * s.y / i.y, s.y) : vec2(s.x, i.y * s.x / i.x);\n vec2 offset = (rs < ri ? vec2((new.x - s.x) / 2.0, 0.0) : vec2(0.0, (new.y - s.y) / 2.0)) / new;\n vec2 uv = vUv * s / new + offset;\n vec2 zUv = (uv - vec2(0.5, 0.5)) / zoom + vec2(0.5, 0.5);\n gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity), grayscale);\n \n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }\n"),ze=T.forwardRef((({children:t,color:r,segments:n=1,scale:a=1,zoom:i=1,grayscale:s=0,opacity:l=1,texture:c,toneMapped:u,transparent:m,...d},f)=>{o.extend({ImageMaterial:ge});const p=Array.isArray(a)?[a[0],a[1]]:[a,a],h=[c.image.width,c.image.height];return T.createElement("mesh",e({ref:f,scale:Array.isArray(a)?[...a,1]:a},d),T.createElement("planeGeometry",{args:[1,1,n,n]}),T.createElement("imageMaterial",{color:r,map:c,zoom:i,grayscale:s,opacity:l,scale:p,imageBounds:h,toneMapped:u,transparent:m}),t)})),we=T.forwardRef((({url:t,...r},n)=>{const o=ve(t);return T.createElement(ze,e({},r,{texture:o,ref:n}))})),be=T.forwardRef((({url:t,...r},n)=>T.createElement(ze,e({},r,{ref:n})))),Ee=T.forwardRef(((t,r)=>{if(t.url)return T.createElement(we,e({},t,{ref:r}));if(t.texture)return T.createElement(be,e({},t,{ref:r}));throw new Error("<Image /> requires a url or texture")})),Me=T.forwardRef((({userData:t,children:r,geometry:n,threshold:o=15,color:a="black",...i},s)=>{const l=T.useRef(null);return T.useLayoutEffect((()=>{const e=l.current.parent;if(e){const t=n||e.geometry;t===l.current.userData.currentGeom&&o===l.current.userData.currentThreshold||(l.current.userData.currentGeom=t,l.current.userData.currentThreshold=o,l.current.geometry=new P.EdgesGeometry(t,o))}})),T.useImperativeHandle(s,(()=>l.current)),T.createElement("lineSegments",e({ref:l,raycast:()=>null},i),r||T.createElement("lineBasicMaterial",{color:a}))})),Se={width:.2,length:1,decay:1,local:!1,stride:0,interval:1},Te=(e,t=1)=>(e.set(e.subarray(t)),e.fill(-1/0,-t),e);function Ce(e,t){const{length:r,local:a,decay:i,interval:s,stride:l}={...Se,...t},c=T.useRef(),[u]=T.useState((()=>new n.Vector3));T.useLayoutEffect((()=>{e&&(c.current=Float32Array.from({length:10*r*3},((t,r)=>e.position.getComponent(r%3))))}),[r,e]);const m=T.useRef(new n.Vector3),d=T.useRef(0);return o.useFrame((()=>{if(e&&c.current){if(0===d.current){let t;a?t=e.position:(e.getWorldPosition(u),t=u);const r=1*i;for(let e=0;e<r;e++)t.distanceTo(m.current)<l||(Te(c.current,3),c.current.set(t.toArray(),c.current.length-3));m.current.copy(t)}d.current++,d.current=d.current%s}})),c}const Pe=T.forwardRef(((e,t)=>{const{children:r}=e,{width:a,length:i,decay:s,local:l,stride:c,interval:u}={...Se,...e},{color:m="hotpink",attenuation:d,target:f}=e,p=o.useThree((e=>e.size)),x=o.useThree((e=>e.scene)),y=T.useRef(null),[v,g]=T.useState(null),z=Ce(v,{length:i,decay:s,local:l,stride:c,interval:u});T.useEffect((()=>{const e=(null==f?void 0:f.current)||y.current.children.find((e=>e instanceof n.Object3D));e&&g(e)}),[z,f]);const w=T.useMemo((()=>new h.MeshLineGeometry),[]),b=T.useMemo((()=>{var e;const t=new h.MeshLineMaterial({lineWidth:.1*a,color:m,sizeAttenuation:1,resolution:new n.Vector2(p.width,p.height)});let o;if(r)if(Array.isArray(r))o=r.find((e=>{const t=e;return"string"==typeof t.type&&"meshLineMaterial"===t.type}));else{const e=r;"string"==typeof e.type&&"meshLineMaterial"===e.type&&(o=e)}return"object"==typeof(null==(e=o)?void 0:e.props)&&t.setValues(o.props),t}),[a,m,p,r]);return T.useEffect((()=>{b.uniforms.resolution.value.set(p.width,p.height)}),[p]),o.useFrame((()=>{z.current&&w.setPoints(z.current,d)})),T.createElement("group",null,o.createPortal(T.createElement("mesh",{ref:t,geometry:w,material:b}),x),T.createElement("group",{ref:y},r))}));function Re(e,t=16,r,o,a){const[i,s]=T.useState((()=>{const e=Array.from({length:t},(()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])).flat();return new n.InstancedBufferAttribute(Float32Array.from(e),16)}));return T.useLayoutEffect((()=>{if(void 0===e.current)return;const l=new m.MeshSurfaceSampler(e.current);o&&l.setWeightAttribute(o),l.build();const c=new n.Vector3,u=new n.Vector3,d=new n.Color,f=new n.Object3D;e.current.updateMatrixWorld(!0);for(let n=0;n<t;n++)l.sample(c,u,d),"function"==typeof r?r({dummy:f,sampledMesh:e.current,position:c,normal:u,color:d},n):f.position.copy(c),f.updateMatrix(),null!=a&&a.current&&a.current.setMatrixAt(n,f.matrix),f.matrix.toArray(i.array,16*n);null!=a&&a.current&&(a.current.instanceMatrix.needsUpdate=!0),i.needsUpdate=!0,s(i.clone())}),[e,a,o,t,r]),i}const De=T.forwardRef((({isChild:t=!1,object:r,children:n,deep:o,castShadow:a,receiveShadow:i,inject:s,keys:l,...c},u)=>{var d;const f={keys:l,deep:o,inject:s,castShadow:a,receiveShadow:i};if(r=T.useMemo((()=>{if(!1===t&&!Array.isArray(r)){let e=!1;if(r.traverse((t=>{t.isSkinnedMesh&&(e=!0)})),e)return m.SkeletonUtils.clone(r)}return r}),[r,t]),Array.isArray(r))return T.createElement("group",e({},c,{ref:u}),r.map((t=>T.createElement(De,e({key:t.uuid,object:t},f)))),n);const{children:p,...h}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:n,castShadow:o,receiveShadow:a}){let i=x(e,t);return r&&(i.geometry&&"materialsOnly"!==r&&(i.geometry=i.geometry.clone()),i.material&&"geometriesOnly"!==r&&(i.material=i.material.clone())),n&&(i="function"==typeof n?{...i,children:n(e)}:T.isValidElement(n)?{...i,children:n}:{...i,...n}),e instanceof P.Mesh&&(o&&(i.castShadow=!0),a&&(i.receiveShadow=!0)),i}(r,f),y=r.type[0].toLowerCase()+r.type.slice(1);return T.createElement(y,e({},h,c,{ref:u}),(null==(d=r)?void 0:d.children).map((t=>"Bone"===t.type?T.createElement("primitive",e({key:t.uuid,object:t},f)):T.createElement(De,e({key:t.uuid,object:t},f,{isChild:!0})))),n,p)})),Fe=T.createContext(null),ke=T.forwardRef((({resolution:t=28,maxPolyCount:r=1e4,enableUvs:n=!1,enableColors:a=!1,children:s,...l},c)=>{const u=T.useRef(null),d=T.useMemo((()=>new m.MarchingCubes(t,null,n,a,r)),[t,r,n,a]),f=T.useMemo((()=>({getParent:()=>u})),[]);return o.useFrame((()=>{d.update(),d.reset()}),-1),T.createElement(T.Fragment,null,T.createElement("primitive",e({object:d,ref:i([u,c])},l),T.createElement(Fe.Provider,{value:f},s)))})),_e=T.forwardRef((({strength:t=.5,subtract:r=12,color:n,...a},s)=>{const{getParent:l}=T.useContext(Fe),c=T.useMemo((()=>l()),[l]),u=T.useRef(),m=new P.Vector3;return o.useFrame((e=>{c.current&&u.current&&(u.current.getWorldPosition(m),c.current.addBall(.5+.5*m.x,.5+.5*m.y,.5+.5*m.z,t,r,n))})),T.createElement("group",e({ref:i([s,u])},a))})),Le=T.forwardRef((({planeType:t="x",strength:r=.5,subtract:n=12,...a},s)=>{const{getParent:l}=T.useContext(Fe),c=T.useMemo((()=>l()),[l]),u=T.useRef(),m=T.useMemo((()=>"x"===t?"addPlaneX":"y"===t?"addPlaneY":"addPlaneZ"),[t]);return o.useFrame((()=>{c.current&&u.current&&c.current[m](r,n)})),T.createElement("group",e({ref:i([s,u])},a))}));function Ae(e=[0,0,0]){return function(e){return Array.isArray(e)}(e)?e:e instanceof P.Vector3||e instanceof P.Euler?[e.x,e.y,e.z]:[e,e,e]}const Be=T.forwardRef((function({debug:t,depthTest:r=!1,polygonOffsetFactor:n=-10,map:a,mesh:i,children:s,position:l,rotation:c,scale:u,...d},f){const p=T.useRef(null);T.useImperativeHandle(f,(()=>p.current));const h=T.useRef(null);return T.useLayoutEffect((()=>{const e=(null==i?void 0:i.current)||p.current.parent,t=p.current;if(!(e instanceof P.Mesh))throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');const r={position:new P.Vector3,rotation:new P.Euler,scale:new P.Vector3(1,1,1)};if(e){o.applyProps(r,{position:l,scale:u});const n=e.matrixWorld.clone();if(e.matrixWorld.identity(),c&&"number"!=typeof c)o.applyProps(r,{rotation:c});else{const t=new P.Object3D;t.position.copy(r.position),t.lookAt(e.position),"number"==typeof c&&t.rotateZ(c),o.applyProps(r,{rotation:t.rotation})}return t.geometry=new m.DecalGeometry(e,r.position,r.rotation,r.scale),h.current&&(o.applyProps(h.current,r),h.current.traverse((e=>e.raycast=()=>null))),e.matrixWorld=n,()=>{t.geometry.dispose()}}}),[i,...Ae(l),...Ae(u),...Ae(c)]),T.createElement("mesh",e({ref:p,"material-transparent":!0,"material-polygonOffset":!0,"material-polygonOffsetFactor":n,"material-depthTest":r,"material-map":a},d),s,t&&T.createElement("mesh",{ref:h},T.createElement("boxGeometry",null),T.createElement("meshNormalMaterial",{wireframe:!0}),T.createElement("axesHelper",null)))})),Ue=t.forwardRef((function({src:r,skipFill:a,skipStrokes:i,fillMaterial:s,strokeMaterial:l,fillMeshProps:c,strokeMeshProps:u,...d},f){const p=o.useLoader(m.SVGLoader,r.startsWith("<svg")?`data:image/svg+xml;utf8,${r}`:r),h=t.useMemo((()=>i?[]:p.paths.map((e=>{var t;return void 0===(null==(t=e.userData)?void 0:t.style.stroke)||"none"===e.userData.style.stroke?null:e.subPaths.map((t=>m.SVGLoader.pointsToStroke(t.getPoints(),e.userData.style)))}))),[p,i]);return t.useEffect((()=>()=>h.forEach((e=>e&&e.map((e=>e.dispose()))))),[h]),T.createElement("object3D",e({ref:f},d),T.createElement("object3D",{scale:[1,-1,1]},p.paths.map(((r,o)=>{var d,f;return T.createElement(t.Fragment,{key:o},!a&&void 0!==(null==(d=r.userData)?void 0:d.style.fill)&&"none"!==r.userData.style.fill&&m.SVGLoader.createShapes(r).map(((t,o)=>T.createElement("mesh",e({key:o},c),T.createElement("shapeGeometry",{args:[t]}),T.createElement("meshBasicMaterial",e({color:r.userData.style.fill,opacity:r.userData.style.fillOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},s))))),!i&&void 0!==(null==(f=r.userData)?void 0:f.style.stroke)&&"none"!==r.userData.style.stroke&&r.subPaths.map(((t,a)=>T.createElement("mesh",e({key:a,geometry:h[o][a]},u),T.createElement("meshBasicMaterial",e({color:r.userData.style.stroke,opacity:r.userData.style.strokeOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},l))))))}))))}));let Oe=null;function Ne(e,t,r){return n=>{r&&r(n),e&&(Oe||(Oe=new m.DRACOLoader),Oe.setDecoderPath("string"==typeof e?e:"https://www.gstatic.com/draco/versioned/decoders/1.5.5/"),n.setDRACOLoader(Oe)),t&&n.setMeshoptDecoder("function"==typeof m.MeshoptDecoder?m.MeshoptDecoder():m.MeshoptDecoder)}}function Ie(e,t=!0,r=!0,n){return o.useLoader(m.GLTFLoader,e,Ne(t,r,n))}Ie.preload=(e,t=!0,r=!0,n)=>o.useLoader.preload(m.GLTFLoader,e,Ne(t,r,n)),Ie.clear=e=>o.useLoader.clear(m.GLTFLoader,e);const Ve=T.forwardRef((({src:t,...r},n)=>{const{scene:o}=Ie(t);return T.createElement(De,e({ref:n},r,{object:o}))}));function je(e,t,r){const n=o.useThree((e=>e.size)),a=o.useThree((e=>e.viewport)),i="number"==typeof e?e:n.width*a.dpr,s="number"==typeof t?t:n.height*a.dpr,l=("number"==typeof e?r:e)||{},{samples:c=0,depth:u,...m}=l,d=T.useMemo((()=>{const e=new P.WebGLRenderTarget(i,s,{minFilter:P.LinearFilter,magFilter:P.LinearFilter,type:P.HalfFloatType,...m});return u&&(e.depthTexture=new P.DepthTexture(i,s,P.FloatType)),e.samples=c,e}),[]);return T.useLayoutEffect((()=>{d.setSize(i,s),c&&(d.samples=c)}),[c,d,i,s]),T.useEffect((()=>()=>d.dispose()),[]),d}const We=T.forwardRef((({envMap:t,resolution:r=256,frames:n=1/0,children:a,makeDefault:s,...l},c)=>{const u=o.useThree((({set:e})=>e)),m=o.useThree((({camera:e})=>e)),d=o.useThree((({size:e})=>e)),f=T.useRef(null),p=T.useRef(null),h=je(r);T.useLayoutEffect((()=>{l.manual||f.current.updateProjectionMatrix()}),[d,l]),T.useLayoutEffect((()=>{f.current.updateProjectionMatrix()})),T.useLayoutEffect((()=>{if(s){const e=m;return u((()=>({camera:f.current}))),()=>u((()=>({camera:e})))}}),[f,s,u]);let x=0,y=null;const v="function"==typeof a;return o.useFrame((e=>{v&&(n===1/0||x<n)&&(p.current.visible=!1,e.gl.setRenderTarget(h),y=e.scene.background,t&&(e.scene.background=t),e.gl.render(e.scene,f.current),e.scene.background=y,e.gl.setRenderTarget(null),p.current.visible=!0,x++)})),T.createElement(T.Fragment,null,T.createElement("orthographicCamera",e({left:d.width/-2,right:d.width/2,top:d.height/2,bottom:d.height/-2,ref:i([f,c])},l),!v&&a),T.createElement("group",{ref:p},v&&a(h.texture)))})),Ge=T.forwardRef((({envMap:t,resolution:r=256,frames:n=1/0,makeDefault:a,children:s,...l},c)=>{const u=o.useThree((({set:e})=>e)),m=o.useThree((({camera:e})=>e)),d=o.useThree((({size:e})=>e)),f=T.useRef(null),p=T.useRef(null),h=je(r);T.useLayoutEffect((()=>{l.manual||(f.current.aspect=d.width/d.height)}),[d,l]),T.useLayoutEffect((()=>{f.current.updateProjectionMatrix()}));let x=0,y=null;const v="function"==typeof s;return o.useFrame((e=>{v&&(n===1/0||x<n)&&(p.current.visible=!1,e.gl.setRenderTarget(h),y=e.scene.background,t&&(e.scene.background=t),e.gl.render(e.scene,f.current),e.scene.background=y,e.gl.setRenderTarget(null),p.current.visible=!0,x++)})),T.useLayoutEffect((()=>{if(a){const e=m;return u((()=>({camera:f.current}))),()=>u((()=>({camera:e})))}}),[f,a,u]),T.createElement(T.Fragment,null,T.createElement("perspectiveCamera",e({ref:i([f,c])},l),!v&&s),T.createElement("group",{ref:p},v&&s(h.texture)))}));function He({resolution:e=256,near:r=.1,far:a=1e3,envMap:i,fog:s}={}){const l=o.useThree((({gl:e})=>e)),c=o.useThree((({scene:e})=>e)),u=t.useMemo((()=>{const t=new n.WebGLCubeRenderTarget(e);return t.texture.type=n.HalfFloatType,t}),[e]);t.useEffect((()=>()=>{u.dispose()}),[u]);const m=t.useMemo((()=>new P.CubeCamera(r,a,u)),[r,a,u]);let d,f;const p=T.useCallback((()=>{d=c.fog,f=c.background,c.background=i||f,c.fog=s||d,m.update(l,c),c.fog=d,c.background=f}),[l,c,m]);return{fbo:u,camera:m,update:p}}const qe=T.forwardRef(((t,r)=>{const{camera:n,onChange:a,makeDefault:i,...s}=t,l=o.useThree((e=>e.camera)),c=o.useThree((e=>e.invalidate)),u=o.useThree((e=>e.get)),d=o.useThree((e=>e.set)),f=n||l,[p]=T.useState((()=>new m.DeviceOrientationControls(f)));return T.useEffect((()=>{const e=e=>{c(),a&&a(e)};return null==p||null==p.addEventListener||p.addEventListener("change",e),()=>null==p||null==p.removeEventListener?void 0:p.removeEventListener("change",e)}),[a,p,c]),o.useFrame((()=>null==p?void 0:p.update()),-1),T.useEffect((()=>{const e=p;return null==e||e.connect(),()=>null==e?void 0:e.dispose()}),[p]),T.useEffect((()=>{if(i){const e=u().controls;return d({controls:p}),()=>d({controls:e})}}),[i,p]),p?T.createElement("primitive",e({ref:r,object:p},s)):null})),$e=T.forwardRef((({domElement:t,...r},n)=>{const{onChange:a,makeDefault:i,...s}=r,l=o.useThree((e=>e.invalidate)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.gl)),d=o.useThree((e=>e.events)),f=o.useThree((e=>e.get)),p=o.useThree((e=>e.set)),h=t||d.connected||u.domElement,x=T.useMemo((()=>new m.FlyControls(c)),[c]);return T.useEffect((()=>(x.connect(h),()=>{x.dispose()})),[h,x,l]),T.useEffect((()=>{const e=e=>{l(),a&&a(e)};return null==x.addEventListener||x.addEventListener("change",e),()=>null==x.removeEventListener?void 0:x.removeEventListener("change",e)}),[a,l]),T.useEffect((()=>{if(i){const e=f().controls;return p({controls:x}),()=>p({controls:e})}}),[i,x]),o.useFrame(((e,t)=>x.update(t))),T.createElement("primitive",e({ref:n,object:x,args:[c,h]},s))})),Xe=T.forwardRef(((t={enableDamping:!0},r)=>{const{domElement:n,camera:a,makeDefault:i,onChange:s,onStart:l,onEnd:c,...u}=t,d=o.useThree((e=>e.invalidate)),f=o.useThree((e=>e.camera)),p=o.useThree((e=>e.gl)),h=o.useThree((e=>e.events)),x=o.useThree((e=>e.set)),y=o.useThree((e=>e.get)),v=n||h.connected||p.domElement,g=a||f,z=T.useMemo((()=>new m.MapControls(g)),[g]);return T.useEffect((()=>{z.connect(v);const e=e=>{d(),s&&s(e)};return z.addEventListener("change",e),l&&z.addEventListener("start",l),c&&z.addEventListener("end",c),()=>{z.dispose(),z.removeEventListener("change",e),l&&z.removeEventListener("start",l),c&&z.removeEventListener("end",c)}}),[s,l,c,z,d,v]),T.useEffect((()=>{if(i){const e=y().controls;return x({controls:z}),()=>x({controls:e})}}),[i,z]),o.useFrame((()=>z.update()),-1),T.createElement("primitive",e({ref:r,object:z,enableDamping:!0},u))})),Ye=T.forwardRef((({makeDefault:t,camera:r,regress:n,domElement:a,enableDamping:i=!0,keyEvents:s=!1,onChange:l,onStart:c,onEnd:u,...d},f)=>{const p=o.useThree((e=>e.invalidate)),h=o.useThree((e=>e.camera)),x=o.useThree((e=>e.gl)),y=o.useThree((e=>e.events)),v=o.useThree((e=>e.setEvents)),g=o.useThree((e=>e.set)),z=o.useThree((e=>e.get)),w=o.useThree((e=>e.performance)),b=r||h,E=a||y.connected||x.domElement,M=T.useMemo((()=>new m.OrbitControls(b)),[b]);return o.useFrame((()=>{M.enabled&&M.update()}),-1),T.useEffect((()=>(s&&M.connect(!0===s?E:s),M.connect(E),()=>{M.dispose()})),[s,E,n,M,p]),T.useEffect((()=>{const e=e=>{p(),n&&w.regress(),l&&l(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return M.addEventListener("change",e),M.addEventListener("start",t),M.addEventListener("end",r),()=>{M.removeEventListener("start",t),M.removeEventListener("end",r),M.removeEventListener("change",e)}}),[l,c,u,M,p,v]),T.useEffect((()=>{if(t){const e=z().controls;return g({controls:M}),()=>g({controls:e})}}),[t,M]),T.createElement("primitive",e({ref:f,object:M,enableDamping:i},d))})),Ke=T.forwardRef((({makeDefault:t,camera:r,domElement:n,regress:a,onChange:i,onStart:s,onEnd:l,...c},u)=>{const{invalidate:d,camera:f,gl:p,events:h,set:x,get:y,performance:v,viewport:g}=o.useThree(),z=r||f,w=n||h.connected||p.domElement,b=T.useMemo((()=>new m.TrackballControls(z)),[z]);return o.useFrame((()=>{b.enabled&&b.update()}),-1),T.useEffect((()=>(b.connect(w),()=>{b.dispose()})),[w,a,b,d]),T.useEffect((()=>{const e=e=>{d(),a&&v.regress(),i&&i(e)};return b.addEventListener("change",e),s&&b.addEventListener("start",s),l&&b.addEventListener("end",l),()=>{s&&b.removeEventListener("start",s),l&&b.removeEventListener("end",l),b.removeEventListener("change",e)}}),[i,s,l,b,d]),T.useEffect((()=>{b.handleResize()}),[g]),T.useEffect((()=>{if(t){const e=y().controls;return x({controls:b}),()=>x({controls:e})}}),[t,b]),T.createElement("primitive",e({ref:u,object:b},c))})),Ze=t.forwardRef((({camera:r,makeDefault:n,regress:a,domElement:i,onChange:s,onStart:l,onEnd:c,...u},d)=>{const f=o.useThree((e=>e.invalidate)),p=o.useThree((e=>e.camera)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.events)),y=o.useThree((e=>e.set)),v=o.useThree((e=>e.get)),g=o.useThree((e=>e.performance)),z=r||p,w=i||x.connected||h.domElement,b=t.useMemo((()=>new m.ArcballControls(z)),[z]);return o.useFrame((()=>{b.enabled&&b.update()}),-1),t.useEffect((()=>(b.connect(w),()=>{b.dispose()})),[w,a,b,f]),t.useEffect((()=>{const e=e=>{f(),a&&g.regress(),s&&s(e)};return b.addEventListener("change",e),l&&b.addEventListener("start",l),c&&b.addEventListener("end",c),()=>{b.removeEventListener("change",e),l&&b.removeEventListener("start",l),c&&b.removeEventListener("end",c)}}),[s,l,c]),t.useEffect((()=>{if(n){const e=v().controls;return y({controls:b}),()=>y({controls:e})}}),[n,b]),T.createElement("primitive",e({ref:d,object:b},u))})),Qe=T.forwardRef((({children:t,domElement:r,onChange:n,onMouseDown:a,onMouseUp:i,onObjectChange:s,object:l,makeDefault:c,...u},d)=>{const f=["enabled","axis","mode","translationSnap","rotationSnap","scaleSnap","space","size","showX","showY","showZ"],{camera:p,...h}=u,v=x(h,f),g=y(h,f),z=o.useThree((e=>e.controls)),w=o.useThree((e=>e.gl)),b=o.useThree((e=>e.events)),E=o.useThree((e=>e.camera)),M=o.useThree((e=>e.invalidate)),S=o.useThree((e=>e.get)),C=o.useThree((e=>e.set)),R=p||E,D=r||b.connected||w.domElement,F=T.useMemo((()=>new m.TransformControls(R,D)),[R,D]),k=T.useRef();T.useLayoutEffect((()=>(l?F.attach(l instanceof P.Object3D?l:l.current):k.current instanceof P.Object3D&&F.attach(k.current),()=>{F.detach()})),[l,t,F]),T.useEffect((()=>{if(z){const e=e=>z.enabled=!e.value;return F.addEventListener("dragging-changed",e),()=>F.removeEventListener("dragging-changed",e)}}),[F,z]);const _=T.useRef(),L=T.useRef(),A=T.useRef(),B=T.useRef();return T.useLayoutEffect((()=>{_.current=n}),[n]),T.useLayoutEffect((()=>{L.current=a}),[a]),T.useLayoutEffect((()=>{A.current=i}),[i]),T.useLayoutEffect((()=>{B.current=s}),[s]),T.useEffect((()=>{const e=e=>{M(),null==_.current||_.current(e)},t=e=>null==L.current?void 0:L.current(e),r=e=>null==A.current?void 0:A.current(e),n=e=>null==B.current?void 0:B.current(e);return F.addEventListener("change",e),F.addEventListener("mouseDown",t),F.addEventListener("mouseUp",r),F.addEventListener("objectChange",n),()=>{F.removeEventListener("change",e),F.removeEventListener("mouseDown",t),F.removeEventListener("mouseUp",r),F.removeEventListener("objectChange",n)}}),[M,F]),T.useEffect((()=>{if(c){const e=S().controls;return C({controls:F}),()=>C({controls:e})}}),[c,F]),F?T.createElement(T.Fragment,null,T.createElement("primitive",e({ref:d,object:F},v)),T.createElement("group",e({ref:k},g),t)):null})),Je=T.forwardRef((({domElement:t,selector:r,onChange:n,onLock:a,onUnlock:i,enabled:s=!0,makeDefault:l,...c},u)=>{const{camera:d,...f}=c,p=o.useThree((e=>e.setEvents)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.camera)),y=o.useThree((e=>e.invalidate)),v=o.useThree((e=>e.events)),g=o.useThree((e=>e.get)),z=o.useThree((e=>e.set)),w=d||x,b=t||v.connected||h.domElement,[E]=T.useState((()=>new m.PointerLockControls(w)));return T.useEffect((()=>{if(s){E.connect(b);const e=g().events.compute;return p({compute(e,t){const r=t.size.width/2,n=t.size.height/2;t.pointer.set(r/t.size.width*2-1,-n/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),()=>{E.disconnect(),p({compute:e})}}}),[s,E]),T.useEffect((()=>{const e=e=>{y(),n&&n(e)};E.addEventListener("change",e),a&&E.addEventListener("lock",a),i&&E.addEventListener("unlock",i);const t=()=>E.lock(),o=r?Array.from(document.querySelectorAll(r)):[document];return o.forEach((e=>e&&e.addEventListener("click",t))),()=>{E.removeEventListener("change",e),a&&E.addEventListener("lock",a),i&&E.addEventListener("unlock",i),o.forEach((e=>e?e.removeEventListener("click",t):void 0))}}),[n,a,i,r,E,y]),T.useEffect((()=>{if(l){const e=g().controls;return z({controls:E}),()=>z({controls:e})}}),[l,E]),T.createElement("primitive",e({ref:u,object:E},f))})),et=T.forwardRef((({domElement:t,makeDefault:r,...n},a)=>{const i=o.useThree((e=>e.camera)),s=o.useThree((e=>e.gl)),l=o.useThree((e=>e.events)),c=o.useThree((e=>e.get)),u=o.useThree((e=>e.set)),d=t||l.connected||s.domElement,[f]=T.useState((()=>new m.FirstPersonControls(i,d)));return T.useEffect((()=>{if(r){const e=c().controls;return u({controls:f}),()=>u({controls:e})}}),[r,f]),o.useFrame(((e,t)=>{f.update(t)}),-1),f?T.createElement("primitive",e({ref:a,object:f},n)):null})),tt=t.forwardRef(((r,a)=>{t.useMemo((()=>{const e={Box3:n.Box3,MathUtils:{clamp:n.MathUtils.clamp},Matrix4:n.Matrix4,Quaternion:n.Quaternion,Raycaster:n.Raycaster,Sphere:n.Sphere,Spherical:n.Spherical,Vector2:n.Vector2,Vector3:n.Vector3,Vector4:n.Vector4};v.install({THREE:e}),o.extend({CameraControlsImpl:v})}),[]);const{camera:i,domElement:s,makeDefault:l,onStart:c,onEnd:u,onChange:m,regress:d,...f}=r,p=o.useThree((e=>e.camera)),h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.invalidate)),y=o.useThree((e=>e.events)),g=o.useThree((e=>e.setEvents)),z=o.useThree((e=>e.set)),w=o.useThree((e=>e.get)),b=o.useThree((e=>e.performance)),E=i||p,M=s||y.connected||h.domElement,S=t.useMemo((()=>new v(E)),[E]);return o.useFrame(((e,t)=>{S.enabled&&S.update(t)}),-1),t.useEffect((()=>(S.connect(M),()=>{S.disconnect()})),[M,S]),t.useEffect((()=>{const e=e=>{x(),d&&b.regress(),m&&m(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return S.addEventListener("update",e),S.addEventListener("controlstart",t),S.addEventListener("controlend",r),S.addEventListener("control",e),S.addEventListener("transitionstart",e),S.addEventListener("wake",e),()=>{S.removeEventListener("update",e),S.removeEventListener("controlstart",t),S.removeEventListener("controlend",r),S.removeEventListener("control",e),S.removeEventListener("transitionstart",e),S.removeEventListener("wake",e)}}),[S,c,u,x,g,d,m]),t.useEffect((()=>{if(l){const e=w().controls;return z({controls:S}),()=>z({controls:e})}}),[l,S]),T.createElement("primitive",e({ref:a,object:S},f))}));function rt(e,r){const{unsuspend:n,start:a,crossOrigin:i,muted:s,loop:l,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...r},u=o.useThree((e=>e.gl)),m=p.suspend((()=>new Promise(((t,r)=>{const o=Object.assign(document.createElement("video"),{src:"string"==typeof e&&e||void 0,srcObject:e instanceof MediaStream&&e||void 0,crossOrigin:i,loop:l,muted:s,...c}),a=new P.VideoTexture(o);"colorSpace"in a?a.colorSpace=u.outputColorSpace:a.encoding=u.outputEncoding,o.addEventListener(n,(()=>t(a)))}))),[e]);return t.useEffect((()=>{a&&m.image.play()}),[m,a]),m}const nt=new P.Vector3(0,0,-1),ot=function(){const e=new P.Vector3,t=new P.Vector3,r=new P.Vector3,n=new P.Vector3,o=new P.Vector3;return function(a,i,s,l){return e.copy(a),t.copy(i),r.copy(s),n.copy(t).sub(e),o.copy(r).sub(e),l.crossVectors(o,n).normalize()}}();const at=T.forwardRef((({points:e=lt.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0],face:t,facialTransformationMatrix:r,faceBlendshapes:n,offset:a,offsetScalar:i=80,width:s,height:l,depth:c=1,verticalTri:u=[159,386,152],origin:m,eyes:d=!0,eyesAsOrigin:f=!1,debug:p=!1,children:h,...x},y)=>{var v;t&&(e=t.keypoints,console.warn("Facemesh `face` prop is deprecated: use `points` instead"));const g=T.useRef(null),z=T.useRef(null),w=T.useRef(null),b=T.useRef(null),E=T.useRef(null),M=T.useRef(null),S=T.useRef(null),[C]=T.useState((()=>new P.Vector3)),[R]=T.useState((()=>new P.Object3D)),[D]=T.useState((()=>new P.Quaternion)),[F]=T.useState((()=>new P.Vector3)),{invalidate:k}=o.useThree();T.useEffect((()=>{var e;null==(e=E.current)||e.geometry.setIndex(lt.TRIANGULATION)}),[]);const[_]=T.useState((()=>new P.Vector3));T.useEffect((()=>{var t,o;const h=null==(t=E.current)?void 0:t.geometry;if(!h)return;var x,y;(h.setFromPoints(e),h.setDrawRange(0,lt.TRIANGULATION.length),r)?(R.matrix.fromArray(r.data),R.matrix.decompose(R.position,R.quaternion,R.scale),R.rotation.y*=-1,R.rotation.z*=-1,D.setFromEuler(R.rotation),a?(R.position.y*=-1,R.position.z*=-1,null==(x=g.current)||x.position.copy(R.position.divideScalar(i))):null==(y=g.current)||y.position.set(0,0,0)):(ot(e[u[0]],e[u[1]],e[u[2]],C),D.setFromUnitVectors(nt,C));const v=D.clone().invert();if(h.computeBoundingBox(),p&&k(),h.center(),h.applyQuaternion(v),null==(o=b.current)||o.setRotationFromQuaternion(D),d)if(n){if(M.current&&S.current&&w.current)if(f){const e=M.current._computeSphere(h),t=S.current._computeSphere(h),r=function(e,t){return e.clone().add(t).multiplyScalar(.5)}(e.center,t.center);m=r.negate(),M.current._update(h,n,e),S.current._update(h,n,t)}else M.current._update(h,n),S.current._update(h,n)}else console.warn("Facemesh `eyes` option only works if `faceBlendshapes` is provided: skipping.");if(w.current){if(void 0!==m)if("number"==typeof m){const e=h.getAttribute("position");F.set(-e.getX(m),-e.getY(m),-e.getZ(m))}else m.isVector3&&F.copy(m);else F.setScalar(0);w.current.position.copy(F)}if(z.current){let e=1;(s||l||c)&&(h.boundingBox.getSize(_),s&&(e=s/_.x),l&&(e=l/_.y),c&&(e=c/_.z)),z.current.scale.setScalar(1!==e?e:1)}h.computeVertexNormals(),h.attributes.position.needsUpdate=!0}),[e,r,n,R,a,i,s,l,c,u,m,d,p,k,C,D,_,F]);const L=T.useMemo((()=>({outerRef:b,meshRef:E,eyeRightRef:M,eyeLeftRef:S})),[]);T.useImperativeHandle(y,(()=>L),[L]);const[A]=T.useState((()=>new P.Vector3)),B=null==(v=E.current)?void 0:v.geometry.boundingBox,U=(null==B?void 0:B.getSize(A).z)||1;return T.createElement("group",x,T.createElement("group",{ref:g},T.createElement("group",{ref:b},T.createElement("group",{ref:z},p?T.createElement(T.Fragment,null,T.createElement("axesHelper",{args:[U]}),T.createElement(re,{points:[[0,0,0],[0,0,-U]],color:65535})):null,T.createElement("group",{ref:w},d&&n&&T.createElement("group",{name:"eyes"},T.createElement(st,{side:"left",ref:M,debug:p}),T.createElement(st,{side:"right",ref:S,debug:p})),T.createElement("mesh",{ref:E,name:"face"},h,p?T.createElement(T.Fragment,null,B&&T.createElement("box3Helper",{args:[B]})):null))))))})),it={contourLandmarks:{right:[33,133,159,145,153],left:[263,362,386,374,380]},blendshapes:{right:[14,16,18,12],left:[13,15,17,11]},color:{right:"red",left:"#00ff00"},fov:{horizontal:100,vertical:90}},st=T.forwardRef((({side:e,debug:t=!0},r)=>{const n=T.useRef(null),o=T.useRef(null),[a]=T.useState((()=>new P.Sphere)),i=T.useCallback((t=>{const r=t.getAttribute("position"),n=it.contourLandmarks[e].map((e=>new P.Vector3(r.getX(e),r.getY(e),r.getZ(e))));return a.center.set(0,0,0),n.forEach((e=>a.center.add(e))),a.center.divideScalar(n.length),a.radius=n[0].sub(n[1]).length()/2,a}),[a,e]),[s]=T.useState((()=>new P.Euler)),l=T.useCallback(((t,r,a)=>{var l;n.current&&(null!==(l=a)&&void 0!==l||(a=i(t)),n.current.position.copy(a.center),n.current.scale.setScalar(a.radius));if(r&&o.current){const t=it.blendshapes[e],n=r.categories[t[0]].score,a=r.categories[t[1]].score,i=r.categories[t[2]].score,l=r.categories[t[3]].score,c=.5*(it.fov.horizontal*P.MathUtils.DEG2RAD)*(l-i),u=.5*(it.fov.vertical*P.MathUtils.DEG2RAD)*(n-a)*("left"===e?1:-1);s.set(c,u,0),o.current.setRotationFromEuler(s)}}),[i,e,s]),c=T.useMemo((()=>({eyeMeshRef:n,irisDirRef:o,_computeSphere:i,_update:l})),[i,l]);T.useImperativeHandle(r,(()=>c),[c]);const u=it.color[e];return T.createElement("group",null,T.createElement("group",{ref:n},t&&T.createElement("axesHelper",null),T.createElement("group",{ref:o},T.createElement(T.Fragment,null,t&&T.createElement(re,{points:[[0,0,0],[0,0,-2]],lineWidth:1,color:u})))))})),lt={TRIANGULATION:[127,34,139,11,0,37,232,231,120,72,37,39,128,121,47,232,121,128,104,69,67,175,171,148,157,154,155,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,173,155,133,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,246,33,7,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,163,161,246,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,153,158,159,170,169,150,188,174,196,216,186,92,144,160,161,2,97,167,141,125,241,164,167,37,72,38,12,145,159,160,38,82,13,63,68,71,226,35,111,158,153,154,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,384,398,382,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,382,398,362,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,263,466,249,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,390,249,466,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,380,374,386,395,378,379,412,351,419,436,426,322,373,390,388,2,164,393,370,462,461,164,0,267,302,11,12,374,373,387,268,12,13,293,300,301,446,261,340,385,384,381,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,173,157,155,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,7,163,246,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,145,153,159,149,170,150,122,188,196,206,216,92,163,144,161,164,2,167,242,141,241,0,164,37,11,72,12,144,145,160,12,38,13,70,63,71,31,226,111,157,158,154,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,381,384,382,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,388,390,466,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,385,380,386,394,395,379,399,412,419,410,436,322,387,373,388,326,2,393,354,370,461,393,164,267,268,302,12,386,374,387,312,268,13,298,293,301,265,446,340,380,385,381,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],SAMPLE_FACE:{keypoints:[{x:356.2804412841797,y:295.1960563659668,z:-23.786449432373047,name:"lips"},{x:354.8859405517578,y:264.69520568847656,z:-36.718435287475586},{x:355.2180862426758,y:275.3360366821289,z:-21.183712482452393},{x:347.349853515625,y:242.4400234222412,z:-25.093655586242676},{x:354.40135955810547,y:256.67933464050293,z:-38.23572635650635},{x:353.7689971923828,y:247.54886627197266,z:-34.5475435256958},{x:352.1288299560547,y:227.34312057495117,z:-13.095386028289795},{x:303.5013198852539,y:234.67002868652344,z:12.500141859054565,name:"rightEye"},{x:351.09378814697266,y:211.87547206878662,z:-6.413471698760986},{x:350.7115936279297,y:202.1251630783081,z:-6.413471698760986},{x:348.33667755126953,y:168.7741756439209,z:6.483500003814697,name:"faceOval"},{x:356.4806365966797,y:299.2995357513428,z:-23.144519329071045},{x:356.5511703491211,y:302.66146659851074,z:-21.020312309265137},{x:356.6239547729492,y:304.1536331176758,z:-18.137459754943848,name:"lips"},{x:356.5807342529297,y:305.1840591430664,z:-18.767719268798828,name:"lips"},{x:356.8241500854492,y:308.25711250305176,z:-20.16829490661621},{x:357.113037109375,y:312.26277351379395,z:-22.10575819015503},{x:357.34962463378906,y:317.1123218536377,z:-21.837315559387207,name:"lips"},{x:357.6658630371094,y:325.51036834716797,z:-16.27002477645874},{x:355.0201416015625,y:269.36279296875,z:-33.73054027557373},{x:348.5237503051758,y:270.33411026000977,z:-24.93025302886963},{x:279.97331619262695,y:213.24176788330078,z:47.759642601013184,name:"faceOval"},{x:322.66529083251953,y:238.5027265548706,z:5.535193085670471},{x:316.0983657836914,y:239.94489669799805,z:5.777376294136047},{x:309.9431610107422,y:240.24518966674805,z:7.510589361190796},{x:301.31994247436523,y:237.86138534545898,z:13.118728399276733},{x:328.14266204833984,y:235.80496788024902,z:6.646900177001953},{x:313.7326431274414,y:222.11161136627197,z:3.9887237548828125},{x:320.45196533203125,y:221.87729358673096,z:4.601476192474365},{x:307.35679626464844,y:223.63793849945068,z:5.932023525238037},{x:303.0031204223633,y:226.3743782043457,z:8.479321002960205},{x:296.80023193359375,y:242.94299125671387,z:15.931552648544312},{x:332.2352981567383,y:340.77341079711914,z:-10.165848731994629},{x:301.38587951660156,y:233.46447944641113,z:14.764405488967896,name:"rightEye"},{x:279.0147018432617,y:244.37155723571777,z:45.77549457550049},{x:289.60548400878906,y:239.1807460784912,z:23.191204071044922},{x:320.32257080078125,y:267.1292781829834,z:-4.954537749290466},{x:347.64583587646484,y:294.4955062866211,z:-23.062820434570312,name:"lips"},{x:349.28138732910156,y:303.1095886230469,z:-20.238323211669922},{x:338.9453125,y:298.19186210632324,z:-19.456336498260498,name:"lips"},{x:333.36788177490234,y:302.6706790924072,z:-14.776077270507812,name:"lips"},{x:342.89188385009766,y:304.3561363220215,z:-17.752301692962646},{x:337.7375030517578,y:306.0098361968994,z:-13.410515785217285},{x:325.6159210205078,y:316.22995376586914,z:-6.681914925575256},{x:349.0104675292969,y:264.9818515777588,z:-36.274919509887695},{x:347.7138900756836,y:257.5664806365967,z:-37.67549514770508},{x:291.79357528686523,y:218.88171672821045,z:11.578094959259033,name:"rightEyebrow"},{x:332.2689437866211,y:247.56946563720703,z:-3.3730539679527283},{x:332.0074462890625,y:267.1201229095459,z:-19.969879388809204},{x:331.27952575683594,y:263.6967658996582,z:-17.47218608856201},{x:301.04373931884766,y:269.56552505493164,z:3.61815482378006},{x:347.4863815307617,y:249.0706443786621,z:-32.633421421051025},{x:307.26118087768555,y:208.2646894454956,z:1.1591226607561111,name:"rightEyebrow"},{x:297.91919708251953,y:212.22604751586914,z:5.914516448974609,name:"rightEyebrow"},{x:285.1651382446289,y:197.98450469970703,z:36.391637325286865,name:"faceOval"},{x:337.04097747802734,y:211.25229835510254,z:-4.548954665660858},{x:326.5912628173828,y:223.16698551177979,z:6.670243740081787},{x:320.05664825439453,y:309.5834255218506,z:-4.055835008621216},{x:289.6866226196289,y:314.617395401001,z:53.875489234924316,name:"faceOval"},{x:337.4256896972656,y:270.8755302429199,z:-17.67060160636902},{x:343.69922637939453,y:273.0000400543213,z:-18.756048679351807},{x:327.4242401123047,y:309.22399520874023,z:-4.703601002693176,name:"lips"},{x:330.37220001220703,y:308.3323001861572,z:-6.442649960517883},{x:293.87027740478516,y:207.7961826324463,z:9.821539521217346,name:"rightEyebrow"},{x:332.11437225341797,y:271.22812271118164,z:-16.64351224899292},{x:320.1197814941406,y:207.40366458892822,z:-2.48164564371109,name:"rightEyebrow"},{x:318.59575271606445,y:201.07443809509277,z:-3.110446035861969,name:"rightEyebrow"},{x:310.72303771972656,y:175.75075149536133,z:13.328815698623657,name:"faceOval"},{x:289.67578887939453,y:202.29835510253906,z:21.370456218719482},{x:315.30879974365234,y:187.35260009765625,z:5.0304025411605835},{x:287.8936767578125,y:216.54793739318848,z:17.81065821647644,name:"rightEyebrow"},{x:283.9391899108887,y:215.01142501831055,z:32.04984903335571},{x:348.35330963134766,y:299.4155788421631,z:-22.47924566268921},{x:341.1790466308594,y:301.8221855163574,z:-18.977805376052856},{x:335.69713592529297,y:304.4266891479492,z:-14.682706594467163},{x:339.4615173339844,y:272.3654365539551,z:-16.38674020767212},{x:328.99600982666016,y:308.86685371398926,z:-5.616893768310547},{x:332.00313568115234,y:309.1875743865967,z:-10.335084199905396},{x:331.0068130493164,y:307.9274368286133,z:-6.681914925575256,name:"lips"},{x:341.13792419433594,y:266.4876937866211,z:-26.56425952911377},{x:339.02950286865234,y:305.6663703918457,z:-12.33674168586731,name:"lips"},{x:344.22935485839844,y:304.9452781677246,z:-15.161235332489014,name:"lips"},{x:350.1844024658203,y:304.374303817749,z:-17.5305438041687,name:"lips"},{x:348.52630615234375,y:325.9562301635742,z:-16.164982318878174},{x:348.6581802368164,y:317.1624183654785,z:-21.510512828826904,name:"lips"},{x:348.9766311645508,y:312.1923065185547,z:-21.708929538726807},{x:349.2427444458008,y:308.0660820007324,z:-19.643079042434692},{x:349.67491149902344,y:305.42747497558594,z:-18.16080331802368,name:"lips"},{x:337.95589447021484,y:306.6535949707031,z:-12.803598642349243,name:"lips"},{x:337.06878662109375,y:307.63169288635254,z:-14.274203777313232},{x:335.77449798583984,y:309.8449516296387,z:-15.698124170303345},{x:334.6099090576172,y:312.7997016906738,z:-14.764405488967896,name:"lips"},{x:327.2330856323242,y:293.80866050720215,z:-11.864047050476074},{x:280.97679138183594,y:279.79928970336914,z:68.90834331512451,name:"faceOval"},{x:355.13843536376953,y:271.7875671386719,z:-25.350427627563477},{x:334.7235870361328,y:307.4656391143799,z:-9.302158951759338,name:"lips"},{x:333.5293960571289,y:307.89782524108887,z:-10.200862884521484},{x:346.29688262939453,y:276.4256286621094,z:-19.748122692108154},{x:335.16246795654297,y:276.22097969055176,z:-12.313398122787476},{x:345.09132385253906,y:274.7082996368408,z:-19.304605722427368},{x:325.4267883300781,y:252.95130729675293,z:-1.6661019623279572},{x:315.347843170166,y:259.05200958251953,z:-.25604281574487686},{x:330.44933319091797,y:267.7570152282715,z:-14.017432928085327},{x:294.96768951416016,y:185.26001930236816,z:23.903164863586426,name:"faceOval"},{x:299.63531494140625,y:192.7913761138916,z:12.640198469161987},{x:304.5452117919922,y:202.4142837524414,z:3.244667649269104,name:"rightEyebrow"},{x:331.6915512084961,y:320.0467872619629,z:-10.632705688476562},{x:334.5911407470703,y:201.27566814422607,z:-6.133356094360352,name:"rightEyebrow"},{x:331.4815902709961,y:185.44180870056152,z:.6627205014228821},{x:328.05816650390625,y:170.8385467529297,z:7.358860373497009,name:"faceOval"},{x:304.49764251708984,y:239.76297855377197,z:10.387605428695679},{x:290.6382179260254,y:248.85257720947266,z:19.03616428375244},{x:331.5682601928711,y:233.20727348327637,z:7.837390303611755},{x:295.5115509033203,y:228.9834451675415,z:14.41426157951355},{x:336.94332122802734,y:241.8259334564209,z:-5.27842104434967},{x:336.2792205810547,y:262.7049922943115,z:-26.12074375152588},{x:284.4102478027344,y:255.3262710571289,z:25.467140674591064},{x:295.1420593261719,y:253.02655220031738,z:12.430112361907959},{x:303.5196113586426,y:254.20703887939453,z:6.139191389083862},{x:315.73450088500977,y:251.64799690246582,z:3.3788898587226868},{x:324.69661712646484,y:247.56494522094727,z:2.3328344523906708},{x:331.57970428466797,y:243.02241325378418,z:1.1423448473215103},{x:345.6210708618164,y:229.9976634979248,z:-10.825285911560059},{x:286.26644134521484,y:270.37991523742676,z:21.708929538726807},{x:290.2525520324707,y:228.4921360015869,z:17.71728754043579},{x:351.65367126464844,y:269.3400764465332,z:-33.450424671173096},{x:333.1378936767578,y:253.88388633728027,z:-7.230473756790161},{x:277.8318977355957,y:246.95331573486328,z:68.20805549621582,name:"faceOval"},{x:336.6680908203125,y:238.10003757476807,z:.7688578963279724},{x:329.95800018310547,y:269.18323516845703,z:-7.207130789756775},{x:299.17491912841797,y:234.13324356079102,z:15.95489501953125},{x:335.61729431152344,y:258.71752738952637,z:-23.016133308410645},{x:284.1079330444336,y:297.0343494415283,z:63.25934886932373,name:"faceOval"},{x:331.44542694091797,y:230.6892442703247,z:9.92658257484436,name:"rightEye"},{x:341.41536712646484,y:253.01264762878418,z:-29.038610458374023},{x:303.5472869873047,y:327.5896739959717,z:16.725212335586548},{x:304.7756576538086,y:337.4389457702637,z:27.38126277923584,name:"faceOval"},{x:280.80501556396484,y:275.32050132751465,z:45.0752067565918},{x:295.43582916259766,y:318.4501647949219,z:26.2608003616333},{x:281.4303207397461,y:228.7355661392212,z:40.94350814819336},{x:331.2549591064453,y:349.4216537475586,z:-7.376367449760437},{x:352.4247741699219,y:271.7330074310303,z:-24.953596591949463},{x:327.5672912597656,y:260.41900634765625,z:-5.456410646438599},{x:284.5432472229004,y:241.7647933959961,z:29.668869972229004},{x:310,y:235.66174507141113,z:8.502663969993591,name:"rightEye"},{x:315.7071113586426,y:235.7572603225708,z:6.938687562942505,name:"rightEye"},{x:330.41088104248047,y:311.04143142700195,z:-9.325502514839172,name:"lips"},{x:288.5377502441406,y:285.31983375549316,z:21.837315559387207},{x:344.55039978027344,y:359.4300842285156,z:-6.705257892608643,name:"faceOval"},{x:323.41880798339844,y:351.67362213134766,z:7.802375555038452,name:"faceOval"},{x:314.64088439941406,y:346.11894607543945,z:16.36339783668518,name:"faceOval"},{x:349.4945526123047,y:184.8434829711914,z:-.21847527474164963},{x:359.24694061279297,y:359.8348903656006,z:-8.403456211090088,name:"faceOval"},{x:321.26182556152344,y:234.64492321014404,z:6.90950870513916,name:"rightEye"},{x:326.318359375,y:232.90250301361084,z:8.029969334602356,name:"rightEye"},{x:329.6211624145508,y:231.6195774078369,z:9.722331762313843,name:"rightEye"},{x:285.9398078918457,y:228.2351303100586,z:24.650139808654785},{x:325.79288482666016,y:227.88007736206055,z:7.469738721847534,name:"rightEye"},{x:320.1699447631836,y:227.5934886932373,z:6.168370842933655,name:"rightEye"},{x:314.85408782958984,y:227.85282611846924,z:6.2675780057907104,name:"rightEye"},{x:309.3084907531738,y:229.1516876220703,z:7.7031683921813965,name:"rightEye"},{x:305.5621337890625,y:230.92366218566895,z:9.722331762313843,name:"rightEye"},{x:277.8681945800781,y:228.5354232788086,z:59.71122741699219,name:"faceOval"},{x:306.1444664001465,y:235.1954698562622,z:10.603528022766113,name:"rightEye"},{x:355.4478454589844,y:281.96210861206055,z:-20.565123558044434},{x:333.02661895751953,y:288.0105400085449,z:-14.72939133644104},{x:337.15728759765625,y:269.2059516906738,z:-19.8414945602417},{x:345.9898376464844,y:283.5453128814697,z:-20.4834246635437},{x:351.48963928222656,y:219.98916149139404,z:-7.0378947257995605},{x:312.39574432373047,y:336.50628089904785,z:8.671900033950806},{x:321.32152557373047,y:343.1755256652832,z:.9067271649837494},{x:343.78379821777344,y:353.2975959777832,z:-14.355905055999756},{x:296.8791389465332,y:327.91497230529785,z:41.01353645324707,name:"faceOval"},{x:329.6939468383789,y:229.27897453308105,z:8.934508562088013,name:"rightEye"},{x:341.6905212402344,y:241.4073657989502,z:-14.589333534240723},{x:359.03079986572266,y:353.48859786987305,z:-15.803166627883911},{x:333.1861877441406,y:356.43213272094727,z:-1.0234417766332626,name:"faceOval"},{x:283.97483825683594,y:291.4318656921387,z:41.94725513458252},{x:343.33770751953125,y:305.830135345459,z:-15.756480693817139,name:"lips"},{x:342.40283966064453,y:307.7453899383545,z:-17.4021577835083},{x:341.53621673583984,y:311.0595703125,z:-19.047834873199463},{x:340.9107208251953,y:315.4837703704834,z:-18.5576331615448,name:"lips"},{x:339.1478729248047,y:323.42233657836914,z:-14.367576837539673},{x:333.3201599121094,y:307.4406337738037,z:-9.617288708686829},{x:331.2411117553711,y:306.9811820983887,z:-9.669809937477112},{x:329.23255920410156,y:306.0508346557617,z:-9.582273960113525,name:"lips"},{x:322.4586486816406,y:301.33323669433594,z:-7.720675468444824},{x:297.1712112426758,y:286.9552803039551,z:8.240055441856384},{x:341.3060760498047,y:235.4432201385498,z:-7.504753470420837},{x:336.9318389892578,y:224.3451976776123,z:5.829898118972778},{x:332.65323638916016,y:226.70403957366943,z:8.105834126472473},{x:334.67357635498047,y:306.4397621154785,z:-8.981193900108337,name:"lips"},{x:297.4601936340332,y:306.29210472106934,z:15.476365089416504},{x:342.9119110107422,y:222.37077713012695,z:-2.754466235637665},{x:335.4629898071289,y:332.20250129699707,z:-11.823196411132812},{x:353.2412338256836,y:240.56339263916016,z:-27.147831916809082},{x:346.3080596923828,y:236.41446590423584,z:-18.452589511871338},{x:352.6475143432617,y:234.1420555114746,z:-19.748122692108154},{x:337.3209762573242,y:253.39937210083008,z:-16.024924516677856},{x:358.6122131347656,y:344.90861892700195,z:-18.592647314071655},{x:358.1117248535156,y:334.64990615844727,z:-17.49552845954895},{x:346.4450454711914,y:335.0321102142334,z:-16.32838249206543},{x:319.17640686035156,y:320.2833938598633,z:-3.276764452457428},{x:325.2540588378906,y:276.2369728088379,z:-6.460157036781311},{x:326.7214584350586,y:327.3939514160156,z:-7.417217493057251},{x:310.7190132141113,y:277.2265148162842,z:-3.5452082753181458},{x:319.78355407714844,y:284.8238182067871,z:-6.4543211460113525},{x:305.773983001709,y:290.83580017089844,z:.06907138042151928},{x:344.4001770019531,y:344.85408782958984,z:-16.946970224380493},{x:333.1879425048828,y:258.74256134033203,z:-11.90489649772644},{x:313.80598068237305,y:327.08919525146484,z:2.2277912497520447},{x:322.9637908935547,y:334.6819496154785,z:-3.3643004298210144},{x:313.4055519104004,y:311.2166690826416,z:-1.1175429821014404},{x:291.0865783691406,y:298.2831001281738,z:22.467575073242188},{x:305.6580924987793,y:313.3707904815674,z:5.561453700065613},{x:288.23760986328125,y:305.9941864013672,z:36.765122413635254},{x:315.10692596435547,y:296.26991271972656,z:-4.604393839836121},{x:337.50518798828125,y:247.5944423675537,z:-10.597691535949707},{x:338.8450622558594,y:265.47778129577637,z:-27.778091430664062},{x:334.25254821777344,y:269.0671920776367,z:-20.938611030578613},{x:341.64512634277344,y:259.6387195587158,z:-32.189905643463135},{x:331.44081115722656,y:219.0976095199585,z:4.207563698291779},{x:320.56339263916016,y:216.49658203125,z:2.930997312068939},{x:311.21912002563477,y:216.57853603363037,z:2.9674705862998962},{x:303.46256256103516,y:218.54614734649658,z:5.357203483581543},{x:297.99999237060547,y:222.505202293396,z:9.325502514839172},{x:294.93839263916016,y:236.39654159545898,z:18.534289598464966},{x:278.87489318847656,y:259.7095584869385,z:45.68212032318115},{x:300.3782653808594,y:245.38593292236328,z:12.278382778167725},{x:307.06348419189453,y:246.36857986450195,z:8.164191246032715},{x:315.5229187011719,y:245.3949737548828,z:5.503097176551819},{x:323.71395111083984,y:242.75178909301758,z:4.6335723996162415},{x:330.2785873413086,y:239.34658527374268,z:4.937030673027039},{x:334.6982192993164,y:236.0460376739502,z:4.823233783245087},{x:279.3412208557129,y:263.5196113586426,z:70.91583728790283,name:"faceOval"},{x:334.65972900390625,y:271.6648578643799,z:-17.775644063949585},{x:342.05677032470703,y:246.99846267700195,z:-20.84523916244507},{x:344.0357971191406,y:264.5701503753662,z:-32.936880588531494},{x:348.25531005859375,y:268.6645030975342,z:-30.695960521697998},{x:344.12227630615234,y:266.34212493896484,z:-29.808926582336426},{x:337.12318420410156,y:274.2556858062744,z:-15.768152475357056},{x:349.49047088623047,y:269.071683883667,z:-32.51670837402344},{x:350.1683044433594,y:271.4691352844238,z:-24.93025302886963},{x:333.9634704589844,y:230.56639194488525,z:8.89949381351471},{x:338.2147979736328,y:231.4807891845703,z:4.6715047955513},{x:340.4712677001953,y:231.74463272094727,z:-.34996166825294495},{x:303.28975677490234,y:232.24980354309082,z:11.916568279266357,name:"rightEye"},{x:299.4649124145508,y:229.53842639923096,z:12.325069904327393},{x:359.09618377685547,y:241.77349090576172,z:-24.650139808654785},{x:399.46216583251953,y:229.89503860473633,z:15.919880867004395,name:"leftEye"},{x:361.38919830322266,y:269.6129894256592,z:-24.510080814361572},{x:416.9973373413086,y:206.0895538330078,z:53.26857566833496,name:"faceOval"},{x:381.32179260253906,y:235.5476474761963,z:7.6214683055877686},{x:387.8068542480469,y:236.25958442687988,z:8.345099091529846},{x:393.95751953125,y:235.8660364151001,z:10.475142002105713},{x:401.84600830078125,y:232.77019500732422,z:16.760226488113403},{x:375.70568084716797,y:233.48456382751465,z:8.234220147132874},{x:388.17752838134766,y:218.94717693328857,z:6.810300946235657},{x:381.64928436279297,y:219.2656660079956,z:6.711093783378601},{x:394.4760513305664,y:219.66821193695068,z:9.173773527145386},{x:398.8843536376953,y:221.8837022781372,z:12.03328251838684},{x:406.5454864501953,y:237.12156772613525,z:19.7131085395813},{x:383.87447357177734,y:337.6932907104492,z:-8.631049990653992},{x:401.2682342529297,y:228.5916566848755,z:18.359217643737793,name:"leftEye"},{x:422.0449447631836,y:236.73934936523438,z:51.16771221160889},{x:412.69153594970703,y:232.80198097229004,z:27.52131938934326},{x:387.3497772216797,y:263.298397064209,z:-2.8609684109687805},{x:364.5124053955078,y:293.39221000671387,z:-22.397546768188477,name:"lips"},{x:363.62987518310547,y:302.1291446685791,z:-19.643079042434692},{x:373.2334518432617,y:295.8647060394287,z:-18.125789165496826,name:"lips"},{x:378.83365631103516,y:299.5177745819092,z:-13.153743743896484,name:"lips"},{x:369.91477966308594,y:302.5704002380371,z:-16.65518283843994},{x:374.9167251586914,y:303.5416603088379,z:-11.963253021240234},{x:387.58888244628906,y:312.2716999053955,z:-4.680258631706238},{x:360.6635284423828,y:264.31986808776855,z:-35.94811677932739},{x:361.04564666748047,y:256.8225860595703,z:-37.278664112091064},{x:408.3855438232422,y:213.52088928222656,z:15.756480693817139,name:"leftEyebrow"},{x:373.2946014404297,y:245.38101196289062,z:-1.9316278398036957},{x:376.83860778808594,y:264.3721103668213,z:-18.510947227478027},{x:376.9546127319336,y:261.0010528564453,z:-15.989909172058105},{x:406.1498260498047,y:263.5030174255371,z:7.072908878326416},{x:360.07205963134766,y:248.3631706237793,z:-32.16656446456909},{x:393.11119079589844,y:205.10473251342773,z:3.7786373496055603,name:"leftEyebrow"},{x:402.12791442871094,y:207.89000988006592,z:9.383859634399414,name:"leftEyebrow"},{x:410.8693313598633,y:191.6182279586792,z:41.27030849456787,name:"faceOval"},{x:364.9509811401367,y:210.40483474731445,z:-3.758212625980377},{x:375.94444274902344,y:221.1331844329834,z:8.368442058563232},{x:392.1904754638672,y:305.0360298156738,z:-1.752179116010666},{x:419.50225830078125,y:307.25592613220215,z:58.96425247192383,name:"faceOval"},{x:372.0027160644531,y:268.7212657928467,z:-16.631840467453003},{x:366.1614227294922,y:271.6237449645996,z:-18.219159841537476},{x:385.00938415527344,y:305.3863334655762,z:-2.567722797393799},{x:381.99771881103516,y:304.9723720550537,z:-4.575215280056},{x:405.078125,y:203.21216583251953,z:13.713973760604858,name:"leftEyebrow"},{x:377.13207244873047,y:268.4710121154785,z:-15.266278982162476},{x:380.9713363647461,y:205.36980628967285,z:-.7250899076461792,name:"leftEyebrow"},{x:381.7788314819336,y:198.9268398284912,z:-1.184653863310814,name:"leftEyebrow"},{x:385.5204772949219,y:172.1484375,z:16.04826807975769,name:"faceOval"},{x:407.94189453125,y:196.76236152648926,z:25.723915100097656},{x:383.03890228271484,y:184.5157527923584,z:7.393874526023865},{x:411.61781311035156,y:210.79241752624512,z:22.315845489501953,name:"leftEyebrow"},{x:414.30870056152344,y:208.4643030166626,z:37.021894454956055},{x:364.28722381591797,y:298.35777282714844,z:-21.86065673828125},{x:371.3682556152344,y:299.78848457336426,z:-17.834001779556274},{x:376.88201904296875,y:301.6696071624756,z:-13.153743743896484},{x:370.2193832397461,y:270.49095153808594,z:-15.569736957550049},{x:383.5081100463867,y:305.2726364135742,z:-3.673594295978546},{x:380.73760986328125,y:305.96869468688965,z:-8.660228252410889},{x:381.2334442138672,y:304.63574409484863,z:-4.820316135883331,name:"lips"},{x:368.1698989868164,y:264.8884963989258,z:-25.653886795043945},{x:373.5087203979492,y:303.4233856201172,z:-10.95950722694397,name:"lips"},{x:368.4544372558594,y:303.29601287841797,z:-14.169161319732666,name:"lips"},{x:362.76554107666016,y:303.5735607147217,z:-16.911956071853638,name:"lips"},{x:366.60980224609375,y:324.8870658874512,z:-15.616422891616821},{x:365.7067108154297,y:315.95678329467773,z:-20.903596878051758,name:"lips"},{x:365.0083923339844,y:311.2232208251953,z:-21.066999435424805},{x:364.1508102416992,y:307.0583438873291,z:-18.907777070999146},{x:363.37512969970703,y:304.5721435546875,z:-17.42550015449524,name:"lips"},{x:374.580078125,y:304.3059539794922,z:-11.40302300453186,name:"lips"},{x:375.55362701416016,y:305.0998020172119,z:-12.861957550048828},{x:377.2437286376953,y:307.1674346923828,z:-14.215847253799438},{x:378.68587493896484,y:309.9015712738037,z:-13.223772048950195,name:"lips"},{x:383.8992691040039,y:290.29629707336426,z:-9.97326910495758},{x:423.3871841430664,y:271.91688537597656,z:74.37058925628662,name:"faceOval"},{x:377.68043518066406,y:304.62209701538086,z:-7.603961229324341,name:"lips"},{x:379.00428771972656,y:304.9314594268799,z:-8.57852816581726},{x:364.00279998779297,y:275.2813911437988,z:-19.25792098045349},{x:374.68231201171875,y:273.82555961608887,z:-11.28047227859497},{x:365.0354766845703,y:273.4548568725586,z:-18.791062831878662},{x:380.61901092529297,y:249.8848056793213,z:.15501167625188828},{x:391.14158630371094,y:254.7934627532959,z:2.0906515419483185},{x:378.1761169433594,y:264.9612236022949,z:-12.605184316635132},{x:400.9540557861328,y:179.99592304229736,z:27.82477855682373,name:"faceOval"},{x:398.0038833618164,y:188.50656509399414,z:16.094952821731567},{x:394.8717498779297,y:199.0359592437744,z:6.226727366447449,name:"leftEyebrow"},{x:382.10926055908203,y:316.83926582336426,z:-8.946179747581482},{x:366.51588439941406,y:200.32583713531494,z:-5.24632453918457,name:"leftEyebrow"},{x:367.4893569946289,y:183.87210845947266,z:1.9039081037044525},{x:368.6243438720703,y:168.8127565383911,z:8.736093044281006,name:"faceOval"},{x:398.96175384521484,y:234.9675178527832,z:13.713973760604858},{x:412.9645538330078,y:242.23042488098145,z:23.272905349731445},{x:372.05257415771484,y:231.41919136047363,z:9.226294755935669},{x:406.0722351074219,y:223.58965873718262,z:18.370890617370605},{x:368.27442169189453,y:240.2039337158203,z:-4.166713654994965},{x:372.3575210571289,y:260.66442489624023,z:-24.976940155029297},{x:419.2244338989258,y:247.9079246520996,z:30.299127101898193},{x:409.43885803222656,y:246.60913467407227,z:16.398411989212036},{x:401.69139862060547,y:248.76328468322754,z:9.395531415939331},{x:389.7608184814453,y:247.56915092468262,z:5.841569304466248},{x:380.5461883544922,y:244.55984115600586,z:4.263003468513489},{x:373.25817108154297,y:240.80214500427246,z:2.5356262922286987},{x:358.77086639404297,y:229.35615062713623,z:-10.387605428695679},{x:419.5793914794922,y:262.8478717803955,z:26.5175724029541},{x:410.8808898925781,y:222.51372814178467,z:22.199130058288574},{x:358.45714569091797,y:268.91467094421387,z:-33.17030906677246},{x:373.4129333496094,y:251.6385841369629,z:-5.771540403366089},{x:422.5408172607422,y:239.23919677734375,z:74.04378890991211,name:"faceOval"},{x:367.8171920776367,y:236.58040523529053,z:1.820748895406723},{x:378.51959228515625,y:266.2532329559326,z:-5.74819803237915},{x:403.3472442626953,y:229.05112266540527,z:19.689764976501465},{x:372.34840393066406,y:256.6451168060303,z:-21.872329711914062},{x:422.54566192626953,y:289.1587829589844,z:68.67491245269775,name:"faceOval"},{x:371.9297409057617,y:228.90116214752197,z:11.432201862335205,name:"leftEye"},{x:366.21360778808594,y:251.6158962249756,z:-28.19826364517212},{x:409.1571807861328,y:321.3156223297119,z:20.2266526222229},{x:408.52943420410156,y:331.44238471984863,z:31.09278917312622,name:"faceOval"},{x:424.2788314819336,y:267.1992301940918,z:50.467424392700195},{x:415.60352325439453,y:311.6528606414795,z:30.579242706298828},{x:418.12793731689453,y:221.59927368164062,z:46.26569747924805},{x:385.68286895751953,y:346.0184955596924,z:-5.70151150226593},{x:357.82936096191406,y:271.3758373260498,z:-24.836881160736084},{x:379.588623046875,y:257.5071716308594,z:-3.755294680595398},{x:417.4592590332031,y:234.71948146820068,z:34.5475435256958},{x:393.4684371948242,y:231.58967971801758,z:11.408859491348267,name:"leftEye"},{x:387.8864288330078,y:232.14245796203613,z:9.51808214187622,name:"leftEye"},{x:382.4981689453125,y:307.5654888153076,z:-7.522260546684265,name:"lips"},{x:419.00169372558594,y:277.8332805633545,z:26.424202919006348},{x:373.62953186035156,y:357.6375102996826,z:-5.75986921787262,name:"faceOval"},{x:392.8708267211914,y:347.72446632385254,z:10.154176950454712,name:"faceOval"},{x:400.3953552246094,y:341.0005187988281,z:19.39797878265381,name:"faceOval"},{x:382.25440979003906,y:231.66935920715332,z:8.998700976371765,name:"leftEye"},{x:377.14550018310547,y:230.4228687286377,z:9.804032444953918,name:"leftEye"},{x:373.8358688354492,y:229.64950561523438,z:11.292144060134888,name:"leftEye"},{x:414.5794677734375,y:221.67891025543213,z:29.412097930908203},{x:377.00672149658203,y:225.66201210021973,z:9.360517263412476,name:"leftEye"},{x:382.29530334472656,y:224.8431158065796,z:8.32175612449646,name:"leftEye"},{x:387.5133514404297,y:224.49507236480713,z:8.917000889778137,name:"leftEye"},{x:393.15906524658203,y:225.24795055389404,z:10.737749338150024,name:"leftEye"},{x:397.05554962158203,y:226.55359268188477,z:13.002015352249146,name:"leftEye"},{x:420.5299377441406,y:221.014666557312,z:65.40690422058105,name:"faceOval"},{x:397.06920623779297,y:230.6661558151245,z:13.807345628738403,name:"leftEye"},{x:377.94647216796875,y:285.1647090911865,z:-13.305472135543823},{x:372.1118927001953,y:267.1267318725586,z:-18.83774757385254},{x:364.9968719482422,y:282.24411964416504,z:-19.818150997161865},{x:401.973876953125,y:331.20131492614746,z:11.566424369812012},{x:394.3083190917969,y:338.86693954467773,z:3.142542541027069},{x:373.9820861816406,y:351.4504623413086,z:-13.50388765335083},{x:414.3888854980469,y:321.24735832214355,z:45.51872253417969,name:"faceOval"},{x:373.44234466552734,y:227.33163356781006,z:10.626870393753052,name:"leftEye"},{x:364.0731430053711,y:240.31539916992188,z:-13.807345628738403},{x:384.2658233642578,y:353.3793067932129,z:.7385850697755814,name:"faceOval"},{x:423.20526123046875,y:283.5176181793213,z:47.152724266052246},{x:369.42798614501953,y:304.0898895263672,z:-14.647691249847412,name:"lips"},{x:370.63812255859375,y:305.90051651000977,z:-16.211668252944946},{x:371.91192626953125,y:309.0167713165283,z:-17.84567356109619},{x:373.0583953857422,y:313.3545398712158,z:-17.378815412521362,name:"lips"},{x:375.39905548095703,y:321.09289169311523,z:-13.118728399276733},{x:379.2567825317383,y:304.3582534790039,z:-7.924926280975342},{x:381.18797302246094,y:303.7031364440918,z:-7.843226194381714},{x:383.0918502807617,y:302.4884605407715,z:-7.6506465673446655,name:"lips"},{x:389.09461975097656,y:297.1475315093994,z:-5.5497825145721436},{x:411.6408920288086,y:280.24898529052734,z:12.02161192893982},{x:363.3110809326172,y:234.27620887756348,z:-6.775286793708801},{x:366.0474395751953,y:223.29872131347656,z:6.827808618545532},{x:370.34427642822266,y:225.1457118988037,z:9.558931589126587},{x:377.5371551513672,y:303.60079765319824,z:-7.358860373497009,name:"lips"},{x:412.9557800292969,y:299.53579902648926,z:19.39797878265381},{x:360.0810241699219,y:221.72012329101562,z:-2.153385728597641},{x:379.82784271240234,y:329.47723388671875,z:-10.48097848892212},{x:359.08477783203125,y:235.7911491394043,z:-18.079102039337158},{x:369.6688461303711,y:251.5407943725586,z:-14.962821006774902},{x:369.5555114746094,y:333.5307312011719,z:-15.67478060722351},{x:394.0193176269531,y:315.6973171234131,z:-.9920747578144073},{x:383.78997802734375,y:272.7268695831299,z:-4.689012169837952},{x:387.67765045166016,y:323.6722755432129,z:-5.640236139297485},{x:397.8769302368164,y:272.1331214904785,z:-.9395531564950943},{x:389.87476348876953,y:280.5630111694336,z:-4.29218202829361},{x:403.83888244628906,y:285.1167869567871,z:3.0229100584983826},{x:372.5467300415039,y:343.1070327758789,z:-16.153310537338257},{x:374.1112518310547,y:256.3721466064453,z:-10.574349164962769},{x:399.73785400390625,y:321.77515983581543,z:4.849494695663452},{x:392.03365325927734,y:330.56447982788086,z:-1.3407598435878754},{x:398.59134674072266,y:305.93902587890625,z:1.517290621995926},{x:417.95997619628906,y:290.9716987609863,z:26.89105987548828},{x:406.04541778564453,y:307.35154151916504,z:8.666064143180847},{x:420.75328826904297,y:298.40752601623535,z:41.78385257720947},{x:395.4522705078125,y:291.4153575897217,z:-2.1752697229385376},{x:368.6452102661133,y:245.8882999420166,z:-9.453888535499573},{x:370.34900665283203,y:263.56690406799316,z:-26.75100326538086},{x:374.98477935791016,y:266.6126346588135,z:-19.77146625518799},{x:366.99840545654297,y:258.12140464782715,z:-31.372904777526855},{x:371.00616455078125,y:217.63479709625244,z:5.60522198677063},{x:381.30577087402344,y:214.14087295532227,z:4.983716309070587},{x:390.1496124267578,y:213.38221549987793,z:5.593550801277161},{x:397.7696990966797,y:214.3659782409668,z:8.57852816581726},{x:403.1652069091797,y:217.65509605407715,z:13.013685941696167},{x:407.3551940917969,y:230.72525024414062,z:22.444231510162354},{x:424.0876770019531,y:251.7839241027832,z:51.16771221160889},{x:403.50196838378906,y:239.88757610321045,z:15.803166627883911},{x:397.31719970703125,y:241.49806022644043,z:11.233787536621094},{x:388.99425506591797,y:241.4366912841797,z:7.948269248008728},{x:380.7804489135742,y:239.78078842163086,z:6.600214838981628},{x:374.01336669921875,y:237.11946487426758,z:6.349278092384338},{x:369.39125061035156,y:234.35351371765137,z:5.987462401390076},{x:422.9730987548828,y:255.76455116271973,z:76.61150932312012,name:"faceOval"},{x:374.73915100097656,y:269.24214363098145,z:-16.608498096466064},{x:364.61681365966797,y:245.71088790893555,z:-20.02823829650879},{x:365.3834533691406,y:263.34174156188965,z:-32.32996463775635},{x:361.58252716064453,y:267.8273677825928,z:-30.345816612243652},{x:365.37208557128906,y:265.0249671936035,z:-29.178667068481445},{x:372.72605895996094,y:272.05135345458984,z:-14.834434986114502},{x:360.48614501953125,y:268.34827423095703,z:-32.189905643463135},{x:359.9516296386719,y:270.8049201965332,z:-24.650139808654785},{x:369.5049285888672,y:229.01945114135742,z:10.107489824295044},{x:365.5447769165039,y:230.24096488952637,z:5.593550801277161},{x:363.50669860839844,y:230.6208372116089,z:.43622106313705444},{x:399.3529510498047,y:227.65677452087402,z:15.35965085029602,name:"leftEye"},{x:402.5693130493164,y:224.60190296173096,z:15.931552648544312}],box:{xMin:277.8318977355957,yMin:168.7741756439209,xMax:424.2788314819336,yMax:359.8348903656006,width:146.4469337463379,height:191.0607147216797}},SAMPLE_FACELANDMARKER_RESULT:{faceLandmarks:[[{x:.5760777592658997,y:.8639070391654968,z:-.030997956171631813},{x:.572094738483429,y:.7886289358139038,z:-.07189624011516571},{x:.5723551511764526,y:.8075382709503174,z:-.03578168898820877},{x:.5548420548439026,y:.7188365459442139,z:-.057787876576185226},{x:.5706077814102173,y:.7674974799156189,z:-.07740399986505508},{x:.5681378245353699,y:.7387768030166626,z:-.07356284558773041},{x:.5621535181999207,y:.6681165099143982,z:-.04189874976873398},{x:.46613582968711853,y:.6679812073707581,z:.011289681307971478},{x:.5579932928085327,y:.6174106597900391,z:-.03502821549773216},{x:.5563451647758484,y:.5905600190162659,z:-.03928658738732338},{x:.5487832427024841,y:.4900572597980499,z:-.029898937791585922},{x:.5765544176101685,y:.8692144751548767,z:-.02831427752971649},{x:.5771114230155945,y:.873644232749939,z:-.02345779910683632},{x:.5771905779838562,y:.877016007900238,z:-.016658689826726913},{x:.5778058767318726,y:.8770116567611694,z:-.014505492523312569},{x:.5783766508102417,y:.8835000991821289,z:-.015996402129530907},{x:.5792440176010132,y:.8913810849189758,z:-.01924579218029976},{x:.5796768069267273,y:.8996334671974182,z:-.018261712044477463},{x:.5817288160324097,y:.9255813956260681,z:-.007126849144697189},{x:.5726592540740967,y:.7992473244667053,z:-.0643521398305893},{x:.5579419136047363,y:.7996989488601685,z:-.04566684365272522},{x:.4216199815273285,y:.5958762764930725,z:.06776496022939682},{x:.5052269697189331,y:.6796539425849915,z:-.0010737782577052712},{x:.49243026971817017,y:.6838865876197815,z:-.0005227324436418712},{x:.4796970784664154,y:.6856290102005005,z:.002684245817363262},{x:.4618356227874756,y:.6764569878578186,z:.013439622707664967},{x:.5160380601882935,y:.6737282276153564,z:-17607348127057776e-21},{x:.48070961236953735,y:.6255870461463928,z:-.008339674212038517},{x:.49719780683517456,y:.6256808042526245,z:-.008027955889701843},{x:.46674346923828125,y:.6317623853683472,z:-.004460199736058712},{x:.4582492709159851,y:.641118049621582,z:.0011905613355338573},{x:.45408669114112854,y:.6911458969116211,z:.020514748990535736},{x:.535312294960022,y:.9619986414909363,z:.012499462813138962},{x:.4608460068702698,y:.6628725528717041,z:.01517564244568348},{x:.4206731915473938,y:.6828458309173584,z:.07848648726940155},{x:.4390624463558197,y:.6796106696128845,z:.03283142298460007},{x:.5029968619346619,y:.7701570391654968,z:-.009734481573104858},{x:.5595027208328247,y:.8607323169708252,z:-.030043255537748337},{x:.5621269941329956,y:.8738374710083008,z:-.021709579974412918},{x:.5451499819755554,y:.865527331829071,z:-.022014077752828598},{x:.5351184010505676,y:.8705098032951355,z:-.011602800339460373},{x:.5495014190673828,y:.8744956254959106,z:-.016490943729877472},{x:.5395170450210571,y:.8759440779685974,z:-.007333362940698862},{x:.5183624029159546,y:.8959754705429077,z:.010520773939788342},{x:.5604349374771118,y:.7895449995994568,z:-.07082037627696991},{x:.557381272315979,y:.7687489986419678,z:-.07590588927268982},{x:.4432901442050934,y:.6308897733688354,z:.0027153254486620426},{x:.5258325338363647,y:.7151225805282593,z:-.014676518738269806},{x:.5271827578544617,y:.7833116054534912,z:-.037643320858478546},{x:.5257382988929749,y:.7717816233634949,z:-.03401920944452286},{x:.46516409516334534,y:.7705106735229492,z:.0065747760236263275},{x:.5558893084526062,y:.7420997619628906,z:-.0694495290517807},{x:.4720408320426941,y:.6066038608551025,z:-.021204356104135513},{x:.45432573556900024,y:.6158540844917297,z:-.011054684408009052},{x:.4305151402950287,y:.5608053803443909,z:.0396830290555954},{x:.5310865640640259,y:.6157484650611877,z:-.03081176057457924},{x:.5114666223526001,y:.6329749226570129,z:-.00335998204536736},{x:.506435751914978,y:.8786543607711792,z:.012980876490473747},{x:.4480472207069397,y:.8640613555908203,z:.12569651007652283},{x:.5372058153152466,y:.7942581176757812,z:-.03168361634016037},{x:.5488379597663879,y:.8001630306243896,z:-.03280917927622795},{x:.5213388204574585,y:.8794381618499756,z:.011892606504261494},{x:.5242055654525757,y:.8789222240447998,z:.008370225317776203},{x:.4477175176143646,y:.6039950251579285,z:-.0050799972377717495},{x:.526964008808136,y:.7916748523712158,z:-.02968614175915718},{x:.4971255660057068,y:.6050706505775452,z:-.028175678104162216},{x:.4938119053840637,y:.5882453918457031,z:-.03210941329598427},{x:.4757143557071686,y:.5094879865646362,z:-.01300730835646391},{x:.43947282433509827,y:.5816648006439209,z:.01415177434682846},{x:.485664039850235,y:.5477864146232605,z:-.023685332387685776},{x:.43635931611061096,y:.6226438283920288,z:.013606148771941662},{x:.42910251021385193,y:.6102726459503174,z:.03926564007997513},{x:.5605402588844299,y:.8680099248886108,z:-.027318159118294716},{x:.5474816560745239,y:.8702861070632935,z:-.019686367362737656},{x:.5373021364212036,y:.8728838562965393,z:-.010484928265213966},{x:.540735125541687,y:.7979167103767395,z:-.029073253273963928},{x:.5228585004806519,y:.87913578748703,z:.009915109723806381},{x:.530497670173645,y:.8815253973007202,z:.0020524784922599792},{x:.5259912610054016,y:.8790552616119385,z:.007895970717072487},{x:.5433906316757202,y:.7882310748100281,z:-.05121905356645584},{x:.541388213634491,y:.8777219653129578,z:-.00466804439201951},{x:.5515822172164917,y:.8767023086547852,z:-.010475946590304375},{x:.5637003779411316,y:.877059817314148,z:-.015273625031113625},{x:.5640299320220947,y:.9263423085212708,z:-.00658724969252944},{x:.5642300248146057,y:.8993074893951416,z:-.017653480172157288},{x:.5637336373329163,y:.8910360932350159,z:-.01852807030081749},{x:.5637134313583374,y:.8837276697158813,z:-.01482592523097992},{x:.564205527305603,y:.8768964409828186,z:-.01331155002117157},{x:.5419867634773254,y:.8778373599052429,z:-.0037720394320786},{x:.5404468774795532,y:.880696177482605,z:-.005610354244709015},{x:.5392338633537292,y:.8845721483230591,z:-.007352025713771582},{x:.538469672203064,y:.8891173601150513,z:-.005154991988092661},{x:.5189250111579895,y:.8452741503715515,z:-.009755070321261883},{x:.4258975088596344,y:.7662280797958374,z:.1387351155281067},{x:.5725725293159485,y:.8041572570800781,z:-.04583907872438431},{x:.5342061519622803,y:.8785833120346069,z:.002659974154084921},{x:.5324031114578247,y:.8804071545600891,z:.0017832003068178892},{x:.5538818836212158,y:.8078407645225525,z:-.03254539892077446},{x:.5325431823730469,y:.8026832938194275,z:-.019140373915433884},{x:.5514076948165894,y:.8043903112411499,z:-.03313535451889038},{x:.5131856203079224,y:.7284771800041199,z:-.009399853646755219},{x:.49331504106521606,y:.7443980574607849,z:-.005225230939686298},{x:.5239617824554443,y:.7807451486587524,z:-.025881027802824974},{x:.4473606050014496,y:.5315827131271362,z:.011164786294102669},{x:.45718759298324585,y:.5604941248893738,z:-.005943301599472761},{x:.4670005738735199,y:.5909327268600464,z:-.019681761041283607},{x:.5311570167541504,y:.9076261520385742,z:.00389476353302598},{x:.5249923467636108,y:.5893563628196716,z:-.037981919944286346},{x:.5166932344436646,y:.5429551005363464,z:-.03319704160094261},{x:.5085030198097229,y:.49676206707954407,z:-.02691275253891945},{x:.4687720239162445,y:.6834565997123718,z:.008113506250083447},{x:.4426414966583252,y:.7069531679153442,z:.028577271848917007},{x:.5230373740196228,y:.6675713658332825,z:.001773772411979735},{x:.4481240212917328,y:.6527872085571289,z:.012414850294589996},{x:.5339856743812561,y:.7012367844581604,z:-.020220188423991203},{x:.5347223281860352,y:.7761190533638,z:-.05141595005989075},{x:.4315067231655121,y:.7211957573890686,z:.04381405934691429},{x:.45203351974487305,y:.7206180095672607,z:.017288070172071457},{x:.46892452239990234,y:.7265436053276062,z:.005602988880127668},{x:.49314674735069275,y:.7202282547950745,z:-.0006408205372281373},{x:.5104925632476807,y:.7091827392578125,z:-.00362918758764863},{x:.5232142210006714,y:.698553740978241,z:-.00787867046892643},{x:.5497883558273315,y:.6743605136871338,z:-.036349106580019},{x:.43658503890037537,y:.7627100348472595,z:.042555369436740875},{x:.4397648870944977,y:.6528646349906921,z:.017956094816327095},{x:.5653332471847534,y:.7992802858352661,z:-.06365057826042175},{x:.5285563468933105,y:.736810564994812,z:-.018836988136172295},{x:.4180678725242615,y:.6792560815811157,z:.12284679710865021},{x:.5328429937362671,y:.6865872144699097,z:-.010484723374247551},{x:.5230283141136169,y:.7809416055679321,z:-.011922398582100868},{x:.4551771283149719,y:.6650775074958801,z:.01774493046104908},{x:.5337203741073608,y:.7618928551673889,z:-.04697106033563614},{x:.43463975191116333,y:.8133478164672852,z:.1354849934577942},{x:.5225707292556763,y:.6605283617973328,z:.004980515688657761},{x:.5441933870315552,y:.7497199773788452,z:-.06091512367129326},{x:.4774007797241211,y:.9159183502197266,z:.059622734785079956},{x:.48068761825561523,y:.9364941716194153,z:.08404944837093353},{x:.4268292486667633,y:.7657528519630432,z:.09051097184419632},{x:.46051913499832153,y:.8880485892295837,z:.0738474428653717},{x:.4243420660495758,y:.6434382200241089,z:.06230505183339119},{x:.5342157483100891,y:.9835634231567383,z:.021662971004843712},{x:.5668109655380249,y:.8042187094688416,z:-.044937074184417725},{x:.5176341533660889,y:.7530587315559387,z:-.012967454269528389},{x:.430206298828125,y:.6835605502128601,z:.04612284153699875},{x:.4794231951236725,y:.6732114553451538,z:.003970044665038586},{x:.49073347449302673,y:.6722435355186462,z:.0008692514384165406},{x:.5294116139411926,y:.884677529335022,z:.004413890186697245},{x:.4430122375488281,y:.80235356092453,z:.04987282305955887},{x:.5603825449943542,y:1.0092442035675049,z:.026417359709739685},{x:.5186598300933838,y:.9828659892082214,z:.0513598807156086},{x:.5010536909103394,y:.9640932679176331,z:.06591596454381943},{x:.5524769425392151,y:.539441704750061,z:-.035816047340631485},{x:.5879997611045837,y:1.0091472864151,z:.02285068854689598},{x:.5016193985939026,y:.6684437990188599,z:.00028415941051207483},{x:.511952817440033,y:.6642197370529175,z:.0021144719794392586},{x:.5194343328475952,y:.6623469591140747,z:.004674181342124939},{x:.4321230351924896,y:.6496355533599854,z:.03124697133898735},{x:.508686363697052,y:.6479565501213074,z:-.00044765998609364033},{x:.4963986277580261,y:.6431032419204712,z:-.0032507688738405704},{x:.4845542013645172,y:.6430778503417969,z:-.002903624437749386},{x:.4733612537384033,y:.647506833076477,z:.00023347247042693198},{x:.4668654501438141,y:.653346598148346,z:.004762572236359119},{x:.41815051436424255,y:.633708119392395,z:.09809435904026031},{x:.47159942984580994,y:.6711485385894775,z:.007849935442209244},{x:.5734396576881409,y:.8256140351295471,z:-.03155219927430153},{x:.5306524038314819,y:.8337990641593933,z:-.018351426348090172},{x:.5371729135513306,y:.7910830974578857,z:-.037286680191755295},{x:.5549534559249878,y:.8275275826454163,z:-.030664825811982155},{x:.5597432255744934,y:.6418541669845581,z:-.03318847343325615},{x:.4958484172821045,y:.9429569244384766,z:.048340678215026855},{x:.5140507817268372,y:.9634028077125549,z:.03589847311377525},{x:.5587693452835083,y:.9951097369194031,z:.00908728688955307},{x:.46411189436912537,y:.9051855206489563,z:.10601935535669327},{x:.5181609392166138,y:.6554316878318787,z:.002546071307733655},{x:.5436590909957886,y:.7085841298103333,z:-.03844436630606651},{x:.5872187614440918,y:.9960382580757141,z:.0063423276878893375},{x:.5379653573036194,y:.9989125728607178,z:.03636329993605614},{x:.4350326955318451,y:.8088565468788147,z:.09147704392671585},{x:.5523084998130798,y:.8773422837257385,z:-.009068487212061882},{x:.5510149598121643,y:.8816931843757629,z:-.011043853126466274},{x:.5503793954849243,y:.88776695728302,z:-.01348799467086792},{x:.5501549243927002,y:.8954370617866516,z:-.012142189778387547},{x:.546072781085968,y:.9192524552345276,z:-.003157563041895628},{x:.5314661860466003,y:.8771666884422302,z:.0005075141089037061},{x:.5293324589729309,y:.8762547969818115,z:.00039177737198770046},{x:.5275698900222778,y:.8750609755516052,z:47732755774632096e-21},{x:.5104271173477173,y:.8607332110404968,z:.0012934643309563398},{x:.45938700437545776,y:.8134918212890625,z:.023569690063595772},{x:.5418947339057922,y:.6864100694656372,z:-.027333909645676613},{x:.531914234161377,y:.6456130743026733,z:-.005434140563011169},{x:.523697018623352,y:.647885262966156,z:-.0002466466394253075},{x:.5338191390037537,y:.8783687353134155,z:.002268768846988678},{x:.46226605772972107,y:.8610277771949768,z:.04718952998518944},{x:.5434442758560181,y:.6456181406974792,z:-.02327350154519081},{x:.5399754643440247,y:.940219521522522,z:.005075343884527683},{x:.5661457777023315,y:.71457839012146,z:-.06242101639509201},{x:.5523148775100708,y:.6974870562553406,z:-.04863070324063301},{x:.5639959573745728,y:.6923378109931946,z:-.05180761218070984},{x:.5367592573165894,y:.7423217296600342,z:-.03623027727007866},{x:.5853689908981323,y:.9752064943313599,z:-.002361974213272333},{x:.5835235118865967,y:.9493685960769653,z:-.003941743168979883},{x:.5615018606185913,y:.949194610118866,z:-.0015953965485095978},{x:.5068561434745789,y:.9048219323158264,z:.01862684078514576},{x:.5134067535400391,y:.7971825003623962,z:-.008485661819577217},{x:.5223897099494934,y:.925589919090271,z:.01249657291918993},{x:.48500555753707886,y:.7959478497505188,z:-.0032065745908766985},{x:.5037734508514404,y:.8184596300125122,z:-.004932103678584099},{x:.4766361117362976,y:.828806459903717,z:.01027688942849636},{x:.5589827299118042,y:.974656343460083,z:.0009666886180639267},{x:.5294582843780518,y:.7541216611862183,z:-.025603046640753746},{x:.4973002076148987,y:.9208990931510925,z:.031931452453136444},{x:.5163551568984985,y:.9432790875434875,z:.024321340024471283},{x:.49399662017822266,y:.8814862370491028,z:.018687399104237556},{x:.44948166608810425,y:.836137592792511,z:.05702034756541252},{x:.47898444533348083,y:.8836610913276672,z:.03150695189833641},{x:.4454479217529297,y:.8499438166618347,z:.08868525922298431},{x:.49572959542274475,y:.8452823758125305,z:.0036111653316766024},{x:.5362502336502075,y:.7222585678100586,z:-.027912352234125137},{x:.5393770337104797,y:.7850722074508667,z:-.05415399745106697},{x:.531399667263031,y:.7898418307304382,z:-.03883346915245056},{x:.5451627373695374,y:.7717036604881287,z:-.06480253487825394},{x:.5206395983695984,y:.6287745833396912,z:-.010521138086915016},{x:.4974782466888428,y:.6191938519477844,z:-.014098240062594414},{x:.4774145185947418,y:.6193130612373352,z:-.013643337413668633},{x:.4616098403930664,y:.6259890198707581,z:-.008448202162981033},{x:.4516478478908539,y:.6368461847305298,z:9050309745362028e-20},{x:.4485096037387848,y:.6719120740890503,z:.022984720766544342},{x:.42177659273147583,y:.7240667343139648,z:.08511673659086227},{x:.4616215229034424,y:.6988231539726257,z:.014238474890589714},{x:.4755798876285553,y:.7034608721733093,z:.00625590980052948},{x:.4924992024898529,y:.7005885243415833,z:.0009391739731654525},{x:.5082254409790039,y:.693384051322937,z:-.0009464038303121924},{x:.5203112959861755,y:.6849707961082458,z:-.0022114769089967012},{x:.52867591381073,y:.6779075860977173,z:-.002962538506835699},{x:.4213953912258148,y:.7219811677932739,z:.1350894570350647},{x:.5320829749107361,y:.794858992099762,z:-.03181503340601921},{x:.5452795028686523,y:.7286570072174072,z:-.04771539941430092},{x:.5496407747268677,y:.7866933345794678,z:-.06452003121376038},{x:.557040274143219,y:.7962084412574768,z:-.05837344378232956},{x:.549176812171936,y:.7895247936248779,z:-.057761140167713165},{x:.5362890362739563,y:.8005836606025696,z:-.026903774589300156},{x:.560200035572052,y:.7983731031417847,z:-.06172555685043335},{x:.5616944432258606,y:.8022753596305847,z:-.045200999826192856},{x:.5273328423500061,y:.6611284017562866,z:.0029021520167589188},{x:.534850537776947,y:.6660012006759644,z:-.005215510260313749},{x:.5394860506057739,y:.6701375246047974,z:-.014931917190551758},{x:.4634307324886322,y:.658291757106781,z:.009295716881752014},{x:.4538393020629883,y:.6519932150840759,z:.00930330716073513},{x:.5776031613349915,y:.7159298658370972,z:-.057365912944078445},{x:.6504855155944824,y:.6461779475212097,z:.014184834435582161},{x:.5860154032707214,y:.7962266206741333,z:-.04522843658924103},{x:.6842049360275269,y:.5631637573242188,z:.07207967340946198},{x:.6152560710906982,y:.6674962639808655,z:.0007529259892180562},{x:.6280948519706726,y:.6684326529502869,z:.0016892586136236787},{x:.6408625245094299,y:.6663892269134521,z:.005331226624548435},{x:.6557814478874207,y:.6534678936004639,z:.01646413467824459},{x:.6035663485527039,y:.6639701724052429,z:.0013799630105495453},{x:.6329053044319153,y:.608010470867157,z:-.006195899099111557},{x:.6167260408401489,y:.6117533445358276,z:-.006319951266050339},{x:.6471013426780701,y:.6112449765205383,z:-.0017843559617176652},{x:.6560901999473572,y:.6185776591300964,z:.004047257360070944},{x:.6666946411132812,y:.6651176810264587,z:.023647578433156013},{x:.6311345100402832,y:.9495396018028259,z:.014004078693687916},{x:.6544655561447144,y:.6397901773452759,z:.01809609681367874},{x:.6965808868408203,y:.6482675075531006,z:.08304904401302338},{x:.679817259311676,y:.650188148021698,z:.03632688894867897},{x:.6336516737937927,y:.7541458010673523,z:-.007742783520370722},{x:.5921701192855835,y:.8567668199539185,z:-.029399123042821884},{x:.591663658618927,y:.870215654373169,z:-.02103729173541069},{x:.6068367958068848,y:.8584195375442505,z:-.020668085664510727},{x:.6176617741584778,y:.860965371131897,z:-.009790095500648022},{x:.6040634512901306,y:.8686612844467163,z:-.015289564616978168},{x:.6143736839294434,y:.8671170473098755,z:-.005712216719985008},{x:.6373105049133301,y:.8815656900405884,z:.012672550976276398},{x:.5832505822181702,y:.7866312861442566,z:-.07051534950733185},{x:.5836675763130188,y:.7658692598342896,z:-.07566110789775848},{x:.6709531545639038,y:.604898989200592,z:.005951565690338612},{x:.6029891967773438,y:.705652117729187,z:-.013388276100158691},{x:.6131622195243835,y:.7728396058082581,z:-.036248479038476944},{x:.6123163104057312,y:.7612020373344421,z:-.03264721855521202},{x:.6696187853813171,y:.744706928730011,z:.009673702530562878},{x:.5803102254867554,y:.7385968565940857,z:-.0689152330160141},{x:.6404349207878113,y:.5877999663352966,z:-.01929756999015808},{x:.6588467955589294,y:.5929454565048218,z:-.008487257175147533},{x:.6720337867736816,y:.530631422996521,z:.043437421321868896},{x:.584305465221405,y:.6099005341529846,z:-.030301367864012718},{x:.6034283638000488,y:.6217452883720398,z:-.001970183802768588},{x:.6460927724838257,y:.8608663082122803,z:.015541625209152699},{x:.6957815289497375,y:.8326103091239929,z:.13015234470367432},{x:.6043362617492676,y:.7861682772636414,z:-.030476901680231094},{x:.594293475151062,y:.7942103147506714,z:-.032218821346759796},{x:.6324057579040527,y:.8665139675140381,z:.014255806803703308},{x:.6296147704124451,y:.8667733669281006,z:.010388285852968693},{x:.663644552230835,y:.5798642635345459,z:-.0022301070857793093},{x:.6140630841255188,y:.7809288501739502,z:-.02835679054260254},{x:.615908145904541,y:.5921698212623596,z:-.026804860681295395},{x:.617181122303009,y:.5748661756515503,z:-.03060605563223362},{x:.6222207546234131,y:.49137672781944275,z:-.011151673272252083},{x:.6669357419013977,y:.5541607141494751,z:.017466170713305473},{x:.6182981729507446,y:.5320425629615784,z:-.021793590858578682},{x:.6760554313659668,y:.595052182674408,z:.017115700989961624},{x:.6801463961601257,y:.5800720453262329,z:.043127160519361496},{x:.5922210812568665,y:.8644017577171326,z:-.02662893570959568},{x:.6054555177688599,y:.8637874722480774,z:-.018363753333687782},{x:.6161889433860779,y:.8641164898872375,z:-.008808949030935764},{x:.6017249822616577,y:.7901403307914734,z:-.028126630932092667},{x:.631446123123169,y:.8664817810058594,z:.012112865224480629},{x:.6249198913574219,y:.8716511130332947,z:.003882825840264559},{x:.6281915903091431,y:.867301881313324,z:.009891441091895103},{x:.5986843109130859,y:.7813931703567505,z:-.050227612257003784},{x:.6126407384872437,y:.869275689125061,z:-.0031255714129656553},{x:.6027271151542664,y:.8711842894554138,z:-.009324162267148495},{x:.59088134765625,y:.8742044568061829,z:-.014608660712838173},{x:.5984604358673096,y:.9216185212135315,z:-.005981989670544863},{x:.5950398445129395,y:.8964707255363464,z:-.01703473925590515},{x:.5941568613052368,y:.8882410526275635,z:-.017784785479307175},{x:.5928806662559509,y:.8803883194923401,z:-.014153128489851952},{x:.5909661054611206,y:.8748103976249695,z:-.012609979137778282},{x:.6128016710281372,y:.8702545762062073,z:-.0022550546564161777},{x:.6150846481323242,y:.8726804256439209,z:-.00414019962772727},{x:.6173093914985657,y:.8770190477371216,z:-.005970994010567665},{x:.619335412979126,y:.8814800977706909,z:-.0036864024586975574},{x:.6292637586593628,y:.8314558267593384,z:-.007714875973761082},{x:.702275276184082,y:.7320667505264282,z:.1433621346950531},{x:.6204835176467896,y:.8689177632331848,z:.0044869170524179935},{x:.6223508715629578,y:.8704851269721985,z:.00352082890458405},{x:.590448260307312,y:.8029727935791016,z:-.03200828656554222},{x:.6097423434257507,y:.7933741211891174,z:-.018042555078864098},{x:.59229576587677,y:.7993767261505127,z:-.032564569264650345},{x:.6171364188194275,y:.7153720259666443,z:-.007672437466681004},{x:.6389747858047485,y:.726390540599823,z:-.002999067772179842},{x:.6151940226554871,y:.769412100315094,z:-.024427521973848343},{x:.6526776552200317,y:.505868136882782,z:.01412637997418642},{x:.6475822329521179,y:.5375454425811768,z:-.0033899128902703524},{x:.6433356404304504,y:.5714520215988159,z:-.017428796738386154},{x:.626949667930603,y:.8962116837501526,z:.005602736957371235},{x:.5868416428565979,y:.5829002261161804,z:-.03727729618549347},{x:.5877229571342468,y:.5345035791397095,z:-.032396964728832245},{x:.5887066125869751,y:.48655083775520325,z:-.025856535881757736},{x:.6507197618484497,y:.6612282991409302,z:.011114613153040409},{x:.6803066730499268,y:.677992045879364,z:.032125361263751984},{x:.5963194370269775,y:.6598632335662842,z:.002976928371936083},{x:.667536199092865,y:.6274255514144897,z:.015618261881172657},{x:.5930740833282471,y:.6940041780471802,z:-.019217798486351967},{x:.6053346395492554,y:.7676517963409424,z:-.050308309495449066},{x:.6934473514556885,y:.6884298920631409,z:.04794462397694588},{x:.6738007664680481,y:.6934011578559875,z:.020697161555290222},{x:.6588084697723389,y:.7033141851425171,z:.008462334051728249},{x:.6346072554588318,y:.7029502391815186,z:.001542167621664703},{x:.6157816648483276,y:.6966525912284851,z:-.002009218093007803},{x:.6015574336051941,y:.688928484916687,z:-.006588225718587637},{x:.5746836066246033,y:.6711069345474243,z:-.03597589209675789},{x:.6947521567344666,y:.7309479117393494,z:.046707939356565475},{x:.6759101152420044,y:.6249120831489563,z:.021654341369867325},{x:.5794773101806641,y:.7971615195274353,z:-.06339326500892639},{x:.6041849851608276,y:.727514922618866,z:-.017512541264295578},{x:.6968844532966614,y:.6440950036048889,z:.12727996706962585},{x:.5910853147506714,y:.679325520992279,z:-.009497715160250664},{x:.6157375574111938,y:.7695677280426025,z:-.010624290443956852},{x:.6606494784355164,y:.6410489678382874,z:.0208158977329731},{x:.6040687561035156,y:.7531470656394958,z:-.045887019485235214},{x:.7012156248092651,y:.780247151851654,z:.14028730988502502},{x:.595149576663971,y:.6527782678604126,z:.006308757700026035},{x:.5925500392913818,y:.7436665892601013,z:-.060151755809783936},{x:.6780198812484741,y:.8905693888664246,z:.0626060739159584},{x:.676746666431427,y:.9113880395889282,z:.08726003766059875},{x:.7030686140060425,y:.7312687635421753,z:.09529774636030197},{x:.688987135887146,y:.8588417172431946,z:.07752864807844162},{x:.6883691549301147,y:.6109960675239563,z:.06669612973928452},{x:.6358906030654907,y:.9702065587043762,z:.023120900616049767},{x:.5781539678573608,y:.8023634552955627,z:-.044763918966054916},{x:.6170316934585571,y:.7408350706100464,z:-.011375460773706436},{x:.688542366027832,y:.6516284346580505,z:.050206027925014496},{x:.6385149359703064,y:.6540714502334595,z:.006462941411882639},{x:.6279382109642029,y:.6563615798950195,z:.003062846139073372},{x:.6268895268440247,y:.8736732006072998,z:.00627936702221632},{x:.6944946050643921,y:.7709181308746338,z:.053824134171009064},{x:.614617109298706,y:1.0022112131118774,z:.02719894051551819},{x:.6493719220161438,y:.9665167927742004,z:.053563784807920456},{x:.6624587178230286,y:.943530797958374,z:.068605437874794},{x:.6162528991699219,y:.6558693051338196,z:.002187855076044798},{x:.6058168411254883,y:.654328465461731,z:.0036193584091961384},{x:.5987918972969055,y:.6536934971809387,z:.006134530063718557},{x:.6831037402153015,y:.6195642948150635,z:.03511790186166763},{x:.6062582731246948,y:.6356398463249207,z:.001280312892049551},{x:.6174948811531067,y:.62776118516922,z:-.0013642468256875873},{x:.6297246217727661,y:.6253792643547058,z:-.0007034156005829573},{x:.6407091617584229,y:.627578616142273,z:.0028144705574959517},{x:.6479622721672058,y:.6322650909423828,z:.00750273372977972},{x:.6915091276168823,y:.5990704298019409,z:.10270945727825165},{x:.6457163095474243,y:.6504453420639038,z:.010696077719330788},{x:.6164222955703735,y:.8231936097145081,z:-.016772059723734856},{x:.6042401194572449,y:.7830976843833923,z:-.03630910441279411},{x:.5922216773033142,y:.8228387236595154,z:-.029992375522851944},{x:.6646111011505127,y:.92097008228302,z:.050967294722795486},{x:.651232898235321,y:.9460107088088989,z:.038000158965587616},{x:.6140977144241333,y:.9882472157478333,z:.009882091544568539},{x:.6870781183242798,y:.8768675327301025,z:.10980932414531708},{x:.5986856818199158,y:.6456438899040222,z:.003999010659754276},{x:.585981547832489,y:.7034481763839722,z:-.0377722829580307},{x:.6342031359672546,y:.9867448806762695,z:.03786521404981613},{x:.7013950943946838,y:.776049017906189,z:.09598205983638763},{x:.6030206680297852,y:.8719133138656616,z:-.007931148633360863},{x:.6050592064857483,y:.8767156004905701,z:-.009791925549507141},{x:.6073468923568726,y:.8831382393836975,z:-.012361008673906326},{x:.6087977290153503,y:.890143632888794,z:-.01098148338496685},{x:.6147705316543579,y:.9110084772109985,z:-.0018823575228452682},{x:.622577965259552,y:.8670604825019836,z:.002609190298244357},{x:.6241236329078674,y:.8651344180107117,z:.0025534380692988634},{x:.6257084608078003,y:.8638408184051514,z:.0023300074972212315},{x:.639931321144104,y:.8449671268463135,z:.0038123116828501225},{x:.6810906529426575,y:.7856625318527222,z:.02717764675617218},{x:.583532452583313,y:.6811994910240173,z:-.026588857173919678},{x:.5855660438537598,y:.6393819451332092,z:-.004512844607234001},{x:.5932201743125916,y:.6398029327392578,z:.0008020466193556786},{x:.6200879812240601,y:.8683351874351501,z:.00417016725987196},{x:.6842559576034546,y:.8330534100532532,z:.050836317241191864},{x:.5754412412643433,y:.6418221592903137,z:-.022838059812784195},{x:.6232790350914001,y:.9295297265052795,z:.006339520215988159},{x:.5764067769050598,y:.694546639919281,z:-.04825803264975548},{x:.59778892993927,y:.7343927621841431,z:-.035004377365112305},{x:.6042810678482056,y:.9441440105438232,z:-.0010970570147037506},{x:.6496372222900391,y:.8869078159332275,z:.021036235615611076},{x:.6274012327194214,y:.7830310463905334,z:-.006658440921455622},{x:.637792706489563,y:.9104999899864197,z:.014290250837802887},{x:.6549934148788452,y:.7748609185218811,z:-.0006672973395325243},{x:.6404005289077759,y:.801220715045929,z:-.0026642554439604282},{x:.6671456694602966,y:.8045546412467957,z:.013180811889469624},{x:.6107483506202698,y:.9680658578872681,z:.001778992242179811},{x:.6060343980789185,y:.744587242603302,z:-.024382334202528},{x:.6602751612663269,y:.8998945355415344,z:.0344940721988678},{x:.6463775038719177,y:.9262562394142151,z:.02617623284459114},{x:.6579852104187012,y:.8602304458618164,z:.021586716175079346},{x:.6926165223121643,y:.8053340315818787,z:.061075080186128616},{x:.6724731922149658,y:.8594399690628052,z:.03457934781908989},{x:.6975721716880798,y:.8183245062828064,z:.09300774335861206},{x:.6512877941131592,y:.8258221745491028,z:.006324059329926968},{x:.594887375831604,y:.7148372530937195,z:-.026898479089140892},{x:.6017440557479858,y:.7773507833480835,z:-.05312420800328255},{x:.6096571683883667,y:.7806998491287231,z:-.037646256387233734},{x:.5952993035316467,y:.7654367685317993,z:-.06398405134677887},{x:.5950021147727966,y:.6201304793357849,z:-.009297547861933708},{x:.6165438890457153,y:.6052900552749634,z:-.012455573305487633},{x:.6362661719322205,y:.6015968918800354,z:-.011649220250546932},{x:.6522727608680725,y:.6046400666236877,z:-.005903332494199276},{x:.6625409722328186,y:.6128141283988953,z:.0030042496509850025},{x:.6688099503517151,y:.6457712054252625,z:.026322703808546066},{x:.7013440728187561,y:.6893666386604309,z:.08984331786632538},{x:.6608623266220093,y:.6749406456947327,z:.0172116681933403},{x:.6482325196266174,y:.6823726296424866,z:.008881398476660252},{x:.6313265562057495,y:.6842025518417358,z:.0031308617908507586},{x:.6147016286849976,y:.6809731721878052,z:.0007630771724507213},{x:.6018834114074707,y:.6755372285842896,z:-.0008834321051836014},{x:.5925027132034302,y:.670681357383728,z:-.001968748401850462},{x:.700127363204956,y:.6871103644371033,z:.13980500400066376},{x:.6095665693283081,y:.7853189706802368,z:-.03074747882783413},{x:.5880423784255981,y:.7229287028312683,z:-.04691500961780548},{x:.5930182337760925,y:.7811514139175415,z:-.06398335844278336},{x:.5867722034454346,y:.7922660112380981,z:-.05794971063733101},{x:.5933279991149902,y:.7842848896980286,z:-.05714067071676254},{x:.6063535809516907,y:.7920218706130981,z:-.02590685710310936},{x:.5839452743530273,y:.794978141784668,z:-.0615212507545948},{x:.5828126072883606,y:.8000800013542175,z:-.0449722595512867},{x:.5909603834152222,y:.6541213393211365,z:.003991890233010054},{x:.5852181911468506,y:.6602938771247864,z:-.004428438376635313},{x:.5825737714767456,y:.6651063561439514,z:-.014345290139317513},{x:.6517343521118164,y:.6362385153770447,z:.012151890434324741},{x:.6615052819252014,y:.6281577944755554,z:.0123682152479887},{x:.4856873154640198,y:.6568945646286011,z:.000720038078725338},{x:.49988406896591187,y:.6547410488128662,z:.0006949726957827806},{x:.48438939452171326,y:.6392973065376282,z:.000705525919329375},{x:.47143134474754333,y:.6589511632919312,z:.0006980331381782889},{x:.48704618215560913,y:.6752797961235046,z:.0006921177846379578},{x:.6243702173233032,y:.640461802482605,z:-6592126737814397e-20},{x:.6390967965126038,y:.6385173797607422,z:-.00016105435497593135},{x:.6230536699295044,y:.6224825382232666,z:-.00016136496560648084},{x:.6095397472381592,y:.641917884349823,z:-.0001803556369850412},{x:.6250996589660645,y:.6586247682571411,z:-.0001785515050869435}]],faceBlendshapes:[{categories:[{index:0,score:5187174338061595e-21,categoryName:"_neutral",displayName:""},{index:1,score:.24521504342556,categoryName:"browDownLeft",displayName:""},{index:2,score:.1987743377685547,categoryName:"browDownRight",displayName:""},{index:3,score:.013400448486208916,categoryName:"browInnerUp",displayName:""},{index:4,score:.012361560948193073,categoryName:"browOuterUpLeft",displayName:""},{index:5,score:.019305096939206123,categoryName:"browOuterUpRight",displayName:""},{index:6,score:28426356948330067e-21,categoryName:"cheekPuff",displayName:""},{index:7,score:3.4500112633395474e-7,categoryName:"cheekSquintLeft",displayName:""},{index:8,score:4.83789051486383e-7,categoryName:"cheekSquintRight",displayName:""},{index:9,score:.07650448381900787,categoryName:"eyeBlinkLeft",displayName:""},{index:10,score:.05070012807846069,categoryName:"eyeBlinkRight",displayName:""},{index:11,score:.13978900015354156,categoryName:"eyeLookDownLeft",displayName:""},{index:12,score:.14198613166809082,categoryName:"eyeLookDownRight",displayName:""},{index:13,score:.2177766114473343,categoryName:"eyeLookInLeft",displayName:""},{index:14,score:.014739357866346836,categoryName:"eyeLookInRight",displayName:""},{index:15,score:.02361512929201126,categoryName:"eyeLookOutLeft",displayName:""},{index:16,score:.19679604470729828,categoryName:"eyeLookOutRight",displayName:""},{index:17,score:.04874616861343384,categoryName:"eyeLookUpLeft",displayName:""},{index:18,score:.049392376095056534,categoryName:"eyeLookUpRight",displayName:""},{index:19,score:.34944331645965576,categoryName:"eyeSquintLeft",displayName:""},{index:20,score:.2939716875553131,categoryName:"eyeSquintRight",displayName:""},{index:21,score:.005955042317509651,categoryName:"eyeWideLeft",displayName:""},{index:22,score:.006776117719709873,categoryName:"eyeWideRight",displayName:""},{index:23,score:16942436559475027e-21,categoryName:"jawForward",displayName:""},{index:24,score:.0045165494084358215,categoryName:"jawLeft",displayName:""},{index:25,score:.07803940027952194,categoryName:"jawOpen",displayName:""},{index:26,score:2090057751047425e-20,categoryName:"jawRight",displayName:""},{index:27,score:.06032035872340202,categoryName:"mouthClose",displayName:""},{index:28,score:.00228882092051208,categoryName:"mouthDimpleLeft",displayName:""},{index:29,score:.00781762320548296,categoryName:"mouthDimpleRight",displayName:""},{index:30,score:.0017093931091949344,categoryName:"mouthFrownLeft",displayName:""},{index:31,score:.0019319106359034777,categoryName:"mouthFrownRight",displayName:""},{index:32,score:8485237776767462e-20,categoryName:"mouthFunnel",displayName:""},{index:33,score:.0009051355300471187,categoryName:"mouthLeft",displayName:""},{index:34,score:.0003630454302765429,categoryName:"mouthLowerDownLeft",displayName:""},{index:35,score:.00017601238505449146,categoryName:"mouthLowerDownRight",displayName:""},{index:36,score:.12865161895751953,categoryName:"mouthPressLeft",displayName:""},{index:37,score:.20137207210063934,categoryName:"mouthPressRight",displayName:""},{index:38,score:.0022203284315764904,categoryName:"mouthPucker",displayName:""},{index:39,score:.0009096377179957926,categoryName:"mouthRight",displayName:""},{index:40,score:.34189721941947937,categoryName:"mouthRollLower",displayName:""},{index:41,score:.11409689486026764,categoryName:"mouthRollUpper",displayName:""},{index:42,score:.17172536253929138,categoryName:"mouthShrugLower",displayName:""},{index:43,score:.004038424696773291,categoryName:"mouthShrugUpper",displayName:""},{index:44,score:.00023205230536404997,categoryName:"mouthSmileLeft",displayName:""},{index:45,score:.00019313619122840464,categoryName:"mouthSmileRight",displayName:""},{index:46,score:.0018571305554360151,categoryName:"mouthStretchLeft",displayName:""},{index:47,score:.0023813238367438316,categoryName:"mouthStretchRight",displayName:""},{index:48,score:24323100660694763e-21,categoryName:"mouthUpperUpLeft",displayName:""},{index:49,score:3161552012898028e-20,categoryName:"mouthUpperUpRight",displayName:""},{index:50,score:1.08198406678639e-7,categoryName:"noseSneerLeft",displayName:""},{index:51,score:12652527630052646e-22,categoryName:"noseSneerRight",displayName:""}],headIndex:-1,headName:""}],facialTransformationMatrixes:[{rows:4,columns:4,data:[.9947517514228821,.10230544209480286,.0013679931871592999,0,-.10230997204780579,.9947447776794434,.003816320328041911,0,-.000970348424743861,-.0039362297393381596,.9999914169311523,0,2.8888821601867676,-7.808934211730957,-30.52109146118164,1]}]}},ct=t.createContext({}),ut={basePath:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.2-rc2/wasm",options:{baseOptions:{modelAssetPath:"https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task",delegate:"GPU"},runningMode:"VIDEO",outputFaceBlendshapes:!0,outputFacialTransformationMatrixes:!0}};function mt(){return t.useContext(ct)}function dt(e,t){return e.clone().add(t).multiplyScalar(.5)}function ft(e,t,r){const n=e.localToWorld(t);return r.worldToLocal(n)}const pt=t.createContext({}),ht=t.forwardRef((({camera:r,autostart:n=!0,webcam:a=!0,webcamVideoTextureSrc:i,manualUpdate:l=!1,manualDetect:c=!1,onVideoFrame:u,smoothTime:m=.25,offset:d=!0,offsetScalar:f=80,eyes:p=!1,eyesAsOrigin:h=!0,depth:x=.15,debug:y=!1,facemesh:v,makeDefault:g},z)=>{var w,b;const E=o.useThree((e=>e.scene)),M=o.useThree((e=>e.camera)),S=o.useThree((e=>e.set)),C=o.useThree((e=>e.get)),R=r||M,D=t.useRef(null),F=t.useRef(null),[k]=t.useState((()=>new P.Object3D)),[_]=t.useState((()=>new P.Vector3)),[L]=t.useState((()=>new P.Vector3)),[A]=t.useState((()=>new P.Vector3)),[B]=t.useState((()=>new P.Vector3)),U=t.useCallback((()=>{k.parent=R.parent;const e=F.current;if(e){const{outerRef:t,eyeRightRef:r,eyeLeftRef:n}=e;if(r.current&&n.current){const{irisDirRef:e}=r.current,{irisDirRef:o}=n.current;e.current&&o.current&&t.current&&(_.copy(ft(e.current,new P.Vector3(0,0,0),t.current)),L.copy(ft(o.current,new P.Vector3(0,0,0),t.current)),k.position.copy(ft(t.current,dt(_,L),R.parent||E)),A.copy(ft(e.current,new P.Vector3(0,0,1),t.current)),B.copy(ft(o.current,new P.Vector3(0,0,1),t.current)),k.lookAt(t.current.localToWorld(dt(A,B))))}else t.current&&(k.position.copy(ft(t.current,new P.Vector3(0,0,0),R.parent||E)),k.lookAt(t.current.localToWorld(new P.Vector3(0,0,1))))}return k}),[R,L,B,_,A,E,k]),[O]=t.useState((()=>new P.Object3D)),N=t.useCallback((function(e,t){if(R){var r;if(null!==(r=t)&&void 0!==r||(t=U()),m>0){const r=1e-9;s.easing.damp3(O.position,t.position,m,e,void 0,void 0,r),s.easing.dampE(O.rotation,t.rotation,m,e,void 0,void 0,r)}else O.position.copy(t.position),O.rotation.copy(t.rotation);R.position.copy(O.position),R.rotation.copy(O.rotation)}}),[R,U,m,O.position,O.rotation]),[I,V]=t.useState(),j=mt(),W=t.useCallback(((e,t)=>{const r=null==j?void 0:j.detectForVideo(e,t);V(r)}),[j]);o.useFrame(((e,t)=>{l||N(t)}));const G=t.useMemo((()=>Object.assign(Object.create(P.EventDispatcher.prototype),{detect:W,computeTarget:U,update:N,facemeshApiRef:F,webcamApiRef:D,play:()=>{var e,t;null==(e=D.current)||null==(t=e.videoTextureApiRef.current)||t.texture.source.data.play()},pause:()=>{var e,t;null==(e=D.current)||null==(t=e.videoTextureApiRef.current)||t.texture.source.data.pause()}})),[W,U,N]);t.useImperativeHandle(z,(()=>G),[G]),t.useEffect((()=>{const e=e=>{c||W(e.texture.source.data,e.time),u&&u(e)};return G.addEventListener("videoFrame",e),()=>{G.removeEventListener("videoFrame",e)}}),[G,W,j,c,u]),t.useEffect((()=>{if(g){const e=C().controls;return S({controls:G}),()=>S({controls:e})}}),[g,G,C,S]);const H=null==I?void 0:I.faceLandmarks[0],q=null==I||null==(w=I.facialTransformationMatrixes)?void 0:w[0],$=null==I||null==(b=I.faceBlendshapes)?void 0:b[0];return T.createElement(pt.Provider,{value:G},a&&T.createElement(t.Suspense,{fallback:null},T.createElement(yt,{ref:D,autostart:n,videoTextureSrc:i})),T.createElement(at,e({ref:F},v,{points:H,depth:x,facialTransformationMatrix:q,faceBlendshapes:$,eyes:p,eyesAsOrigin:h,offset:d,offsetScalar:f,debug:y,"rotation-z":Math.PI,visible:y}),T.createElement("meshBasicMaterial",{side:P.DoubleSide})))})),xt=()=>t.useContext(pt),yt=t.forwardRef((({videoTextureSrc:e,autostart:r=!0},n)=>{const o=t.useRef(null),a=xt(),i=p.suspend((async()=>e?Promise.resolve(null):await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"user"}})),[e]);t.useEffect((()=>(a.dispatchEvent({type:"stream",stream:i}),()=>{null==i||i.getTracks().forEach((e=>e.stop())),p.clear([e])})),[i,a,e]);const s=t.useMemo((()=>({videoTextureApiRef:o})),[]);return t.useImperativeHandle(n,(()=>s),[s]),T.createElement(t.Suspense,{fallback:null},T.createElement(vt,{ref:o,src:e||i,start:r}))})),vt=t.forwardRef((({src:e,start:r},n)=>{const o=rt(e,{start:r}),a=o.source.data,i=xt(),s=t.useCallback((e=>{i.dispatchEvent({type:"videoFrame",texture:o,time:e})}),[o,i]);gt(a,s);const l=t.useMemo((()=>({texture:o})),[o]);return t.useImperativeHandle(n,(()=>l),[l]),T.createElement(T.Fragment,null)})),gt=(e,r)=>{t.useEffect((()=>{if(!e||!e.requestVideoFrameCallback)return;let t;return e.requestVideoFrameCallback((function n(...o){r(...o),t=e.requestVideoFrameCallback(n)})),()=>e.cancelVideoFrameCallback(t)}),[e,r])};function zt({defaultScene:e,defaultCamera:t,renderPriority:r=1}){const{gl:n,scene:a,camera:i}=o.useThree();let s;return o.useFrame((()=>{s=n.autoClear,1===r&&(n.autoClear=!0,n.render(e,t)),n.autoClear=!1,n.clearDepth(),n.render(a,i),n.autoClear=s}),r),T.createElement("group",{onPointerOver:()=>null})}function wt({children:e,renderPriority:t=1}){const{scene:r,camera:n}=o.useThree(),[a]=T.useState((()=>new P.Scene));return T.createElement(T.Fragment,null,o.createPortal(T.createElement(T.Fragment,null,e,T.createElement(zt,{defaultScene:r,defaultCamera:n,renderPriority:t})),a,{events:{priority:t+1}}))}const bt=T.createContext({}),Et=()=>T.useContext(bt),Mt=2*Math.PI,St=new n.Object3D,Tt=new n.Matrix4,[Ct,Pt]=[new n.Quaternion,new n.Quaternion],Rt=new n.Vector3,Dt=new n.Vector3,Ft="#f0f0f0",kt="#999",_t="black",Lt="black",At=["Right","Left","Top","Bottom","Front","Back"],Bt=e=>new n.Vector3(...e).multiplyScalar(.38),Ut=[[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]].map(Bt),Ot=[.25,.25,.25],Nt=[[1,1,0],[1,0,1],[1,0,-1],[1,-1,0],[0,1,1],[0,1,-1],[0,-1,1],[0,-1,-1],[-1,1,0],[-1,0,1],[-1,0,-1],[-1,-1,0]].map(Bt),It=Nt.map((e=>e.toArray().map((e=>0==e?.5:.25)))),Vt=({hover:e,index:t,font:r="20px Inter var, Arial, sans-serif",faces:a=At,color:i=Ft,hoverColor:s=kt,textColor:l=_t,strokeColor:c=Lt,opacity:u=1})=>{const m=o.useThree((e=>e.gl)),d=T.useMemo((()=>{const e=document.createElement("canvas");e.width=128,e.height=128;const o=e.getContext("2d");return o.fillStyle=i,o.fillRect(0,0,e.width,e.height),o.strokeStyle=c,o.strokeRect(0,0,e.width,e.height),o.font=r,o.textAlign="center",o.fillStyle=l,o.fillText(a[t].toUpperCase(),64,76),new n.CanvasTexture(e)}),[t,a,r,i,l,c]);return T.createElement("meshBasicMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,attach:`material-${t}`,color:e?s:"white",transparent:!0,opacity:u})},jt=t=>{const{tweenCamera:r}=Et(),[n,o]=T.useState(null);return T.createElement("mesh",{onPointerOut:e=>{e.stopPropagation(),o(null)},onPointerMove:e=>{e.stopPropagation(),o(Math.floor(e.faceIndex/2))},onClick:t.onClick||(e=>{e.stopPropagation(),r(e.face.normal)})},[...Array(6)].map(((r,o)=>T.createElement(Vt,e({key:o,index:o,hover:n===o},t)))),T.createElement("boxGeometry",null))},Wt=({onClick:e,dimensions:t,position:r,hoverColor:n=kt})=>{const{tweenCamera:o}=Et(),[a,i]=T.useState(!1);return T.createElement("mesh",{scale:1.01,position:r,onPointerOver:e=>{e.stopPropagation(),i(!0)},onPointerOut:e=>{e.stopPropagation(),i(!1)},onClick:e||(e=>{e.stopPropagation(),o(r)})},T.createElement("meshBasicMaterial",{color:a?n:"white",transparent:!0,opacity:.6,visible:a}),T.createElement("boxGeometry",{args:t}))};function Gt({scale:e=[.8,.05,.05],color:t,rotation:r}){return T.createElement("group",{rotation:r},T.createElement("mesh",{position:[.4,0,0]},T.createElement("boxGeometry",{args:e}),T.createElement("meshBasicMaterial",{color:t,toneMapped:!1})))}function Ht({onClick:t,font:r,disabled:a,arcStyle:i,label:s,labelColor:l,axisHeadScale:c=1,...u}){const m=o.useThree((e=>e.gl)),d=T.useMemo((()=>{const e=document.createElement("canvas");e.width=64,e.height=64;const t=e.getContext("2d");return t.beginPath(),t.arc(32,32,16,0,2*Math.PI),t.closePath(),t.fillStyle=i,t.fill(),s&&(t.font=r,t.textAlign="center",t.fillStyle=l,t.fillText(s,32,41)),new n.CanvasTexture(e)}),[i,s,l,r]),[f,p]=T.useState(!1),h=(s?1:.75)*(f?1.2:1)*c;return T.createElement("sprite",e({scale:h,onPointerOver:a?void 0:e=>{e.stopPropagation(),p(!0)},onPointerOut:a?void 0:t||(e=>{e.stopPropagation(),p(!1)})},u),T.createElement("spriteMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:s?1:.75,toneMapped:!1}))}const qt=xe({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new P.Color,sectionColor:new P.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new P.Vector3,worldPlanePosition:new P.Vector3},"\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform vec3 worldPlanePosition;\n uniform float fadeDistance;\n uniform bool infiniteGrid;\n uniform bool followCamera;\n\n void main() {\n localPosition = position.xzy;\n if (infiniteGrid) localPosition *= 1.0 + fadeDistance;\n \n worldPosition = modelMatrix * vec4(localPosition, 1.0);\n if (followCamera) {\n worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);\n localPosition = (inverse(modelMatrix) * worldPosition).xyz;\n }\n\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n }\n ","\n varying vec3 localPosition;\n varying vec4 worldPosition;\n\n uniform vec3 worldCamProjPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n\n float getGrid(float size, float thickness) {\n vec2 r = localPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1.0 - thickness;\n return 1.0 - min(line, 1.0);\n }\n\n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n\n float dist = distance(worldCamProjPosition, worldPosition.xyz);\n float d = 1.0 - min(dist / fadeDistance, 1.0);\n vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));\n\n gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }\n "),$t=T.forwardRef((({args:t,cellColor:r="#000000",sectionColor:n="#2080ff",cellSize:a=.5,sectionSize:s=1,followCamera:l=!1,infiniteGrid:c=!1,fadeDistance:u=100,fadeStrength:m=1,cellThickness:d=.5,sectionThickness:f=1,side:p=P.BackSide,...h},x)=>{o.extend({GridMaterial:qt});const y=T.useRef(null),v=new P.Plane,g=new P.Vector3(0,1,0),z=new P.Vector3(0,0,0);o.useFrame((e=>{v.setFromNormalAndCoplanarPoint(g,z).applyMatrix4(y.current.matrixWorld);const t=y.current.material,r=t.uniforms.worldCamProjPosition,n=t.uniforms.worldPlanePosition;v.projectPoint(e.camera.position,r.value),n.value.set(0,0,0).applyMatrix4(y.current.matrixWorld)}));const w={cellSize:a,sectionSize:s,cellColor:r,sectionColor:n,cellThickness:d,sectionThickness:f},b={fadeDistance:u,fadeStrength:m,infiniteGrid:c,followCamera:l};return T.createElement("mesh",e({ref:i([y,x]),frustumCulled:!1},h),T.createElement("gridMaterial",e({transparent:!0,"extensions-derivatives":!0,side:p},w,b)),T.createElement("planeGeometry",{args:t}))}));function Xt(e,{path:t}){const[r]=o.useLoader(n.CubeTextureLoader,[e],(e=>e.setPath(t)));return r}function Yt(e){return o.useLoader(m.FBXLoader,e)}Xt.preload=(e,{path:t})=>o.useLoader.preload(n.CubeTextureLoader,[e],(e=>e.setPath(t))),Yt.preload=e=>o.useLoader.preload(m.FBXLoader,e),Yt.clear=e=>o.useLoader.clear(m.FBXLoader,e);const Kt="https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master";function Zt(e,r=`${Kt}/basis/`){const n=o.useThree((e=>e.gl)),a=o.useLoader(m.KTX2Loader,ye(e)?Object.values(e):e,(e=>{e.detectSupport(n),e.setTranscoderPath(r)}));if(t.useEffect((()=>{(Array.isArray(a)?a:[a]).forEach(n.initTexture)}),[n,a]),ye(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:a[t.indexOf(e)]}))),r}return a}function Qt(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}Zt.preload=(e,t=`${Kt}/basis/`)=>o.useLoader.preload(m.KTX2Loader,e,(e=>{e.setTranscoderPath(t)})),Zt.clear=e=>o.useLoader.clear(m.KTX2Loader,e);function Jt(e,t,...r){const n=T.useRef(),a=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>{let o;if(e&&null!=e&&e.current&&t&&(n.current=o=new t(e.current,...r)),o)return o.traverse((e=>e.raycast=()=>null)),a.add(o),()=>{n.current=void 0,a.remove(o),null==o.dispose||o.dispose()}}),[a,t,e,...r]),o.useFrame((()=>{var e;null==(e=n.current)||null==e.update||e.update()})),n}const er=e=>e.isMesh;const tr=T.forwardRef((({enabled:t=!0,firstHitOnly:r=!1,children:a,strategy:i=b.SAH,verbose:s=!1,setBoundingBox:l=!0,maxDepth:c=40,maxLeafTris:u=10,...m},d)=>{const f=T.useRef(null),p=o.useThree((e=>e.raycaster));return T.useImperativeHandle(d,(()=>f.current),[]),T.useEffect((()=>{if(t){const e={strategy:i,verbose:s,setBoundingBox:l,maxDepth:c,maxLeafTris:u},t=f.current;return p.firstHitOnly=r,t.traverse((t=>{er(t)&&!t.geometry.boundsTree&&t.raycast===n.Mesh.prototype.raycast&&(t.raycast=b.acceleratedRaycast,t.geometry.computeBoundsTree=b.computeBoundsTree,t.geometry.disposeBoundsTree=b.disposeBoundsTree,t.geometry.computeBoundsTree(e))})),()=>{delete p.firstHitOnly,t.traverse((e=>{er(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=n.Mesh.prototype.raycast)}))}}})),T.createElement("group",e({ref:f},m),a)}));function rr(e){const t=T.useRef(null),r=T.useRef(!1),n=T.useRef(!1),a=T.useRef(e);return T.useLayoutEffect((()=>{a.current=e}),[e]),T.useEffect((()=>{const e=t.current;if(e){const t=o.addEffect((()=>(r.current=!1,!0))),i=e.onBeforeRender;e.onBeforeRender=()=>r.current=!0;const s=o.addAfterEffect((()=>(r.current!==n.current&&(null==a.current||a.current(n.current=r.current)),!0)));return()=>{e.onBeforeRender=i,t(),s()}}}),[]),t}const nr="\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n #ifdef BOX_PROJECTED_ENV_MAP\n vWorldPosition = worldPosition.xyz;\n #endif\n#endif\n",or="\n#ifdef BOX_PROJECTED_ENV_MAP\n uniform vec3 envMapSize;\n uniform vec3 envMapPosition;\n varying vec3 vWorldPosition;\n \n vec3 parallaxCorrectNormal( vec3 v, vec3 cubeSize, vec3 cubePos ) {\n vec3 nDir = normalize( v );\n vec3 rbmax = ( .5 * cubeSize + cubePos - vWorldPosition ) / nDir;\n vec3 rbmin = ( -.5 * cubeSize + cubePos - vWorldPosition ) / nDir;\n vec3 rbminmax;\n rbminmax.x = ( nDir.x > 0. ) ? rbmax.x : rbmin.x;\n rbminmax.y = ( nDir.y > 0. ) ? rbmax.y : rbmin.y;\n rbminmax.z = ( nDir.z > 0. ) ? rbmax.z : rbmin.z;\n float correction = min( min( rbminmax.x, rbminmax.y ), rbminmax.z );\n vec3 boxIntersection = vWorldPosition + nDir * correction; \n return boxIntersection - cubePos;\n }\n#endif\n",ar="\n#ifdef BOX_PROJECTED_ENV_MAP\n worldNormal = parallaxCorrectNormal( worldNormal, envMapSize, envMapPosition );\n#endif\n",ir="\n#ifdef BOX_PROJECTED_ENV_MAP\n reflectVec = parallaxCorrectNormal( reflectVec, envMapSize, envMapPosition );\n#endif\n";const sr=new P.Box3,lr=new P.Vector3;const cr=e=>Math.sqrt(1-Math.pow(e-1,2));class ur{constructor({size:e=256,maxAge:t=750,radius:r=.3,intensity:n=.2,interpolate:o=0,smoothing:a=0,minForce:i=.3,blend:s="screen",ease:l=cr}={}){this.size=e,this.maxAge=t,this.radius=r,this.intensity=n,this.ease=l,this.interpolate=o,this.smoothing=a,this.minForce=i,this.blend=s,this.trail=[],this.force=0,this.initTexture()}initTexture(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=this.size,this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height),this.texture=new n.Texture(this.canvas),this.canvas.id="touchTexture",this.canvas.style.width=this.canvas.style.height=`${this.canvas.width}px`}update(e){this.clear(),this.trail.forEach(((t,r)=>{t.age+=1e3*e,t.age>this.maxAge&&this.trail.splice(r,1)})),this.trail.length||(this.force=0),this.trail.forEach((e=>{this.drawTouch(e)})),this.texture.needsUpdate=!0}clear(){this.ctx.globalCompositeOperation="source-over",this.ctx.fillStyle="black",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}addTouch(e){const t=this.trail[this.trail.length-1];if(t){const r=t.x-e.x,n=t.y-e.y,o=r*r+n*n,a=Math.max(this.minForce,Math.min(1e4*o,1));if(this.force=function(e,t,r=.9){return t*r+e*(1-r)}(a,this.force,this.smoothing),this.interpolate){const e=Math.ceil(o/Math.pow(.5*this.radius/this.interpolate,2));if(e>1)for(let o=1;o<e;o++)this.trail.push({x:t.x-r/e*o,y:t.y-n/e*o,age:0,force:a})}}this.trail.push({x:e.x,y:e.y,age:0,force:this.force})}drawTouch(e){const t={x:e.x*this.size,y:(1-e.y)*this.size};let r=1;r=e.age<.3*this.maxAge?this.ease(e.age/(.3*this.maxAge)):this.ease(1-(e.age-.3*this.maxAge)/(.7*this.maxAge)),r*=e.force,this.ctx.globalCompositeOperation=this.blend;const n=this.size*this.radius*r,o=this.ctx.createRadialGradient(t.x,t.y,Math.max(0,.25*n),t.x,t.y,Math.max(0,n));o.addColorStop(0,`rgba(255, 255, 255, ${this.intensity})`),o.addColorStop(1,"rgba(0, 0, 0, 0.0)"),this.ctx.beginPath(),this.ctx.fillStyle=o,this.ctx.arc(t.x,t.y,Math.max(0,n),0,2*Math.PI),this.ctx.fill()}}const mr=T.forwardRef((function({children:t,disable:r,disableX:o,disableY:a,disableZ:i,left:s,right:l,top:c,bottom:u,front:m,back:d,onCentered:f,precise:p=!0,cacheKey:h=0,...x},y){const v=T.useRef(null),g=T.useRef(null),z=T.useRef(null);return T.useLayoutEffect((()=>{g.current.matrixWorld.identity();const e=(new n.Box3).setFromObject(z.current,p),t=new n.Vector3,h=new n.Sphere,x=e.max.x-e.min.x,y=e.max.y-e.min.y,w=e.max.z-e.min.z;e.getCenter(t),e.getBoundingSphere(h);const b=c?y/2:u?-y/2:0,E=s?-x/2:l?x/2:0,M=m?w/2:d?-w/2:0;g.current.position.set(r||o?0:-t.x+E,r||a?0:-t.y+b,r||i?0:-t.z+M),void 0!==f&&f({parent:v.current.parent,container:v.current,width:x,height:y,depth:w,boundingBox:e,boundingSphere:h,center:t,verticalAlignment:b,horizontalAlignment:E,depthAlignment:M})}),[h,f,c,s,m,r,o,a,i,p,l,u,d]),T.useImperativeHandle(y,(()=>v.current),[]),T.createElement("group",e({ref:v},x),T.createElement("group",{ref:g},T.createElement("group",{ref:z},t)))})),dr=T.forwardRef((({font:e,color:t="#cbcbcb",bevelSize:r=.04,debug:n=!1,children:o,...a},i)=>{const[s,l]=T.useState(0),c=T.useCallback(((e=1)=>l(s+e)),[s]),u=T.useCallback(((e=1)=>l(s-e)),[s]),m=T.useMemo((()=>({incr:c,decr:u})),[c,u]);return T.useImperativeHandle(i,(()=>m),[m]),T.createElement("group",a,T.createElement(T.Suspense,{fallback:null},T.createElement(mr,{top:!0,cacheKey:JSON.stringify({counter:s,font:e})},T.createElement(fe,{bevelEnabled:!0,bevelSize:r,font:e},n?T.createElement("meshNormalMaterial",{wireframe:!0}):T.createElement("meshStandardMaterial",{color:t}),s))),o)})),fr=T.forwardRef((({children:e,curve:t},r)=>{const[n]=T.useState((()=>new P.Scene)),[a,i]=T.useState(),s=T.useRef();return T.useEffect((()=>{s.current=new m.Flow(n.children[0]),i(s.current.object3D)}),[e]),T.useEffect((()=>{var e;t&&(null==(e=s.current)||e.updateCurve(0,t))}),[t]),T.useImperativeHandle(r,(()=>({moveAlongCurve:e=>{var t;null==(t=s.current)||t.moveAlongCurve(e)}}))),T.createElement(T.Fragment,null,o.createPortal(e,n),a&&T.createElement("primitive",{object:a}))}));class pr extends n.MeshPhysicalMaterial{constructor(e={}){super(e),this.setValues(e),this._time={value:0},this._distort={value:.4},this._radius={value:1}}onBeforeCompile(e){e.uniforms.time=this._time,e.uniforms.radius=this._radius,e.uniforms.distort=this._distort,e.vertexShader=`\n uniform float time;\n uniform float radius;\n uniform float distort;\n #define GLSLIFY 1\nvec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 permute(vec4 x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float snoise(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}\n ${e.vertexShader}\n `,e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","\n float updateTime = time / 50.0;\n float noise = snoise(vec3(position / 2.0 + updateTime * 5.0));\n vec3 transformed = vec3(position * (noise * pow(distort, 2.0) + radius));\n ")}get time(){return this._time.value}set time(e){this._time.value=e}get distort(){return this._distort.value}set distort(e){this._distort.value=e}get radius(){return this._radius.value}set radius(e){this._radius.value=e}}const hr=T.forwardRef((({speed:t=1,...r},n)=>{const[a]=T.useState((()=>new pr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),T.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class xr extends n.MeshStandardMaterial{constructor(e={}){super(e),this.setValues(e),this._time={value:0},this._factor={value:1}}onBeforeCompile(e){e.uniforms.time=this._time,e.uniforms.factor=this._factor,e.vertexShader=`\n uniform float time;\n uniform float factor;\n ${e.vertexShader}\n `,e.vertexShader=e.vertexShader.replace("#include <begin_vertex>","float theta = sin( time + position.y ) / 2.0 * factor;\n float c = cos( theta );\n float s = sin( theta );\n mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );\n vec3 transformed = vec3( position ) * m;\n vNormal = vNormal * m;")}get time(){return this._time.value}set time(e){this._time.value=e}get factor(){return this._factor.value}set factor(e){this._factor.value=e}}const yr=T.forwardRef((({speed:t=1,...r},n)=>{const[a]=T.useState((()=>new xr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),T.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class vr extends n.ShaderMaterial{constructor(e=new n.Vector2){super({uniforms:{inputBuffer:new n.Uniform(null),depthBuffer:new n.Uniform(null),resolution:new n.Uniform(new n.Vector2),texelSize:new n.Uniform(new n.Vector2),halfTexelSize:new n.Uniform(new n.Vector2),kernel:new n.Uniform(0),scale:new n.Uniform(1),cameraNear:new n.Uniform(0),cameraFar:new n.Uniform(1),minDepthThreshold:new n.Uniform(0),maxDepthThreshold:new n.Uniform(1),depthScale:new n.Uniform(0),depthToBlurRatioBias:new n.Uniform(.25)},fragmentShader:"#include <common>\n #include <dithering_pars_fragment> \n uniform sampler2D inputBuffer;\n uniform sampler2D depthBuffer;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n float depthFactor = 0.0;\n \n #ifdef USE_DEPTH\n vec4 depth = texture2D(depthBuffer, vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0, min(1.0, depthFactor + 0.25));\n #endif\n \n vec4 sum = texture2D(inputBuffer, mix(vUv0, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv1, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv2, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv3, vUv, depthFactor));\n gl_FragColor = sum * 0.25 ;\n\n #include <dithering_fragment>\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }",vertexShader:"uniform vec2 texelSize;\n uniform vec2 halfTexelSize;\n uniform float kernel;\n uniform float scale;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n vec2 uv = position.xy * 0.5 + 0.5;\n vUv = uv;\n\n vec2 dUv = (texelSize * vec2(kernel) + halfTexelSize) * scale;\n vUv0 = vec2(uv.x - dUv.x, uv.y + dUv.y);\n vUv1 = vec2(uv.x + dUv.x, uv.y + dUv.y);\n vUv2 = vec2(uv.x + dUv.x, uv.y - dUv.y);\n vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y);\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n }",blending:n.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setTexelSize(e.x,e.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}setResolution(e){this.uniforms.resolution.value.copy(e)}}class gr{constructor({gl:e,resolution:t,width:r=500,height:o=500,minDepthThreshold:a=0,maxDepthThreshold:i=1,depthScale:s=0,depthToBlurRatioBias:l=.25}){this.renderToScreen=!1,this.renderTargetA=new n.WebGLRenderTarget(t,t,{minFilter:n.LinearFilter,magFilter:n.LinearFilter,stencilBuffer:!1,depthBuffer:!1,type:n.HalfFloatType}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new vr,this.convolutionMaterial.setTexelSize(1/r,1/o),this.convolutionMaterial.setResolution(new n.Vector2(r,o)),this.scene=new n.Scene,this.camera=new n.Camera,this.convolutionMaterial.uniforms.minDepthThreshold.value=a,this.convolutionMaterial.uniforms.maxDepthThreshold.value=i,this.convolutionMaterial.uniforms.depthScale.value=s,this.convolutionMaterial.uniforms.depthToBlurRatioBias.value=l,this.convolutionMaterial.defines.USE_DEPTH=s>0;const c=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),u=new Float32Array([0,0,2,0,0,2]),m=new n.BufferGeometry;m.setAttribute("position",new n.BufferAttribute(c,3)),m.setAttribute("uv",new n.BufferAttribute(u,2)),this.screen=new n.Mesh(m,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(e,t,r){const n=this.scene,o=this.camera,a=this.renderTargetA,i=this.renderTargetB;let s=this.convolutionMaterial,l=s.uniforms;l.depthBuffer.value=t.depthTexture;const c=s.kernel;let u,m,d,f=t;for(m=0,d=c.length-1;m<d;++m)u=0==(1&m)?a:i,l.kernel.value=c[m],l.inputBuffer.value=f.texture,e.setRenderTarget(u),e.render(n,o),f=u;l.kernel.value=c[m],l.inputBuffer.value=f.texture,e.setRenderTarget(this.renderToScreen?null:r),e.render(n,o)}}let zr=class extends n.MeshStandardMaterial{constructor(e={}){super(e),this._tDepth={value:null},this._distortionMap={value:null},this._tDiffuse={value:null},this._tDiffuseBlur={value:null},this._textureMatrix={value:null},this._hasBlur={value:!1},this._mirror={value:0},this._mixBlur={value:0},this._blurStrength={value:.5},this._minDepthThreshold={value:.9},this._maxDepthThreshold={value:1},this._depthScale={value:0},this._depthToBlurRatioBias={value:.25},this._distortion={value:1},this._mixContrast={value:1},this.setValues(e)}onBeforeCompile(e){var t;null!=(t=e.defines)&&t.USE_UV||(e.defines.USE_UV=""),e.uniforms.hasBlur=this._hasBlur,e.uniforms.tDiffuse=this._tDiffuse,e.uniforms.tDepth=this._tDepth,e.uniforms.distortionMap=this._distortionMap,e.uniforms.tDiffuseBlur=this._tDiffuseBlur,e.uniforms.textureMatrix=this._textureMatrix,e.uniforms.mirror=this._mirror,e.uniforms.mixBlur=this._mixBlur,e.uniforms.mixStrength=this._blurStrength,e.uniforms.minDepthThreshold=this._minDepthThreshold,e.uniforms.maxDepthThreshold=this._maxDepthThreshold,e.uniforms.depthScale=this._depthScale,e.uniforms.depthToBlurRatioBias=this._depthToBlurRatioBias,e.uniforms.distortion=this._distortion,e.uniforms.mixContrast=this._mixContrast,e.vertexShader=`\n uniform mat4 textureMatrix;\n varying vec4 my_vUv;\n ${e.vertexShader}`,e.vertexShader=e.vertexShader.replace("#include <project_vertex>","#include <project_vertex>\n my_vUv = textureMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );"),e.fragmentShader=`\n uniform sampler2D tDiffuse;\n uniform sampler2D tDiffuseBlur;\n uniform sampler2D tDepth;\n uniform sampler2D distortionMap;\n uniform float distortion;\n uniform float cameraNear;\n\t\t\t uniform float cameraFar;\n uniform bool hasBlur;\n uniform float mixBlur;\n uniform float mirror;\n uniform float mixStrength;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float mixContrast;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec4 my_vUv;\n ${e.fragmentShader}`,e.fragmentShader=e.fragmentShader.replace("#include <emissivemap_fragment>","#include <emissivemap_fragment>\n\n float distortionFactor = 0.0;\n #ifdef USE_DISTORTION\n distortionFactor = texture2D(distortionMap, vUv).r * distortion;\n #endif\n\n vec4 new_vUv = my_vUv;\n new_vUv.x += distortionFactor;\n new_vUv.y += distortionFactor;\n\n vec4 base = texture2DProj(tDiffuse, new_vUv);\n vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);\n\n vec4 merge = base;\n\n #ifdef USE_NORMALMAP\n vec2 normal_uv = vec2(0.0);\n vec4 normalColor = texture2D(normalMap, vUv * normalScale);\n vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );\n vec3 coord = new_vUv.xyz / new_vUv.w;\n normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;\n vec4 base_normal = texture2D(tDiffuse, normal_uv);\n vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);\n merge = base_normal;\n blur = blur_normal;\n #endif\n\n float depthFactor = 0.0001;\n float blurFactor = 0.0;\n\n #ifdef USE_DEPTH\n vec4 depth = texture2DProj(tDepth, new_vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0001, min(1.0, depthFactor));\n\n #ifdef USE_BLUR\n blur = blur * min(1.0, depthFactor + depthToBlurRatioBias);\n merge = merge * min(1.0, depthFactor + 0.5);\n #else\n merge = merge * depthFactor;\n #endif\n\n #endif\n\n float reflectorRoughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv );\n reflectorRoughnessFactor *= reflectorTexelRoughness.g;\n #endif\n\n #ifdef USE_BLUR\n blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor);\n merge = mix(merge, blur, blurFactor);\n #endif\n\n vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0);\n newMerge.r = (merge.r - 0.5) * mixContrast + 0.5;\n newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;\n newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;\n\n diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);\n ")}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(e){this._tDiffuse.value=e}get tDepth(){return this._tDepth.value}set tDepth(e){this._tDepth.value=e}get distortionMap(){return this._distortionMap.value}set distortionMap(e){this._distortionMap.value=e}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(e){this._tDiffuseBlur.value=e}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(e){this._textureMatrix.value=e}get hasBlur(){return this._hasBlur.value}set hasBlur(e){this._hasBlur.value=e}get mirror(){return this._mirror.value}set mirror(e){this._mirror.value=e}get mixBlur(){return this._mixBlur.value}set mixBlur(e){this._mixBlur.value=e}get mixStrength(){return this._blurStrength.value}set mixStrength(e){this._blurStrength.value=e}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(e){this._minDepthThreshold.value=e}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(e){this._maxDepthThreshold.value=e}get depthScale(){return this._depthScale.value}set depthScale(e){this._depthScale.value=e}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(e){this._depthToBlurRatioBias.value=e}get distortion(){return this._distortion.value}set distortion(e){this._distortion.value=e}get mixContrast(){return this._mixContrast.value}set mixContrast(e){this._mixContrast.value=e}};o.extend({MeshReflectorMaterialImpl:zr});const wr=T.forwardRef((({mixBlur:t=0,mixStrength:r=1,resolution:a=256,blur:s=[0,0],minDepthThreshold:l=.9,maxDepthThreshold:c=1,depthScale:u=0,depthToBlurRatioBias:m=.25,mirror:d=0,distortion:f=1,mixContrast:p=1,distortionMap:h,reflectorOffset:x=0,...y},v)=>{const g=o.useThree((({gl:e})=>e)),z=o.useThree((({camera:e})=>e)),w=o.useThree((({scene:e})=>e)),b=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,E=T.useRef(null),[M]=T.useState((()=>new n.Plane)),[S]=T.useState((()=>new n.Vector3)),[C]=T.useState((()=>new n.Vector3)),[P]=T.useState((()=>new n.Vector3)),[R]=T.useState((()=>new n.Matrix4)),[D]=T.useState((()=>new n.Vector3(0,0,-1))),[F]=T.useState((()=>new n.Vector4)),[k]=T.useState((()=>new n.Vector3)),[_]=T.useState((()=>new n.Vector3)),[L]=T.useState((()=>new n.Vector4)),[A]=T.useState((()=>new n.Matrix4)),[B]=T.useState((()=>new n.PerspectiveCamera)),U=T.useCallback((()=>{var e;const t=E.current.parent||(null==(e=E.current)?void 0:e.__r3f.parent);if(!t)return;if(C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(z.matrixWorld),R.extractRotation(t.matrixWorld),S.set(0,0,1),S.applyMatrix4(R),C.addScaledVector(S,x),k.subVectors(C,P),k.dot(S)>0)return;k.reflect(S).negate(),k.add(C),R.extractRotation(z.matrixWorld),D.set(0,0,-1),D.applyMatrix4(R),D.add(P),_.subVectors(C,D),_.reflect(S).negate(),_.add(C),B.position.copy(k),B.up.set(0,1,0),B.up.applyMatrix4(R),B.up.reflect(S),B.lookAt(_),B.far=z.far,B.updateMatrixWorld(),B.projectionMatrix.copy(z.projectionMatrix),A.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),A.multiply(B.projectionMatrix),A.multiply(B.matrixWorldInverse),A.multiply(t.matrixWorld),M.setFromNormalAndCoplanarPoint(S,C),M.applyMatrix4(B.matrixWorldInverse),F.set(M.normal.x,M.normal.y,M.normal.z,M.constant);const r=B.projectionMatrix;L.x=(Math.sign(F.x)+r.elements[8])/r.elements[0],L.y=(Math.sign(F.y)+r.elements[9])/r.elements[5],L.z=-1,L.w=(1+r.elements[10])/r.elements[14],F.multiplyScalar(2/F.dot(L)),r.elements[2]=F.x,r.elements[6]=F.y,r.elements[10]=F.z+1,r.elements[14]=F.w}),[z,x]),[O,N,I,V]=T.useMemo((()=>{const e={minFilter:n.LinearFilter,magFilter:n.LinearFilter,type:n.HalfFloatType},o=new n.WebGLRenderTarget(a,a,e);o.depthBuffer=!0,o.depthTexture=new n.DepthTexture(a,a),o.depthTexture.format=n.DepthFormat,o.depthTexture.type=n.UnsignedShortType;const i=new n.WebGLRenderTarget(a,a,e);return[o,i,new gr({gl:g,resolution:a,width:s[0],height:s[1],minDepthThreshold:l,maxDepthThreshold:c,depthScale:u,depthToBlurRatioBias:m}),{mirror:d,textureMatrix:A,mixBlur:t,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:i.texture,hasBlur:b,mixStrength:r,minDepthThreshold:l,maxDepthThreshold:c,depthScale:u,depthToBlurRatioBias:m,distortion:f,distortionMap:h,mixContrast:p,"defines-USE_BLUR":b?"":void 0,"defines-USE_DEPTH":u>0?"":void 0,"defines-USE_DISTORTION":h?"":void 0}]}),[g,s,A,a,d,b,t,r,l,c,u,m,f,h,p]);return o.useFrame((()=>{var e;const t=E.current.parent||(null==(e=E.current)?void 0:e.__r3f.parent);if(!t)return;t.visible=!1;const r=g.xr.enabled,n=g.shadowMap.autoUpdate;U(),g.xr.enabled=!1,g.shadowMap.autoUpdate=!1,g.setRenderTarget(O),g.state.buffers.depth.setMask(!0),g.autoClear||g.clear(),g.render(w,B),b&&I.render(g,O,N),g.xr.enabled=r,g.shadowMap.autoUpdate=n,t.visible=!0,g.setRenderTarget(null)})),T.createElement("meshReflectorMaterialImpl",e({attach:"material",key:"key"+V["defines-USE_BLUR"]+V["defines-USE_DEPTH"]+V["defines-USE_DISTORTION"],ref:i([E,v])},V,y))})),br=xe({envMap:null,bounces:3,ior:2.4,correctMips:!0,aberrationStrength:.01,fresnel:0,bvh:new b.MeshBVHUniformStruct,color:new P.Color("white"),resolution:new P.Vector2,viewMatrixInverse:new P.Matrix4,projectionMatrixInverse:new P.Matrix4},"\n uniform mat4 viewMatrixInverse;\n\n varying vec3 vWorldPosition; \n varying vec3 vNormal;\n varying mat4 vModelMatrixInverse;\n\n #ifdef USE_INSTANCING_COLOR\n varying vec3 vInstanceColor;\n #endif\n\n void main() { \n vec4 transformedNormal = vec4(normal, 0.0);\n vec4 transformedPosition = vec4(position, 1.0);\n #ifdef USE_INSTANCING\n transformedNormal = instanceMatrix * transformedNormal;\n transformedPosition = instanceMatrix * transformedPosition;\n #endif\n\n #ifdef USE_INSTANCING\n vModelMatrixInverse = inverse(modelMatrix * instanceMatrix);\n #else\n vModelMatrixInverse = inverse(modelMatrix);\n #endif\n\n #ifdef USE_INSTANCING_COLOR\n vInstanceColor = instanceColor.rgb;\n #endif\n\n vWorldPosition = (modelMatrix * transformedPosition).xyz;\n vNormal = normalize((viewMatrixInverse * vec4(normalMatrix * transformedNormal.xyz, 0.0)).xyz);\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * transformedPosition;\n }",`\n #define ENVMAP_TYPE_CUBE_UV\n precision highp isampler2D;\n precision highp usampler2D;\n varying vec3 vWorldPosition;\n varying vec3 vNormal;\n varying mat4 vModelMatrixInverse;\n\n #ifdef USE_INSTANCING_COLOR\n varying vec3 vInstanceColor;\n #endif\n \n #ifdef ENVMAP_TYPE_CUBEM\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n \n uniform float bounces;\n ${b.shaderStructs}\n ${b.shaderIntersectFunction}\n uniform BVH bvh;\n uniform float ior;\n uniform bool correctMips;\n uniform vec2 resolution;\n uniform float fresnel;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrixInverse;\n uniform mat4 viewMatrixInverse;\n uniform float aberrationStrength;\n uniform vec3 color;\n \n float fresnelFunc(vec3 viewDirection, vec3 worldNormal) {\n return pow( 1.0 + dot( viewDirection, worldNormal), 10.0 );\n }\n \n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 normal, float ior, mat4 modelMatrixInverse) {\n vec3 rayOrigin = ro;\n vec3 rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = vWorldPosition + rayDirection * 0.001;\n rayOrigin = (modelMatrixInverse * vec4(rayOrigin, 1.0)).xyz;\n rayDirection = normalize((modelMatrixInverse * vec4(rayDirection, 0.0)).xyz);\n for(float i = 0.0; i < bounces; i++) {\n uvec4 faceIndices = uvec4( 0u );\n vec3 faceNormal = vec3( 0.0, 0.0, 1.0 );\n vec3 barycoord = vec3( 0.0 );\n float side = 1.0;\n float dist = 0.0;\n bvhIntersectFirstHit( bvh, rayOrigin, rayDirection, faceIndices, faceNormal, barycoord, side, dist );\n vec3 hitPos = rayOrigin + rayDirection * max(dist - 0.001, 0.0); \n vec3 tempDir = refract(rayDirection, faceNormal, ior);\n if (length(tempDir) != 0.0) {\n rayDirection = tempDir;\n break;\n }\n rayDirection = reflect(rayDirection, faceNormal);\n rayOrigin = hitPos + rayDirection * 0.01;\n }\n rayDirection = normalize((modelMatrix * vec4(rayDirection, 0.0)).xyz);\n return rayDirection;\n }\n \n #include <common>\n #include <cube_uv_reflection_fragment>\n \n #ifdef ENVMAP_TYPE_CUBEM\n vec4 textureGradient(samplerCube envMap, vec3 rayDirection, vec3 directionCamPerfect) {\n return textureGrad(envMap, rayDirection, dFdx(correctMips ? directionCamPerfect: rayDirection), dFdy(correctMips ? directionCamPerfect: rayDirection));\n }\n #else\n vec4 textureGradient(sampler2D envMap, vec3 rayDirection, vec3 directionCamPerfect) {\n vec2 uvv = equirectUv( rayDirection );\n vec2 smoothUv = equirectUv( directionCamPerfect );\n return textureGrad(envMap, uvv, dFdx(correctMips ? smoothUv : uvv), dFdy(correctMips ? smoothUv : uvv));\n }\n #endif\n \n void main() {\n vec2 uv = gl_FragCoord.xy / resolution;\n vec3 directionCamPerfect = (projectionMatrixInverse * vec4(uv * 2.0 - 1.0, 0.0, 1.0)).xyz;\n directionCamPerfect = (viewMatrixInverse * vec4(directionCamPerfect, 0.0)).xyz;\n directionCamPerfect = normalize(directionCamPerfect);\n vec3 normal = vNormal;\n vec3 rayOrigin = cameraPosition;\n vec3 rayDirection = normalize(vWorldPosition - cameraPosition);\n vec3 finalColor;\n #ifdef CHROMATIC_ABERRATIONS\n vec3 rayDirectionG = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse);\n #ifdef FAST_CHROMA \n vec3 rayDirectionR = normalize(rayDirectionG + 1.0 * vec3(aberrationStrength / 2.0));\n vec3 rayDirectionB = normalize(rayDirectionG - 1.0 * vec3(aberrationStrength / 2.0));\n #else\n vec3 rayDirectionR = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 - aberrationStrength), 1.0), vModelMatrixInverse);\n vec3 rayDirectionB = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior * (1.0 + aberrationStrength), 1.0), vModelMatrixInverse);\n #endif\n float finalColorR = textureGradient(envMap, rayDirectionR, directionCamPerfect).r;\n float finalColorG = textureGradient(envMap, rayDirectionG, directionCamPerfect).g;\n float finalColorB = textureGradient(envMap, rayDirectionB, directionCamPerfect).b;\n finalColor = vec3(finalColorR, finalColorG, finalColorB);\n #else\n rayDirection = totalInternalReflection(rayOrigin, rayDirection, normal, max(ior, 1.0), vModelMatrixInverse);\n finalColor = textureGradient(envMap, rayDirection, directionCamPerfect).rgb; \n #endif\n\n finalColor *= color;\n #ifdef USE_INSTANCING_COLOR\n finalColor *= vInstanceColor;\n #endif\n\n vec3 viewDirection = normalize(vWorldPosition - cameraPosition);\n float nFresnel = fresnelFunc(viewDirection, normal) * fresnel;\n gl_FragColor = vec4(mix(finalColor, vec3(1.0), nFresnel), 1.0); \n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }`);const Er=xe({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class Mr extends P.MeshPhysicalMaterial{constructor(e=6,t=!1){super(),this.uniforms={chromaticAberration:{value:.05},transmission:{value:0},_transmission:{value:1},transmissionMap:{value:null},roughness:{value:0},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:1/0},attenuationColor:{value:new P.Color("white")},anisotropicBlur:{value:.1},time:{value:0},distortion:{value:0},distortionScale:{value:.5},temporalDistortion:{value:0},buffer:{value:null}},this.onBeforeCompile=r=>{r.uniforms={...r.uniforms,...this.uniforms},t?r.defines.USE_SAMPLER="":r.defines.USE_TRANSMISSION="",r.fragmentShader="\n uniform float chromaticAberration; \n uniform float anisotropicBlur; \n uniform float time;\n uniform float distortion;\n uniform float distortionScale;\n uniform float temporalDistortion;\n uniform sampler2D buffer;\n\n vec3 random3(vec3 c) {\n float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n vec3 r;\n r.z = fract(512.0*j);\n j *= .125;\n r.x = fract(512.0*j);\n j *= .125;\n r.y = fract(512.0*j);\n return r-0.5;\n }\n\n float seed = 0.0;\n uint hash( uint x ) {\n x += ( x << 10u );\n x ^= ( x >> 6u );\n x += ( x << 3u );\n x ^= ( x >> 11u );\n x += ( x << 15u );\n return x;\n }\n\n // Compound versions of the hashing algorithm I whipped together.\n uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }\n uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }\n uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }\n\n // Construct a float with half-open range [0:1] using low 23 bits.\n // All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.\n float floatConstruct( uint m ) {\n const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask\n const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32\n m &= ieeeMantissa; // Keep only mantissa bits (fractional part)\n m |= ieeeOne; // Add fractional part to 1.0\n float f = uintBitsToFloat( m ); // Range [1:2]\n return f - 1.0; // Range [0:1]\n }\n\n // Pseudo-random value in half-open range [0:1].\n float random( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }\n float random( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float random( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float random( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n\n float rand() {\n float result = random(vec3(gl_FragCoord.xy, seed));\n seed += 1.0;\n return result;\n }\n\n const float F3 = 0.3333333;\n const float G3 = 0.1666667;\n\n float snoise(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n vec3 x = p - s + dot(s, vec3(G3));\n vec3 e = step(vec3(0.0), x - x.yzx);\n vec3 i1 = e*(1.0 - e.zxy);\n vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n vec3 x1 = x - i1 + G3;\n vec3 x2 = x - i2 + 2.0*G3;\n vec3 x3 = x - 1.0 + 3.0*G3;\n vec4 w, d;\n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n w = max(0.6 - w, 0.0);\n d.x = dot(random3(s), x);\n d.y = dot(random3(s + i1), x1);\n d.z = dot(random3(s + i2), x2);\n d.w = dot(random3(s + 1.0), x3);\n w *= w;\n w *= w;\n d *= w;\n return dot(d, vec4(52.0));\n }\n\n float snoiseFractal(vec3 m) {\n return 0.5333333* snoise(m)\n +0.2666667* snoise(2.0*m)\n +0.1333333* snoise(4.0*m)\n +0.0666667* snoise(8.0*m);\n }\n"+r.fragmentShader,r.fragmentShader=r.fragmentShader.replace("#include <transmission_pars_fragment>","\n #ifdef USE_TRANSMISSION\n // Transmission code is based on glTF-Sampler-Viewer\n // https://github.com/KhronosGroup/glTF-Sample-Viewer\n uniform float _transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n // Direction of refracted light.\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n // Compute rotation-independant scaling of the model matrix.\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n // The thickness is specified in local space.\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n // an IOR of 1.5 results in the default amount of microfacet refraction.\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); \n #ifdef USE_SAMPLER\n #ifdef texture2DLodEXT\n return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #else\n return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #endif\n #else\n return texture2D(buffer, fragCoord.xy);\n #endif\n }\n vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n // Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.\n return radiance;\n } else {\n // Compute light attenuation using Beer's law.\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law\n return transmittance * radiance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n // Sample framebuffer to get pixel the refracted ray hits.\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n // Get the specular component.\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n }\n #endif\n"),r.fragmentShader=r.fragmentShader.replace("#include <transmission_fragment>",` \n // Improve the refraction to use the world pos\n material.transmission = _transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vUv ).g;\n #endif\n \n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec3 transmission = vec3(0.0);\n float transmissionR, transmissionB, transmissionG;\n float randomCoords = rand();\n float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur);\n vec3 distortionNormal = vec3(0.0);\n vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;\n if (distortion > 0.0) {\n distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));\n }\n for (float i = 0.0; i < ${e}.0; i ++) {\n vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand() - 0.5, rand() - 0.5, rand() - 0.5)) * pow(rand(), 0.33) + distortionNormal);\n transmissionR = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).r;\n transmissionG = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${e})) , material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).g;\n transmissionB = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${e})), material.thickness + thickness_smear * (i + randomCoords) / float(${e}),\n material.attenuationColor, material.attenuationDistance\n ).b;\n transmission.r += transmissionR;\n transmission.g += transmissionG;\n transmission.b += transmissionB;\n }\n transmission /= ${e}.0;\n totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n`)},Object.keys(this.uniforms).forEach((e=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t})))}}const Sr=T.forwardRef((({buffer:t,transmissionSampler:r=!1,backside:n=!1,side:a=P.FrontSide,transmission:i=1,thickness:s=0,backsideThickness:l=0,samples:c=10,resolution:u,backsideResolution:m,background:d,anisotropy:f,anisotropicBlur:p,...h},x)=>{o.extend({MeshTransmissionMaterial:Mr});const y=T.useRef(null),[v]=T.useState((()=>new Er)),g=je(m||u),z=je(u);let w,b,E;return o.useFrame((e=>{y.current.time=e.clock.getElapsedTime(),y.current.buffer!==z.texture||r||(E=y.current.__r3f.parent,E&&(b=e.gl.toneMapping,w=e.scene.background,e.gl.toneMapping=P.NoToneMapping,d&&(e.scene.background=d),E.material=v,n&&(e.gl.setRenderTarget(g),e.gl.render(e.scene,e.camera),E.material=y.current,E.material.buffer=g.texture,E.material.thickness=l,E.material.side=P.BackSide),e.gl.setRenderTarget(z),e.gl.render(e.scene,e.camera),E.material.thickness=s,E.material.side=a,E.material.buffer=z.texture,e.scene.background=w,e.gl.setRenderTarget(null),E.material=y.current,e.gl.toneMapping=b))})),T.useImperativeHandle(x,(()=>y.current),[]),T.createElement("meshTransmissionMaterial",e({args:[c,r],ref:y},h,{buffer:t||z.texture,_transmission:i,anisotropicBlur:null!=p?p:f,transmission:r?i:0,thickness:s,side:a}))})),Tr=T.forwardRef(((t,r)=>(o.extend({DiscardMaterialImpl:Er}),T.createElement("discardMaterialImpl",e({ref:r},t)))));class Cr extends P.PointsMaterial{constructor(e){super(e),this.onBeforeCompile=(e,t)=>{const{isWebGL2:r}=t.capabilities;e.fragmentShader=e.fragmentShader.replace("#include <output_fragment>",`\n ${r?"#include <output_fragment>":"#extension GL_OES_standard_derivatives : enable\n#include <output_fragment>"}\n vec2 cxy = 2.0 * gl_PointCoord - 1.0;\n float r = dot(cxy, cxy);\n float delta = fwidth(r); \n float mask = 1.0 - smoothstep(1.0 - delta, 1.0 + delta, r);\n gl_FragColor = vec4(gl_FragColor.rgb, mask * gl_FragColor.a );\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n `)}}}const Pr=T.forwardRef(((t,r)=>{const[n]=T.useState((()=>new Cr(null)));return T.createElement("primitive",e({},t,{object:n,ref:r,attach:"material"}))}));function Rr(e,t,r){t.traverse((t=>{t.material&&(e.properties.remove(t.material),null==t.material.dispose||t.material.dispose())})),e.info.programs.length=0,e.compile(t,r)}function Dr(t,r){const n=t+"Geometry";return T.forwardRef((({args:t,children:o,...a},i)=>{const s=T.useRef(null);return T.useImperativeHandle(i,(()=>s.current)),T.useLayoutEffect((()=>{null==r||r(s.current)})),T.createElement("mesh",e({ref:s},a),T.createElement(n,{attach:"geometry",args:t}),o)}))}const Fr=Dr("box"),kr=Dr("circle"),_r=Dr("cone"),Lr=Dr("cylinder"),Ar=Dr("sphere"),Br=Dr("plane"),Ur=Dr("tube"),Or=Dr("torus"),Nr=Dr("torusKnot"),Ir=Dr("tetrahedron"),Vr=Dr("ring"),jr=Dr("polyhedron"),Wr=Dr("icosahedron"),Gr=Dr("octahedron"),Hr=Dr("dodecahedron"),qr=Dr("extrude"),$r=Dr("lathe"),Xr=Dr("capsule"),Yr=Dr("shape",(({geometry:e})=>{const t=e.attributes.position,r=(new P.Box3).setFromBufferAttribute(t),n=new P.Vector3;r.getSize(n);const o=[];let a=0,i=0,s=0,l=0;for(let e=0;e<t.count;e++)a=t.getX(e),i=t.getY(e),s=(a-r.min.x)/n.x,l=(i-r.min.y)/n.y,o.push(s,l);e.setAttribute("uv",new P.Float32BufferAttribute(o,2))})),Kr=1e-5;const Zr=T.forwardRef((function({args:[t=1,r=1,o=1]=[],radius:a=.05,steps:i=1,smoothness:s=4,creaseAngle:l=.4,children:c,...u},d){const f=T.useMemo((()=>function(e,t,r){const o=new n.Shape,a=r-Kr;return o.absarc(Kr,Kr,Kr,-Math.PI/2,-Math.PI,!0),o.absarc(Kr,t-2*a,Kr,Math.PI,Math.PI/2,!0),o.absarc(e-2*a,t-2*a,Kr,Math.PI/2,0,!0),o.absarc(e-2*a,Kr,Kr,0,-Math.PI/2,!0),o}(t,r,a)),[t,r,a]),p=T.useMemo((()=>({depth:o-2*a,bevelEnabled:!0,bevelSegments:2*s,steps:i,bevelSize:a-Kr,bevelThickness:a,curveSegments:s})),[o,a,s]),h=T.useRef();return T.useLayoutEffect((()=>{h.current&&(h.current.center(),m.toCreasedNormals(h.current,l))}),[f,p]),T.createElement("mesh",e({ref:d},u),T.createElement("extrudeGeometry",{ref:h,args:[f,p]}),c)}));function Qr(){const e=new P.BufferGeometry,t=new Float32Array([-1,-1,3,-1,-1,3]);return e.setAttribute("position",new P.BufferAttribute(t,2)),e}const Jr=T.forwardRef((function({children:t,...r},n){const o=T.useMemo(Qr,[]);return T.createElement("mesh",e({ref:n,geometry:o,frustumCulled:!1},r),t)})),en=T.forwardRef((({children:t,width:r,height:n,depth:o,box3:a,precise:i=!0,...s},l)=>{const c=T.useRef(null),u=T.useRef(null),m=T.useRef(null);return T.useLayoutEffect((()=>{u.current.matrixWorld.identity();let e=a||(new P.Box3).setFromObject(m.current,i);const t=e.max.x-e.min.x,s=e.max.y-e.min.y,l=e.max.z-e.min.z;let c=Math.max(t,s,l);r&&(c=t),n&&(c=s),o&&(c=l),u.current.scale.setScalar(1/c)}),[r,n,o,a,i]),T.useImperativeHandle(l,(()=>c.current),[]),T.createElement("group",e({ref:c},s),T.createElement("group",{ref:u},T.createElement("group",{ref:m},t)))})),tn=e=>e&&e.isOrthographicCamera,rn=e=>e&&e.isBox3,nn=T.createContext(null);function on({children:e,damping:t=6,fit:r,clip:n,observe:a,margin:i=1.2,eps:s=.01,onFit:l}){const c=T.useRef(null),{camera:u,invalidate:m,size:d,controls:f}=o.useThree(),p=f,h=T.useRef(l);function x(e,t){return Math.abs(e.x-t.x)<s&&Math.abs(e.y-t.y)<s&&Math.abs(e.z-t.z)<s}function y(e,t,r,n){e.x=P.MathUtils.damp(e.x,t.x,r,n),e.y=P.MathUtils.damp(e.y,t.y,r,n),e.z=P.MathUtils.damp(e.z,t.z,r,n)}h.current=l;const[v]=T.useState((()=>({animating:!1,focus:new P.Vector3,camera:new P.Vector3,zoom:1}))),[g]=T.useState((()=>({focus:new P.Vector3,camera:new P.Vector3,zoom:1}))),[z]=T.useState((()=>new P.Box3)),w=T.useMemo((()=>{function e(){const e=z.getSize(new P.Vector3),t=z.getCenter(new P.Vector3),r=Math.max(e.x,e.y,e.z),n=tn(u)?4*r:r/(2*Math.atan(Math.PI*u.fov/360)),o=tn(u)?4*r:n/u.aspect,a=i*Math.max(n,o);return{box:z,size:e,center:t,distance:a}}return{getSize:e,refresh(t){if(rn(t))z.copy(t);else{const e=t||c.current;e.updateWorldMatrix(!0,!0),z.setFromObject(e)}if(z.isEmpty()){const e=u.position.length()||10;z.setFromCenterAndSize(new P.Vector3,new P.Vector3(e,e,e))}if("OrthographicTrackballControls"===(null==p?void 0:p.constructor.name)){const{distance:t}=e(),r=u.position.clone().sub(p.target).normalize().multiplyScalar(t),n=p.target.clone().add(r);u.position.copy(n)}return this},clip(){const{distance:t}=e();return p&&(p.maxDistance=10*t),u.near=t/100,u.far=100*t,u.updateProjectionMatrix(),p&&p.update(),m(),this},to({position:r,target:n}){v.camera.copy(u.position);const{center:o}=e();return g.camera.set(...r),n?g.focus.set(...n):g.focus.copy(o),t?v.animating=!0:u.position.set(...r),this},fit(){v.camera.copy(u.position),p&&v.focus.copy(p.target);const{center:r,distance:n}=e(),o=r.clone().sub(u.position).normalize().multiplyScalar(n);if(g.camera.copy(r).sub(o),g.focus.copy(r),tn(u)){v.zoom=u.zoom;let e=0,n=0;const o=[new P.Vector3(z.min.x,z.min.y,z.min.z),new P.Vector3(z.min.x,z.max.y,z.min.z),new P.Vector3(z.min.x,z.min.y,z.max.z),new P.Vector3(z.min.x,z.max.y,z.max.z),new P.Vector3(z.max.x,z.max.y,z.max.z),new P.Vector3(z.max.x,z.max.y,z.min.z),new P.Vector3(z.max.x,z.min.y,z.max.z),new P.Vector3(z.max.x,z.min.y,z.min.z)];r.applyMatrix4(u.matrixWorldInverse);for(const t of o)t.applyMatrix4(u.matrixWorldInverse),e=Math.max(e,Math.abs(t.y-r.y)),n=Math.max(n,Math.abs(t.x-r.x));e*=2,n*=2;const a=(u.top-u.bottom)/e,s=(u.right-u.left)/n;g.zoom=Math.min(a,s)/i,t||(u.zoom=g.zoom,u.updateProjectionMatrix())}return t?v.animating=!0:(u.position.copy(g.camera),u.lookAt(g.focus),p&&(p.target.copy(g.focus),p.update())),h.current&&h.current(this.getSize()),m(),this}}}),[z,u,p,i,t,m]);T.useLayoutEffect((()=>{if(p){const e=()=>v.animating=!1;return p.addEventListener("start",e),()=>p.removeEventListener("start",e)}}),[p]);const b=T.useRef(0);return T.useLayoutEffect((()=>{(a||0==b.current++)&&(w.refresh(),r&&w.fit(),n&&w.clip())}),[d,n,r,a,u,p]),o.useFrame(((e,r)=>{if(v.animating){if(y(v.focus,g.focus,t,r),y(v.camera,g.camera,t,r),v.zoom=P.MathUtils.damp(v.zoom,g.zoom,t,r),u.position.copy(v.camera),tn(u)&&(u.zoom=v.zoom,u.updateProjectionMatrix()),p?(p.target.copy(v.focus),p.update()):u.lookAt(v.focus),m(),tn(u)&&!(Math.abs(v.zoom-g.zoom)<s))return;if(!tn(u)&&!x(v.camera,g.camera))return;if(p&&!x(v.focus,g.focus))return;v.animating=!1}})),T.createElement("group",{ref:c},T.createElement(nn.Provider,{value:w},e))}function an(){return T.useContext(nn)}const sn=T.forwardRef((({intensity:e=1,decay:t,decayRate:r=.65,maxYaw:n=.1,maxPitch:a=.1,maxRoll:i=.1,yawFrequency:s=.1,pitchFrequency:l=.1,rollFrequency:c=.1},u)=>{const d=o.useThree((e=>e.camera)),f=o.useThree((e=>e.controls)),p=T.useRef(e),h=T.useRef(d.rotation.clone()),[x]=T.useState((()=>new m.SimplexNoise)),[y]=T.useState((()=>new m.SimplexNoise)),[v]=T.useState((()=>new m.SimplexNoise)),g=()=>{(p.current<0||p.current>1)&&(p.current=p.current<0?0:1)};return T.useImperativeHandle(u,(()=>({getIntensity:()=>p.current,setIntensity:e=>{p.current=e,g()}})),[]),T.useEffect((()=>{if(f){const e=()=>{h.current=d.rotation.clone()};return f.addEventListener("change",e),e(),()=>{f.removeEventListener("change",e)}}}),[d,f]),o.useFrame(((e,o)=>{const u=Math.pow(p.current,2),m=n*u*x.noise(e.clock.elapsedTime*s,1),f=a*u*y.noise(e.clock.elapsedTime*l,1),z=i*u*v.noise(e.clock.elapsedTime*c,1);d.rotation.set(h.current.x+f,h.current.y+m,h.current.z+z),t&&p.current>0&&(p.current-=r*o,g())})),null})),ln=T.forwardRef((({children:e,enabled:t=!0,speed:r=1,rotationIntensity:n=1,floatIntensity:a=1,floatingRange:s=[-.1,.1],...l},c)=>{const u=T.useRef(null),m=T.useRef(1e4*Math.random());return o.useFrame((e=>{var o,i;if(!t||0===r)return;const l=m.current+e.clock.getElapsedTime();u.current.rotation.x=Math.cos(l/4*r)/8*n,u.current.rotation.y=Math.sin(l/4*r)/8*n,u.current.rotation.z=Math.sin(l/4*r)/20*n;let c=Math.sin(l/4*r)/10;c=P.MathUtils.mapLinear(c,-.1,.1,null!==(o=null==s?void 0:s[0])&&void 0!==o?o:-.1,null!==(i=null==s?void 0:s[1])&&void 0!==i?i:.1),u.current.position.y=c*a,u.current.updateMatrix()})),T.createElement("group",l,T.createElement("group",{ref:i([u,c]),matrixAutoUpdate:!1},e))})),cn={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},un="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",mn=e=>Array.isArray(e);function dn({files:e=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:t="",preset:r,encoding:a,extensions:i}={}){var s;let l,c=null,u=!1;if(r){if(!(r in cn))throw new Error("Preset must be one of: "+Object.keys(cn).join(", "));e=cn[r],t=un}if(u=mn(e),l=mn(e)?"cube":e.startsWith("data:application/exr")?"exr":e.startsWith("data:application/hdr")?"hdr":null==(s=e.split(".").pop())?void 0:s.toLowerCase(),c=u?n.CubeTextureLoader:"hdr"===l?m.RGBELoader:"exr"===l?m.EXRLoader:null,!c)throw new Error("useEnvironment: Unrecognized file extension: "+e);const d=o.useLoader(c,u?[e]:e,(e=>{null==e.setPath||e.setPath(t),i&&i(e)})),f=u?d[0]:d;f.mapping=u?n.CubeReflectionMapping:n.EquirectangularReflectionMapping;return"colorSpace"in f?f.colorSpace=(null!=a?a:u)?"srgb":"srgb-linear":f.encoding=(null!=a?a:u)?3001:3e3,f}const fn=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function pn(e,t,r,n,o=0){const a=fn(t||r),i=a.background,s=a.environment,l=a.backgroundBlurriness||0;return"only"!==e&&(a.environment=n),e&&(a.background=n),e&&void 0!==a.backgroundBlurriness&&(a.backgroundBlurriness=o),()=>{"only"!==e&&(a.environment=s),e&&(a.background=i),e&&void 0!==a.backgroundBlurriness&&(a.backgroundBlurriness=l)}}function hn({scene:e,background:t=!1,blur:r,map:n}){const a=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>{if(n)return pn(t,e,a,n,r)}),[a,e,n,t,r]),null}function xn({background:e=!1,scene:t,blur:r,...n}){const a=dn(n),i=o.useThree((e=>e.scene));return T.useLayoutEffect((()=>pn(e,t,i,a,r)),[a,e,t,i,r]),null}function yn({children:e,near:t=1,far:r=1e3,resolution:a=256,frames:i=1,map:s,background:l=!1,blur:c,scene:u,files:m,path:d,preset:f,extensions:p}){const h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.scene)),y=T.useRef(null),[v]=T.useState((()=>new n.Scene)),g=T.useMemo((()=>{const e=new n.WebGLCubeRenderTarget(a);return e.texture.type=n.HalfFloatType,e}),[a]);T.useLayoutEffect((()=>(1===i&&y.current.update(h,v),pn(l,u,x,g.texture,c))),[e,v,g.texture,u,x,l,i,h]);let z=1;return o.useFrame((()=>{(i===1/0||z<i)&&(y.current.update(h,v),z++)})),T.createElement(T.Fragment,null,o.createPortal(T.createElement(T.Fragment,null,e,T.createElement("cubeCamera",{ref:y,args:[t,r,g]}),m||f?T.createElement(xn,{background:!0,files:m,preset:f,path:d,extensions:p}):s?T.createElement(hn,{background:!0,map:s,extensions:p}):null),v))}function vn(t){var r,n,a,i;const s=dn(t),l=t.map||s;T.useMemo((()=>o.extend({GroundProjectedEnvImpl:m.GroundProjectedEnv})),[]);const c=T.useMemo((()=>[l]),[l]),u=null==(r=t.ground)?void 0:r.height,d=null==(n=t.ground)?void 0:n.radius,f=null!==(a=null==(i=t.ground)?void 0:i.scale)&&void 0!==a?a:1e3;return T.createElement(T.Fragment,null,T.createElement(hn,e({},t,{map:l})),T.createElement("groundProjectedEnvImpl",{args:c,scale:f,height:u,radius:d}))}function gn(e){return e.ground?T.createElement(vn,e):e.map?T.createElement(hn,e):e.children?T.createElement(yn,e):T.createElement(xn,e)}const zn=T.forwardRef((({scale:t=10,frames:r=1/0,opacity:n=1,width:a=1,height:i=1,blur:s=1,near:l=0,far:c=10,resolution:u=512,smooth:d=!0,color:f="#000000",depthWrite:p=!1,renderOrder:h,...x},y)=>{const v=T.useRef(null),g=o.useThree((e=>e.scene)),z=o.useThree((e=>e.gl)),w=T.useRef(null);a*=Array.isArray(t)?t[0]:t||1,i*=Array.isArray(t)?t[1]:t||1;const[b,E,M,S,C,R,D]=T.useMemo((()=>{const e=new P.WebGLRenderTarget(u,u),t=new P.WebGLRenderTarget(u,u);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const r=new P.PlaneGeometry(a,i).rotateX(Math.PI/2),n=new P.Mesh(r),o=new P.MeshDepthMaterial;o.depthTest=o.depthWrite=!1,o.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new P.Color(f)}},e.fragmentShader=e.fragmentShader.replace("void main() {","uniform vec3 ucolor;\n void main() {\n "),e.fragmentShader=e.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")};const s=new P.ShaderMaterial(m.HorizontalBlurShader),l=new P.ShaderMaterial(m.VerticalBlurShader);return l.depthTest=s.depthTest=!1,[e,r,o,n,s,l,t]}),[u,a,i,t,f]),F=e=>{S.visible=!0,S.material=C,C.uniforms.tDiffuse.value=b.texture,C.uniforms.h.value=1*e/256,z.setRenderTarget(D),z.render(S,w.current),S.material=R,R.uniforms.tDiffuse.value=D.texture,R.uniforms.v.value=1*e/256,z.setRenderTarget(b),z.render(S,w.current),S.visible=!1};let k,_,L=0;return o.useFrame((()=>{w.current&&(r===1/0||L<r)&&(L++,k=g.background,_=g.overrideMaterial,v.current.visible=!1,g.background=null,g.overrideMaterial=M,z.setRenderTarget(b),z.render(g,w.current),F(s),d&&F(.4*s),z.setRenderTarget(null),v.current.visible=!0,g.overrideMaterial=_,g.background=k)})),T.useImperativeHandle(y,(()=>v.current),[]),T.createElement("group",e({"rotation-x":Math.PI/2},x,{ref:v}),T.createElement("mesh",{renderOrder:h,geometry:E,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},T.createElement("meshBasicMaterial",{transparent:!0,map:b.texture,opacity:n,depthWrite:p})),T.createElement("orthographicCamera",{ref:w,args:[-a/2,a/2,i/2,-i/2,l,c]}))}));const wn=T.createContext(null),bn=xe({color:new P.Color,blend:2,alphaTest:.75,opacity:0,map:null},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }","varying vec2 vUv;\n uniform sampler2D map;\n uniform vec3 color;\n uniform float opacity;\n uniform float alphaTest;\n uniform float blend;\n void main() {\n vec4 sampledDiffuseColor = texture2D(map, vUv);\n gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),En=T.forwardRef((({children:e,temporal:t,frames:r=40,limit:n=1/0,blend:a=20,scale:i=10,opacity:s=1,alphaTest:l=.75,color:c="black",colorBlend:u=2,resolution:m=1024,toneMapped:d=!0,...f},p)=>{o.extend({SoftShadowMaterial:bn});const h=o.useThree((e=>e.gl)),x=o.useThree((e=>e.scene)),y=o.useThree((e=>e.camera)),v=o.useThree((e=>e.invalidate)),g=T.useRef(null),z=T.useRef(null),[w]=T.useState((()=>new Sn(h,x,m)));T.useLayoutEffect((()=>{w.configure(g.current)}),[]);const b=T.useMemo((()=>({lights:new Map,temporal:!!t,frames:Math.max(2,r),blend:Math.max(2,r===1/0?a:r),count:0,getMesh:()=>g.current,reset:()=>{w.clear();const e=g.current.material;e.opacity=0,e.alphaTest=0,b.count=0},update:(e=1)=>{const t=g.current.material;b.temporal?(t.opacity=Math.min(s,t.opacity+s/b.blend),t.alphaTest=Math.min(l,t.alphaTest+l/b.blend)):(t.opacity=s,t.alphaTest=l),z.current.visible=!0,w.prepare();for(let t=0;t<e;t++)b.lights.forEach((e=>e.update())),w.update(y,b.blend);z.current.visible=!1,w.finish()}})),[w,y,x,t,r,a,s,l]);return T.useLayoutEffect((()=>{b.reset(),b.temporal||b.frames===1/0||b.update(b.blend)})),T.useImperativeHandle(p,(()=>b),[b]),o.useFrame((()=>{(b.temporal||b.frames===1/0)&&b.count<b.frames&&b.count<n&&(v(),b.update(),b.count++)})),T.createElement("group",f,T.createElement("group",{traverse:()=>null,ref:z},T.createElement(wn.Provider,{value:b},e)),T.createElement("mesh",{receiveShadow:!0,ref:g,scale:i,rotation:[-Math.PI/2,0,0]},T.createElement("planeGeometry",null),T.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:d,color:c,blend:u,map:w.progressiveLightMap2.texture})))})),Mn=T.forwardRef((({castShadow:t=!0,bias:r=.001,mapSize:n=512,size:o=5,near:a=.5,far:i=500,frames:s=1,position:l=[0,0,0],radius:c=1,amount:u=8,intensity:m=1,ambient:d=.5,...f},p)=>{const h=T.useRef(null),x=new P.Vector3(...l).length(),y=T.useContext(wn),v=T.useCallback((()=>{let e;if(h.current)for(let t=0;t<h.current.children.length;t++)if(e=h.current.children[t],Math.random()>d)e.position.set(l[0]+P.MathUtils.randFloatSpread(c),l[1]+P.MathUtils.randFloatSpread(c),l[2]+P.MathUtils.randFloatSpread(c));else{let t=Math.acos(2*Math.random()-1)-Math.PI/2,r=2*Math.PI*Math.random();e.position.set(Math.cos(t)*Math.cos(r)*x,Math.abs(Math.cos(t)*Math.sin(r)*x),Math.sin(t)*x)}}),[c,d,x,...l]),g=T.useMemo((()=>({update:v})),[v]);return T.useImperativeHandle(p,(()=>g),[g]),T.useLayoutEffect((()=>{const e=h.current;return y&&y.lights.set(e.uuid,g),()=>{y.lights.delete(e.uuid)}}),[y,g]),T.createElement("group",e({ref:h},f),Array.from({length:u},((e,s)=>T.createElement("directionalLight",{key:s,castShadow:t,"shadow-bias":r,"shadow-mapSize":[n,n],intensity:m/u},T.createElement("orthographicCamera",{attach:"shadow-camera",args:[-o,o,o,-o,a,i]})))))}));class Sn{constructor(e,t,r=1024){this.renderer=e,this.res=r,this.scene=t,this.buffer1Active=!1,this.lights=[],this.meshes=[],this.object=null,this.clearColor=new P.Color,this.clearAlpha=0;const n=/(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent)?P.HalfFloatType:P.FloatType;this.progressiveLightMap1=new P.WebGLRenderTarget(this.res,this.res,{type:n}),this.progressiveLightMap2=new P.WebGLRenderTarget(this.res,this.res,{type:n}),this.discardMat=new Er,this.targetMat=new P.MeshLambertMaterial({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:100},this.targetMat.onBeforeCompile=e=>{e.vertexShader="varying vec2 vUv;\n"+e.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const t=e.fragmentShader.indexOf("void main() {");e.fragmentShader="varying vec2 vUv;\n"+e.fragmentShader.slice(0,t)+"uniform sampler2D previousShadowMap;\n\tuniform float averagingWindow;\n"+e.fragmentShader.slice(t-1,-1)+"\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;\n gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);\n }",e.uniforms.previousShadowMap=this.previousShadowMap,e.uniforms.averagingWindow=this.averagingWindow}}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.lights=[],this.meshes=[],this.scene.traverse((e=>{!function(e){return!!e.geometry}(e)?function(e){return e.isLight}(e)&&this.lights.push({object:e,intensity:e.intensity}):this.meshes.push({object:e,material:e.material})}))}prepare(){this.lights.forEach((e=>e.object.intensity=0)),this.meshes.forEach((e=>e.object.material=this.discardMat))}finish(){this.lights.forEach((e=>e.object.intensity=e.intensity)),this.meshes.forEach((e=>e.object.material=e.material))}configure(e){this.object=e}update(e,t=100){if(!this.object)return;this.averagingWindow.value=t,this.object.material=this.targetMat;const r=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,n=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1,o=this.scene.background;this.scene.background=null,this.renderer.setRenderTarget(r),this.previousShadowMap.value=n.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,e),this.renderer.setRenderTarget(null),this.scene.background=o}}const Tn={rembrandt:{main:[1,2,1],fill:[-2,-.5,-2]},portrait:{main:[-1,2,.5],fill:[-1,.5,-1.5]},upfront:{main:[0,2,1],fill:[-1,.5,-1.5]},soft:{main:[-2,4,4],fill:[-1,.5,-1.5]}};function Cn({radius:e,adjustCamera:t}){const r=an();return T.useEffect((()=>{t&&r.refresh().clip().fit()}),[e,t]),null}const Pn=e=>0===e?0:Math.pow(2,10*e-10);const Rn=T.forwardRef((({fog:t=!1,renderOrder:r,depthWrite:o=!1,colorStop:a=0,color:i="black",opacity:s=.5,...l},c)=>{const u=T.useMemo((()=>{const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d"),r=t.createRadialGradient(e.width/2,e.height/2,0,e.width/2,e.height/2,e.width/2);return r.addColorStop(a,new n.Color(i).getStyle()),r.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height),e}),[i,a]);return T.createElement("mesh",e({renderOrder:r,ref:c,"rotation-x":-Math.PI/2},l),T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,opacity:s,fog:t,depthWrite:o,side:n.DoubleSide},T.createElement("canvasTexture",{attach:"map",args:[u]})))}));function Dn(e=P.FrontSide){const t={value:new P.Matrix4};return Object.assign(new P.MeshNormalMaterial({side:e}),{viewMatrix:t,onBeforeCompile:e=>{e.uniforms.viewMatrix=t,e.fragmentShader="vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n }\n"+e.fragmentShader.replace("#include <normal_fragment_maps>","#include <normal_fragment_maps>\n normal = inverseTransformDirection( normal, viewMatrix );\n")}})}const Fn=xe({causticsTexture:null,causticsTextureB:null,color:new P.Color,lightProjMatrix:new P.Matrix4,lightViewMatrix:new P.Matrix4},"varying vec3 vWorldPosition; \n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vec4 worldPosition = modelMatrix * vec4(position, 1.);\n vWorldPosition = worldPosition.xyz;\n }","varying vec3 vWorldPosition;\n uniform vec3 color;\n uniform sampler2D causticsTexture; \n uniform sampler2D causticsTextureB; \n uniform mat4 lightProjMatrix;\n uniform mat4 lightViewMatrix;\n void main() {\n // Apply caustics \n vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);\n lightSpacePos.xyz /= lightSpacePos.w;\n lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5; \n vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;\n vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;\n gl_FragColor = vec4((front + back) * color, 1.0);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),kn=xe({cameraMatrixWorld:new P.Matrix4,cameraProjectionMatrixInv:new P.Matrix4,normalTexture:null,depthTexture:null,lightDir:new P.Vector3(0,1,0),lightPlaneNormal:new P.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new P.Matrix4,worldRadius:1/40,ior:1.1,bounces:0,resolution:1024,size:10,intensity:.5},"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }"," \n uniform mat4 cameraMatrixWorld;\n uniform mat4 cameraProjectionMatrixInv;\n uniform vec3 lightDir;\n uniform vec3 lightPlaneNormal;\n uniform float lightPlaneConstant;\n uniform float near;\n uniform float far;\n uniform float time;\n uniform float worldRadius;\n uniform float resolution;\n uniform float size;\n uniform float intensity;\n uniform float ior;\n precision highp isampler2D;\n precision highp usampler2D;\n uniform sampler2D normalTexture;\n uniform sampler2D depthTexture;\n uniform float bounces;\n varying vec2 vUv;\n vec3 WorldPosFromDepth(float depth, vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;\n // Perspective division\n viewSpacePosition /= viewSpacePosition.w;\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n return worldSpacePosition.xyz;\n } \n float sdPlane( vec3 p, vec3 n, float h ) {\n // n must be normalized\n return dot(p,n) + h;\n }\n float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {\n return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);\n }\n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {\n rayOrigin = ro;\n rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = pos + rayDirection * 0.1;\n return rayDirection;\n }\n void main() {\n // Each sample consists of random offset in the x and y direction\n float caustic = 0.0;\n float causticTexelSize = (1.0 / resolution) * size * 2.0;\n float texelsNeeded = worldRadius / causticTexelSize;\n float sampleRadius = texelsNeeded / resolution;\n float sum = 0.0;\n if (texture2D(depthTexture, vUv).x == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 uv1 = vUv + offset1 * sampleRadius;\n vec2 uv2 = vUv + offset2 * sampleRadius;\n vec2 uv3 = vUv + offset3 * sampleRadius;\n vec2 uv4 = vUv + offset4 * sampleRadius;\n vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;\n vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;\n vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;\n vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;\n float depth1 = texture2D(depthTexture, uv1, -10.0).x;\n float depth2 = texture2D(depthTexture, uv2, -10.0).x;\n float depth3 = texture2D(depthTexture, uv3, -10.0).x;\n float depth4 = texture2D(depthTexture, uv4, -10.0).x;\n // Sanity check the depths\n if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec3 pos1 = WorldPosFromDepth(depth1, uv1);\n vec3 pos2 = WorldPosFromDepth(depth2, uv2);\n vec3 pos3 = WorldPosFromDepth(depth3, uv3);\n vec3 pos4 = WorldPosFromDepth(depth4, uv4);\n vec3 originPos1 = WorldPosFromDepth(0.0, uv1);\n vec3 originPos2 = WorldPosFromDepth(0.0, uv2);\n vec3 originPos3 = WorldPosFromDepth(0.0, uv3);\n vec3 originPos4 = WorldPosFromDepth(0.0, uv4);\n vec3 endPos1, endPos2, endPos3, endPos4;\n vec3 endDir1, endDir2, endDir3, endDir4;\n totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);\n totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);\n totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);\n totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);\n float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));\n float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));\n float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));\n float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));\n float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));\n vec3 finalPos1 = endPos1 + endDir1 * t1;\n vec3 finalPos2 = endPos2 + endDir2 * t2;\n vec3 finalPos3 = endPos3 + endDir3 * t3;\n vec3 finalPos4 = endPos4 + endDir4 * t4;\n float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));\n caustic += intensity * (lightPosArea / finalArea);\n // Calculate the area of the triangle in light spaces\n gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);\n }"),_n={depth:!0,minFilter:P.LinearFilter,magFilter:P.LinearFilter,type:P.UnsignedByteType},Ln={minFilter:P.LinearMipmapLinearFilter,magFilter:P.LinearFilter,type:P.FloatType,generateMipmaps:!0},An=T.forwardRef((({debug:t,children:r,frames:n=1,ior:a=1.1,color:i="white",causticsOnly:s=!1,backside:l=!1,backsideIOR:c=1.1,worldRadius:u=.3125,intensity:d=.05,resolution:f=2024,lightSource:p=[5,5,5],...h},x)=>{o.extend({CausticsProjectionMaterial:Fn});const y=T.useRef(null),v=T.useRef(null),g=T.useRef(null),z=T.useRef(null),w=o.useThree((e=>e.gl)),b=Jt(t&&v,P.CameraHelper),E=je(f,f,_n),M=je(f,f,_n),S=je(f,f,Ln),C=je(f,f,Ln),[R]=T.useState((()=>Dn())),[D]=T.useState((()=>Dn(P.BackSide))),[F]=T.useState((()=>new kn)),[k]=T.useState((()=>new m.FullScreenQuad(F)));T.useLayoutEffect((()=>{y.current.updateWorldMatrix(!1,!0)}));let _=0;const L=new P.Vector3,A=new P.Frustum,B=new P.Matrix4,U=new P.Plane,O=new P.Vector3,N=new P.Vector3,I=new P.Box3,V=new P.Vector3,j=[],W=[],G=[],H=[],q=new P.Vector3;for(let e=0;e<8;e++)j.push(new P.Vector3),W.push(new P.Vector3),G.push(new P.Vector3),H.push(new P.Vector3);return o.useFrame((()=>{if(n===1/0||_++<n){var e,r;Array.isArray(p)?O.fromArray(p).normalize():O.copy(y.current.worldToLocal(p.current.getWorldPosition(L)).normalize()),N.copy(O).multiplyScalar(-1),null==(e=g.current.parent)||e.matrixWorld.identity(),I.setFromObject(g.current,!0),j[0].set(I.min.x,I.min.y,I.min.z),j[1].set(I.min.x,I.min.y,I.max.z),j[2].set(I.min.x,I.max.y,I.min.z),j[3].set(I.min.x,I.max.y,I.max.z),j[4].set(I.max.x,I.min.y,I.min.z),j[5].set(I.max.x,I.min.y,I.max.z),j[6].set(I.max.x,I.max.y,I.min.z),j[7].set(I.max.x,I.max.y,I.max.z);for(let e=0;e<8;e++)W[e].copy(j[e]);I.getCenter(V),j.map((e=>e.sub(V)));const n=U.set(N,0);j.map(((e,t)=>n.projectPoint(e,G[t])));const o=G.reduce(((e,t)=>e.add(t)),L.set(0,0,0)).divideScalar(G.length),i=G.map((e=>e.distanceTo(o))).reduce(((e,t)=>Math.max(e,t))),m=j.map((e=>e.dot(O))).reduce(((e,t)=>Math.max(e,t)));v.current.position.copy(q.copy(O).multiplyScalar(m).add(V)),v.current.lookAt(g.current.localToWorld(V));const h=B.lookAt(v.current.position,V,L.set(0,1,0));v.current.left=-i,v.current.right=i,v.current.top=i,v.current.bottom=-i;const x=L.set(0,i,0).applyMatrix4(h),T=(v.current.position.y+x.y)/O.y;v.current.near=.1,v.current.far=T,v.current.updateProjectionMatrix(),v.current.updateMatrixWorld();const P=W.map(((e,t)=>e.add(H[t].copy(O).multiplyScalar(-e.y/O.y)))),_=P.reduce(((e,t)=>e.add(t)),L.set(0,0,0)).divideScalar(P.length),$=2*P.map((e=>Math.hypot(e.x-_.x,e.z-_.z))).reduce(((e,t)=>Math.max(e,t)));z.current.scale.setScalar($),z.current.position.copy(_),t&&(null==(r=b.current)||r.update()),D.viewMatrix.value=R.viewMatrix.value=v.current.matrixWorldInverse;const X=A.setFromProjectionMatrix(B.multiplyMatrices(v.current.projectionMatrix,v.current.matrixWorldInverse)).planes[4];F.cameraMatrixWorld=v.current.matrixWorld,F.cameraProjectionMatrixInv=v.current.projectionMatrixInverse,F.lightDir=N,F.lightPlaneNormal=X.normal,F.lightPlaneConstant=X.constant,F.near=v.current.near,F.far=v.current.far,F.resolution=f,F.size=i,F.intensity=d,F.worldRadius=u,g.current.visible=!0,w.setRenderTarget(E),w.clear(),g.current.overrideMaterial=R,w.render(g.current,v.current),w.setRenderTarget(M),w.clear(),l&&(g.current.overrideMaterial=D,w.render(g.current,v.current)),g.current.overrideMaterial=null,F.ior=a,z.current.material.lightProjMatrix=v.current.projectionMatrix,z.current.material.lightViewMatrix=v.current.matrixWorldInverse,F.normalTexture=E.texture,F.depthTexture=E.depthTexture,w.setRenderTarget(S),w.clear(),k.render(w),F.ior=c,F.normalTexture=M.texture,F.depthTexture=M.depthTexture,w.setRenderTarget(C),w.clear(),l&&k.render(w),w.setRenderTarget(null),s&&(g.current.visible=!1)}})),T.useImperativeHandle(x,(()=>y.current),[]),T.createElement("group",e({ref:y},h),T.createElement("scene",{ref:g},T.createElement("orthographicCamera",{ref:v,up:[0,1,0]}),r),T.createElement("mesh",{renderOrder:2,ref:z,"rotation-x":-Math.PI/2},T.createElement("planeGeometry",null),T.createElement("causticsProjectionMaterial",{transparent:!0,color:i,causticsTexture:S.texture,causticsTextureB:C.texture,blending:P.CustomBlending,blendSrc:P.OneFactor,blendDst:P.SrcAlphaFactor,depthWrite:!1}),t&&T.createElement(Me,null,T.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))}));o.extend({MeshReflectorMaterial:zr});const Bn=T.forwardRef((({mixBlur:t=0,mixStrength:r=.5,resolution:a=256,blur:s=[0,0],args:l=[1,1],minDepthThreshold:c=.9,maxDepthThreshold:u=1,depthScale:m=0,depthToBlurRatioBias:d=.25,mirror:f=0,children:p,debug:h=0,distortion:x=1,mixContrast:y=1,distortionMap:v,...g},z)=>{T.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const w=o.useThree((({gl:e})=>e)),b=o.useThree((({camera:e})=>e)),E=o.useThree((({scene:e})=>e)),M=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,S=T.useRef(null),[C]=T.useState((()=>new n.Plane)),[P]=T.useState((()=>new n.Vector3)),[R]=T.useState((()=>new n.Vector3)),[D]=T.useState((()=>new n.Vector3)),[F]=T.useState((()=>new n.Matrix4)),[k]=T.useState((()=>new n.Vector3(0,0,-1))),[_]=T.useState((()=>new n.Vector4)),[L]=T.useState((()=>new n.Vector3)),[A]=T.useState((()=>new n.Vector3)),[B]=T.useState((()=>new n.Vector4)),[U]=T.useState((()=>new n.Matrix4)),[O]=T.useState((()=>new n.PerspectiveCamera)),N=T.useCallback((()=>{if(R.setFromMatrixPosition(S.current.matrixWorld),D.setFromMatrixPosition(b.matrixWorld),F.extractRotation(S.current.matrixWorld),P.set(0,0,1),P.applyMatrix4(F),L.subVectors(R,D),L.dot(P)>0)return;L.reflect(P).negate(),L.add(R),F.extractRotation(b.matrixWorld),k.set(0,0,-1),k.applyMatrix4(F),k.add(D),A.subVectors(R,k),A.reflect(P).negate(),A.add(R),O.position.copy(L),O.up.set(0,1,0),O.up.applyMatrix4(F),O.up.reflect(P),O.lookAt(A),O.far=b.far,O.updateMatrixWorld(),O.projectionMatrix.copy(b.projectionMatrix),U.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),U.multiply(O.projectionMatrix),U.multiply(O.matrixWorldInverse),U.multiply(S.current.matrixWorld),C.setFromNormalAndCoplanarPoint(P,R),C.applyMatrix4(O.matrixWorldInverse),_.set(C.normal.x,C.normal.y,C.normal.z,C.constant);const e=O.projectionMatrix;B.x=(Math.sign(_.x)+e.elements[8])/e.elements[0],B.y=(Math.sign(_.y)+e.elements[9])/e.elements[5],B.z=-1,B.w=(1+e.elements[10])/e.elements[14],_.multiplyScalar(2/_.dot(B)),e.elements[2]=_.x,e.elements[6]=_.y,e.elements[10]=_.z+1,e.elements[14]=_.w}),[]),[I,V,j,W]=T.useMemo((()=>{const e={type:n.HalfFloatType,minFilter:n.LinearFilter,magFilter:n.LinearFilter},o=new n.WebGLRenderTarget(a,a,e);o.depthBuffer=!0,o.depthTexture=new n.DepthTexture(a,a),o.depthTexture.format=n.DepthFormat,o.depthTexture.type=n.UnsignedShortType;const i=new n.WebGLRenderTarget(a,a,e);return[o,i,new gr({gl:w,resolution:a,width:s[0],height:s[1],minDepthThreshold:c,maxDepthThreshold:u,depthScale:m,depthToBlurRatioBias:d}),{mirror:f,textureMatrix:U,mixBlur:t,tDiffuse:o.texture,tDepth:o.depthTexture,tDiffuseBlur:i.texture,hasBlur:M,mixStrength:r,minDepthThreshold:c,maxDepthThreshold:u,depthScale:m,depthToBlurRatioBias:d,transparent:!0,debug:h,distortion:x,distortionMap:v,mixContrast:y,"defines-USE_BLUR":M?"":void 0,"defines-USE_DEPTH":m>0?"":void 0,"defines-USE_DISTORTION":v?"":void 0}]}),[w,s,U,a,f,M,t,r,c,u,m,d,h,x,v,y]);return o.useFrame((()=>{if(null==S||!S.current)return;S.current.visible=!1;const e=w.xr.enabled,t=w.shadowMap.autoUpdate;N(),w.xr.enabled=!1,w.shadowMap.autoUpdate=!1,w.setRenderTarget(I),w.state.buffers.depth.setMask(!0),w.autoClear||w.clear(),w.render(E,O),M&&j.render(w,I,V),w.xr.enabled=e,w.shadowMap.autoUpdate=t,S.current.visible=!0,w.setRenderTarget(null)})),T.createElement("mesh",e({ref:i([S,z])},g),T.createElement("planeGeometry",{args:l}),p?p("meshReflectorMaterial",W):T.createElement("meshReflectorMaterial",W))}));class Un extends n.ShaderMaterial{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new n.Vector3(0,0,0)},lightColor:{value:new n.Color("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new n.Vector2(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation; \n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity; \n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",fragmentShader:"\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}var On="#define GLSLIFY 1\nvarying vec2 vUv;uniform sampler2D uShadowMap;uniform float uTime;void main(){vec3 color=texture2D(uShadowMap,vUv).xyz;gl_FragColor=vec4(color,1.);}";const Nn=e=>null==e?void 0:e.isSpotLight;function In({opacity:e=1,radiusTop:t,radiusBottom:r,depthBuffer:a,color:i="white",distance:s=5,angle:l=.15,attenuation:c=5,anglePower:u=5}){const m=T.useRef(null),d=o.useThree((e=>e.size)),f=o.useThree((e=>e.camera)),p=o.useThree((e=>e.viewport.dpr)),[h]=T.useState((()=>new Un)),[x]=T.useState((()=>new n.Vector3));t=void 0===t?.1:t,r=void 0===r?7*l:r,o.useFrame((()=>{h.uniforms.spotPosition.value.copy(m.current.getWorldPosition(x)),m.current.lookAt(m.current.parent.target.getWorldPosition(x))}));const y=T.useMemo((()=>{const e=new n.CylinderGeometry(t,r,s,128,64,!0);return e.applyMatrix4((new n.Matrix4).makeTranslation(0,-s/2,0)),e.applyMatrix4((new n.Matrix4).makeRotationX(-Math.PI/2)),e}),[s,t,r]);return T.createElement(T.Fragment,null,T.createElement("mesh",{ref:m,geometry:y,raycast:()=>null},T.createElement("primitive",{object:h,attach:"material","uniforms-opacity-value":e,"uniforms-lightColor-value":i,"uniforms-attenuation-value":c,"uniforms-anglePower-value":u,"uniforms-depth-value":a,"uniforms-cameraNear-value":f.near,"uniforms-cameraFar-value":f.far,"uniforms-resolution-value":a?[d.width*p,d.height*p]:[0,0]})))}function Vn(e,t,r,a,i){const[[s,l]]=T.useState((()=>[new n.Vector3,new n.Vector3]));T.useLayoutEffect((()=>{if(!Nn(e.current))throw new Error("SpotlightShadow must be a child of a SpotLight");e.current.shadow.mapSize.set(r,a),e.current.shadow.needsUpdate=!0}),[e,r,a]),o.useFrame((()=>{if(!e.current)return;const r=e.current.position,n=e.current.target.position;l.copy(n).sub(r);var o=l.length();l.normalize().multiplyScalar(o*i),s.copy(r).add(l),t.current.position.copy(s),t.current.lookAt(e.current.target.position)}))}function jn({distance:e=.4,alphaTest:t=.5,map:r,shader:a=On,width:i=512,height:s=512,scale:l=1,children:c,...u}){const d=T.useRef(null),f=u.spotlightRef,p=u.debug;Vn(f,d,i,s,e);const h=T.useMemo((()=>new n.WebGLRenderTarget(i,s,{format:n.RGBAFormat,encoding:n.LinearEncoding,stencilBuffer:!1})),[i,s]),x=T.useRef({uShadowMap:{value:r},uTime:{value:0}});T.useEffect((()=>{x.current.uShadowMap.value=r}),[r]);const y=T.useMemo((()=>new m.FullScreenQuad(new n.ShaderMaterial({uniforms:x.current,vertexShader:"\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:a}))),[a]);return T.useEffect((()=>()=>{y.material.dispose(),y.dispose()}),[y]),T.useEffect((()=>()=>h.dispose()),[h]),o.useFrame((({gl:e},t)=>{x.current.uTime.value+=t,e.setRenderTarget(h),y.render(e),e.setRenderTarget(null)})),T.createElement(T.Fragment,null,T.createElement("mesh",{ref:d,scale:l,castShadow:!0},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,side:n.DoubleSide,alphaTest:t,alphaMap:h.texture,"alphaMap-wrapS":n.RepeatWrapping,"alphaMap-wrapT":n.RepeatWrapping,opacity:p?1:0},c)))}function Wn({distance:e=.4,alphaTest:t=.5,map:r,width:o=512,height:a=512,scale:i,children:s,...l}){const c=T.useRef(null),u=l.spotlightRef,m=l.debug;return Vn(u,c,o,a,e),T.createElement(T.Fragment,null,T.createElement("mesh",{ref:c,scale:i,castShadow:!0},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,side:n.DoubleSide,alphaTest:t,alphaMap:r,"alphaMap-wrapS":n.RepeatWrapping,"alphaMap-wrapT":n.RepeatWrapping,opacity:m?1:0},s)))}const Gn=T.forwardRef((({opacity:t=1,radiusTop:r,radiusBottom:n,depthBuffer:o,color:a="white",distance:s=5,angle:l=.15,attenuation:c=5,anglePower:u=5,volumetric:m=!0,debug:d=!1,children:f,...p},h)=>{const x=T.useRef(null);return T.createElement("group",null,d&&x.current&&T.createElement("spotLightHelper",{args:[x.current]}),T.createElement("spotLight",e({ref:i([h,x]),angle:l,color:a,distance:s,castShadow:!0},p),m&&T.createElement(In,{debug:d,opacity:t,radiusTop:r,radiusBottom:n,depthBuffer:o,color:a,distance:s,angle:l,attenuation:c,anglePower:u})),f&&T.cloneElement(f,{spotlightRef:x,debug:d}))})),Hn=T.forwardRef((({args:t,map:r,toneMapped:n=!1,color:a="white",form:s="rect",intensity:l=1,scale:c=1,target:u,children:m,...d},f)=>{const p=T.useRef(null);return T.useLayoutEffect((()=>{m||d.material||(o.applyProps(p.current.material,{color:a}),p.current.material.color.multiplyScalar(l))}),[a,l,m,d.material]),T.useLayoutEffect((()=>{u&&p.current.lookAt(Array.isArray(u)?new P.Vector3(...u):u)}),[u]),c=Array.isArray(c)&&2===c.length?[c[0],c[1],1]:c,T.createElement("mesh",e({ref:i([p,f]),scale:c},d),"circle"===s?T.createElement("ringGeometry",{args:[0,1,64]}):"ring"===s?T.createElement("ringGeometry",{args:[.5,1,64]}):"rect"===s?T.createElement("planeGeometry",null):T.createElement(s,{args:t}),m||(d.material?null:T.createElement("meshBasicMaterial",{toneMapped:n,map:r,side:P.DoubleSide})))}));function qn(e,t,r=new n.Vector3){const o=Math.PI*(e-.5),a=2*Math.PI*(t-.5);return r.x=Math.cos(a),r.y=Math.sin(o),r.z=Math.sin(a),r}const $n=T.forwardRef((({inclination:t=.6,azimuth:r=.1,distance:o=1e3,mieCoefficient:a=.005,mieDirectionalG:i=.8,rayleigh:s=.5,turbidity:l=10,sunPosition:c=qn(t,r),...u},d)=>{const f=T.useMemo((()=>(new n.Vector3).setScalar(o)),[o]),[p]=T.useState((()=>new m.Sky));return T.createElement("primitive",e({object:p,ref:d,"material-uniforms-mieCoefficient-value":a,"material-uniforms-mieDirectionalG-value":i,"material-uniforms-rayleigh-value":s,"material-uniforms-sunPosition-value":c,"material-uniforms-turbidity-value":l,scale:f},u))}));class Xn extends n.ShaderMaterial{constructor(){super({uniforms:{time:{value:0},fade:{value:1}},vertexShader:"\n uniform float time;\n attribute float size;\n varying vec3 vColor;\n void main() {\n vColor = color;\n vec4 mvPosition = modelViewMatrix * vec4(position, 0.5);\n gl_PointSize = size * (30.0 / -mvPosition.z) * (3.0 + sin(time + 100.0));\n gl_Position = projectionMatrix * mvPosition;\n }",fragmentShader:"\n uniform sampler2D pointTexture;\n uniform float fade;\n varying vec3 vColor;\n void main() {\n float opacity = 1.0;\n if (fade == 1.0) {\n float d = distance(gl_PointCoord, vec2(0.5, 0.5));\n opacity = 1.0 / (1.0 + exp(16.0 * (d - 0.25)));\n }\n gl_FragColor = vec4(vColor, opacity);\n\n #include <tonemapping_fragment>\n\t #include <encodings_fragment>\n }"})}}const Yn=e=>(new n.Vector3).setFromSpherical(new n.Spherical(e,Math.acos(1-2*Math.random()),2*Math.random()*Math.PI)),Kn=T.forwardRef((({radius:e=100,depth:t=50,count:r=5e3,saturation:a=0,factor:i=4,fade:s=!1,speed:l=1},c)=>{const u=T.useRef(),[m,d,f]=T.useMemo((()=>{const o=[],s=[],l=Array.from({length:r},(()=>(.5+.5*Math.random())*i)),c=new n.Color;let u=e+t;const m=t/r;for(let e=0;e<r;e++)u-=m*Math.random(),o.push(...Yn(u).toArray()),c.setHSL(e/r,a,.9),s.push(c.r,c.g,c.b);return[new Float32Array(o),new Float32Array(s),new Float32Array(l)]}),[r,t,i,e,a]);o.useFrame((e=>u.current&&(u.current.uniforms.time.value=e.clock.getElapsedTime()*l)));const[p]=T.useState((()=>new Xn));return T.createElement("points",{ref:c},T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",args:[m,3]}),T.createElement("bufferAttribute",{attach:"attributes-color",args:[d,3]}),T.createElement("bufferAttribute",{attach:"attributes-size",args:[f,1]})),T.createElement("primitive",{ref:u,object:p,attach:"material",blending:n.AdditiveBlending,"uniforms-fade-value":s,depthWrite:!1,transparent:!0,vertexColors:!0}))}));const Zn=xe({time:0,pixelRatio:1}," uniform float pixelRatio;\n uniform float time;\n attribute float size; \n attribute float speed; \n attribute float opacity;\n attribute vec3 noise;\n attribute vec3 color;\n varying vec3 vColor;\n varying float vOpacity;\n void main() {\n vec4 modelPosition = modelMatrix * vec4(position, 1.0);\n modelPosition.y += sin(time * speed + modelPosition.x * noise.x * 100.0) * 0.2;\n modelPosition.z += cos(time * speed + modelPosition.x * noise.y * 100.0) * 0.2;\n modelPosition.x += cos(time * speed + modelPosition.x * noise.z * 100.0) * 0.2;\n vec4 viewPosition = viewMatrix * modelPosition;\n vec4 projectionPostion = projectionMatrix * viewPosition;\n gl_Position = projectionPostion;\n gl_PointSize = size * 25. * pixelRatio;\n gl_PointSize *= (1.0 / - viewPosition.z);\n vColor = color;\n vOpacity = opacity;\n }"," varying vec3 vColor;\n varying float vOpacity;\n void main() {\n float distanceToCenter = distance(gl_PointCoord, vec2(0.5));\n float strength = 0.05 / distanceToCenter - 0.1;\n gl_FragColor = vec4(vColor, strength * vOpacity);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),Qn=e=>e&&e.constructor===Float32Array,Jn=e=>e instanceof P.Vector2||e instanceof P.Vector3||e instanceof P.Vector4,eo=e=>Array.isArray(e)?e:Jn(e)?e.toArray():[e,e,e];function to(e,t,r){return T.useMemo((()=>{if(void 0!==t){if(Qn(t))return t;if(t instanceof P.Color){const r=Array.from({length:3*e},(()=>(e=>[e.r,e.g,e.b])(t))).flat();return Float32Array.from(r)}if(Jn(t)||Array.isArray(t)){const r=Array.from({length:3*e},(()=>eo(t))).flat();return Float32Array.from(r)}return Float32Array.from({length:e},(()=>t))}return Float32Array.from({length:e},r)}),[t])}const ro=T.forwardRef((({noise:t=1,count:r=100,speed:n=1,opacity:a=1,scale:i=1,size:s,color:l,children:c,...u},m)=>{T.useMemo((()=>o.extend({SparklesImplMaterial:Zn})),[]);const d=T.useRef(null),f=o.useThree((e=>e.viewport.dpr)),p=T.useMemo((()=>Float32Array.from(Array.from({length:r},(()=>eo(i).map(P.MathUtils.randFloatSpread))).flat())),[r,i]),h=to(r,s,Math.random),x=to(r,a),y=to(r,n),v=to(3*r,t),g=to(void 0===l?3*r:r,Qn(l)?l:new P.Color(l),(()=>1));return o.useFrame((e=>{d.current&&d.current.material&&(d.current.material.time=e.clock.elapsedTime)})),T.useImperativeHandle(m,(()=>d.current),[]),T.createElement("points",e({key:`particle-${r}-${JSON.stringify(i)}`},u,{ref:d}),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",args:[p,3]}),T.createElement("bufferAttribute",{attach:"attributes-size",args:[h,1]}),T.createElement("bufferAttribute",{attach:"attributes-opacity",args:[x,1]}),T.createElement("bufferAttribute",{attach:"attributes-speed",args:[y,1]}),T.createElement("bufferAttribute",{attach:"attributes-color",args:[g,3]}),T.createElement("bufferAttribute",{attach:"attributes-noise",args:[v,3]})),c||T.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:f,depthWrite:!1}))}));const no={uniforms:{strokeOpacity:1,fillOpacity:.25,fillMix:0,thickness:.05,colorBackfaces:!1,dashInvert:!0,dash:!1,dashRepeats:4,dashLength:.5,squeeze:!1,squeezeMin:.2,squeezeMax:1,stroke:new P.Color("#ff0000"),backfaceStroke:new P.Color("#0000ff"),fill:new P.Color("#00ff00")},vertex:"\n\t attribute vec3 barycentric;\n\t\n\t\tvarying vec3 v_edges_Barycentric;\n\t\tvarying vec3 v_edges_Position;\n\n\t\tvoid initWireframe() {\n\t\t\tv_edges_Barycentric = barycentric;\n\t\t\tv_edges_Position = position.xyz;\n\t\t}\n\t ",fragment:"\n\t\t#ifndef PI\n\t \t#define PI 3.1415926535897932384626433832795\n\t\t#endif\n \n\t varying vec3 v_edges_Barycentric;\n\t varying vec3 v_edges_Position;\n \n\t uniform float strokeOpacity;\n\t uniform float fillOpacity;\n\t uniform float fillMix;\n\t uniform float thickness;\n\t uniform bool colorBackfaces;\n \n\t // Dash\n\t uniform bool dashInvert;\n\t uniform bool dash;\n\t uniform bool dashOnly;\n\t uniform float dashRepeats;\n\t uniform float dashLength;\n \n\t // Squeeze\n\t uniform bool squeeze;\n\t uniform float squeezeMin;\n\t uniform float squeezeMax;\n \n\t // Colors\n\t uniform vec3 stroke;\n\t uniform vec3 backfaceStroke;\n\t uniform vec3 fill;\n \n\t // This is like\n\t float wireframe_aastep(float threshold, float dist) {\n\t\t float afwidth = fwidth(dist) * 0.5;\n\t\t return smoothstep(threshold - afwidth, threshold + afwidth, dist);\n\t }\n \n\t float wireframe_map(float value, float min1, float max1, float min2, float max2) {\n\t\t return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n\t }\n \n\t float getWireframe() {\n\t\t\tvec3 barycentric = v_edges_Barycentric;\n\t\t\n\t\t\t// Distance from center of each triangle to its edges.\n\t\t\tfloat d = min(min(barycentric.x, barycentric.y), barycentric.z);\n\n\t\t\t// for dashed rendering, we can use this to get the 0 .. 1 value of the line length\n\t\t\tfloat positionAlong = max(barycentric.x, barycentric.y);\n\t\t\tif (barycentric.y < barycentric.x && barycentric.y < barycentric.z) {\n\t\t\t\tpositionAlong = 1.0 - positionAlong;\n\t\t\t}\n\n\t\t\t// the thickness of the stroke\n\t\t\tfloat computedThickness = wireframe_map(thickness, 0.0, 1.0, 0.0, 0.34);\n\n\t\t\t// if we want to shrink the thickness toward the center of the line segment\n\t\t\tif (squeeze) {\n\t\t\t\tcomputedThickness *= mix(squeezeMin, squeezeMax, (1.0 - sin(positionAlong * PI)));\n\t\t\t}\n\n\t\t\t// Create dash pattern\n\t\t\tif (dash) {\n\t\t\t\t// here we offset the stroke position depending on whether it\n\t\t\t\t// should overlap or not\n\t\t\t\tfloat offset = 1.0 / dashRepeats * dashLength / 2.0;\n\t\t\t\tif (!dashInvert) {\n\t\t\t\t\toffset += 1.0 / dashRepeats / 2.0;\n\t\t\t\t}\n\n\t\t\t\t// if we should animate the dash or not\n\t\t\t\t// if (dashAnimate) {\n\t\t\t\t// \toffset += time * 0.22;\n\t\t\t\t// }\n\n\t\t\t\t// create the repeating dash pattern\n\t\t\t\tfloat pattern = fract((positionAlong + offset) * dashRepeats);\n\t\t\t\tcomputedThickness *= 1.0 - wireframe_aastep(dashLength, pattern);\n\t\t\t}\n\n\t\t\t// compute the anti-aliased stroke edge \n\t\t\tfloat edge = 1.0 - wireframe_aastep(computedThickness, d);\n\n\t\t\treturn edge;\n\t }\n\t "},oo=xe(no.uniforms,no.vertex+"\n \tvoid main() {\n\t\tinitWireframe();\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n\t}\n ",no.fragment+"\n void main () {\n\t\t// Compute color\n\n\t\tfloat edge = getWireframe();\n\t\tvec4 colorStroke = vec4(stroke, edge);\n\n\t\t#ifdef FLIP_SIDED\n\t\t\tcolorStroke.rgb = backfaceStroke;\n\t\t#endif\n \n\t\tvec4 colorFill = vec4(fill, fillOpacity);\n\t\tvec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);\n\n\t\tgl_FragColor = outColor;\n\t}\n ");function ao(e){return void 0!==(null==e?void 0:e.current)}function io(e){return"WireframeGeometry"===e.type}function so(e){const t=null!=(r=e)&&r.current?e.current:e;var r;if(function(e){return!(null==e||!e.isBufferGeometry)}(t))return t;{if(io(t))throw new Error("Wireframe: WireframeGeometry is not supported.");const e=t.parent;if(function(e){return!(null==e||!e.geometry)}(e)){if(io(e.geometry))throw new Error("Wireframe: WireframeGeometry is not supported.");return e.geometry}}}function lo(e,t){if(e.index){console.warn("Wireframe: Requires non-indexed geometry, converting to non-indexed geometry.");const t=e.toNonIndexed();e.copy(t),e.setIndex(null)}const r=function(e,t){const r=e.getAttribute("position").count,n=[];for(let e=0;e<r;e++){const r=t?1:0;e%2==0?n.push(0,0,1,0,1,0,1,0,r):n.push(0,1,0,0,0,1,1,0,r)}return new P.BufferAttribute(Float32Array.from(n),3)}(e,t);e.setAttribute("barycentric",r)}function co({geometry:t,simplify:r=!1,...n}){const[o,a]=T.useState(null);T.useLayoutEffect((()=>{const e=so(t);if(!e)throw new Error("Wireframe: geometry prop must be a BufferGeometry or a ref to a BufferGeometry.");lo(e,r),ao(t)&&a(e)}),[r,t]);const i=ao(t)?o:t;return T.createElement(T.Fragment,null,i&&T.createElement("mesh",{geometry:i},T.createElement("meshWireframeMaterial",e({attach:"material",transparent:!0,side:P.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-4},n,{extensions:{derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1}}))))}function uo({simplify:e=!1,...t}){const r=T.useRef(null),n=T.useMemo((()=>function(){const e={};for(const t in no.uniforms)e[t]={value:no.uniforms[t]};return e}()),[no.uniforms]);return function(e,t){T.useEffect((()=>{var r;e.fillOpacity.value=null!==(r=t.fillOpacity)&&void 0!==r?r:e.fillOpacity.value}),[t.fillOpacity]),T.useEffect((()=>{var r;e.fillMix.value=null!==(r=t.fillMix)&&void 0!==r?r:e.fillMix.value}),[t.fillMix]),T.useEffect((()=>{var r;e.strokeOpacity.value=null!==(r=t.strokeOpacity)&&void 0!==r?r:e.strokeOpacity.value}),[t.strokeOpacity]),T.useEffect((()=>{var r;e.thickness.value=null!==(r=t.thickness)&&void 0!==r?r:e.thickness.value}),[t.thickness]),T.useEffect((()=>{e.colorBackfaces.value=!!t.colorBackfaces}),[t.colorBackfaces]),T.useEffect((()=>{e.dash.value=!!t.dash}),[t.dash]),T.useEffect((()=>{e.dashInvert.value=!!t.dashInvert}),[t.dashInvert]),T.useEffect((()=>{var r;e.dashRepeats.value=null!==(r=t.dashRepeats)&&void 0!==r?r:e.dashRepeats.value}),[t.dashRepeats]),T.useEffect((()=>{var r;e.dashLength.value=null!==(r=t.dashLength)&&void 0!==r?r:e.dashLength.value}),[t.dashLength]),T.useEffect((()=>{e.squeeze.value=!!t.squeeze}),[t.squeeze]),T.useEffect((()=>{var r;e.squeezeMin.value=null!==(r=t.squeezeMin)&&void 0!==r?r:e.squeezeMin.value}),[t.squeezeMin]),T.useEffect((()=>{var r;e.squeezeMax.value=null!==(r=t.squeezeMax)&&void 0!==r?r:e.squeezeMax.value}),[t.squeezeMax]),T.useEffect((()=>{e.stroke.value=t.stroke?new P.Color(t.stroke):e.stroke.value}),[t.stroke]),T.useEffect((()=>{e.fill.value=t.fill?new P.Color(t.fill):e.fill.value}),[t.fill]),T.useEffect((()=>{e.backfaceStroke.value=t.backfaceStroke?new P.Color(t.backfaceStroke):e.backfaceStroke.value}),[t.backfaceStroke])}(n,t),T.useLayoutEffect((()=>{const t=so(r);if(!t)throw new Error("Wireframe: Must be a child of a Mesh, Line or Points object or specify a geometry prop.");const n=t.clone();return lo(t,e),()=>{t.copy(n),n.dispose()}}),[e]),T.useLayoutEffect((()=>{const e=r.current.parent,t=e.material.clone();return function(e,t){e.onBeforeCompile=e=>{e.uniforms={...e.uniforms,...t},e.vertexShader=e.vertexShader.replace("void main() {",`\n\t\t ${no.vertex}\n\t\t void main() {\n\t\t\tinitWireframe();\n\t\t`),e.fragmentShader=e.fragmentShader.replace("void main() {",`\n\t\t ${no.fragment}\n\t\t void main() {\n\t\t`),e.fragmentShader=e.fragmentShader.replace("#include <color_fragment>","\n\t\t #include <color_fragment>\n\t\t\t float edge = getWireframe();\n\t\t vec4 colorStroke = vec4(stroke, edge);\n\t\t #ifdef FLIP_SIDED\n\t\t\tcolorStroke.rgb = backfaceStroke;\n\t\t #endif\n\t\t vec4 colorFill = vec4(mix(diffuseColor.rgb, fill, fillMix), mix(diffuseColor.a, fillOpacity, fillMix));\n\t\t vec4 outColor = mix(colorFill, colorStroke, edge * strokeOpacity);\n\n\t\t diffuseColor.rgb = outColor.rgb;\n\t\t diffuseColor.a *= outColor.a;\n\t\t")},e.side=P.DoubleSide,e.transparent=!0}(e.material,n),()=>{e.material.dispose(),e.material=t}}),[]),T.createElement("object3D",{ref:r})}R.extend({MeshWireframeMaterial:oo});const mo=new P.Matrix4,fo=new P.Ray,po=new P.Sphere,ho=new P.Vector3;class xo extends P.Group{constructor(){super(),this.size=0,this.color=new P.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){var r,n;const o=this.instance.current;if(!o||!o.geometry)return;const a=o.userData.instances.indexOf(this.instanceKey);if(-1===a||a>o.geometry.drawRange.count)return;const i=null!==(r=null==(n=e.params.Points)?void 0:n.threshold)&&void 0!==r?r:1;if(po.set(this.getWorldPosition(ho),i),!1===e.ray.intersectsSphere(po))return;mo.copy(o.matrixWorld).invert(),fo.copy(e.ray).applyMatrix4(mo);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),l=s*s,c=fo.distanceSqToPoint(this.position);if(c<l){const r=new P.Vector3;fo.closestPointToPoint(this.position,r),r.applyMatrix4(this.matrixWorld);const n=e.ray.origin.distanceTo(r);if(n<e.near||n>e.far)return;t.push({distance:n,distanceToRay:Math.sqrt(c),point:r,index:a,face:null,object:this})}}}let yo,vo;const go=T.createContext(null),zo=new P.Matrix4,wo=new P.Vector3,bo=T.forwardRef((({children:t,range:r,limit:n=1e3,...a},s)=>{const l=T.useRef(null),[c,u]=T.useState([]),[[m,d,f]]=T.useState((()=>[new Float32Array(3*n),Float32Array.from({length:3*n},(()=>1)),Float32Array.from({length:n},(()=>1))]));T.useEffect((()=>{l.current.geometry.attributes.position.needsUpdate=!0})),o.useFrame((()=>{for(l.current.updateMatrix(),l.current.updateMatrixWorld(),zo.copy(l.current.matrixWorld).invert(),l.current.geometry.drawRange.count=Math.min(n,void 0!==r?r:n,c.length),yo=0;yo<c.length;yo++)vo=c[yo].current,vo.getWorldPosition(wo).applyMatrix4(zo),wo.toArray(m,3*yo),l.current.geometry.attributes.position.needsUpdate=!0,vo.matrixWorldNeedsUpdate=!0,vo.color.toArray(d,3*yo),l.current.geometry.attributes.color.needsUpdate=!0,f.set([vo.size],yo),l.current.geometry.attributes.size.needsUpdate=!0}));const p=T.useMemo((()=>({getParent:()=>l,subscribe:e=>(u((t=>[...t,e])),()=>u((t=>t.filter((t=>t.current!==e.current)))))})),[]);return T.createElement("points",e({userData:{instances:c},matrixAutoUpdate:!1,ref:i([s,l]),raycast:()=>null},a),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",count:m.length/3,array:m,itemSize:3,usage:P.DynamicDrawUsage}),T.createElement("bufferAttribute",{attach:"attributes-color",count:d.length/3,array:d,itemSize:3,usage:P.DynamicDrawUsage}),T.createElement("bufferAttribute",{attach:"attributes-size",count:f.length,array:f,itemSize:1,usage:P.DynamicDrawUsage})),T.createElement(go.Provider,{value:p},t))})),Eo=T.forwardRef((({children:t,...r},n)=>{T.useMemo((()=>o.extend({PositionPoint:xo})),[]);const a=T.useRef(),{subscribe:s,getParent:l}=T.useContext(go);return T.useLayoutEffect((()=>s(a)),[]),T.createElement("positionPoint",e({instance:l(),instanceKey:a,ref:i([n,a])},r),t)})),Mo=T.forwardRef((({children:t,positions:r,colors:n,sizes:a,stride:s=3,...l},c)=>{const u=T.useRef(null);return o.useFrame((()=>{const e=u.current.geometry.attributes;e.position.needsUpdate=!0,n&&(e.color.needsUpdate=!0),a&&(e.size.needsUpdate=!0)})),T.createElement("points",e({ref:i([c,u])},l),T.createElement("bufferGeometry",null,T.createElement("bufferAttribute",{attach:"attributes-position",count:r.length/s,array:r,itemSize:s,usage:P.DynamicDrawUsage}),n&&T.createElement("bufferAttribute",{attach:"attributes-color",count:n.length/s,array:n,itemSize:3,usage:P.DynamicDrawUsage}),a&&T.createElement("bufferAttribute",{attach:"attributes-size",count:a.length/s,array:a,itemSize:1,usage:P.DynamicDrawUsage})),t)})),So=T.forwardRef(((t,r)=>t.positions instanceof Float32Array?T.createElement(Mo,e({},t,{ref:r})):T.createElement(bo,e({},t,{ref:r})))),To=new P.Matrix4,Co=new P.Matrix4,Po=[],Ro=new P.Mesh;class Do extends P.Group{constructor(){super(),this.color=new P.Color("white"),this.instance={current:void 0},this.instanceKey={current:void 0}}get geometry(){var e;return null==(e=this.instance.current)?void 0:e.geometry}raycast(e,t){const r=this.instance.current;if(!r)return;if(!r.geometry||!r.material)return;Ro.geometry=r.geometry;const n=r.matrixWorld,o=r.userData.instances.indexOf(this.instanceKey);if(!(-1===o||o>r.count)){r.getMatrixAt(o,To),Co.multiplyMatrices(n,To),Ro.matrixWorld=Co,r.material instanceof P.Material?Ro.material.side=r.material.side:Ro.material.side=r.material[0].side,Ro.raycast(e,Po);for(let e=0,r=Po.length;e<r;e++){const r=Po[e];r.instanceId=o,r.object=this,t.push(r)}Po.length=0}}}const Fo=T.createContext(null),ko=new P.Matrix4,_o=new P.Matrix4,Lo=new P.Matrix4,Ao=new P.Vector3,Bo=new P.Quaternion,Uo=new P.Vector3,Oo=T.forwardRef((({context:t,children:r,...n},a)=>{T.useMemo((()=>o.extend({PositionMesh:Do})),[]);const s=T.useRef(),{subscribe:l,getParent:c}=T.useContext(t||Fo);return T.useLayoutEffect((()=>l(s)),[]),T.createElement("positionMesh",e({instance:c(),instanceKey:s,ref:i([a,s])},n),r)})),No=T.forwardRef((({children:t,range:r,limit:n=1e3,frames:a=1/0,...s},l)=>{const[{context:c,instance:u}]=T.useState((()=>{const t=T.createContext(null);return{context:t,instance:T.forwardRef(((r,n)=>T.createElement(Oo,e({context:t},r,{ref:n}))))}})),m=T.useRef(null),[d,f]=T.useState([]),[[p,h]]=T.useState((()=>{const e=new Float32Array(16*n);for(let t=0;t<n;t++)Lo.identity().toArray(e,16*t);return[e,new Float32Array([...new Array(3*n)].map((()=>1)))]}));T.useEffect((()=>{m.current.instanceMatrix.needsUpdate=!0}));let x=0,y=0;o.useFrame((()=>{if(a===1/0||x<a){m.current.updateMatrix(),m.current.updateMatrixWorld(),ko.copy(m.current.matrixWorld).invert(),y=Math.min(n,void 0!==r?r:n,d.length),m.current.count=y,m.current.instanceMatrix.updateRange.count=16*y,m.current.instanceColor.updateRange.count=3*y;for(let e=0;e<d.length;e++){const t=d[e].current;t.matrixWorld.decompose(Ao,Bo,Uo),_o.compose(Ao,Bo,Uo).premultiply(ko),_o.toArray(p,16*e),m.current.instanceMatrix.needsUpdate=!0,t.color.toArray(h,3*e),m.current.instanceColor.needsUpdate=!0}x++}}));const v=T.useMemo((()=>({getParent:()=>m,subscribe:e=>(f((t=>[...t,e])),()=>f((t=>t.filter((t=>t.current!==e.current)))))})),[]);return T.createElement("instancedMesh",e({userData:{instances:d},matrixAutoUpdate:!1,ref:i([l,m]),args:[null,null,0],raycast:()=>null},s),T.createElement("instancedBufferAttribute",{attach:"instanceMatrix",count:p.length/16,array:p,itemSize:16,usage:P.DynamicDrawUsage}),T.createElement("instancedBufferAttribute",{attach:"instanceColor",count:h.length/3,array:h,itemSize:3,usage:P.DynamicDrawUsage}),"function"==typeof t?T.createElement(c.Provider,{value:v},t(u)):T.createElement(Fo.Provider,{value:v},t))})),Io=T.forwardRef((function({meshes:t,children:r,...n},o){const a=Array.isArray(t);if(!a)for(const e of Object.keys(t))t[e].isMesh||delete t[e];return T.createElement("group",{ref:o},T.createElement(E,{components:(a?t:Object.values(t)).map((({geometry:t,material:r})=>T.createElement(No,e({key:t.uuid,geometry:t,material:r},n))))},(e=>a?r(...e):r(Object.keys(t).filter((e=>t[e].isMesh)).reduce(((t,r,n)=>({...t,[r]:e[n]})),{})))))})),Vo=T.createContext(null),jo=T.forwardRef(((t,r)=>{T.useMemo((()=>o.extend({SegmentObject:Wo})),[]);const{limit:n=1e3,lineWidth:a=1,children:i,...s}=t,[l,c]=T.useState([]),[u]=T.useState((()=>new m.Line2)),[d]=T.useState((()=>new m.LineMaterial)),[f]=T.useState((()=>new m.LineSegmentsGeometry)),[p]=T.useState((()=>new P.Vector2(512,512))),[h]=T.useState((()=>Array(6*n).fill(0))),[x]=T.useState((()=>Array(6*n).fill(0))),y=T.useMemo((()=>({subscribe:e=>(c((t=>[...t,e])),()=>c((t=>t.filter((t=>t.current!==e.current)))))})),[]);return o.useFrame((()=>{for(let t=0;t<n;t++){var e;const r=null==(e=l[t])?void 0:e.current;r&&(h[6*t+0]=r.start.x,h[6*t+1]=r.start.y,h[6*t+2]=r.start.z,h[6*t+3]=r.end.x,h[6*t+4]=r.end.y,h[6*t+5]=r.end.z,x[6*t+0]=r.color.r,x[6*t+1]=r.color.g,x[6*t+2]=r.color.b,x[6*t+3]=r.color.r,x[6*t+4]=r.color.g,x[6*t+5]=r.color.b)}f.setColors(x),f.setPositions(h),u.computeLineDistances()})),T.createElement("primitive",{object:u,ref:r},T.createElement("primitive",{object:f,attach:"geometry"}),T.createElement("primitive",e({object:d,attach:"material",vertexColors:!0,resolution:p,linewidth:a},s)),T.createElement(Vo.Provider,{value:y},i))}));class Wo{constructor(){this.color=new P.Color("white"),this.start=new P.Vector3(0,0,0),this.end=new P.Vector3(0,0,0)}}const Go=e=>e instanceof P.Vector3?e:new P.Vector3(..."number"==typeof e?[e,e,e]:e),Ho=T.forwardRef((({color:e,start:t,end:r},n)=>{const o=T.useContext(Vo);if(!o)throw"Segment must used inside Segments component.";const a=T.useRef(null);return T.useLayoutEffect((()=>o.subscribe(a)),[]),T.createElement("segmentObject",{ref:i([a,n]),color:e,start:Go(t),end:Go(r)})})),qo=T.forwardRef((({children:t,hysteresis:r=0,distances:n,...a},s)=>{const l=T.useRef(null);return T.useLayoutEffect((()=>{const{current:e}=l;e.levels.length=0,e.children.forEach(((t,o)=>e.levels.push({object:t,hysteresis:r,distance:n[o]})))})),o.useFrame((e=>{var t;return null==(t=l.current)?void 0:t.update(e.camera)})),T.createElement("lOD",e({ref:i([l,s])},a),t)}));const $o=new n.Matrix4,Xo=new n.Ray,Yo=new n.Sphere,Ko=new n.Vector3;const Zo=t.createContext(null);const Qo=T.forwardRef((({children:t,compute:r,width:n,height:a,samples:i=8,renderPriority:s=0,eventPriority:l=0,frames:c=1/0,stencilBuffer:u=!1,depthBuffer:m=!0,generateMipmaps:d=!1,...f},p)=>{const{size:h,viewport:x}=o.useThree(),y=je((n||h.width)*x.dpr,(a||h.height)*x.dpr,{samples:i,stencilBuffer:u,depthBuffer:m,generateMipmaps:d}),[v]=T.useState((()=>new P.Scene)),g=T.useCallback(((e,t,r)=>{var n,o;let a=null==(n=y.texture)?void 0:n.__r3f.parent;for(;a&&!(a instanceof P.Object3D);)a=a.__r3f.parent;if(!a)return!1;r.raycaster.camera||r.events.compute(e,r,null==(o=r.previousRoot)?void 0:o.getState());const[i]=r.raycaster.intersectObject(a);if(!i)return!1;const s=i.uv;if(!s)return!1;t.raycaster.setFromCamera(t.pointer.set(2*s.x-1,2*s.y-1),t.camera)}),[]);return T.useImperativeHandle(p,(()=>y.texture),[y]),T.createElement(T.Fragment,null,o.createPortal(T.createElement(Jo,{renderPriority:s,frames:c,fbo:y},t,T.createElement("group",{onPointerOver:()=>null})),v,{events:{compute:r||g,priority:l}}),T.createElement("primitive",e({object:y.texture},f)))}));function Jo({frames:e,renderPriority:t,children:r,fbo:n}){let a,i=0;return o.useFrame((t=>{(e===1/0||i<e)&&(a=t.gl.autoClear,t.gl.autoClear=!0,t.gl.setRenderTarget(n),t.gl.render(t.scene,t.camera),t.gl.setRenderTarget(null),t.gl.autoClear=a,i++)}),t),T.createElement(T.Fragment,null,r)}const ea=T.forwardRef((({id:t=1,colorWrite:r=!1,depthWrite:n=!1,...o},a)=>{const i=T.useRef(null),s=T.useMemo((()=>({colorWrite:r,depthWrite:n,stencilWrite:!0,stencilRef:t,stencilFunc:P.AlwaysStencilFunc,stencilFail:P.ReplaceStencilOp,stencilZFail:P.ReplaceStencilOp,stencilZPass:P.ReplaceStencilOp})),[t,r,n]);return T.useLayoutEffect((()=>{Object.assign(i.current.material,s)})),T.useImperativeHandle(a,(()=>i.current),[]),T.createElement("mesh",e({ref:i,renderOrder:-t},o))}));const ta=xe({blur:0,map:null,sdf:null,blend:0,size:0,resolution:new P.Vector2},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vUv = uv;\n }","uniform sampler2D sdf;\n uniform sampler2D map;\n uniform float blur;\n uniform float size;\n uniform float time;\n uniform vec2 resolution;\n varying vec2 vUv;\n #include <packing>\n void main() {\n vec2 uv = gl_FragCoord.xy / resolution.xy;\n vec4 t = texture2D(map, uv);\n float k = blur;\n float d = texture2D(sdf, vUv).r/size;\n float alpha = 1.0 - smoothstep(0.0, 1.0, clamp(d/k + 1.0, 0.0, 1.0));\n gl_FragColor = vec4(t.rgb, blur == 0.0 ? t.a : t.a * alpha);\n #include <tonemapping_fragment>\n #include <encodings_fragment>\n }"),ra=T.forwardRef((({children:t,events:r,blur:n=0,eventPriority:a=0,renderPriority:i=0,worldUnits:s=!1,resolution:l=512,...c},u)=>{o.extend({PortalMaterialImpl:ta});const m=T.useRef(null),{scene:d,gl:f,size:p,viewport:h,setEvents:x}=o.useThree(),y=je(l,l),[v,g]=T.useState(0);o.useFrame((()=>{const e=m.current.blend>0?Math.max(1,i):0;v!==e&&g(e)})),T.useEffect((()=>{void 0!==r&&x({enabled:!r})}),[r]);const[z,w]=T.useState(!0),b=rr(w);T.useLayoutEffect((()=>{var e;b.current=null==(e=m.current)?void 0:e.__r3f.parent}),[]),T.useLayoutEffect((()=>{if(b.current&&n&&null===m.current.sdf){const e=new P.Mesh(b.current.geometry,new P.MeshBasicMaterial),t=(new P.Box3).setFromBufferAttribute(e.geometry.attributes.position),r=new P.OrthographicCamera(t.min.x*(1+2/l),t.max.x*(1+2/l),t.max.y*(1+2/l),t.min.y*(1+2/l),.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0),f.setRenderTarget(y),f.render(e,r);const n=oa(l,l,f)(y.texture),o=new Float32Array(l*l);f.readRenderTargetPixels(n,0,0,l,l,o);let a=1/0;for(let e=0;e<o.length;e++)o[e]<a&&(a=o[e]);a=-a,m.current.size=a,m.current.sdf=n.texture,f.setRenderTarget(null)}}),[l,n]),T.useImperativeHandle(u,(()=>m.current));const E=T.useCallback(((e,t,r)=>{var n;if(!b.current)return!1;if(t.pointer.set(e.offsetX/t.size.width*2-1,-e.offsetY/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera),0===(null==(n=m.current)?void 0:n.blend)){const[e]=t.raycaster.intersectObject(b.current);if(!e)return t.raycaster.camera=void 0,!1}}),[]);return T.createElement("portalMaterialImpl",e({ref:m,blur:n,blend:0,resolution:[p.width*h.dpr,p.height*h.dpr],toneMapped:!1,attach:"material"},c),T.createElement(Qo,{attach:"map",frames:z?1/0:0,eventPriority:a,renderPriority:i,compute:E},t,T.createElement(na,{events:r,rootScene:d,priority:v,material:m,worldUnits:s})))}));function na({events:e,rootScene:t,material:r,priority:n,worldUnits:a}){const i=o.useThree((e=>e.scene)),s=o.useThree((e=>e.setEvents)),l=je(),c=je();T.useLayoutEffect((()=>{i.matrixAutoUpdate=!1}),[]),T.useEffect((()=>{void 0!==e&&s({enabled:e})}),[e]);const[u,d]=T.useMemo((()=>{const e={value:0};return[new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{a:{value:l.texture},b:{value:c.texture},blend:e},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D a;\n uniform sampler2D b;\n uniform float blend;\n varying vec2 vUv;\n #include <packing>\n void main() {\n vec4 ta = texture2D(a, vUv);\n vec4 tb = texture2D(b, vUv);\n gl_FragColor = mix(tb, ta, blend);\n #include <encodings_fragment>\n }"})),e]}),[]);return o.useFrame((e=>{var o;let s=null==r||null==(o=r.current)?void 0:o.__r3f.parent;if(s){var m,f,p,h;if(a)i.matrixWorld.identity();else n&&1===(null==(m=r.current)?void 0:m.blend)&&s.updateWorldMatrix(!0,!1),i.matrixWorld.copy(s.matrixWorld);if(n)(null==(f=r.current)?void 0:f.blend)>0&&(null==(p=r.current)?void 0:p.blend)<1?(d.value=r.current.blend,e.gl.setRenderTarget(l),e.gl.render(i,e.camera),e.gl.setRenderTarget(c),e.gl.render(t,e.camera),e.gl.setRenderTarget(null),u.render(e.gl)):1===(null==(h=r.current)?void 0:h.blend)&&e.gl.render(i,e.camera)}}),n),T.createElement(T.Fragment,null)}const oa=(e,t,r)=>{let n=new P.WebGLRenderTarget(e,t,{minFilter:P.LinearMipmapLinearFilter,magFilter:P.LinearFilter,type:P.FloatType,format:P.RedFormat,generateMipmaps:!0}),o=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),a=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),i=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),s=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter}),l=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter,type:P.FloatType,format:P.RedFormat}),c=new P.WebGLRenderTarget(e,t,{minFilter:P.NearestFilter,magFilter:P.NearestFilter,type:P.FloatType,format:P.RedFormat});const u=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D tex;\n varying vec2 vUv;\n #include <packing>\n void main() {\n gl_FragColor = pack2HalfToRGBA(vUv * (round(texture2D(tex, vUv).x)));\n }"})),d=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform sampler2D tex;\n varying vec2 vUv;\n #include <packing>\n void main() {\n gl_FragColor = pack2HalfToRGBA(vUv * (1.0 - round(texture2D(tex, vUv).x)));\n }"})),f=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null},offset:{value:0},level:{value:0},maxSteps:{value:0}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:`\n varying vec2 vUv;\n uniform sampler2D tex;\n uniform float offset;\n uniform float level;\n uniform float maxSteps;\n #include <packing>\n void main() {\n float closestDist = 9999999.9;\n vec2 closestPos = vec2(0.0);\n for (float x = -1.0; x <= 1.0; x += 1.0) {\n for (float y = -1.0; y <= 1.0; y += 1.0) {\n vec2 voffset = vUv;\n voffset += vec2(x, y) * vec2(${1/e}, ${1/t}) * offset;\n vec2 pos = unpackRGBATo2Half(texture2D(tex, voffset));\n float dist = distance(pos.xy, vUv);\n if(pos.x != 0.0 && pos.y != 0.0 && dist < closestDist) {\n closestDist = dist;\n closestPos = pos;\n }\n }\n }\n gl_FragColor = pack2HalfToRGBA(closestPos);\n }`})),p=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{tex:{value:null},size:{value:new P.Vector2(e,t)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D tex;\n uniform vec2 size;\n #include <packing>\n void main() {\n gl_FragColor = vec4(distance(size * unpackRGBATo2Half(texture2D(tex, vUv)), size * vUv), 0.0, 0.0, 0.0);\n }"})),h=new m.FullScreenQuad(new P.ShaderMaterial({uniforms:{inside:{value:c.texture},outside:{value:l.texture},tex:{value:null}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n varying vec2 vUv;\n uniform sampler2D inside;\n uniform sampler2D outside;\n uniform sampler2D tex;\n #include <packing>\n void main() {\n float i = texture2D(inside, vUv).x;\n float o =texture2D(outside, vUv).x;\n if (texture2D(tex, vUv).x == 0.0) {\n gl_FragColor = vec4(o, 0.0, 0.0, 0.0);\n } else {\n gl_FragColor = vec4(-i, 0.0, 0.0, 0.0);\n }\n }"}));return m=>{let x=n;m.minFilter=P.NearestFilter,m.magFilter=P.NearestFilter,u.material.uniforms.tex.value=m,r.setRenderTarget(o),u.render(r);const y=Math.ceil(Math.log(Math.max(e,t))/Math.log(2));let v=o,g=null;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===o?i:o,f.material.uniforms.level.value=e,f.material.uniforms.maxSteps.value=y,f.material.uniforms.offset.value=t,f.material.uniforms.tex.value=v.texture,r.setRenderTarget(g),f.render(r),v=g}r.setRenderTarget(l),p.material.uniforms.tex.value=g.texture,p.render(r),d.material.uniforms.tex.value=m,r.setRenderTarget(a),d.render(r),v=a;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===a?s:a,f.material.uniforms.level.value=e,f.material.uniforms.maxSteps.value=y,f.material.uniforms.offset.value=t,f.material.uniforms.tex.value=v.texture,r.setRenderTarget(g),f.render(r),v=g}return r.setRenderTarget(c),p.material.uniforms.tex.value=g.texture,p.render(r),r.setRenderTarget(x),h.material.uniforms.tex.value=m,h.render(r),r.setRenderTarget(null),x}},aa=new P.Color;function ia(e){return"top"in e}function sa({canvasSize:e,scene:t,index:r,children:n,frames:a,rect:i,track:s}){const l=o.useThree((e=>e.get)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.scene)),m=o.useThree((e=>e.setEvents));let d=0;return o.useFrame((r=>{var o,l;(a===1/0||d<=a)&&(i.current=null==(o=s.current)?void 0:o.getBoundingClientRect(),d++);if(i.current){const{position:{left:o,bottom:a,width:s,height:m},isOffscreen:d}=function(e,t){const{right:r,top:n,left:o,bottom:a,width:i,height:s}=t,l=t.bottom<0||n>e.height||r<0||t.left>e.width;if(ia(e)){const t=e.top+e.height-a;return{position:{width:i,height:s,left:o-e.left,top:n,bottom:t,right:r},isOffscreen:l}}return{position:{width:i,height:s,top:n,left:o,bottom:e.height-a,right:r},isOffscreen:l}}(e,i.current),f=s/m;(l=c)&&l.isOrthographicCamera?c.left===s/-2&&c.right===s/2&&c.top===m/2&&c.bottom===m/-2||(Object.assign(c,{left:s/-2,right:s/2,top:m/2,bottom:m/-2}),c.updateProjectionMatrix()):c.aspect!==f&&(c.aspect=f,c.updateProjectionMatrix()),r.gl.setViewport(o,a,s,m),r.gl.setScissor(o,a,s,m),r.gl.setScissorTest(!0),d?(r.gl.getClearColor(aa),r.gl.setClearColor(aa,r.gl.getClearAlpha()),r.gl.clear(!0,!0)):r.gl.render(n?u:t,c),r.gl.setScissorTest(!0)}}),r),T.useEffect((()=>{const e=l().events.connected;return m({connected:s.current}),()=>m({connected:e})}),[]),T.useEffect((()=>{ia(e)||console.warn("Detected @react-three/fiber canvas size does not include position information. <View /> may not work as expected. Upgrade to @react-three/fiber ^8.1.0 for support.\n See https://github.com/pmndrs/drei/issues/944")}),[]),T.createElement(T.Fragment,null,n)}const la=T.createContext(null),ca=new P.Vector3,ua=new P.Vector3,ma=new P.Vector3(0,1,0),da=new P.Matrix4,fa=({direction:e,axis:t})=>{const{translation:r,translationLimits:n,annotations:a,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:m,hoveredColor:d,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=T.useContext(la),v=o.useThree((e=>e.controls)),g=T.useRef(null),z=T.useRef(null),w=T.useRef(null),b=T.useRef(0),[E,M]=T.useState(!1),S=T.useCallback((n=>{a&&(g.current.innerText=`${r.current[t].toFixed(2)}`,g.current.style.display="block"),n.stopPropagation();const o=(new P.Matrix4).extractRotation(z.current.matrixWorld),i=n.point.clone(),s=(new P.Vector3).setFromMatrixPosition(z.current.matrixWorld),l=e.clone().applyMatrix4(o).normalize();w.current={clickPoint:i,dir:l},b.current=r.current[t],p({component:"Arrow",axis:t,origin:s,directions:[l]}),v&&(v.enabled=!1),n.target.setPointerCapture(n.pointerId)}),[a,e,v,p,r,t]),C=T.useCallback((e=>{if(e.stopPropagation(),E||M(!0),w.current){const{clickPoint:o,dir:i}=w.current,[s,l]=(null==n?void 0:n[t])||[void 0,void 0];let c=((e,t,r,n)=>{const o=t.dot(t),a=t.dot(e)-t.dot(r),i=t.dot(n);return 0===i?-a/o:(ca.copy(n).multiplyScalar(o/i).sub(t),ua.copy(n).multiplyScalar(a/i).add(r).sub(e),-ca.dot(ua)/ca.dot(ca))})(o,i,e.ray.origin,e.ray.direction);void 0!==s&&(c=Math.max(c,s-b.current)),void 0!==l&&(c=Math.min(c,l-b.current)),r.current[t]=b.current+c,a&&(g.current.innerText=`${r.current[t].toFixed(2)}`),da.makeTranslation(i.x*c,i.y*c,i.z*c),h(da)}}),[a,h,E,r,n,t]),R=T.useCallback((e=>{a&&(g.current.style.display="none"),e.stopPropagation(),w.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[a,v,x]),D=T.useCallback((e=>{e.stopPropagation(),M(!1)}),[]),{cylinderLength:F,coneWidth:k,coneLength:_,matrixL:L}=T.useMemo((()=>{const t=u?c/l*1.6:l/20,r=u?.2:l/5,n=u?1-r:l-r,o=(new P.Quaternion).setFromUnitVectors(ma,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new P.Matrix4).makeRotationFromQuaternion(o)}}),[e,l,c,u]),A=E?d:m[t];return T.createElement("group",{ref:z},T.createElement("group",{matrix:L,matrixAutoUpdate:!1,onPointerDown:S,onPointerMove:C,onPointerUp:R,onPointerOut:D},a&&T.createElement(N,{position:[0,-_,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),T.createElement("mesh",{visible:!1,position:[0,(F+_)/2,0],userData:y},T.createElement("cylinderGeometry",{args:[1.4*k,1.4*k,F+_,8,1]})),T.createElement(re,{transparent:!0,raycast:()=>null,depthTest:s,points:[0,0,0,0,F,0],lineWidth:c,color:A,opacity:f,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),T.createElement("mesh",{raycast:()=>null,position:[0,F+_/2,0],renderOrder:500},T.createElement("coneGeometry",{args:[k,_,24,1]}),T.createElement("meshBasicMaterial",{transparent:!0,depthTest:s,color:A,opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},pa=new P.Ray,ha=new P.Vector3,xa=new P.Matrix4,ya=({dir1:e,dir2:t,axis:r})=>{const{translation:n,translationLimits:a,annotations:i,annotationsClass:s,depthTest:l,scale:c,lineWidth:u,fixed:m,axisColors:d,hoveredColor:f,opacity:p,onDragStart:h,onDrag:x,onDragEnd:y,userData:v}=T.useContext(la),g=o.useThree((e=>e.controls)),z=T.useRef(null),w=T.useRef(null),b=T.useRef(null),E=T.useRef(0),M=T.useRef(0),[S,C]=T.useState(!1),R=T.useCallback((e=>{i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`,z.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),o=(new P.Vector3).setFromMatrixPosition(w.current.matrixWorld),a=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,0).normalize(),s=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,1).normalize(),l=(new P.Vector3).setFromMatrixColumn(w.current.matrixWorld,2).normalize(),c=(new P.Plane).setFromNormalAndCoplanarPoint(l,o);b.current={clickPoint:t,e1:a,e2:s,plane:c},E.current=n.current[(r+1)%3],M.current=n.current[(r+2)%3],h({component:"Slider",axis:r,origin:o,directions:[a,s,l]}),g&&(g.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[i,g,h,r]),D=T.useCallback((e=>{if(e.stopPropagation(),S||C(!0),b.current){const{clickPoint:t,e1:o,e2:s,plane:l}=b.current,[c,u]=(null==a?void 0:a[(r+1)%3])||[void 0,void 0],[m,d]=(null==a?void 0:a[(r+2)%3])||[void 0,void 0];pa.copy(e.ray),pa.intersectPlane(l,ha),pa.direction.negate(),pa.intersectPlane(l,ha),ha.sub(t);let[f,p]=((e,t,r)=>{const n=Math.abs(e.x)>=Math.abs(e.y)&&Math.abs(e.x)>=Math.abs(e.z)?0:Math.abs(e.y)>=Math.abs(e.x)&&Math.abs(e.y)>=Math.abs(e.z)?1:2,o=[0,1,2].sort(((e,r)=>Math.abs(t.getComponent(r))-Math.abs(t.getComponent(e)))),a=n===o[0]?o[1]:o[0],i=e.getComponent(n),s=e.getComponent(a),l=t.getComponent(n),c=t.getComponent(a),u=r.getComponent(n),m=(r.getComponent(a)-u*(s/i))/(c-l*(s/i));return[(u-m*l)/i,m]})(o,s,ha);void 0!==c&&(f=Math.max(f,c-E.current)),void 0!==u&&(f=Math.min(f,u-E.current)),void 0!==m&&(p=Math.max(p,m-M.current)),void 0!==d&&(p=Math.min(p,d-M.current)),n.current[(r+1)%3]=E.current+f,n.current[(r+2)%3]=M.current+p,i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`),xa.makeTranslation(f*o.x+p*s.x,f*o.y+p*s.y,f*o.z+p*s.z),x(xa)}}),[i,x,S,n,a,r]),F=T.useCallback((e=>{i&&(z.current.style.display="none"),e.stopPropagation(),b.current=null,y(),g&&(g.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[i,g,y]),k=T.useCallback((e=>{e.stopPropagation(),C(!1)}),[]),_=T.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new P.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),L=m?1/7:c/7,A=m?.225:.225*c,B=S?f:d[r],U=T.useMemo((()=>[new P.Vector3(0,0,0),new P.Vector3(0,A,0),new P.Vector3(A,A,0),new P.Vector3(A,0,0),new P.Vector3(0,0,0)]),[A]);return T.createElement("group",{ref:w,matrix:_,matrixAutoUpdate:!1},i&&T.createElement(N,{position:[0,0,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:s,ref:z})),T.createElement("group",{position:[1.7*L,1.7*L,0]},T.createElement("mesh",{visible:!0,onPointerDown:R,onPointerMove:D,onPointerUp:F,onPointerOut:k,scale:A,userData:v},T.createElement("planeGeometry",null),T.createElement("meshBasicMaterial",{transparent:!0,depthTest:l,color:B,polygonOffset:!0,polygonOffsetFactor:-10,side:P.DoubleSide,fog:!1})),T.createElement(re,{position:[-A/2,-A/2,0],transparent:!0,depthTest:l,points:U,lineWidth:u,color:B,opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,userData:v,fog:!1})))},va=new P.Vector3,ga=new P.Vector3,za=e=>180*e/Math.PI,wa=e=>{let t=((e,t)=>{let r=Math.floor(e/t);return r=r<0?r+1:r,e-r*t})(e,2*Math.PI);return Math.abs(t)<1e-6?0:(t<0&&(t+=2*Math.PI),t)},ba=new P.Matrix4,Ea=new P.Vector3,Ma=new P.Ray,Sa=new P.Vector3,Ta=({dir1:e,dir2:t,axis:r})=>{const{rotationLimits:n,annotations:a,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:m,hoveredColor:d,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=T.useContext(la),v=o.useThree((e=>e.controls)),g=T.useRef(null),z=T.useRef(null),w=T.useRef(0),b=T.useRef(0),E=T.useRef(null),[S,C]=T.useState(!1),R=T.useCallback((e=>{a&&(g.current.innerText=`${za(b.current).toFixed(0)}º`,g.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),n=(new P.Vector3).setFromMatrixPosition(z.current.matrixWorld),o=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,0).normalize(),i=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,1).normalize(),s=(new P.Vector3).setFromMatrixColumn(z.current.matrixWorld,2).normalize(),l=(new P.Plane).setFromNormalAndCoplanarPoint(s,n);E.current={clickPoint:t,origin:n,e1:o,e2:i,normal:s,plane:l},p({component:"Rotator",axis:r,origin:n,directions:[o,i,s]}),v&&(v.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[a,v,p,r]),D=T.useCallback((e=>{if(e.stopPropagation(),S||C(!0),E.current){const{clickPoint:t,origin:o,e1:i,e2:s,normal:l,plane:c}=E.current,[u,m]=(null==n?void 0:n[r])||[void 0,void 0];Ma.copy(e.ray),Ma.intersectPlane(c,Sa),Ma.direction.negate(),Ma.intersectPlane(c,Sa);let d=((e,t,r,n,o)=>{va.copy(e).sub(r),ga.copy(t).sub(r);const a=n.dot(n),i=o.dot(o),s=va.dot(n)/a,l=va.dot(o)/i,c=ga.dot(n)/a,u=ga.dot(o)/i,m=Math.atan2(l,s);return Math.atan2(u,c)-m})(t,Sa,o,i,s),f=za(d);e.shiftKey&&(f=10*Math.round(f/10),d=(e=>e*Math.PI/180)(f)),void 0!==u&&void 0!==m&&m-u<2*Math.PI?(d=wa(d),d=d>Math.PI?d-2*Math.PI:d,d=M(d,u-w.current,m-w.current),b.current=w.current+d):(b.current=wa(w.current+d),b.current=b.current>Math.PI?b.current-2*Math.PI:b.current),a&&(f=za(b.current),g.current.innerText=`${f.toFixed(0)}º`),ba.makeRotationAxis(l,d),Ea.copy(o).applyMatrix4(ba).sub(o).negate(),ba.setPosition(Ea),h(ba)}}),[a,h,S,n,r]),F=T.useCallback((e=>{a&&(g.current.style.display="none"),e.stopPropagation(),w.current=b.current,E.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[a,v,x]),k=T.useCallback((e=>{e.stopPropagation(),C(!1)}),[]),_=T.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new P.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),L=u?.65:.65*l,A=T.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new P.Vector3(Math.cos(r)*L,Math.sin(r)*L,0))}return e}),[L]);return T.createElement("group",{ref:z,onPointerDown:R,onPointerMove:D,onPointerUp:F,onPointerOut:k,matrix:_,matrixAutoUpdate:!1},a&&T.createElement(N,{position:[L,L,0]},T.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),T.createElement(re,{points:A,lineWidth:4*c,visible:!1,userData:y}),T.createElement(re,{transparent:!0,raycast:()=>null,depthTest:s,points:A,lineWidth:c,color:S?d:m[r],opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))},Ca=new P.Vector3,Pa=new P.Vector3,Ra=new P.Vector3,Da=(e,t,r,n=1)=>{const o=Ca.set(e.x/r.width*2-1,-e.y/r.height*2+1,n);return o.unproject(t),o},Fa=(e,t,r,n)=>{const o=((e,t,r)=>{const n=r.width/2,o=r.height/2;t.updateMatrixWorld(!1);const a=e.project(t);return a.x=a.x*n+n,a.y=-a.y*o+o,a})(Ra.copy(e),r,n);let a=0;for(let i=0;i<2;++i){const s=Pa.copy(o).setComponent(i,o.getComponent(i)+t),l=Da(s,r,n,s.z);a=Math.max(a,e.distanceTo(l))}return a},ka=new P.Matrix4,_a=new P.Matrix4,La=new P.Matrix4,Aa=new P.Matrix4,Ba=new P.Matrix4,Ua=new P.Matrix4,Oa=new P.Matrix4,Na=new P.Matrix4,Ia=new P.Box3,Va=new P.Box3,ja=new P.Vector3,Wa=new P.Vector3,Ga=new P.Vector3,Ha=new P.Vector3,qa=new P.Vector3(1,0,0),$a=new P.Vector3(0,1,0),Xa=new P.Vector3(0,0,1),Ya=T.forwardRef((({matrix:t,onDragStart:r,onDrag:n,onDragEnd:a,autoTransform:i=!0,anchor:s,disableAxes:l=!1,disableSliders:c=!1,disableRotations:u=!1,activeAxes:m=[!0,!0,!0],offset:d=[0,0,0],rotation:f=[0,0,0],scale:p=1,lineWidth:h=4,fixed:x=!1,translationLimits:y,rotationLimits:v,depthTest:g=!0,axisColors:z=["#ff2060","#20df80","#2080ff"],hoveredColor:w="#ffff40",annotations:b=!1,annotationsClass:E,opacity:M=1,visible:S=!0,userData:C,children:R,...D},F)=>{const k=o.useThree((e=>e.invalidate)),_=T.useRef(null),L=T.useRef(null),A=T.useRef(null),B=T.useRef(null),U=T.useRef([0,0,0]);T.useLayoutEffect((()=>{s&&(B.current.updateWorldMatrix(!0,!0),Aa.copy(B.current.matrixWorld).invert(),Ia.makeEmpty(),B.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),Ua.copy(e.matrixWorld).premultiply(Aa),Va.copy(e.geometry.boundingBox),Va.applyMatrix4(Ua),Ia.union(Va))})),ja.copy(Ia.max).add(Ia.min).multiplyScalar(.5),Wa.copy(Ia.max).sub(Ia.min).multiplyScalar(.5),Ga.copy(Wa).multiply(new P.Vector3(...s)).add(ja),Ha.set(...d).add(Ga),A.current.position.copy(Ha),k())}));const O=T.useMemo((()=>({onDragStart:e=>{ka.copy(L.current.matrix),_a.copy(L.current.matrixWorld),r&&r(e),k()},onDrag:e=>{La.copy(_.current.matrixWorld),Aa.copy(La).invert(),Ba.copy(_a).premultiply(e),Ua.copy(Ba).premultiply(Aa),Oa.copy(ka).invert(),Na.copy(Ua).multiply(Oa),i&&L.current.matrix.copy(Ua),n&&n(Ua,Na,Ba,e),k()},onDragEnd:()=>{a&&a(),k()},translation:U,translationLimits:y,rotationLimits:v,axisColors:z,hoveredColor:w,opacity:M,scale:p,lineWidth:h,fixed:x,depthTest:g,userData:C,annotations:b,annotationsClass:E})),[r,n,a,U,y,v,g,p,h,x,...z,w,M,C,i,b,E]),N=new P.Vector3;return o.useFrame((e=>{if(x){const o=Fa(A.current.getWorldPosition(N),p,e.camera,e.size);var t,r,n;if(A.current)(null==(t=A.current)?void 0:t.scale.x)===o&&(null==(r=A.current)?void 0:r.scale.y)===o&&(null==(n=A.current)?void 0:n.scale.z)===o||(A.current.scale.setScalar(o),e.invalidate())}})),T.useImperativeHandle(F,(()=>L.current),[]),T.useLayoutEffect((()=>{t&&t instanceof P.Matrix4&&(L.current.matrix=t)}),[t]),T.createElement(la.Provider,{value:O},T.createElement("group",{ref:_},T.createElement("group",e({ref:L,matrix:t,matrixAutoUpdate:!1},D),T.createElement("group",{visible:S,ref:A,position:d,rotation:f},!l&&m[0]&&T.createElement(fa,{axis:0,direction:qa}),!l&&m[1]&&T.createElement(fa,{axis:1,direction:$a}),!l&&m[2]&&T.createElement(fa,{axis:2,direction:Xa}),!c&&m[0]&&m[1]&&T.createElement(ya,{axis:2,dir1:qa,dir2:$a}),!c&&m[0]&&m[2]&&T.createElement(ya,{axis:1,dir1:Xa,dir2:qa}),!c&&m[2]&&m[1]&&T.createElement(ya,{axis:0,dir1:$a,dir2:Xa}),!u&&m[0]&&m[1]&&T.createElement(Ta,{axis:2,dir1:qa,dir2:$a}),!u&&m[0]&&m[2]&&T.createElement(Ta,{axis:1,dir1:Xa,dir2:qa}),!u&&m[2]&&m[1]&&T.createElement(Ta,{axis:0,dir1:$a,dir2:Xa})),T.createElement("group",{ref:B},R))))}));exports.AccumulativeShadows=En,exports.AdaptiveDpr=function({pixelated:e}){const t=o.useThree((e=>e.gl)),r=o.useThree((e=>e.internal.active)),n=o.useThree((e=>e.performance.current)),a=o.useThree((e=>e.viewport.initialDpr)),i=o.useThree((e=>e.setDpr));return T.useEffect((()=>{const n=t.domElement;return()=>{r&&i(a),e&&n&&(n.style.imageRendering="auto")}}),[]),T.useEffect((()=>{i(n*a),e&&t.domElement&&(t.domElement.style.imageRendering=1===n?"auto":"pixelated")}),[n]),null},exports.AdaptiveEvents=function(){const e=o.useThree((e=>e.get)),t=o.useThree((e=>e.setEvents)),r=o.useThree((e=>e.performance.current));return T.useEffect((()=>{const r=e().events.enabled;return()=>t({enabled:r})}),[]),T.useEffect((()=>t({enabled:1===r})),[r]),null},exports.ArcballControls=Ze,exports.AsciiRenderer=function({renderIndex:e=1,bgColor:t="black",fgColor:r="white",characters:n=" .:-+*=%@#",invert:a=!0,color:i=!1,resolution:s=.15}){const{size:l,gl:c,scene:u,camera:d}=o.useThree(),f=T.useMemo((()=>{const e=new m.AsciiEffect(c,n,{invert:a,color:i,resolution:s});return e.domElement.style.position="absolute",e.domElement.style.top="0px",e.domElement.style.left="0px",e.domElement.style.pointerEvents="none",e}),[n,a,i,s]);return T.useLayoutEffect((()=>{f.domElement.style.color=r,f.domElement.style.backgroundColor=t}),[r,t]),T.useEffect((()=>(c.domElement.style.opacity="0",c.domElement.parentNode.appendChild(f.domElement),()=>{c.domElement.style.opacity="1",c.domElement.parentNode.removeChild(f.domElement)})),[f]),T.useEffect((()=>{f.setSize(l.width,l.height)}),[f,l]),o.useFrame((e=>{f.render(u,d)}),e),T.createElement(T.Fragment,null)},exports.BBAnchor=({anchor:t,...r})=>{const n=T.useRef(null),a=T.useRef(null);return T.useEffect((()=>{var e,t;null!=(e=n.current)&&null!=(t=e.parent)&&t.parent&&(a.current=n.current.parent,n.current.parent.parent.add(n.current))}),[]),o.useFrame((()=>{a.current&&(sr.setFromObject(a.current),sr.getSize(lr),n.current.position.set(a.current.position.x+lr.x*t[0]/2,a.current.position.y+lr.y*t[1]/2,a.current.position.z+lr.z*t[2]/2))})),T.createElement("group",e({ref:n},r))},exports.Backdrop=function({children:e,floor:t=.25,segments:r=20,receiveShadow:n,...o}){const a=T.useRef(null);return T.useLayoutEffect((()=>{let e=0;const n=r/r/2,o=a.current.attributes.position;for(let a=0;a<r+1;a++)for(let i=0;i<r+1;i++)o.setXYZ(e++,a/r-n+(0===a?-t:0),i/r-n,Pn(a/r));o.needsUpdate=!0,a.current.computeVertexNormals()}),[r,t]),T.createElement("group",o,T.createElement("mesh",{receiveShadow:n,rotation:[-Math.PI/2,0,Math.PI/2]},T.createElement("planeGeometry",{ref:a,args:[1,1,r,r]}),e))},exports.BakeShadows=function(){const e=o.useThree((e=>e.gl));return t.useEffect((()=>(e.shadowMap.autoUpdate=!1,e.shadowMap.needsUpdate=!0,()=>{e.shadowMap.autoUpdate=e.shadowMap.needsUpdate=!0})),[e.shadowMap]),null},exports.Billboard=ee,exports.Bounds=on,exports.Box=Fr,exports.Bvh=tr,exports.CameraControls=tt,exports.CameraShake=sn,exports.Capsule=Xr,exports.CatmullRomLine=ie,exports.Caustics=An,exports.Center=mr,exports.Circle=kr,exports.Clone=De,exports.Cloud=function({opacity:e=.5,speed:t=.4,width:r=10,depth:n=1.5,segments:a=20,texture:i="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",color:s="#ffffff",depthTest:l=!0,...c}){const u=T.useRef(),m=ve(i),d=T.useMemo((()=>[...new Array(a)].map(((e,n)=>({x:r/2-Math.random()*r,y:r/2-Math.random()*r,scale:.4+Math.sin((n+1)/a*Math.PI)*(10*(.2+Math.random())),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*t})))),[r,a,t]);return o.useFrame((e=>{var t;return null==(t=u.current)?void 0:t.children.forEach(((t,r)=>{t.children[0].rotation.z+=d[r].rotation,t.children[0].scale.setScalar(d[r].scale+(1+Math.sin(e.clock.getElapsedTime()/10))/2*r/10)}))})),T.createElement("group",c,T.createElement("group",{position:[0,0,a/2*n],ref:u},d.map((({x:t,y:r,scale:o,density:a},i)=>T.createElement(ee,{key:i,position:[t,r,-i*n]},T.createElement(Br,{scale:o,rotation:[0,0,0]},T.createElement("meshStandardMaterial",{map:m,transparent:!0,opacity:o/6*a*e,depthTest:l,color:s})))))))},exports.ComputedAttribute=({compute:t,name:r,...o})=>{const[a]=T.useState((()=>new n.BufferAttribute(new Float32Array(0),1))),i=T.useRef(null);return T.useLayoutEffect((()=>{if(i.current){var e;const r=null!==(e=i.current.parent)&&void 0!==e?e:i.current.__r3f.parent,n=t(r);i.current.copy(n)}}),[t]),T.createElement("primitive",e({ref:i,object:a,attach:`attributes-${r}`},o))},exports.Cone=_r,exports.ContactShadows=zn,exports.CubeCamera=function({children:e,frames:t=1/0,resolution:r,near:n,far:a,envMap:i,fog:s,...l}){const c=T.useRef(),{fbo:u,camera:m,update:d}=He({resolution:r,near:n,far:a,envMap:i,fog:s});let f=0;return o.useFrame((()=>{c.current&&(t===1/0||f<t)&&(c.current.visible=!1,d(),c.current.visible=!0,f++)})),T.createElement("group",l,T.createElement("primitive",{object:m}),T.createElement("group",{ref:c},e(u.texture)))},exports.CubicBezierLine=ae,exports.CurveModifier=fr,exports.CycleRaycast=function({onChanged:e,portal:t,preventDefault:r=!0,scroll:n=!0,keyCode:a=9}){const i=T.useRef(0),s=o.useThree((e=>e.setEvents)),l=o.useThree((e=>e.get)),c=o.useThree((e=>e.gl));return T.useEffect((()=>{var o;let u,m=[];const d=l().events.filter,f=null!==(o=null==t?void 0:t.current)&&void 0!==o?o:c.domElement.parentNode,p=()=>f&&e&&e(m,Math.round(i.current)%m.length);s({filter:(e,t)=>{let r=[...e];r.length===m.length&&m.every((e=>r.map((e=>e.object.uuid)).includes(e.object.uuid)))||(i.current=0,m=r,p()),d&&(r=d(r,t));for(let e=0;e<Math.round(i.current)%r.length;e++){const e=r.shift();r=[...r,e]}return r}});const h=e=>{var t,r;i.current=e(i.current),null==(t=l().events.handlers)||t.onPointerCancel(void 0),null==(r=l().events.handlers)||r.onPointerMove(u),p()},x=e=>{(e.keyCode||e.which===a)&&(r&&e.preventDefault(),m.length>1&&h((e=>e+1)))},y=e=>{r&&e.preventDefault();let t=0;e||(e=window.event),e.wheelDelta?t=e.wheelDelta/120:e.detail&&(t=-e.detail/3),m.length>1&&h((e=>Math.abs(e-t)))},v=e=>u=e;return document.addEventListener("pointermove",v,{passive:!0}),n&&document.addEventListener("wheel",y),void 0!==a&&document.addEventListener("keydown",x),()=>{s({filter:d}),void 0!==a&&document.removeEventListener("keydown",x),n&&document.removeEventListener("wheel",y),document.removeEventListener("pointermove",v)}}),[c,l,s,r,n,a]),null},exports.Cylinder=Lr,exports.Decal=Be,exports.Detailed=qo,exports.DeviceOrientationControls=qe,exports.Dodecahedron=Hr,exports.Edges=Me,exports.Effects=pe,exports.Environment=gn,exports.EnvironmentCube=xn,exports.EnvironmentMap=hn,exports.EnvironmentPortal=yn,exports.Example=dr,exports.Extrude=qr,exports.FaceControls=ht,exports.FaceLandmarker=function({basePath:e=ut.basePath,options:r=ut.options,children:n}){const o=JSON.stringify(r),a=p.suspend((async()=>await g.FilesetResolver.forVisionTasks(e).then((e=>g.FaceLandmarker.createFromOptions(e,r)))),[e,o]);return t.useEffect((()=>()=>{null==a||a.close(),p.clear([e,o])}),[a,e,o]),T.createElement(ct.Provider,{value:a},n)},exports.FaceLandmarkerDefaults=ut,exports.Facemesh=at,exports.FacemeshDatas=lt,exports.FacemeshEye=st,exports.FacemeshEyeDefaults=it,exports.FirstPersonControls=et,exports.Float=ln,exports.FlyControls=$e,exports.GizmoHelper=({alignment:e="bottom-right",margin:t=[80,80],renderPriority:r=1,onUpdate:a,onTarget:i,children:s})=>{const l=o.useThree((e=>e.size)),c=o.useThree((e=>e.camera)),u=o.useThree((e=>e.controls)),m=o.useThree((e=>e.invalidate)),d=T.useRef(),f=T.useRef(null),p=T.useRef(!1),h=T.useRef(0),x=T.useRef(new n.Vector3(0,0,0)),y=T.useRef(new n.Vector3(0,0,0));T.useEffect((()=>{y.current.copy(c.up)}),[c]);const v=T.useCallback((e=>{p.current=!0,(u||i)&&(x.current=(null==u?void 0:u.target)||(null==i?void 0:i())),h.current=c.position.distanceTo(Rt),Ct.copy(c.quaternion),Dt.copy(e).multiplyScalar(h.current).add(Rt),St.lookAt(Dt),St.up.copy(c.up),Pt.copy(St.quaternion),m()}),[u,c,i,m]);o.useFrame(((e,t)=>{if(f.current&&d.current){var r;if(p.current)if(Ct.angleTo(Pt)<.01)p.current=!1,"minPolarAngle"in u&&c.up.copy(y.current);else{const e=t*Mt;Ct.rotateTowards(Pt,e),c.position.set(0,0,1).applyQuaternion(Ct).multiplyScalar(h.current).add(x.current),c.up.set(0,1,0).applyQuaternion(Ct).normalize(),c.quaternion.copy(Ct),a?a():u&&u.update(),m()}Tt.copy(c.matrix).invert(),null==(r=d.current)||r.quaternion.setFromRotationMatrix(Tt)}}));const g=T.useMemo((()=>({tweenCamera:v})),[v]),[z,w]=t,b=e.endsWith("-center")?0:e.endsWith("-left")?-l.width/2+z:l.width/2-z,E=e.startsWith("center-")?0:e.startsWith("top-")?l.height/2-w:-l.height/2+w;return T.createElement(wt,{renderPriority:r},T.createElement(bt.Provider,{value:g},T.createElement(We,{makeDefault:!0,ref:f,position:[0,0,200]}),T.createElement("group",{ref:d,position:[b,E,0]},s)))},exports.GizmoViewcube=t=>T.createElement("group",{scale:[60,60,60]},T.createElement(jt,t),Nt.map(((r,n)=>T.createElement(Wt,e({key:n,position:r,dimensions:It[n]},t)))),Ut.map(((r,n)=>T.createElement(Wt,e({key:n,position:r,dimensions:Ot},t))))),exports.GizmoViewport=({hideNegativeAxes:t,hideAxisHeads:r,disabled:n,font:o="18px Inter var, Arial, sans-serif",axisColors:a=["#ff2060","#20df80","#2080ff"],axisHeadScale:i=1,axisScale:s,labels:l=["X","Y","Z"],labelColor:c="#000",onClick:u,...m})=>{const[d,f,p]=a,{tweenCamera:h}=Et(),x={font:o,disabled:n,labelColor:c,onClick:u,axisHeadScale:i,onPointerDown:n?void 0:e=>{h(e.object.position),e.stopPropagation()}};return T.createElement("group",e({scale:40},m),T.createElement(Gt,{color:d,rotation:[0,0,0],scale:s}),T.createElement(Gt,{color:f,rotation:[0,0,Math.PI/2],scale:s}),T.createElement(Gt,{color:p,rotation:[0,-Math.PI/2,0],scale:s}),!r&&T.createElement(T.Fragment,null,T.createElement(Ht,e({arcStyle:d,position:[1,0,0],label:l[0]},x)),T.createElement(Ht,e({arcStyle:f,position:[0,1,0],label:l[1]},x)),T.createElement(Ht,e({arcStyle:p,position:[0,0,1],label:l[2]},x)),!t&&T.createElement(T.Fragment,null,T.createElement(Ht,e({arcStyle:d,position:[-1,0,0]},x)),T.createElement(Ht,e({arcStyle:f,position:[0,-1,0]},x)),T.createElement(Ht,e({arcStyle:p,position:[0,0,-1]},x)))))},exports.Gltf=Ve,exports.GradientTexture=function({stops:t,colors:r,size:n=1024,width:a=16,type:i=he.Linear,innerCircleRadius:s=0,outerCircleRadius:l="auto",...c}){const u=o.useThree((e=>e.gl)),m=T.useMemo((()=>{const e=document.createElement("canvas"),o=e.getContext("2d");let c;if(e.width=a,e.height=n,i===he.Linear)c=o.createLinearGradient(0,0,0,n);else{const t=e.width/2,r=e.height/2,n="auto"!==l?Math.abs(Number(l)):Math.sqrt(t**2+r**2);c=o.createRadialGradient(t,r,Math.abs(s),t,r,n)}let u=t.length;for(;u--;)c.addColorStop(t[u],r[u]);return o.save(),o.fillStyle=c,o.fillRect(0,0,a,n),o.restore(),e}),[t]);return T.createElement("canvasTexture",e({colorSpace:u.outputColorSpace,args:[m],attach:"map"},c))},exports.GradientType=he,exports.Grid=$t,exports.Html=N,exports.Hud=wt,exports.Icosahedron=Wr,exports.Image=Ee,exports.Instance=Oo,exports.Instances=No,exports.IsObject=ye,exports.KeyboardControls=function({map:e,children:t,onChange:r,domElement:n}){const o=e.map((e=>e.name+e.keys)).join("-"),a=T.useMemo((()=>K(u.subscribeWithSelector((()=>e.reduce(((e,t)=>({...e,[t.name]:!1})),{}))))),[o]),i=T.useMemo((()=>[a.subscribe,a.getState,a]),[o]),s=a.setState;return T.useEffect((()=>{const t=e.map((({name:e,keys:t,up:n})=>({keys:t,up:n,fn:t=>{s({[e]:t}),r&&r(e,t,i[1]())}}))).reduce(((e,{keys:t,fn:r,up:n=!0})=>(t.forEach((t=>e[t]={fn:r,pressed:!1,up:n})),e)),{}),o=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:o,pressed:a,up:i}=n;n.pressed=!0,!i&&a||o(!0)},a=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:o,up:a}=n;n.pressed=!1,a&&o(!1)},l=n||window;return l.addEventListener("keydown",o,{passive:!0}),l.addEventListener("keyup",a,{passive:!0}),()=>{l.removeEventListener("keydown",o),l.removeEventListener("keyup",a)}}),[n,o]),T.createElement(Z.Provider,{value:i,children:t})},exports.Lathe=$r,exports.Lightformer=Hn,exports.Line=re,exports.Loader=function({containerStyles:e,innerStyles:t,barStyles:r,dataStyles:n,dataInterpolation:o=W,initialState:a=(e=>e)}){const{active:i,progress:s}=j(),l=T.useRef(0),c=T.useRef(0),u=T.useRef(null),[m,d]=T.useState(a(i));T.useEffect((()=>{let e;return i!==m&&(e=setTimeout((()=>d(i)),300)),()=>clearTimeout(e)}),[m,i]);const f=T.useCallback((()=>{u.current&&(l.current+=(s-l.current)/2,(l.current>.95*s||100===s)&&(l.current=s),u.current.innerText=o(l.current),l.current<s&&(c.current=requestAnimationFrame(f)))}),[o,s]);return T.useEffect((()=>(f(),()=>cancelAnimationFrame(c.current))),[f]),m?T.createElement("div",{style:{...G.container,opacity:i?1:0,...e}},T.createElement("div",null,T.createElement("div",{style:{...G.inner,...t}},T.createElement("div",{style:{...G.bar,transform:`scaleX(${s/100})`,...r}}),T.createElement("span",{ref:u,style:{...G.data,...n}})))):null},exports.MapControls=Xe,exports.MarchingCube=_e,exports.MarchingCubes=ke,exports.MarchingPlane=Le,exports.Mask=ea,exports.Merged=Io,exports.MeshDiscardMaterial=Tr,exports.MeshDistortMaterial=hr,exports.MeshPortalMaterial=ra,exports.MeshReflectorMaterial=wr,exports.MeshRefractionMaterial=function({aberrationStrength:r=0,fastChroma:n=!0,envMap:a,...i}){o.extend({MeshRefractionMaterial:br});const s=t.useRef(),{size:l}=o.useThree(),c=t.useMemo((()=>{var e,t;const o={},i=(s=a)&&s.isCubeTexture;var s;const l=(null!==(e=i?null==(t=a.image[0])?void 0:t.width:a.image.width)&&void 0!==e?e:1024)/4,c=Math.floor(Math.log2(l)),u=Math.pow(2,c),m=3*Math.max(u,112),d=4*u;return i&&(o.ENVMAP_TYPE_CUBEM=""),o.CUBEUV_TEXEL_WIDTH=""+1/m,o.CUBEUV_TEXEL_HEIGHT=""+1/d,o.CUBEUV_MAX_MIP=`${c}.0`,r>0&&(o.CHROMATIC_ABERRATIONS=""),n&&(o.FAST_CHROMA=""),o}),[r,n]);return t.useLayoutEffect((()=>{var e,t,r;const n=null==(e=s.current)||null==(t=e.__r3f)||null==(r=t.parent)?void 0:r.geometry;n&&(s.current.bvh=new b.MeshBVHUniformStruct,s.current.bvh.updateFrom(new b.MeshBVH(n.clone().toNonIndexed(),{lazyGeneration:!1,strategy:b.SAH})))}),[]),o.useFrame((({camera:e})=>{s.current.viewMatrixInverse=e.matrixWorld,s.current.projectionMatrixInverse=e.projectionMatrixInverse})),T.createElement("meshRefractionMaterial",e({key:JSON.stringify(c),defines:c,ref:s,resolution:[l.width,l.height],aberrationStrength:r,envMap:a},i))},exports.MeshTransmissionMaterial=Sr,exports.MeshWobbleMaterial=yr,exports.Octahedron=Gr,exports.OrbitControls=Ye,exports.OrthographicCamera=We,exports.PerformanceMonitor=function({iterations:e=10,ms:r=250,threshold:n=.75,step:a=.1,factor:i=.5,flipflops:s=1/0,bounds:l=(e=>e>100?[60,100]:[40,60]),onIncline:c,onDecline:u,onChange:m,onFallback:d,children:f}){const p=Math.pow(10,0),[h,x]=t.useState((()=>({fps:0,index:0,factor:i,flipped:0,refreshrate:0,fallback:!1,frames:[],averages:[],subscriptions:new Map,subscribe:e=>{const t=Symbol();return h.subscriptions.set(t,e.current),()=>{h.subscriptions.delete(t)}}})));let y=0;return o.useFrame((()=>{const{frames:t,averages:o}=h;if(!h.fallback&&o.length<e){t.push(performance.now());const i=t[t.length-1]-t[0];if(i>=r){if(h.fps=Math.round(t.length/i*1e3*p)/p,h.refreshrate=Math.max(h.refreshrate,h.fps),o[h.index++%e]=h.fps,o.length===e){const[t,r]=l(h.refreshrate),i=o.filter((e=>e>=r)),f=o.filter((e=>e<t));i.length>e*n&&(h.factor=Math.min(1,h.factor+a),h.flipped++,c&&c(h),h.subscriptions.forEach((e=>e.onIncline&&e.onIncline(h)))),f.length>e*n&&(h.factor=Math.max(0,h.factor-a),h.flipped++,u&&u(h),h.subscriptions.forEach((e=>e.onDecline&&e.onDecline(h)))),y!==h.factor&&(y=h.factor,m&&m(h),h.subscriptions.forEach((e=>e.onChange&&e.onChange(h)))),h.flipped>s&&!h.fallback&&(h.fallback=!0,d&&d(h),h.subscriptions.forEach((e=>e.onFallback&&e.onFallback(h)))),h.averages=[]}h.frames=[]}}})),T.createElement(Zo.Provider,{value:h},f)},exports.PerspectiveCamera=Ge,exports.PivotControls=Ya,exports.Plane=Br,exports.Point=Eo,exports.PointMaterial=Pr,exports.PointMaterialImpl=Cr,exports.PointerLockControls=Je,exports.Points=So,exports.PointsBuffer=Mo,exports.Polyhedron=jr,exports.PositionPoint=xo,exports.PositionalAudio=se,exports.Preload=function({all:e,scene:t,camera:r}){const a=o.useThree((({gl:e})=>e)),i=o.useThree((({camera:e})=>e)),s=o.useThree((({scene:e})=>e));return T.useLayoutEffect((()=>{const o=[];e&&(t||s).traverse((e=>{!1===e.visible&&(o.push(e),e.visible=!0)})),a.compile(t||s,r||i);const l=new n.WebGLCubeRenderTarget(128);new n.CubeCamera(.01,1e5,l).update(a,t||s),l.dispose(),o.forEach((e=>e.visible=!1))}),[]),null},exports.PresentationControls=function({enabled:t=!0,snap:r,global:a,domElement:i,cursor:s=!0,children:u,speed:m=1,rotation:d=[0,0,0],zoom:f=1,polar:p=[0,Math.PI/2],azimuth:h=[-1/0,1/0],config:x={mass:1,tension:170,friction:26}}){const y=o.useThree((e=>e.events)),v=o.useThree((e=>e.gl)),g=i||y.connected||v.domElement,{size:z}=o.useThree(),w=T.useMemo((()=>[d[0]+p[0],d[0]+p[1]]),[d[0],p[0],p[1]]),b=T.useMemo((()=>[d[1]+h[0],d[1]+h[1]]),[d[1],h[0],h[1]]),E=T.useMemo((()=>[n.MathUtils.clamp(d[0],...w),n.MathUtils.clamp(d[1],...b),d[2]]),[d[0],d[1],d[2],w,b]),[M,S]=l.useSpring((()=>({scale:1,rotation:E,config:x})));T.useEffect((()=>{S.start({scale:1,rotation:E,config:x})}),[E]),T.useEffect((()=>{if(a&&s&&t)return g.style.cursor="grab",v.domElement.style.cursor="",()=>{g.style.cursor="default",v.domElement.style.cursor="default"}}),[a,s,g,t]);const C=c.useGesture({onHover:({last:e})=>{s&&!a&&t&&(g.style.cursor=e?"auto":"grab")},onDrag:({down:e,delta:[o,a],memo:[i,l]=M.rotation.animation.to||E})=>{if(!t)return[a,o];s&&(g.style.cursor=e?"grabbing":"grab"),o=n.MathUtils.clamp(l+o/z.width*Math.PI*m,...b),a=n.MathUtils.clamp(i+a/z.height*Math.PI*m,...w);const c=r&&!e&&"boolean"!=typeof r?r:x;return S.start({scale:e&&a>w[1]/2?f:1,rotation:r&&!e?E:[a,o,0],config:e=>"scale"===e?{...c,friction:3*c.friction}:c}),[a,o]}},{target:a?g:void 0});return T.createElement(l.a.group,e({},null==C?void 0:C(),M),u)},exports.QuadraticBezierLine=oe,exports.RandomizedLight=Mn,exports.Reflector=Bn,exports.RenderTexture=Qo,exports.Resize=en,exports.Ring=Vr,exports.RoundedBox=Zr,exports.Sampler=function({children:t,weight:r,transform:n,instances:o,mesh:a,count:i=16,...s}){const l=T.useRef(null),c=T.useRef(null),u=T.useRef(null);return T.useLayoutEffect((()=>{var e,t;c.current=null!==(e=null==o?void 0:o.current)&&void 0!==e?e:l.current.children.find((e=>e.hasOwnProperty("instanceMatrix"))),u.current=null!==(t=null==a?void 0:a.current)&&void 0!==t?t:l.current.children.find((e=>"Mesh"===e.type))}),[t,null==a?void 0:a.current,null==o?void 0:o.current]),Re(u,i,n,r,c),T.createElement("group",e({ref:l},s),t)},exports.ScreenQuad=Jr,exports.ScreenSpace=te,exports.Scroll=Y,exports.ScrollControls=function({eps:e=1e-5,enabled:t=!0,infinite:r,horizontal:n,pages:a=1,distance:i=1,damping:l=.25,maxSpeed:c=1/0,style:u={},children:m}){const{get:d,setEvents:f,gl:p,size:h,invalidate:x,events:y}=o.useThree(),[v]=T.useState((()=>document.createElement("div"))),[g]=T.useState((()=>document.createElement("div"))),[z]=T.useState((()=>document.createElement("div"))),w=p.domElement.parentNode,b=T.useRef(0),E=T.useMemo((()=>{const t={el:v,eps:e,fill:g,fixed:z,horizontal:n,damping:l,offset:0,delta:0,scroll:b,pages:a,range(e,t,r=0){const n=e-r,o=n+t+2*r;return this.offset<n?0:this.offset>o?1:(this.offset-n)/(o-n)},curve(e,t,r=0){return Math.sin(this.range(e,t,r)*Math.PI)},visible(e,t,r=0){const n=e-r,o=n+t+2*r;return this.offset>=n&&this.offset<=o}};return t}),[e,l,n,a]);T.useEffect((()=>{v.style.position="absolute",v.style.width="100%",v.style.height="100%",v.style[n?"overflowX":"overflowY"]="auto",v.style[n?"overflowY":"overflowX"]="hidden",v.style.top="0px",v.style.left="0px";for(const e in u)v.style[e]=u[e];z.style.position="sticky",z.style.top="0px",z.style.left="0px",z.style.width="100%",z.style.height="100%",z.style.overflow="hidden",v.appendChild(z),g.style.height=n?"100%":a*i*100+"%",g.style.width=n?a*i*100+"%":"100%",g.style.pointerEvents="none",v.appendChild(g),w.appendChild(v),v[n?"scrollLeft":"scrollTop"]=1;const e=y.connected||p.domElement;requestAnimationFrame((()=>null==y.connect?void 0:y.connect(v)));const t=d().events.compute;return f({compute(e,t){const{left:r,top:n}=w.getBoundingClientRect(),o=e.clientX-r,a=e.clientY-n;t.pointer.set(o/t.size.width*2-1,-a/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),()=>{w.removeChild(v),f({compute:t}),null==y.connect||y.connect(e)}}),[a,i,n,v,g,z,w]),T.useEffect((()=>{if(y.connected===v){const e=h[n?"width":"height"],o=v[n?"scrollWidth":"scrollHeight"],a=o-e;let i=0,s=!0,l=!0;const c=()=>{if(t&&!l&&(x(),i=v[n?"scrollLeft":"scrollTop"],b.current=i/a,r)){if(!s)if(i>=a){const e=1-E.offset;v[n?"scrollLeft":"scrollTop"]=1,b.current=E.offset=-e,s=!0}else if(i<=0){const e=1+E.offset;v[n?"scrollLeft":"scrollTop"]=o,b.current=E.offset=e,s=!0}s&&setTimeout((()=>s=!1),40)}};v.addEventListener("scroll",c,{passive:!0}),requestAnimationFrame((()=>l=!1));const u=e=>v.scrollLeft+=e.deltaY/2;return n&&v.addEventListener("wheel",u,{passive:!0}),()=>{v.removeEventListener("scroll",c),n&&v.removeEventListener("wheel",u)}}}),[v,y,h,r,E,x,n,t]);let M=0;return o.useFrame(((t,r)=>{M=E.offset,s.easing.damp(E,"offset",b.current,l,r,c,void 0,e),s.easing.damp(E,"delta",Math.abs(M-E.offset),l,r,c,void 0,e),E.delta>e&&x()})),T.createElement(H.Provider,{value:E},m)},exports.Segment=Ho,exports.SegmentObject=Wo,exports.Segments=jo,exports.Select=function({box:t,multiple:r,children:n,onChange:a,onChangePointerUp:i,border:s="1px solid #55aaff",backgroundColor:l="rgba(75, 160, 255, 0.1)",filter:c=(e=>e),...u}){const[d,f]=T.useState(!1),{setEvents:p,camera:h,raycaster:x,gl:y,controls:v,size:g,get:z}=o.useThree(),[w,b]=T.useState(!1),[E,M]=T.useReducer(((e,{object:t,shift:r})=>void 0===t?[]:Array.isArray(t)?t:r?e.includes(t)?e.filter((e=>e!==t)):[t,...e]:e[0]===t?[]:[t]),[]);T.useEffect((()=>{d?null==a||a(E):null==i||i(E)}),[E,d]);const S=T.useCallback((e=>{e.stopPropagation(),M({object:c([e.object])[0],shift:r&&e.shiftKey})}),[]),C=T.useCallback((e=>!w&&M({})),[w]),R=T.useRef(null);return T.useEffect((()=>{if(!t||!r)return;const e=new m.SelectionBox(h,R.current),n=document.createElement("div");n.style.pointerEvents="none",n.style.border=s,n.style.backgroundColor=l,n.style.position="fixed";const o=new P.Vector2,a=new P.Vector2,i=new P.Vector2,u=z().events.enabled,d=null==v?void 0:v.enabled;let x=!1;function w(e,t){const{offsetX:r,offsetY:n}=e,{width:o,height:a}=g;t.set(r/o*2-1,-n/a*2+1)}function b(t){t.shiftKey&&(!function(e){var t;v&&(v.enabled=!1),p({enabled:!1}),f(x=!0),null==(t=y.domElement.parentElement)||t.appendChild(n),n.style.left=`${e.clientX}px`,n.style.top=`${e.clientY}px`,n.style.width="0px",n.style.height="0px",o.x=e.clientX,o.y=e.clientY}(t),w(t,e.startPoint))}let E=[];function S(t){if(x){!function(e){i.x=Math.max(o.x,e.clientX),i.y=Math.max(o.y,e.clientY),a.x=Math.min(o.x,e.clientX),a.y=Math.min(o.y,e.clientY),n.style.left=`${a.x}px`,n.style.top=`${a.y}px`,n.style.width=i.x-a.x+"px",n.style.height=i.y-a.y+"px"}(t),w(t,e.endPoint);const r=e.select().sort((e=>e.uuid)).filter((e=>e.isMesh));Q(r,E)||(E=r,M({object:c(r)}))}}function T(e){var t;x&&x&&(v&&(v.enabled=d),p({enabled:u}),f(x=!1),null==(t=n.parentElement)||t.removeChild(n))}return document.addEventListener("pointerdown",b,{passive:!0}),document.addEventListener("pointermove",S,{passive:!0,capture:!0}),document.addEventListener("pointerup",T,{passive:!0}),()=>{document.removeEventListener("pointerdown",b),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",T)}}),[g.width,g.height,x,h,v,y]),T.createElement("group",e({ref:R,onClick:S,onPointerOver:()=>b(!0),onPointerOut:()=>b(!1),onPointerMissed:C},u),T.createElement(J.Provider,{value:E},n))},exports.Shadow=Rn,exports.Shape=Yr,exports.Sky=$n,exports.SoftShadows=function({focus:e=0,samples:t=10,size:r=25}){const n=o.useThree((e=>e.gl)),a=o.useThree((e=>e.scene)),i=o.useThree((e=>e.camera));return T.useEffect((()=>{const o=P.ShaderChunk.shadowmap_pars_fragment;return P.ShaderChunk.shadowmap_pars_fragment=P.ShaderChunk.shadowmap_pars_fragment.replace("#ifdef USE_SHADOWMAP","#ifdef USE_SHADOWMAP\n"+(({focus:e=0,size:t=25,samples:r=10}={})=>`\n#define PENUMBRA_FILTER_SIZE float(${t})\n#define RGB_NOISE_FUNCTION(uv) (randRGB(uv))\nvec3 randRGB(vec2 uv) {\n return vec3(\n fract(sin(dot(uv, vec2(12.75613, 38.12123))) * 13234.76575),\n fract(sin(dot(uv, vec2(19.45531, 58.46547))) * 43678.23431),\n fract(sin(dot(uv, vec2(23.67817, 78.23121))) * 93567.23423)\n );\n}\n\nvec3 lowPassRandRGB(vec2 uv) {\n // 3x3 convolution (average)\n // can be implemented as separable with an extra buffer for a total of 6 samples instead of 9\n vec3 result = vec3(0);\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, +1.0));\n result *= 0.111111111; // 1.0 / 9.0\n return result;\n}\nvec3 highPassRandRGB(vec2 uv) {\n // by subtracting the low-pass signal from the original signal, we're being left with the high-pass signal\n // hp(x) = x - lp(x)\n return RGB_NOISE_FUNCTION(uv) - lowPassRandRGB(uv) + 0.5;\n}\n\n\nvec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; // radians\n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n}\nfloat penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation\n return (zReceiver - zBlocker) / zBlocker;\n}\nfloat findBlocker(sampler2D shadowMap, vec2 uv, float compare, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float blockerDepthSum = float(${e});\n float blockers = 0.0;\n\n int j = 0;\n vec2 offset = vec2(0.);\n float depth = 0.;\n\n #pragma unroll_loop_start\n for(int i = 0; i < ${r}; i ++) {\n offset = (vogelDiskSample(j, ${r}, angle) * texelSize) * 2.0 * PENUMBRA_FILTER_SIZE;\n depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset));\n if (depth < compare) {\n blockerDepthSum += depth;\n blockers++;\n }\n j++;\n }\n #pragma unroll_loop_end\n\n if (blockers > 0.0) {\n return blockerDepthSum / blockers;\n }\n return -1.0;\n}\n\n \nfloat vogelFilter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float shadow = 0.0f;\n int j = 0;\n vec2 vogelSample = vec2(0.0);\n vec2 offset = vec2(0.0);\n #pragma unroll_loop_start\n for (int i = 0; i < ${r}; i++) {\n vogelSample = vogelDiskSample(j, ${r}, angle) * texelSize;\n offset = vogelSample * (1.0 + filterRadius * float(${t}));\n shadow += step( zReceiver, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );\n j++;\n }\n #pragma unroll_loop_end\n return shadow * 1.0 / ${r}.0;\n}\n\nfloat PCSS (sampler2D shadowMap, vec4 coords) {\n vec2 uv = coords.xy;\n float zReceiver = coords.z; // Assumed to be eye-space z in this code\n float angle = highPassRandRGB(gl_FragCoord.xy).r * PI2;\n float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver, angle);\n if (avgBlockerDepth == -1.0) {\n return 1.0;\n }\n float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth);\n return vogelFilter(shadowMap, uv, zReceiver, 1.25 * penumbraRatio, angle);\n}`)({size:r,samples:t,focus:e})).replace("#if defined( SHADOWMAP_TYPE_PCF )","\nreturn PCSS(shadowMap, shadowCoord);\n#if defined( SHADOWMAP_TYPE_PCF )"),Rr(n,a,i),()=>{P.ShaderChunk.shadowmap_pars_fragment=o,Rr(n,a,i)}}),[e,r,t]),null},exports.Sparkles=ro,exports.Sphere=Ar,exports.SpotLight=Gn,exports.SpotLightShadow=function(e){return e.shader?T.createElement(jn,e):T.createElement(Wn,e)},exports.SpriteAnimator=({startFrame:e,endFrame:t,fps:r,frameName:n,textureDataURL:a,textureImageURL:i,loop:s,numberOfFrames:l,autoPlay:c,animationNames:u,onStart:m,onEnd:d,onLoopEnd:f,onFrame:p,play:h,pause:x,flipX:y,alphaTest:v,children:g,...z},w)=>{o.useThree((e=>e.viewport));const b=T.useRef(null),[E,M]=T.useState(!1),S=T.useRef(),C=T.useRef(),R=T.useRef(window.performance.now()),D=T.useRef(),F=T.useRef(e||0),k=T.useRef(n||""),_=1e3/(r||30),[L,A]=T.useState(new P.Texture),B=T.useRef(0),[U,O]=T.useState([1,1,1]),N=y?-1:1;const I=(e,t)=>{const r=t/e;return C.current.scale.set(1,r,1),[1,r,1]};T.useEffect((()=>{if(a&&i)!function(e,t,r){const n=new P.TextureLoader,o=fetch(e).then((e=>e.json())),a=new Promise((e=>{n.load(t,e)}));Promise.all([o,a]).then((e=>{r(e[0],e[1])}))}(a,i,V);else if(i){const e=new P.TextureLoader;new Promise((t=>{e.load(i,t)})).then((e=>{V(null,e)}))}}),[]),T.useLayoutEffect((()=>{W()}),[L,y]),T.useEffect((()=>{}),[x]),T.useEffect((()=>{k.current!==n&&n&&(F.current=0,k.current=n)}),[n]);const V=(e,t)=>{if(null===e){if(t&&l){const e=t.image.width,r=t.image.height,n=e/l,o=r;if(D.current=t,B.current=l,b.current={frames:[],meta:{version:"1.0",size:{w:e,h:r},scale:"1"}},parseInt(n.toString(),10)===n)for(let e=0;e<l;e++)b.current.frames.push({frame:{x:e*n,y:0,w:n,h:o},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:n,h:o},sourceSize:{w:n,h:r}})}}else if(t){b.current=e,b.current.frames=Array.isArray(e.frames)?e.frames:j(),B.current=Array.isArray(e.frames)?e.frames.length:Object.keys(e.frames).length,D.current=t;const{w:r,h:n}=G(e.frames).sourceSize,o=I(r,n);O(o),S.current&&(S.current.map=t)}t.premultiplyAlpha=!1,A(t)},j=()=>{const e={},t=b.current,r=u;if(r)for(let n=0;n<r.length;n++){e[r[n]]=[];for(let o in t.frames){const a=t.frames[o],i=a.frame,s=i.x,l=i.y,c=i.w,u=i.h,m=a.sourceSize.w,d=a.sourceSize.h;"string"==typeof o&&-1!==o.toLowerCase().indexOf(r[n].toLowerCase())&&e[r[n]].push({x:s,y:l,w:c,h:u,frame:i,sourceSize:{w:m,h:d}})}}return e},W=()=>{if(!b.current)return;const{meta:{size:e},frames:t}=b.current,{w:r,h:o}=Array.isArray(t)?t[0].sourceSize:n&&t[n]?t[n][0].sourceSize:{w:0,h:0};S.current.map.wrapS=S.current.map.wrapT=P.RepeatWrapping,S.current.map.center.set(0,0),S.current.map.repeat.set(1*N/(e.w/r),1/(e.h/o));const a=1/((e.h-1)/o);S.current.map.offset.x=0,S.current.map.offset.y=1-a,M(!0),m&&m({currentFrameName:n,currentFrame:F.current})};o.useFrame(((r,o)=>{var a,i;null!=(a=b.current)&&a.frames&&null!=(i=S.current)&&i.map&&(x||(c||h)&&((()=>{const r=window.performance.now(),o=r-R.current,{meta:{size:a},frames:i}=b.current,{w:l,h:c}=G(i).sourceSize,u=Array.isArray(i)?i:n?i[n]:[];let m=0,p=0;const h=t||u.length-1;if(F.current>h&&(F.current=s&&null!=e?e:0,s?null==f||f({currentFrameName:n,currentFrame:F.current}):null==d||d({currentFrameName:n,currentFrame:F.current}),!s))return;if(o<=_)return;R.current=r-o%_,I(l,c);const x=(a.w-1)/l,y=(a.h-1)/c,{frame:{x:v,y:g},sourceSize:{w:z,h:w}}=u[F.current],E=1/x,M=1/y;m=N>0?E*(v/z):E*(v/z)-S.current.map.repeat.x,p=Math.abs(1-M)-M*(g/w),S.current.map.offset.x=m,S.current.map.offset.y=p,F.current+=1})(),p&&p({currentFrameName:k.current,currentFrame:F.current})))}));const G=e=>{if(Array.isArray(e))return e[0];if("object"==typeof e&&null!==e){return e[Object.keys(e)[0]][0]}return{w:0,h:0}};return T.createElement("group",z,T.createElement(T.Suspense,{fallback:null},T.createElement("sprite",{ref:C,scale:U},T.createElement("spriteMaterial",{toneMapped:!1,ref:S,map:L,transparent:!0,alphaTest:null!=v?v:0}))),g)},exports.Stage=function({children:t,center:r,adjustCamera:n=!0,intensity:o=.5,shadows:a="contact",environment:i="city",preset:s="rembrandt",...l}){var c,u,m,d,f,p,h,x;const y="string"==typeof s?Tn[s]:s,[{radius:v,height:g},z]=T.useState({radius:0,width:0,height:0,depth:0}),w=null!==(c=null==a?void 0:a.bias)&&void 0!==c?c:-1e-4,b=null!==(u=null==a?void 0:a.normalBias)&&void 0!==u?u:0,E=null!==(m=null==a?void 0:a.size)&&void 0!==m?m:1024,M=null!==(d=null==a?void 0:a.offset)&&void 0!==d?d:0,S="contact"===a||"contact"===(null==a?void 0:a.type),C="accumulative"===a||"accumulative"===(null==a?void 0:a.type),P={..."object"==typeof a?a:{}},R=i?"string"==typeof i?{preset:i}:i:null,D=T.useCallback((e=>{const{width:t,height:n,depth:o,boundingSphere:a}=e;z({radius:a.radius,width:t,height:n,depth:o}),null!=r&&r.onCentered&&r.onCentered(e)}),[]);return T.createElement(T.Fragment,null,T.createElement("ambientLight",{intensity:o/3}),T.createElement("spotLight",{penumbra:1,position:[y.main[0]*v,y.main[1]*v,y.main[2]*v],intensity:2*o,castShadow:!!a,"shadow-bias":w,"shadow-normalBias":b,"shadow-mapSize":E}),T.createElement("pointLight",{position:[y.fill[0]*v,y.fill[1]*v,y.fill[2]*v],intensity:o}),T.createElement(on,e({fit:!!n,clip:!!n,margin:Number(n),observe:!0},l),T.createElement(Cn,{radius:v,adjustCamera:n}),T.createElement(mr,e({},r,{position:[0,M/2,0],onCentered:D}),t)),T.createElement("group",{position:[0,-g/2-M/2,0]},S&&T.createElement(zn,e({scale:4*v,far:v,blur:2},P)),C&&T.createElement(En,e({temporal:!0,frames:100,alphaTest:.9,toneMapped:!0,scale:4*v},P),T.createElement(Mn,{amount:null!==(f=P.amount)&&void 0!==f?f:8,radius:null!==(p=P.radius)&&void 0!==p?p:v,ambient:null!==(h=P.ambient)&&void 0!==h?h:.5,intensity:null!==(x=P.intensity)&&void 0!==x?x:1,position:[y.main[0]*v,y.main[1]*v,y.main[2]*v],size:4*v,bias:-w,mapSize:E}))),i&&T.createElement(gn,R))},exports.Stars=Kn,exports.Stats=function({showPanel:e=0,className:t,parent:r}){const n=function(e,t=[],r){const[n,o]=T.useState();return T.useLayoutEffect((()=>{const t=e();return o(t),Qt(r,t),()=>Qt(r,null)}),t),n}((()=>new z),[]);return T.useEffect((()=>{if(n){const a=r&&r.current||document.body;n.showPanel(e),null==a||a.appendChild(n.dom),t&&n.dom.classList.add(...t.split(" ").filter((e=>e)));const i=o.addEffect((()=>n.begin())),s=o.addAfterEffect((()=>n.end()));return()=>{null==a||a.removeChild(n.dom),i(),s()}}}),[r,n,t,e]),null},exports.Svg=Ue,exports.Tetrahedron=Ir,exports.Text=le,exports.Text3D=fe,exports.Torus=Or,exports.TorusKnot=Nr,exports.TrackballControls=Ke,exports.Trail=Pe,exports.TransformControls=Qe,exports.Tube=Ur,exports.View=({track:e,index:t=1,frames:r=1/0,children:n})=>{var a,i;const s=T.useRef(null),{size:l,scene:c}=o.useThree(),[u]=T.useState((()=>new P.Scene)),m=T.useCallback(((t,r)=>{if(s.current&&e.current&&t.target===e.current){const{width:e,height:n,left:o,top:a}=s.current,i=t.clientX-o,l=t.clientY-a;r.pointer.set(i/e*2-1,-l/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[s,e]),[d,f]=T.useReducer((()=>!0),!1);return T.useEffect((()=>{var t;s.current=null==(t=e.current)?void 0:t.getBoundingClientRect(),f()}),[e]),T.createElement(T.Fragment,null,d&&o.createPortal(T.createElement(sa,{canvasSize:l,frames:r,scene:c,track:e,rect:s,index:t},n,T.createElement("group",{onPointerOver:()=>null})),u,{events:{compute:m,priority:t},size:{width:null==(a=s.current)?void 0:a.width,height:null==(i=s.current)?void 0:i.height}}))},exports.Wireframe=function({geometry:t,...r}){return t?T.createElement(co,e({geometry:t},r)):T.createElement(uo,r)},exports.accumulativeContext=wn,exports.calcPosFromAngles=qn,exports.calculateScaleFactor=Fa,exports.isWebGL2Available=()=>{try{var e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},exports.meshBounds=function(e,t){const r=this.geometry,n=this.material,o=this.matrixWorld;void 0!==n&&(null===r.boundingSphere&&r.computeBoundingSphere(),Yo.copy(r.boundingSphere),Yo.applyMatrix4(o),!1!==e.ray.intersectsSphere(Yo)&&($o.copy(o).invert(),Xo.copy(e.ray).applyMatrix4($o),null!==r.boundingBox&&null===Xo.intersectBox(r.boundingBox,Ko)||t.push({distance:Ko.distanceTo(e.ray.origin),point:Ko.clone(),object:this})))},exports.shaderMaterial=xe,exports.useAnimations=function(e,t){const r=T.useRef(),[a]=T.useState((()=>t?t instanceof n.Object3D?{current:t}:t:r)),[i]=T.useState((()=>new n.AnimationMixer(void 0)));T.useLayoutEffect((()=>{i._root=a.current}),[i,t]);const s=T.useRef({}),[l]=T.useState((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(a.current)return s.current[e.name]||(s.current[e.name]=i.clipAction(e,a.current))},configurable:!0}))),{ref:a,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}));return o.useFrame(((e,t)=>i.update(t))),T.useEffect((()=>{const e=a.current;return()=>{s.current={},Object.values(l.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),T.useEffect((()=>()=>{i.stopAllAction()}),[i]),l},exports.useAspect=function(e,t,r=1){const n=o.useThree((e=>e.viewport)),a=t*(n.aspect>e/t?n.width/e:n.height/t);return[e*(n.aspect>e/t?n.width/e:n.height/t)*r,a*r,1]},exports.useBVH=function(e,t){t={strategy:b.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,...t},T.useEffect((()=>{if(e.current){e.current.raycast=b.acceleratedRaycast;const r=e.current.geometry;return r.computeBoundsTree=b.computeBoundsTree,r.disposeBoundsTree=b.disposeBoundsTree,r.computeBoundsTree(t),()=>{r.boundsTree&&r.disposeBoundsTree()}}}),[e,JSON.stringify(t)])},exports.useBounds=an,exports.useBoxProjectedEnv=function(e=new P.Vector3,t=new P.Vector3){const[r]=T.useState((()=>({position:new P.Vector3,size:new P.Vector3})));o.applyProps(r,{position:e,size:t});const n=T.useRef(null),a=T.useMemo((()=>({ref:n,onBeforeCompile:e=>function(e,t,r){e.defines.BOX_PROJECTED_ENV_MAP=!0,e.uniforms.envMapPosition={value:t},e.uniforms.envMapSize={value:r},e.vertexShader=`\n varying vec3 vWorldPosition;\n ${e.vertexShader.replace("#include <worldpos_vertex>",nr)}`,e.fragmentShader=`\n ${or}\n ${e.fragmentShader.replace("#include <envmap_physical_pars_fragment>",P.ShaderChunk.envmap_physical_pars_fragment).replace("vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",`vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n ${ar}\n `).replace("reflectVec = inverseTransformDirection( reflectVec, viewMatrix );",`reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n ${ir}\n `)}`}(e,r.position,r.size),customProgramCacheKey:()=>JSON.stringify(r.position.toArray())+JSON.stringify(r.size.toArray())})),[...r.position.toArray(),...r.size.toArray()]);return T.useLayoutEffect((()=>{n.current.needsUpdate=!0}),[r]),a},exports.useCamera=function(e,t){const r=o.useThree((e=>e.pointer)),[a]=T.useState((()=>{const a=new n.Raycaster;return t&&o.applyProps(a,t,{}),function(t,o){a.setFromCamera(r,e instanceof n.Camera?e:e.current);const i=this.constructor.prototype.raycast.bind(this);i&&i(a,o)}}));return a},exports.useContextBridge=function(...e){const t=T.useRef([]);return t.current=e.map((e=>T.useContext(e))),T.useMemo((()=>({children:r})=>e.reduceRight(((e,r,n)=>T.createElement(r.Provider,{value:t.current[n],children:e})),r)),[])},exports.useCubeCamera=He,exports.useCubeTexture=Xt,exports.useCursor=function(e,t="pointer",r="auto"){T.useEffect((()=>{if(e)return document.body.style.cursor=t,()=>{document.body.style.cursor=r}}),[e])},exports.useDepthBuffer=function({size:e=256,frames:t=1/0}={}){const r=o.useThree((e=>e.viewport.dpr)),{width:a,height:i}=o.useThree((e=>e.size)),s=e||a*r,l=e||i*r,c=T.useMemo((()=>{const e=new n.DepthTexture(s,l);return e.format=n.DepthFormat,e.type=n.UnsignedShortType,{depthTexture:e}}),[s,l]);let u=0;const m=je(s,l,c);return o.useFrame((e=>{(t===1/0||u<t)&&(e.gl.setRenderTarget(m),e.gl.render(e.scene,e.camera),e.gl.setRenderTarget(null),u++)})),m.depthTexture},exports.useDetectGPU=e=>p.suspend((()=>w.getGPUTier(e)),["useDetectGPU"]),exports.useEnvironment=dn,exports.useFBO=je,exports.useFBX=Yt,exports.useFaceControls=xt,exports.useFaceLandmarker=mt,exports.useFont=me,exports.useGLTF=Ie,exports.useGizmoContext=Et,exports.useHelper=Jt,exports.useIntersect=rr,exports.useKTX2=Zt,exports.useKeyboardControls=function(e){const[t,r,n]=T.useContext(Z);return e?n(e):[t,r]},exports.useMask=function(e,t=!1){return{stencilWrite:!0,stencilRef:e,stencilFunc:t?P.NotEqualStencilFunc:P.EqualStencilFunc,stencilFail:P.KeepStencilOp,stencilZFail:P.KeepStencilOp,stencilZPass:P.KeepStencilOp}},exports.useMatcapTexture=function(e=0,t=1024,r){const n=p.suspend((()=>fetch("https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/matcaps.json").then((e=>e.json()))),["matcapList"]),o=n[0],a=T.useMemo((()=>Object.keys(n).length),[]),i=`${T.useMemo((()=>"string"==typeof e?e:"number"==typeof e?n[e]:null),[e])||o}${function(e){switch(e){case 64:return"-64px";case 128:return"-128px";case 256:return"-256px";case 512:return"-512px";default:return""}}(t)}.png`,s=`https://rawcdn.githack.com/emmelleppi/matcaps/9b36ccaaf0a24881a39062d05566c9e92be4aa0d/${t}/${i}`;return[ve(s,r),s,a]},exports.useNormalTexture=function(e=0,t={},r){const{repeat:o=[1,1],anisotropy:a=1,offset:i=[0,0]}=t,s=p.suspend((()=>fetch("https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master/normals/normals.json").then((e=>e.json()))),["normalsList"]),l=T.useMemo((()=>Object.keys(s).length),[]),c=s[0],u=`https://rawcdn.githack.com/pmndrs/drei-assets/7a3104997e1576f83472829815b00880d88b32fb/normals/${s[e]||c}`,m=ve(u,r);return T.useLayoutEffect((()=>{m&&(m.wrapS=m.wrapT=n.RepeatWrapping,m.repeat=new n.Vector2(o[0],o[1]),m.offset=new n.Vector2(i[0],i[1]),m.anisotropy=a)}),[m,a,o,i]),[m,u,l]},exports.usePerformanceMonitor=function({onIncline:e,onDecline:r,onChange:n,onFallback:o}){const a=t.useContext(Zo),i=t.useRef({onIncline:e,onDecline:r,onChange:n,onFallback:o});t.useLayoutEffect((()=>{i.current.onIncline=e,i.current.onDecline=r,i.current.onChange=n,i.current.onFallback=o}),[e,r,n,o]),t.useLayoutEffect((()=>a.subscribe(i)),[a])},exports.useProgress=j,exports.useScroll=q,exports.useSelect=function(){return T.useContext(J)},exports.useSurfaceSampler=Re,exports.useTexture=ve,exports.useTrail=Ce,exports.useTrailTexture=function(e={}){const{size:r,maxAge:n,radius:a,intensity:i,interpolate:s,smoothing:l,minForce:c,blend:u,ease:m}=e,d=t.useMemo((()=>new ur(e)),[r,n,a,i,s,l,c,u,m]);o.useFrame(((e,t)=>{d.update(t)}));const f=t.useCallback((e=>d.addTouch(e.uv)),[d]);return[d.texture,f]},exports.useVideoTexture=rt;