@react-three/drei 9.96.4 → 9.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -9
- package/core/AccumulativeShadows.cjs.js +1 -1
- package/core/AdaptiveDpr.cjs.js +1 -1
- package/core/AdaptiveEvents.cjs.js +1 -1
- package/core/ArcballControls.cjs.js +1 -1
- package/core/AsciiRenderer.cjs.js +1 -1
- package/core/BBAnchor.cjs.js +1 -1
- package/core/Backdrop.cjs.js +1 -1
- package/core/BakeShadows.cjs.js +1 -1
- package/core/Billboard.cjs.js +1 -1
- package/core/Bounds.cjs.js +1 -1
- package/core/CameraControls.cjs.js +1 -1
- package/core/CameraControls.d.ts +2 -2
- package/core/CameraShake.cjs.js +1 -1
- package/core/CatmullRomLine.cjs.js +1 -1
- package/core/Caustics.cjs.js +1 -1
- package/core/Center.cjs.js +1 -1
- package/core/Clone.cjs.js +1 -1
- package/core/Cloud.cjs.js +1 -1
- package/core/ComputedAttribute.cjs.js +1 -1
- package/core/ContactShadows.cjs.js +1 -1
- package/core/CubeCamera.cjs.js +1 -1
- package/core/CubicBezierLine.cjs.js +1 -1
- package/core/CurveModifier.cjs.js +1 -1
- package/core/Decal.cjs.js +1 -1
- package/core/Detailed.cjs.js +1 -1
- package/core/DeviceOrientationControls.cjs.js +1 -1
- package/core/Edges.cjs.js +1 -1
- package/core/Effects.cjs.js +1 -1
- package/core/Environment.cjs.js +1 -1
- package/core/Example.cjs.js +1 -1
- package/core/FirstPersonControls.cjs.js +1 -1
- package/core/Fisheye.cjs.js +1 -1
- package/core/Float.cjs.js +1 -1
- package/core/FlyControls.cjs.js +1 -1
- package/core/GizmoHelper.cjs.js +1 -1
- package/core/GizmoViewcube.cjs.js +1 -1
- package/core/GizmoViewport.cjs.js +1 -1
- package/core/Gltf.cjs.js +1 -1
- package/core/GradientTexture.cjs.js +1 -1
- package/core/Grid.cjs.js +1 -1
- package/core/Hud.cjs.js +1 -1
- package/core/Image.cjs.js +1 -1
- package/core/Instances.cjs.js +1 -1
- package/core/Lightformer.cjs.js +1 -1
- package/core/Line.cjs.js +1 -1
- package/core/MapControls.cjs.js +1 -1
- package/core/MarchingCubes.cjs.js +1 -1
- package/core/Mask.cjs.js +1 -1
- package/core/MeshDiscardMaterial.cjs.js +1 -1
- package/core/MeshDistortMaterial.cjs.js +1 -1
- package/core/MeshPortalMaterial.cjs.js +1 -1
- package/core/MeshReflectorMaterial.cjs.js +1 -1
- package/core/MeshRefractionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.cjs.js +1 -1
- package/core/MeshTransmissionMaterial.d.ts +2 -2
- package/core/MeshWobbleMaterial.cjs.js +1 -1
- package/core/MotionPathControls.cjs.js +1 -1
- package/core/OrbitControls.cjs.js +1 -1
- package/core/OrthographicCamera.cjs.js +1 -1
- package/core/Outlines.cjs.js +1 -1
- package/core/PerformanceMonitor.cjs.js +1 -1
- package/core/PerspectiveCamera.cjs.js +1 -1
- package/core/PointMaterial.cjs.js +1 -1
- package/core/PointerLockControls.cjs.js +1 -1
- package/core/Points.cjs.js +1 -1
- package/core/PositionalAudio.cjs.js +1 -1
- package/core/Preload.cjs.js +1 -1
- package/core/QuadraticBezierLine.cjs.js +1 -1
- package/core/Reflector.cjs.js +1 -1
- package/core/RenderCubeTexture.cjs.js +1 -1
- package/core/RenderTexture.cjs.js +1 -1
- package/core/Resize.cjs.js +1 -1
- package/core/RoundedBox.cjs.js +1 -1
- package/core/Sampler.cjs.js +1 -1
- package/core/ScreenQuad.cjs.js +1 -1
- package/core/ScreenSizer.cjs.js +1 -0
- package/core/ScreenSizer.d.ts +7 -0
- package/core/ScreenSizer.js +39 -0
- package/core/ScreenSpace.cjs.js +1 -1
- package/core/Segments.cjs.js +1 -1
- package/core/Shadow.cjs.js +1 -1
- package/core/ShadowAlpha.cjs.js +1 -1
- package/core/ShadowAlpha.js +0 -1
- package/core/Sky.cjs.js +1 -1
- package/core/Sparkles.cjs.js +1 -1
- package/core/Splat.cjs.js +1 -1
- package/core/SpotLight.cjs.js +1 -1
- package/core/SpriteAnimator.cjs.js +1 -1
- package/core/SpriteAnimator.d.ts +2 -1
- package/core/SpriteAnimator.js +34 -123
- package/core/Stage.cjs.js +1 -1
- package/core/Stars.cjs.js +1 -1
- package/core/Stats.cjs.js +1 -1
- package/core/StatsGl.cjs.js +1 -1
- package/core/Svg.cjs.js +1 -1
- package/core/Text.cjs.js +1 -1
- package/core/Text3D.cjs.js +1 -1
- package/core/TrackballControls.cjs.js +1 -1
- package/core/Trail.cjs.js +1 -1
- package/core/TransformControls.cjs.js +1 -1
- package/core/Wireframe.cjs.js +1 -1
- package/core/calculateScaleFactor.cjs.js +1 -0
- package/core/calculateScaleFactor.d.ts +3 -0
- package/core/calculateScaleFactor.js +31 -0
- package/core/index.cjs.js +1 -1
- package/core/index.d.ts +3 -0
- package/core/index.js +153 -0
- package/core/meshBounds.cjs.js +1 -1
- package/core/shaderMaterial.cjs.js +1 -1
- package/core/shapes.cjs.js +1 -1
- package/core/softShadows.cjs.js +1 -1
- package/core/softShadows.js +0 -1
- package/core/useAnimations.cjs.js +1 -1
- package/core/useAspect.cjs.js +1 -1
- package/core/useBVH.cjs.js +1 -1
- package/core/useBoxProjectedEnv.cjs.js +1 -1
- package/core/useCamera.cjs.js +1 -1
- package/core/useContextBridge.cjs.js +1 -1
- package/core/useCubeCamera.cjs.js +1 -1
- package/core/useCubeTexture.cjs.js +1 -1
- package/core/useDepthBuffer.cjs.js +1 -1
- package/core/useDetectGPU.cjs.js +1 -1
- package/core/useEnvironment.cjs.js +1 -1
- package/core/useFBO.cjs.js +1 -1
- package/core/useFBX.cjs.js +1 -1
- package/core/useFont.cjs.js +1 -1
- package/core/useGLTF.cjs.js +1 -1
- package/core/useHelper.cjs.js +1 -1
- package/core/useIntersect.cjs.js +1 -1
- package/core/useKTX2.cjs.js +1 -1
- package/core/useMatcapTexture.cjs.js +1 -1
- package/core/useNormalTexture.cjs.js +1 -1
- package/core/useProgress.cjs.js +1 -1
- package/core/useSpriteLoader.cjs.js +1 -0
- package/core/useSpriteLoader.d.ts +9 -0
- package/core/useSpriteLoader.js +215 -0
- package/core/useTexture.cjs.js +1 -1
- package/core/useTrailTexture.cjs.js +1 -1
- package/core/useVideoTexture.cjs.js +1 -1
- package/helpers/constants.cjs.js +1 -1
- package/helpers/deprecated.cjs.js +1 -1
- package/helpers/environment-assets.cjs.js +1 -1
- package/helpers/glsl/DefaultSpotlightShadowShadows.glsl.js +3 -1
- package/helpers/glsl/distort.vert.glsl.js +3 -1
- package/helpers/ts-utils.js +1 -0
- package/helpers/useEffectfulState.cjs.js +1 -1
- package/index.cjs.js +1 -1
- package/index.js +4 -2
- package/materials/BlurPass.cjs.js +1 -1
- package/materials/ConvolutionMaterial.cjs.js +1 -1
- package/materials/DiscardMaterial.cjs.js +1 -1
- package/materials/MeshReflectorMaterial.cjs.js +1 -1
- package/materials/MeshRefractionMaterial.cjs.js +1 -1
- package/materials/MeshRefractionMaterial.js +0 -2
- package/materials/SpotLightMaterial.cjs.js +1 -1
- package/materials/WireframeMaterial.cjs.js +1 -1
- package/native/index.cjs.js +1 -1
- package/native/index.js +153 -0
- package/package.json +1 -1
- package/react-three-drei-0.0.0-semantic-release.tgz +0 -0
- package/web/CycleRaycast.cjs.js +1 -1
- package/web/FaceControls.cjs.js +1 -1
- package/web/FaceLandmarker.cjs.js +1 -1
- package/web/Facemesh.cjs.js +1 -1
- package/web/Html.cjs.js +1 -1
- package/web/KeyboardControls.cjs.js +1 -1
- package/web/Loader.cjs.js +1 -1
- package/web/PresentationControls.cjs.js +1 -1
- package/web/ScrollControls.cjs.js +1 -1
- package/web/Select.cjs.js +1 -1
- package/web/View.cjs.js +1 -2
- package/web/View.js +0 -1
- package/web/index.cjs.js +1 -1
- package/web/index.js +176 -0
- package/web/pivotControls/AxisArrow.cjs.js +1 -1
- package/web/pivotControls/AxisRotator.cjs.js +1 -1
- package/web/pivotControls/PlaneSlider.cjs.js +1 -1
- package/web/pivotControls/context.cjs.js +1 -1
- package/web/pivotControls/index.cjs.js +1 -1
- package/web/pivotControls/index.d.ts +2 -4
- package/web/pivotControls/index.js +5 -31
- package/web/useCursor.cjs.js +1 -1
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("camera-controls"),y=require("stats.js"),v=require("stats-gl"),g=require("detect-gpu"),z=require("three-mesh-bvh"),w=require("react-composer"),b=require("uuid"),M=require("tunnel-rat");function E(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 S=E(t),T=E(r),C=E(n);const P=new n.Vector3,R=new n.Vector3,D=new n.Vector3;function F(e,t,r){const n=P.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 k=e=>Math.abs(e)<1e-10?0:e;function _(e,t,r=""){let n="matrix3d(";for(let r=0;16!==r;r++)n+=k(t[r]*e.elements[r])+(15!==r?",":")");return r+n}const A=(L=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>_(e,L));var L;const B=(e,t)=>{return _(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 U=S.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=F,as:b="div",wrapperClass:M,pointerEvents:E="auto",...C},_)=>{const{gl:L,camera:U,scene:I,size:V,raycaster:N,events:O,viewport:j}=o.useThree(),[W]=S.useState((()=>document.createElement(b))),G=S.useRef(),H=S.useRef(null),$=S.useRef(0),q=S.useRef([0,0]),X=S.useRef(null),Z=S.useRef(null),Y=(null==u?void 0:u.current)||O.connected||L.domElement.parentNode,Q=S.useRef(null),K=S.useRef(!1),J=S.useMemo((()=>p&&"blending"!==p||Array.isArray(p)&&p.length&&function(e){return e&&"object"==typeof e&&"current"in e}(p[0])),[p]);S.useLayoutEffect((()=>{const e=L.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]),S.useLayoutEffect((()=>{if(H.current){const e=G.current=T.createRoot(W);if(I.updateMatrixWorld(),f)W.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=w(H.current,U,V);W.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return Y&&(s?Y.prepend(W):Y.appendChild(W)),()=>{Y&&Y.removeChild(W),e.unmount()}}}),[Y,f]),S.useLayoutEffect((()=>{M&&(W.className=M)}),[M]);const ee=S.useMemo((()=>f?{position:"absolute",top:0,left:0,width:V.width,height:V.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:l?"translate3d(-50%,-50%,0)":"none",...c&&{top:-V.height/2,left:-V.width/2,width:V.width,height:V.height},...a}),[a,l,c,V,f]),te=S.useMemo((()=>({position:"absolute",pointerEvents:E})),[E]);S.useLayoutEffect((()=>{var e,r;(K.current=!1,f)?null==(e=G.current)||e.render(S.createElement("div",{ref:X,style:ee},S.createElement("div",{ref:Z,style:te},S.createElement("div",{ref:_,className:i,style:a,children:t})))):null==(r=G.current)||r.render(S.createElement("div",{ref:_,style:ee,className:i,children:t}))}));const re=S.useRef(!0);o.useFrame((e=>{if(H.current){U.updateMatrixWorld(),H.current.updateWorldMatrix(!0,!1);const e=f?q.current:w(H.current,U,V);if(f||Math.abs($.current-U.zoom)>r||Math.abs(q.current[0]-e[0])>r||Math.abs(q.current[1]-e[1])>r){const t=function(e,t){const r=P.setFromMatrixPosition(e.matrixWorld),n=R.setFromMatrixPosition(t.matrixWorld),o=r.sub(n),a=t.getWorldDirection(D);return o.angleTo(a)>Math.PI/2}(H.current,U);let r=!1;J&&(Array.isArray(p)?r=p.map((e=>e.current)):"blending"!==p&&(r=[I]));const o=re.current;if(r){const e=function(e,t,r,n){const o=P.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,U,N,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=P.setFromMatrixPosition(e.matrixWorld),o=R.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,U,i)}`,f){const[e,t]=[V.width/2,V.height/2],r=U.projectionMatrix.elements[5]*t,{isOrthographicCamera:n,top:o,left:a,bottom:i,right:s}=U,l=A(U.matrixWorldInverse),c=n?`scale(${r})translate(${k(-(s+a)/2)}px,${k((o+i)/2)}px)`:`translateZ(${r}px)`;let u=H.current.matrixWorld;d&&(u=U.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=V.width+"px",W.style.height=V.height+"px",W.style.perspective=n?"":`${r}px`,X.current&&Z.current&&(X.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,Z.current.style.transform=B(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=P.setFromMatrixPosition(e.matrixWorld),n=R.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,U)*m;W.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}q.current=e,$.current=U.zoom}}if(!J&&Q.current&&!K.current)if(f){if(X.current){const e=X.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){const{isOrthographicCamera:t}=U;if(t||g)C.scale&&(Array.isArray(C.scale)?C.scale instanceof n.Vector3?Q.current.scale.copy(C.scale.clone().divideScalar(1)):Q.current.scale.set(1/C.scale[0],1/C.scale[1],1/C.scale[2]):Q.current.scale.setScalar(1/C.scale));else{const t=(m||10)/400,r=e.clientWidth*t,n=e.clientHeight*t;Q.current.scale.set(r,n,1)}K.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;Q.current.scale.set(r,n,1),K.current=!0}Q.current.lookAt(e.camera.position)}}));const ne=S.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 S.createElement("group",e({},C,{ref:H}),p&&!J&&S.createElement("mesh",{castShadow:x,receiveShadow:y,ref:Q},g||S.createElement("planeGeometry",null),v||S.createElement("shaderMaterial",{side:n.DoubleSide,vertexShader:ne.vertexShader,fragmentShader:ne.fragmentShader})))}));let I=0;const V=a((e=>(n.DefaultLoadingManager.onStart=(t,r,n)=>{e({active:!0,item:t,loaded:r,total:n,progress:(r-I)/(n-I)*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&&(I=n),e({active:!0,item:t,loaded:r,total:n,progress:(r-I)/(n-I)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0}))),N=e=>`Loading ${e.toFixed(2)}%`;const O={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"}},j=S.createContext(null);function W(){return S.useContext(j)}const G=S.forwardRef((({children:e},t)=>{const r=S.useRef(null),n=W(),{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})),S.createElement("group",{ref:i([t,r])},e)})),H=S.forwardRef((({children:t,style:r,...n},a)=>{const s=W(),l=S.useRef(null),{width:c,height:u}=o.useThree((e=>e.size)),m=S.useContext(o.context),d=S.useMemo((()=>T.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(S.createElement("div",e({ref:i([a,l]),style:{...r,position:"absolute",top:0,left:0,willChange:"transform"}},n),S.createElement(j.Provider,{value:s},S.createElement(o.context.Provider,{value:m},t)))),null})),$=S.forwardRef((({html:t,...r},n)=>{const o=t?H:G;return S.createElement(o,e({ref:n},r))}));const q=S.createContext(null);const X=S.createContext([]);const Z=S.forwardRef((function({children:t,follow:r=!0,lockX:a=!1,lockY:i=!1,lockZ:s=!1,...l},c){const u=S.useRef(null),m=S.useRef(null),d=new n.Quaternion;return o.useFrame((({camera:e})=>{if(!r||!m.current)return;const t=m.current.rotation.clone();m.current.updateMatrix(),m.current.updateWorldMatrix(!1,!1),m.current.getWorldQuaternion(d),e.getWorldQuaternion(u.current.quaternion).premultiply(d.invert()),a&&(m.current.rotation.x=t.x),i&&(m.current.rotation.y=t.y),s&&(m.current.rotation.z=t.z)})),S.useImperativeHandle(c,(()=>m.current),[]),S.createElement("group",e({ref:m,matrixAutoUpdate:!1,matrixWorldAutoUpdate:!1},l),S.createElement("group",{ref:u},t))})),Y=S.forwardRef((({children:t,depth:r=-1,...n},a)=>{const s=S.useRef(null);return o.useFrame((({camera:e})=>{s.current.quaternion.copy(e.quaternion),s.current.position.copy(e.position)})),S.createElement("group",e({ref:i([a,s])},n),S.createElement("group",{"position-z":-r},t))})),Q=S.forwardRef((function({points:t,color:r="black",vertexColors:a,linewidth:i,lineWidth:s,segments:l,dashed:c,...u},d){var f;const p=o.useThree((e=>e.size)),h=S.useMemo((()=>l?new m.LineSegments2:new m.Line2),[l]),[x]=S.useState((()=>new m.LineMaterial)),y=4===(null==a||null==(f=a[0])?void 0:f.length)?4:3,v=S.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 instanceof n.Vector4?[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(),y)}return e}),[t,l,a,y]);return S.useLayoutEffect((()=>{h.computeLineDistances()}),[t,h]),S.useLayoutEffect((()=>{c?x.defines.USE_DASH="":delete x.defines.USE_DASH,x.needsUpdate=!0}),[c,x]),S.useEffect((()=>()=>v.dispose()),[v]),S.createElement("primitive",e({object:h,ref:d},u),S.createElement("primitive",{object:v,attach:"geometry"}),S.createElement("primitive",e({object:x,attach:"material",color:r,vertexColors:Boolean(a),resolution:[p.width,p.height],linewidth:null!=i?i:s,dashed:c,transparent:4===y},u)))})),K=new n.Vector3,J=S.forwardRef((function({start:t=[0,0,0],end:r=[0,0,0],mid:o,segments:a=20,...s},l){const c=S.useRef(null),[u]=S.useState((()=>new n.QuadraticBezierCurve3(void 0,void 0,void 0))),m=S.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(K.set(0,u.v0.y-u.v2.y,0))),u.getPoints(o))),[]);S.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=S.useMemo((()=>m(t,r,o,a)),[t,r,o,a]);return S.createElement(Q,e({ref:i([c,l]),points:d},s))})),ee=S.forwardRef((function({start:t,end:r,midA:o,midB:a,segments:i=20,...s},l){const c=S.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 S.createElement(Q,e({ref:l,points:c},s))})),te=S.forwardRef((function({points:t,closed:r=!1,curveType:o="centripetal",tension:a=.5,segments:i=20,vertexColors:s,...l},c){const u=S.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=S.useMemo((()=>u.getPoints(i)),[u,i]),d=S.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 S.createElement(Q,e({ref:c,points:m,vertexColors:d},l))})),re=S.forwardRef((({url:t,distance:r=1,loop:a=!0,autoplay:s,...l},c)=>{const u=S.useRef(),m=o.useThree((({camera:e})=>e)),[d]=S.useState((()=>new n.AudioListener)),f=o.useLoader(n.AudioLoader,t);return S.useEffect((()=>{const e=u.current;e&&(e.setBuffer(f),e.setRefDistance(r),e.setLoop(a),s&&!e.isPlaying&&e.play())}),[f,m,r,a]),S.useEffect((()=>{const e=u.current;return m.add(d),()=>{m.remove(d),e&&(e.isPlaying&&e.stop(),e.source&&e.source._connected&&e.disconnect())}}),[]),S.createElement("positionalAudio",e({ref:i([u,c]),args:[d]},l))})),ne=S.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]=S.useState((()=>new f.Text)),[x,y]=S.useMemo((()=>{const e=[];let t="";return S.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]),S.useLayoutEffect((()=>{h.sync((()=>{d(),c&&c(h)}))})),S.useEffect((()=>()=>h.dispose()),[h]),S.createElement("primitive",e({object:h,ref:m,font:a,text:y,anchorX:r,anchorY:n,fontSize:i,sdfGlyphSize:t},u),x)}));let oe=null;async function ae(e){oe||(oe=new m.FontLoader);let t="string"==typeof e?await(await fetch(e)).json():e;return oe.parse(t)}function ie(e){return p.suspend(ae,[e])}ie.preload=e=>p.preload(ae,[e]),ie.clear=e=>p.clear([e]);const se=["string","number"],le=S.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)=>{S.useMemo((()=>o.extend({RenamedTextGeometry:m.TextGeometry})),[]);const g=S.useRef(null),z=ie(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,...M]=t.useMemo((()=>(e=>{let t="";const r=[];return S.Children.forEach(e,(e=>{se.includes(typeof e)?t+=e+"":r.push(e)})),[t,...r]})(x)),[x]),E=S.useMemo((()=>[b,w]),[b,w]);return S.useLayoutEffect((()=>{h&&(g.current.geometry=m.mergeVertices(g.current.geometry,h),g.current.geometry.computeVertexNormals())}),[E,h]),S.useImperativeHandle(v,(()=>g.current),[]),S.createElement("mesh",e({},y,{ref:g}),S.createElement("renamedTextGeometry",{args:E}),M)})),ce=S.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)=>{S.useMemo((()=>o.extend({EffectComposer:m.EffectComposer,RenderPass:m.RenderPass,ShaderPass:m.ShaderPass})),[]);const v=S.useRef(),{scene:g,camera:z,gl:w,size:b,viewport:M}=o.useThree(),[E]=S.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}));S.useEffect((()=>{var e,t;null==(e=v.current)||e.setSize(b.width,b.height),null==(t=v.current)||t.setPixelRatio(M.dpr)}),[w,b,M.dpr]),o.useFrame((()=>{var e;s||null==(e=v.current)||e.render()}),a);const T=[];return c||T.push(S.createElement("renderPass",{key:"renderpass",attach:`passes-${T.length}`,args:[g,z]})),l||T.push(S.createElement("shaderPass",{attach:`passes-${T.length}`,key:"gammapass",args:[m.GammaCorrectionShader]})),S.Children.forEach(t,(e=>{e&&T.push(S.cloneElement(e,{key:T.length,attach:`passes-${T.length}`}))})),S.createElement("effectComposer",e({ref:i([y,v]),args:[w,E]},x),T)}));let ue=function(e){return e.Linear="linear",e.Radial="radial",e}({});function me(e,t,r,n){const o=class extends C.ShaderMaterial{constructor(o={}){const a=Object.entries(e);super({uniforms:a.reduce(((e,[t,r])=>({...e,...C.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=C.MathUtils.generateUUID(),o}const de=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function fe(e,r){const a=o.useThree((e=>e.gl)),i=o.useLoader(n.TextureLoader,de(e)?Object.values(e):e);if(t.useLayoutEffect((()=>{null==r||r(i)}),[r]),t.useEffect((()=>{if("initTexture"in a){(Array.isArray(i)?i:[i]).forEach(a.initTexture)}}),[a,i]),de(e)){const t={};let r=0;for(const n in e)t[n]=i[r++];return t}return i}fe.preload=e=>o.useLoader.preload(n.TextureLoader,e),fe.clear=e=>o.useLoader.clear(n.TextureLoader,e);const pe=(()=>parseInt(n.REVISION.replace(/\D+/g,"")))(),he=me({color:new C.Color("white"),scale:new C.Vector2(1,1),imageBounds:new C.Vector2(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},"\n varying vec2 vUv;\n varying vec2 vPos;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n vPos = position.xy;\n }\n",`\n // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44\n varying vec2 vUv;\n varying vec2 vPos;\n uniform vec2 scale;\n uniform vec2 imageBounds;\n uniform float resolution;\n uniform vec3 color;\n uniform sampler2D map;\n uniform float radius;\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 \n const float PI = 3.14159265;\n \n // from https://iquilezles.org/articles/distfunctions\n float udRoundBox( vec2 p, vec2 b, float r ) {\n return length(max(abs(p)-b+r,0.0))-r;\n }\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\n vec2 res = vec2(scale * resolution);\n vec2 halfRes = 0.5 * res;\n float b = udRoundBox(vUv.xy * res - halfRes, halfRes, resolution * radius); \n\t vec3 a = mix(vec3(1.0,0.0,0.0), vec3(0.0,0.0,0.0), smoothstep(0.0, 1.0, b));\n gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity * a), grayscale);\n \n #include <tonemapping_fragment>\n #include <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n`),xe=S.forwardRef((({children:t,color:r,segments:n=1,scale:a=1,zoom:i=1,grayscale:s=0,opacity:l=1,radius:c=0,texture:u,toneMapped:m,transparent:d,side:f,...p},h)=>{o.extend({ImageMaterial:he});const x=S.useRef(null),y=o.useThree((e=>e.size)),v=Array.isArray(a)?[a[0],a[1]]:[a,a],g=[u.image.width,u.image.height],z=Math.max(y.width,y.height);return S.useImperativeHandle(h,(()=>x.current),[]),S.useLayoutEffect((()=>{x.current.geometry.parameters&&x.current.material.scale.set(v[0]*x.current.geometry.parameters.width,v[1]*x.current.geometry.parameters.height)}),[]),S.createElement("mesh",e({ref:x,scale:Array.isArray(a)?[...a,1]:a},p),S.createElement("planeGeometry",{args:[1,1,n,n]}),S.createElement("imageMaterial",{color:r,map:u,zoom:i,grayscale:s,opacity:l,scale:v,imageBounds:g,resolution:z,radius:c,toneMapped:m,transparent:d,side:f,key:he.key}),t)})),ye=S.forwardRef((({url:t,...r},n)=>{const o=fe(t);return S.createElement(xe,e({},r,{texture:o,ref:n}))})),ve=S.forwardRef((({url:t,...r},n)=>S.createElement(xe,e({},r,{ref:n})))),ge=S.forwardRef(((t,r)=>{if(t.url)return S.createElement(ye,e({},t,{ref:r}));if(t.texture)return S.createElement(ve,e({},t,{ref:r}));throw new Error("<Image /> requires a url or texture")})),ze=S.forwardRef((({userData:t,children:r,geometry:n,threshold:o=15,color:a="black",...i},s)=>{const l=S.useRef(null);return S.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 C.EdgesGeometry(t,o))}})),S.useImperativeHandle(s,(()=>l.current)),S.createElement("lineSegments",e({ref:l,raycast:()=>null},i),r||S.createElement("lineBasicMaterial",{color:a}))})),we=me({screenspace:!1,color:new C.Color("black"),opacity:1,thickness:.05,size:new C.Vector2},"#include <common>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n uniform float thickness;\n uniform float screenspace;\n uniform vec2 size;\n void main() {\n #if defined (USE_SKINNING)\n\t #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n\t #include <morphtarget_vertex>\n\t #include <skinning_vertex>\n #include <project_vertex>\n vec4 tNormal = vec4(normal, 0.0);\n vec4 tPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n tNormal = instanceMatrix * tNormal;\n tPosition = instanceMatrix * tPosition;\n #endif\n if (screenspace == 0.0) {\n vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); \n } else {\n vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;\n vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;\n vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;\n clipPosition.xy += offset;\n gl_Position = clipPosition;\n }\n }",`uniform vec3 color;\n uniform float opacity;\n void main(){\n gl_FragColor = vec4(color, opacity);\n #include <tonemapping_fragment>\n #include <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);const be={width:.2,length:1,decay:1,local:!1,stride:0,interval:1},Me=(e,t=1)=>(e.set(e.subarray(t)),e.fill(-1/0,-t),e);function Ee(e,t){const{length:r,local:a,decay:i,interval:s,stride:l}={...be,...t},c=S.useRef(),[u]=S.useState((()=>new n.Vector3));S.useLayoutEffect((()=>{e&&(c.current=Float32Array.from({length:10*r*3},((t,r)=>e.position.getComponent(r%3))))}),[r,e]);const m=S.useRef(new n.Vector3),d=S.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||(Me(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 Se=S.forwardRef(((e,t)=>{const{children:r}=e,{width:a,length:i,decay:s,local:l,stride:c,interval:u}={...be,...e},{color:m="hotpink",attenuation:d,target:f}=e,p=o.useThree((e=>e.size)),x=o.useThree((e=>e.scene)),y=S.useRef(null),[v,g]=S.useState(null),z=Ee(v,{length:i,decay:s,local:l,stride:c,interval:u});S.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=S.useMemo((()=>new h.MeshLineGeometry),[]),b=S.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 S.useEffect((()=>{b.uniforms.resolution.value.set(p.width,p.height)}),[p]),o.useFrame((()=>{z.current&&w.setPoints(z.current,d)})),S.createElement("group",null,o.createPortal(S.createElement("mesh",{ref:t,geometry:w,material:b}),x),S.createElement("group",{ref:y},r))}));function Te(e,t=16,r,o,a){const[i,s]=S.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 S.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 Ce=S.forwardRef((({isChild:t=!1,object:r,children:n,deep:o,castShadow:a,receiveShadow:i,inject:s,keys:l,...c},u)=>{const d={keys:l,deep:o,inject:s,castShadow:a,receiveShadow:i};if(r=S.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 S.createElement("group",e({},c,{ref:u}),r.map((t=>S.createElement(Ce,e({key:t.uuid,object:t},d)))),n);const{children:f,...p}=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={};for(const r of t)i[r]=e[r];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)}:S.isValidElement(n)?{...i,children:n}:{...i,...n}),e instanceof C.Mesh&&(o&&(i.castShadow=!0),a&&(i.receiveShadow=!0)),i}(r,d),h=r.type[0].toLowerCase()+r.type.slice(1);return S.createElement(h,e({},p,c,{ref:u}),r.children.map((t=>"Bone"===t.type?S.createElement("primitive",e({key:t.uuid,object:t},d)):S.createElement(Ce,e({key:t.uuid,object:t},d,{isChild:!0})))),n,f)})),Pe=S.createContext(null),Re=S.forwardRef((({resolution:t=28,maxPolyCount:r=1e4,enableUvs:n=!1,enableColors:a=!1,children:s,...l},c)=>{const u=S.useRef(null),d=S.useMemo((()=>new m.MarchingCubes(t,null,n,a,r)),[t,r,n,a]),f=S.useMemo((()=>({getParent:()=>u})),[]);return o.useFrame((()=>{d.update(),d.reset()}),-1),S.createElement(S.Fragment,null,S.createElement("primitive",e({object:d,ref:i([u,c])},l),S.createElement(Pe.Provider,{value:f},s)))})),De=S.forwardRef((({strength:t=.5,subtract:r=12,color:n,...a},s)=>{const{getParent:l}=S.useContext(Pe),c=S.useMemo((()=>l()),[l]),u=S.useRef(),m=new C.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))})),S.createElement("group",e({ref:i([s,u])},a))})),Fe=S.forwardRef((({planeType:t="x",strength:r=.5,subtract:n=12,...a},s)=>{const{getParent:l}=S.useContext(Pe),c=S.useMemo((()=>l()),[l]),u=S.useRef(),m=S.useMemo((()=>"x"===t?"addPlaneX":"y"===t?"addPlaneY":"addPlaneZ"),[t]);return o.useFrame((()=>{c.current&&u.current&&c.current[m](r,n)})),S.createElement("group",e({ref:i([s,u])},a))}));function ke(e=[0,0,0]){return function(e){return Array.isArray(e)}(e)?e:e instanceof C.Vector3||e instanceof C.Euler?[e.x,e.y,e.z]:[e,e,e]}const _e=S.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=S.useRef(null);S.useImperativeHandle(f,(()=>p.current));const h=S.useRef(null);return S.useLayoutEffect((()=>{const e=(null==i?void 0:i.current)||p.current.parent,t=p.current;if(!(e instanceof C.Mesh))throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');const r={position:new C.Vector3,rotation:new C.Euler,scale:new C.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 C.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,...ke(l),...ke(u),...ke(c)]),S.createElement("mesh",e({ref:p,"material-transparent":!0,"material-polygonOffset":!0,"material-polygonOffsetFactor":n,"material-depthTest":r,"material-map":a},d),s,t&&S.createElement("mesh",{ref:h},S.createElement("boxGeometry",null),S.createElement("meshNormalMaterial",{wireframe:!0}),S.createElement("axesHelper",null)))})),Ae=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]),S.createElement("object3D",e({ref:f},d),S.createElement("object3D",{scale:[1,-1,1]},p.paths.map(((r,o)=>{var d,f;return S.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)=>S.createElement("mesh",e({key:o},c),S.createElement("shapeGeometry",{args:[t]}),S.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)=>S.createElement("mesh",e({key:a,geometry:h[o][a]},u),S.createElement("meshBasicMaterial",e({color:r.userData.style.stroke,opacity:r.userData.style.strokeOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},l))))))}))))}));let Le=null,Be="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function Ue(e,t,r){return n=>{r&&r(n),e&&(Le||(Le=new m.DRACOLoader),Le.setDecoderPath("string"==typeof e?e:Be),n.setDRACOLoader(Le)),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,Ue(t,r,n))}Ie.preload=(e,t=!0,r=!0,n)=>o.useLoader.preload(m.GLTFLoader,e,Ue(t,r,n)),Ie.clear=e=>o.useLoader.clear(m.GLTFLoader,e),Ie.setDecoderPath=e=>{Be=e};const Ve=S.forwardRef((({src:t,...r},n)=>{const{scene:o}=Ie(t);return S.createElement(Ce,e({ref:n},r,{object:o}))}));const Ne=me({alphaTest:0,viewport:new C.Vector2(1980,1080),focal:1e3,centerAndScaleTexture:null,covAndColorTexture:null},"\n precision highp sampler2D;\n precision highp usampler2D;\n out vec4 vColor;\n out vec3 vPosition;\n uniform vec2 resolution;\n uniform vec2 viewport;\n uniform float focal;\n attribute uint splatIndex;\n uniform sampler2D centerAndScaleTexture;\n uniform usampler2D covAndColorTexture; \n\n vec2 unpackInt16(in uint value) {\n int v = int(value);\n int v0 = v >> 16;\n int v1 = (v & 0xFFFF);\n if((v & 0x8000) != 0)\n v1 |= 0xFFFF0000;\n return vec2(float(v1), float(v0));\n }\n\n void main () {\n ivec2 texSize = textureSize(centerAndScaleTexture, 0);\n ivec2 texPos = ivec2(splatIndex%uint(texSize.x), splatIndex/uint(texSize.x));\n vec4 centerAndScaleData = texelFetch(centerAndScaleTexture, texPos, 0);\n vec4 center = vec4(centerAndScaleData.xyz, 1);\n vec4 camspace = modelViewMatrix * center;\n vec4 pos2d = projectionMatrix * camspace;\n\n float bounds = 1.2 * pos2d.w;\n if (pos2d.z < -pos2d.w || pos2d.x < -bounds || pos2d.x > bounds\n || pos2d.y < -bounds || pos2d.y > bounds) {\n gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n return;\n }\n\n uvec4 covAndColorData = texelFetch(covAndColorTexture, texPos, 0);\n vec2 cov3D_M11_M12 = unpackInt16(covAndColorData.x) * centerAndScaleData.w;\n vec2 cov3D_M13_M22 = unpackInt16(covAndColorData.y) * centerAndScaleData.w;\n vec2 cov3D_M23_M33 = unpackInt16(covAndColorData.z) * centerAndScaleData.w;\n mat3 Vrk = mat3(\n cov3D_M11_M12.x, cov3D_M11_M12.y, cov3D_M13_M22.x,\n cov3D_M11_M12.y, cov3D_M13_M22.y, cov3D_M23_M33.x,\n cov3D_M13_M22.x, cov3D_M23_M33.x, cov3D_M23_M33.y\n );\n\n mat3 J = mat3(\n focal / camspace.z, 0., -(focal * camspace.x) / (camspace.z * camspace.z),\n 0., focal / camspace.z, -(focal * camspace.y) / (camspace.z * camspace.z),\n 0., 0., 0.\n );\n\n mat3 W = transpose(mat3(modelViewMatrix));\n mat3 T = W * J;\n mat3 cov = transpose(T) * Vrk * T;\n vec2 vCenter = vec2(pos2d) / pos2d.w;\n float diagonal1 = cov[0][0] + 0.3;\n float offDiagonal = cov[0][1];\n float diagonal2 = cov[1][1] + 0.3;\n float mid = 0.5 * (diagonal1 + diagonal2);\n float radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));\n float lambda1 = mid + radius;\n float lambda2 = max(mid - radius, 0.1);\n vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n vec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n vec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n uint colorUint = covAndColorData.w;\n vColor = vec4(\n float(colorUint & uint(0xFF)) / 255.0,\n float((colorUint >> uint(8)) & uint(0xFF)) / 255.0,\n float((colorUint >> uint(16)) & uint(0xFF)) / 255.0,\n float(colorUint >> uint(24)) / 255.0\n );\n vPosition = position;\n\n gl_Position = vec4(\n vCenter \n + position.x * v2 / viewport * 2.0 \n + position.y * v1 / viewport * 2.0, pos2d.z / pos2d.w, 1.0);\n }\n ",`\n #include <alphatest_pars_fragment>\n #include <alphahash_pars_fragment>\n in vec4 vColor;\n in vec3 vPosition;\n void main () {\n float A = -dot(vPosition.xy, vPosition.xy);\n if (A < -4.0) discard;\n float B = exp(A) * vColor.a;\n vec4 diffuseColor = vec4(vColor.rgb, B);\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <tonemapping_fragment>\n #include <${parseInt(C.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `);function Oe(e){let t=null,r=0;e.onmessage=n=>{if("push"==n.data.method){0===r&&(t=new Float32Array(n.data.length));const e=new Float32Array(n.data.matrices);t.set(e,r),r+=e.length}else if("sort"==n.data.method&&null!==t){const r=function(e,r=!1){const n=t.length/16;let o=-1/0,a=1/0;const i=new Float32Array(n),s=new Int32Array(i.buffer),l=new Int32Array(n);let c=0;for(let s=0;s<n;s++){const n=e[0]*t[16*s+12]+e[1]*t[16*s+13]+e[2]*t[16*s+14]+e[3];(r||n<0&&t[16*s+15]>-1e-4*n)&&(i[c]=n,l[c]=s,c++,n>o&&(o=n),n<a&&(a=n))}const u=65535/(o-a),m=new Uint32Array(65536);for(let e=0;e<c;e++)s[e]=(i[e]-a)*u|0,m[s[e]]++;const d=new Uint32Array(65536);for(let e=1;e<65536;e++)d[e]=d[e-1]+m[e-1];const f=new Uint32Array(c);for(let e=0;e<c;e++)f[d[s[e]]++]=l[e];return f}(new Float32Array(n.data.view),n.data.hashed);e.postMessage({indices:r,key:n.data.key},[r.buffer])}}}class je extends C.Loader{constructor(...e){super(...e),this.gl=null,this.chunkSize=25e3}load(e,t,r,n){const o={gl:this.gl,url:this.manager.resolveURL(e),worker:new Worker(URL.createObjectURL(new Blob(["(",Oe.toString(),")(self)"],{type:"application/javascript"}))),manager:this.manager,update:(e,t,r)=>function(e,t,r,n){if(e.updateMatrixWorld(),t.gl.getCurrentViewport(r.viewport),r.material.viewport.x=r.viewport.z,r.material.viewport.y=r.viewport.w,r.material.focal=r.viewport.w/2*Math.abs(e.projectionMatrix.elements[5]),r.ready){if(n&&r.sorted)return;r.ready=!1;const e=new Float32Array([r.modelViewMatrix.elements[2],-r.modelViewMatrix.elements[6],r.modelViewMatrix.elements[10],r.modelViewMatrix.elements[14]]);t.worker.postMessage({method:"sort",src:t.url,key:r.uuid,view:e.buffer,hashed:n},[e.buffer]),n&&t.loaded&&(r.sorted=!0)}}(t,o,e,r),connect:e=>function(e,t){e.loading||async function(e){e.loading=!0;let t=0,r=0;const n=[];let o=0;const a=0!==e.totalDownloadBytes;for(;;)try{const{value:i,done:s}=await e.stream.read();if(s)break;if(t+=i.length,null!=e.totalDownloadBytes){const r=t/e.totalDownloadBytes*100;if(e.onProgress&&r-o>1){const n=new ProgressEvent("progress",{lengthComputable:a,loaded:t,total:e.totalDownloadBytes});e.onProgress(n),o=r}}n.push(i);const l=t-r;if(null!=e.totalDownloadBytes&&l>e.rowLength*e.chunkSize){let t=Math.floor(l/e.rowLength);const o=new Uint8Array(l);let i=0;for(const e of n)o.set(e,i),i+=e.length;if(n.length=0,l>t*e.rowLength){const r=new Uint8Array(l-t*e.rowLength);r.set(o.subarray(l-r.length,l),0),n.push(r)}const s=new Uint8Array(t*e.rowLength);s.set(o.subarray(0,s.byteLength),0);const c=We(e,s.buffer,t);if(e.worker.postMessage({method:"push",src:e.url,length:16*e.numVertices,matrices:c.buffer},[c.buffer]),r+=t*e.rowLength,e.onProgress){const t=new ProgressEvent("progress",{lengthComputable:a,loaded:e.totalDownloadBytes,total:e.totalDownloadBytes});e.onProgress(t)}}}catch(e){console.error(e);break}if(t-r>0){let t=new Uint8Array(n.reduce(((e,t)=>e+t.length),0)),r=0;for(const e of n)t.set(e,r),r+=e.length;let o=Math.floor(t.byteLength/e.rowLength);const a=We(e,t.buffer,o);e.worker.postMessage({method:"push",src:e.url,length:16*o,matrices:a.buffer},[a.buffer])}e.loaded=!0,e.manager.itemEnd(e.url)}(e);t.ready=!1,t.pm=new C.Matrix4,t.vm1=new C.Matrix4,t.vm2=new C.Matrix4,t.viewport=new C.Vector4;let r=new Uint32Array(e.bufferTextureWidth*e.bufferTextureHeight);const n=new C.InstancedBufferAttribute(r,1,!1);n.setUsage(C.DynamicDrawUsage);const o=t.geometry=new C.InstancedBufferGeometry,a=new Float32Array(18),i=new C.BufferAttribute(a,3);function s(e){if(t&&e.data.key===t.uuid){let r=new Uint32Array(e.data.indices);o.attributes.splatIndex.set(r),o.attributes.splatIndex.needsUpdate=!0,o.instanceCount=r.length,t.ready=!0}}async function l(){for(;;){const t=e.gl.properties.get(e.centerAndScaleTexture),r=e.gl.properties.get(e.covAndColorTexture);if(null!=t&&t.__webglTexture&&null!=r&&r.__webglTexture&&e.loadedVertexCount>0)break;await new Promise((e=>setTimeout(e,10)))}t.ready=!0}return o.setAttribute("position",i),i.setXYZ(2,-2,2,0),i.setXYZ(1,2,2,0),i.setXYZ(0,-2,-2,0),i.setXYZ(5,-2,-2,0),i.setXYZ(4,2,2,0),i.setXYZ(3,2,-2,0),i.needsUpdate=!0,o.setAttribute("splatIndex",n),o.instanceCount=1,e.worker.addEventListener("message",s),l(),()=>e.worker.removeEventListener("message",s)}(o,e),loading:!1,loaded:!1,loadedVertexCount:0,chunkSize:this.chunkSize,totalDownloadBytes:0,numVertices:0,rowLength:32,maxVertexes:0,bufferTextureWidth:0,bufferTextureHeight:0,stream:null,centerAndScaleData:null,covAndColorData:null,covAndColorTexture:null,centerAndScaleTexture:null,onProgress:r};(async function(e){e.manager.itemStart(e.url);const t=await fetch(e.url);if(null===t.body)throw"Failed to fetch file";let r=t.headers.get("Content-Length");const n=r?parseInt(r):void 0;if(null==n)throw"Failed to get content length";e.stream=t.body.getReader(),e.totalDownloadBytes=n,e.numVertices=Math.floor(e.totalDownloadBytes/e.rowLength);const o=e.gl.getContext();let a=o.getParameter(o.MAX_TEXTURE_SIZE);e.maxVertexes=a*a,e.numVertices>e.maxVertexes&&(e.numVertices=e.maxVertexes);return e.bufferTextureWidth=a,e.bufferTextureHeight=Math.floor((e.numVertices-1)/a)+1,e.centerAndScaleData=new Float32Array(e.bufferTextureWidth*e.bufferTextureHeight*4),e.covAndColorData=new Uint32Array(e.bufferTextureWidth*e.bufferTextureHeight*4),e.centerAndScaleTexture=new C.DataTexture(e.centerAndScaleData,e.bufferTextureWidth,e.bufferTextureHeight,C.RGBAFormat,C.FloatType),e.centerAndScaleTexture.needsUpdate=!0,e.covAndColorTexture=new C.DataTexture(e.covAndColorData,e.bufferTextureWidth,e.bufferTextureHeight,C.RGBAIntegerFormat,C.UnsignedIntType),e.covAndColorTexture.internalFormat="RGBA32UI",e.covAndColorTexture.needsUpdate=!0,e})(o).then(t).catch((e=>{null==n||n(e),o.manager.itemError(o.url)}))}}function We(e,t,r){const n=e.gl.getContext();if(e.loadedVertexCount+r>e.maxVertexes&&(r=e.maxVertexes-e.loadedVertexCount),r<=0)throw"Failed to parse file";const o=new Uint8Array(t),a=new Float32Array(t),i=new Float32Array(16*r),s=new Uint8Array(e.covAndColorData.buffer),l=new Int16Array(e.covAndColorData.buffer);for(let t=0;t<r;t++){const r=new C.Quaternion(-(o[32*t+28+1]-128)/128,(o[32*t+28+2]-128)/128,(o[32*t+28+3]-128)/128,-(o[32*t+28+0]-128)/128);r.invert();const n=new C.Vector3(a[8*t+0],a[8*t+1],-a[8*t+2]),c=new C.Vector3(a[8*t+3+0],a[8*t+3+1],a[8*t+3+2]),u=new C.Matrix4;u.makeRotationFromQuaternion(r),u.transpose(),u.scale(c);const m=u.clone();u.transpose(),u.premultiply(m),u.setPosition(n);const d=[0,1,2,5,6,10];let f=0;for(let e=0;e<d.length;e++)Math.abs(u.elements[d[e]])>f&&(f=Math.abs(u.elements[d[e]]));let p=4*e.loadedVertexCount+4*t;e.centerAndScaleData[p+0]=n.x,e.centerAndScaleData[p+1]=-n.y,e.centerAndScaleData[p+2]=n.z,e.centerAndScaleData[p+3]=f/32767,p=8*e.loadedVertexCount+4*t*2;for(let e=0;e<d.length;e++)l[p+e]=32767*u.elements[d[e]]/f;p=16*e.loadedVertexCount+4*(4*t+3);const h=new C.Color(o[32*t+24+0]/255,o[32*t+24+1]/255,o[32*t+24+2]/255);h.convertSRGBToLinear(),s[p+0]=255*h.r,s[p+1]=255*h.g,s[p+2]=255*h.b,s[p+3]=o[32*t+24+3],u.elements[15]=Math.max(c.x,c.y,c.z)*o[32*t+24+3]/255;for(let e=0;e<16;e++)i[16*t+e]=u.elements[e]}for(;r>0;){let t=0,o=0;const a=e.loadedVertexCount%e.bufferTextureWidth,i=Math.floor(e.loadedVertexCount/e.bufferTextureWidth);e.loadedVertexCount%e.bufferTextureWidth!=0?(t=Math.min(e.bufferTextureWidth,a+r)-a,o=1):Math.floor(r/e.bufferTextureWidth)>0?(t=e.bufferTextureWidth,o=Math.floor(r/e.bufferTextureWidth)):(t=r%e.bufferTextureWidth,o=1);const s=e.gl.properties.get(e.centerAndScaleTexture);n.bindTexture(n.TEXTURE_2D,s.__webglTexture),n.texSubImage2D(n.TEXTURE_2D,0,a,i,t,o,n.RGBA,n.FLOAT,e.centerAndScaleData,4*e.loadedVertexCount);const l=e.gl.properties.get(e.covAndColorTexture);n.bindTexture(n.TEXTURE_2D,l.__webglTexture),n.texSubImage2D(n.TEXTURE_2D,0,a,i,t,o,n.RGBA_INTEGER,n.UNSIGNED_INT,e.covAndColorData,4*e.loadedVertexCount),e.gl.resetState(),e.loadedVertexCount+=t*o,r-=t*o}return i}function Ge(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=S.useMemo((()=>{const e=new C.WebGLRenderTarget(i,s,{minFilter:C.LinearFilter,magFilter:C.LinearFilter,type:C.HalfFloatType,...m});return u&&(e.depthTexture=new C.DepthTexture(i,s,C.FloatType)),e.samples=c,e}),[]);return S.useLayoutEffect((()=>{d.setSize(i,s),c&&(d.samples=c)}),[c,d,i,s]),S.useEffect((()=>()=>d.dispose()),[]),d}const He=S.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=S.useRef(null),p=S.useRef(null),h=Ge(r);S.useLayoutEffect((()=>{l.manual||f.current.updateProjectionMatrix()}),[d,l]),S.useLayoutEffect((()=>{f.current.updateProjectionMatrix()})),S.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++)})),S.createElement(S.Fragment,null,S.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),S.createElement("group",{ref:p},v&&a(h.texture)))})),$e=S.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=S.useRef(null),p=S.useRef(null),h=Ge(r);S.useLayoutEffect((()=>{l.manual||(f.current.aspect=d.width/d.height)}),[d,l]),S.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++)})),S.useLayoutEffect((()=>{if(a){const e=m;return u((()=>({camera:f.current}))),()=>u((()=>({camera:e})))}}),[f,a,u]),S.createElement(S.Fragment,null,S.createElement("perspectiveCamera",e({ref:i([f,c])},l),!v&&s),S.createElement("group",{ref:p},v&&s(h.texture)))}));function qe({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 C.CubeCamera(r,a,u)),[r,a,u]);let d,f;const p=S.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 Xe=S.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=S.useMemo((()=>new m.DeviceOrientationControls(f)),[f]);return S.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),S.useEffect((()=>{const e=p;return null==e||e.connect(),()=>null==e?void 0:e.dispose()}),[p]),S.useEffect((()=>{if(i){const e=u().controls;return d({controls:p}),()=>d({controls:e})}}),[i,p]),p?S.createElement("primitive",e({ref:r,object:p},s)):null})),Ze=S.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=S.useMemo((()=>new m.FlyControls(c)),[c]);return S.useEffect((()=>(x.connect(h),()=>{x.dispose()})),[h,x,l]),S.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]),S.useEffect((()=>{if(i){const e=f().controls;return p({controls:x}),()=>p({controls:e})}}),[i,x]),o.useFrame(((e,t)=>x.update(t))),S.createElement("primitive",e({ref:n,object:x,args:[c,h]},s))})),Ye=S.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=S.useMemo((()=>new m.MapControls(g)),[g]);return S.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]),S.useEffect((()=>{if(i){const e=y().controls;return x({controls:z}),()=>x({controls:e})}}),[i,z]),o.useFrame((()=>z.update()),-1),S.createElement("primitive",e({ref:r,object:z,enableDamping:!0},u))})),Qe=S.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,M=a||y.connected||x.domElement,E=S.useMemo((()=>new m.OrbitControls(b)),[b]);return o.useFrame((()=>{E.enabled&&E.update()}),-1),S.useEffect((()=>(s&&E.connect(!0===s?M:s),E.connect(M),()=>{E.dispose()})),[s,M,n,E,p]),S.useEffect((()=>{const e=e=>{p(),n&&w.regress(),l&&l(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return E.addEventListener("change",e),E.addEventListener("start",t),E.addEventListener("end",r),()=>{E.removeEventListener("start",t),E.removeEventListener("end",r),E.removeEventListener("change",e)}}),[l,c,u,E,p,v]),S.useEffect((()=>{if(t){const e=z().controls;return g({controls:E}),()=>g({controls:e})}}),[t,E]),S.createElement("primitive",e({ref:f,object:E,enableDamping:i},d))})),Ke=S.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=S.useMemo((()=>new m.TrackballControls(z)),[z]);return o.useFrame((()=>{b.enabled&&b.update()}),-1),S.useEffect((()=>(b.connect(w),()=>{b.dispose()})),[w,a,b,d]),S.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]),S.useEffect((()=>{b.handleResize()}),[g]),S.useEffect((()=>{if(t){const e=y().controls;return x({controls:b}),()=>x({controls:e})}}),[t,b]),S.createElement("primitive",e({ref:u,object:b},c))})),Je=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]),S.createElement("primitive",e({ref:d,object:b},u))})),et=S.forwardRef((({children:t,domElement:r,onChange:n,onMouseDown:a,onMouseUp:i,onObjectChange:s,object:l,makeDefault:c,camera:u,enabled:d,axis:f,mode:p,translationSnap:h,rotationSnap:x,scaleSnap:y,space:v,size:g,showX:z,showY:w,showZ:b,...M},E)=>{const T=o.useThree((e=>e.controls)),P=o.useThree((e=>e.gl)),R=o.useThree((e=>e.events)),D=o.useThree((e=>e.camera)),F=o.useThree((e=>e.invalidate)),k=o.useThree((e=>e.get)),_=o.useThree((e=>e.set)),A=u||D,L=r||R.connected||P.domElement,B=S.useMemo((()=>new m.TransformControls(A,L)),[A,L]),U=S.useRef(null);S.useLayoutEffect((()=>(l?B.attach(l instanceof C.Object3D?l:l.current):U.current instanceof C.Object3D&&B.attach(U.current),()=>{B.detach()})),[l,t,B]),S.useEffect((()=>{if(T){const e=e=>T.enabled=!e.value;return B.addEventListener("dragging-changed",e),()=>B.removeEventListener("dragging-changed",e)}}),[B,T]);const I=S.useRef(),V=S.useRef(),N=S.useRef(),O=S.useRef();return S.useLayoutEffect((()=>{I.current=n}),[n]),S.useLayoutEffect((()=>{V.current=a}),[a]),S.useLayoutEffect((()=>{N.current=i}),[i]),S.useLayoutEffect((()=>{O.current=s}),[s]),S.useEffect((()=>{const e=e=>{F(),null==I.current||I.current(e)},t=e=>null==V.current?void 0:V.current(e),r=e=>null==N.current?void 0:N.current(e),n=e=>null==O.current?void 0:O.current(e);return B.addEventListener("change",e),B.addEventListener("mouseDown",t),B.addEventListener("mouseUp",r),B.addEventListener("objectChange",n),()=>{B.removeEventListener("change",e),B.removeEventListener("mouseDown",t),B.removeEventListener("mouseUp",r),B.removeEventListener("objectChange",n)}}),[F,B]),S.useEffect((()=>{if(c){const e=k().controls;return _({controls:B}),()=>_({controls:e})}}),[c,B]),S.createElement(S.Fragment,null,S.createElement("primitive",{ref:E,object:B,enabled:d,axis:f,mode:p,translationSnap:h,rotationSnap:x,scaleSnap:y,space:v,size:g,showX:z,showY:w,showZ:b}),S.createElement("group",e({ref:U},M),t))})),tt=S.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,M=S.useMemo((()=>new m.PointerLockControls(w)),[w]);return S.useEffect((()=>{if(s){M.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)}}),()=>{M.disconnect(),p({compute:e})}}}),[s,M]),S.useEffect((()=>{const e=e=>{y(),n&&n(e)};M.addEventListener("change",e),a&&M.addEventListener("lock",a),i&&M.addEventListener("unlock",i);const t=()=>M.lock(),o=r?Array.from(document.querySelectorAll(r)):[document];return o.forEach((e=>e&&e.addEventListener("click",t))),()=>{M.removeEventListener("change",e),a&&M.removeEventListener("lock",a),i&&M.removeEventListener("unlock",i),o.forEach((e=>e?e.removeEventListener("click",t):void 0))}}),[n,a,i,r,M,y]),S.useEffect((()=>{if(l){const e=g().controls;return z({controls:M}),()=>z({controls:e})}}),[l,M]),S.createElement("primitive",e({ref:u,object:M},f))})),rt=S.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]=S.useState((()=>new m.FirstPersonControls(i,d)));return S.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?S.createElement("primitive",e({ref:a,object:f},n)):null})),nt=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};x.install({THREE:e}),o.extend({CameraControlsImpl:x})}),[]);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)),y=o.useThree((e=>e.invalidate)),v=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)),M=i||p,E=s||v.connected||h.domElement,T=t.useMemo((()=>new x(M)),[M]);return o.useFrame(((e,t)=>{T.enabled&&T.update(t)}),-1),t.useEffect((()=>(T.connect(E),()=>{T.disconnect()})),[E,T]),t.useEffect((()=>{const e=e=>{y(),d&&b.regress(),m&&m(e)},t=e=>{c&&c(e)},r=e=>{u&&u(e)};return T.addEventListener("update",e),T.addEventListener("controlstart",t),T.addEventListener("controlend",r),T.addEventListener("control",e),T.addEventListener("transitionstart",e),T.addEventListener("wake",e),()=>{T.removeEventListener("update",e),T.removeEventListener("controlstart",t),T.removeEventListener("controlend",r),T.removeEventListener("control",e),T.removeEventListener("transitionstart",e),T.removeEventListener("wake",e)}}),[T,c,u,y,g,d,m]),t.useEffect((()=>{if(l){const e=w().controls;return z({controls:T}),()=>z({controls:e})}}),[l,T]),S.createElement("primitive",e({ref:a,object:T},f))})),ot=S.createContext(null);function at(){return S.useContext(ot)}function it({points:e=50}){const{path:t}=at(),[r,n]=S.useState([]),[o]=S.useState((()=>new C.MeshBasicMaterial({color:"black"}))),[a]=S.useState((()=>new C.SphereGeometry(.025,16,16))),i=S.useRef([]);return S.useEffect((()=>{t.curves!==i.current&&(n(t.getPoints(e)),i.current=t.curves)})),S.createElement(S.Fragment,null,r.map(((e,t)=>S.createElement("mesh",{key:t,material:o,geometry:a,position:[e.x,e.y,e.z]}))))}const st=S.forwardRef((({children:t,curves:r=[],object:n,debug:a=!1,smooth:i=!1,focus:l,offset:c,eps:u=1e-5,damping:m=.1,focusDamping:d=.1,maxSpeed:f=1/0,...p},h)=>{const{camera:x}=o.useThree(),y=S.useRef(),[v]=S.useState((()=>new C.CurvePath)),g=S.useRef(null!=c?c:0),z=S.useMemo((()=>({focus:l,object:(null==n?void 0:n.current)instanceof C.Object3D?n:{current:x},path:v,current:g.current,offset:g.current,point:new C.Vector3,tangent:new C.Vector3,next:new C.Vector3})),[l,n]);S.useLayoutEffect((()=>{var e;v.curves=[];const t=r.length>0?r:null==(e=y.current)?void 0:e.__r3f.objects;for(var n=0;n<t.length;n++)v.add(t[n]);if(i){const e=v.getPoints("number"==typeof i?i:1),t=new C.CatmullRomCurve3(e);v.curves=[t]}v.updateArcLengths()})),S.useImperativeHandle(h,(()=>y.current),[]),S.useLayoutEffect((()=>{g.current=s.misc.repeat(g.current,1)}),[c]);let w=0;const[b]=S.useState((()=>new C.Vector3));return o.useFrame(((e,t)=>{if(w=z.offset,s.easing.damp(g,"current",void 0!==c?c:z.current,m,t,f,void 0,u),z.offset=s.misc.repeat(g.current,1),v.getCurveLengths().length>0){v.getPointAt(z.offset,z.point),v.getTangentAt(z.offset,z.tangent).normalize(),v.getPointAt(s.misc.repeat(g.current-(w-z.offset),1),z.next);const e=(null==n?void 0:n.current)instanceof C.Object3D?n.current:x;e.position.copy(z.point),l&&s.easing.dampLookAt(e,(e=>(null==e?void 0:e.current)instanceof C.Object3D)(l)?l.current.getWorldPosition(b):l,d,t,f,void 0,u)}})),S.createElement("group",e({ref:y},p),S.createElement(ot.Provider,{value:z},t,a&&S.createElement(it,null)))}));function lt({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),S.createElement("group",{onPointerOver:()=>null})}function ct({children:e,renderPriority:t=1}){const{scene:r,camera:n}=o.useThree(),[a]=S.useState((()=>new C.Scene));return S.createElement(S.Fragment,null,o.createPortal(S.createElement(S.Fragment,null,e,S.createElement(lt,{defaultScene:r,defaultCamera:n,renderPriority:t})),a,{events:{priority:t+1}}))}const ut=S.createContext({}),mt=()=>S.useContext(ut),dt=2*Math.PI,ft=new n.Object3D,pt=new n.Matrix4,[ht,xt]=[new n.Quaternion,new n.Quaternion],yt=new n.Vector3,vt=new n.Vector3,gt="#f0f0f0",zt="#999",wt="black",bt="black",Mt=["Right","Left","Top","Bottom","Front","Back"],Et=e=>new n.Vector3(...e).multiplyScalar(.38),St=[[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(Et),Tt=[.25,.25,.25],Ct=[[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(Et),Pt=Ct.map((e=>e.toArray().map((e=>0==e?.5:.25)))),Rt=({hover:e,index:t,font:r="20px Inter var, Arial, sans-serif",faces:a=Mt,color:i=gt,hoverColor:s=zt,textColor:l=wt,strokeColor:c=bt,opacity:u=1})=>{const m=o.useThree((e=>e.gl)),d=S.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 S.createElement("meshBasicMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,attach:`material-${t}`,color:e?s:"white",transparent:!0,opacity:u})},Dt=t=>{const{tweenCamera:r}=mt(),[n,o]=S.useState(null);return S.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)=>S.createElement(Rt,e({key:o,index:o,hover:n===o},t)))),S.createElement("boxGeometry",null))},Ft=({onClick:e,dimensions:t,position:r,hoverColor:n=zt})=>{const{tweenCamera:o}=mt(),[a,i]=S.useState(!1);return S.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)})},S.createElement("meshBasicMaterial",{color:a?n:"white",transparent:!0,opacity:.6,visible:a}),S.createElement("boxGeometry",{args:t}))};function kt({scale:e=[.8,.05,.05],color:t,rotation:r}){return S.createElement("group",{rotation:r},S.createElement("mesh",{position:[.4,0,0]},S.createElement("boxGeometry",{args:e}),S.createElement("meshBasicMaterial",{color:t,toneMapped:!1})))}function _t({onClick:t,font:r,disabled:a,arcStyle:i,label:s,labelColor:l,axisHeadScale:c=1,...u}){const m=o.useThree((e=>e.gl)),d=S.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]=S.useState(!1),h=(s?1:.75)*(f?1.2:1)*c;return S.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),S.createElement("spriteMaterial",{map:d,"map-anisotropy":m.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:s?1:.75,toneMapped:!1}))}const At=me({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new C.Color,sectionColor:new C.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new C.Vector3,worldPlanePosition:new C.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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `),Lt=S.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=C.BackSide,...h},x)=>{o.extend({GridMaterial:At});const y=S.useRef(null),v=new C.Plane,g=new C.Vector3(0,1,0),z=new C.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 S.createElement("mesh",e({ref:i([y,x]),frustumCulled:!1},h),S.createElement("gridMaterial",e({transparent:!0,"extensions-derivatives":!0,side:p},w,b)),S.createElement("planeGeometry",{args:t}))}));function Bt(e,{path:t}){const[r]=o.useLoader(n.CubeTextureLoader,[e],(e=>e.setPath(t)));return r}function Ut(e){return o.useLoader(m.FBXLoader,e)}Bt.preload=(e,{path:t})=>o.useLoader.preload(n.CubeTextureLoader,[e],(e=>e.setPath(t))),Ut.preload=e=>o.useLoader.preload(m.FBXLoader,e),Ut.clear=e=>o.useLoader.clear(m.FBXLoader,e);const It="https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master";function Vt(e,r=`${It}/basis/`){const n=o.useThree((e=>e.gl)),a=o.useLoader(m.KTX2Loader,de(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]),de(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:a[t.indexOf(e)]}))),r}return a}function Nt(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 C.VideoTexture(o);"colorSpace"in a?a.colorSpace=u.outputColorSpace:a.encoding=u.outputEncoding,o.addEventListener(n,(()=>t(a)))}))),[e]);return t.useEffect((()=>{if(a)return m.image.play(),()=>m.image.pause()}),[m,a]),m}function Ot(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}Vt.preload=(e,t=`${It}/basis/`)=>o.useLoader.preload(m.KTX2Loader,e,(e=>{e.setTranscoderPath(t)})),Vt.clear=e=>o.useLoader.clear(m.KTX2Loader,e);function jt(e,t,...r){const n=S.useRef(),a=o.useThree((e=>e.scene));return S.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 Wt=e=>e.isMesh;const Gt=S.forwardRef((({enabled:t=!0,firstHitOnly:r=!1,children:a,strategy:i=z.SAH,verbose:s=!1,setBoundingBox:l=!0,maxDepth:c=40,maxLeafTris:u=10,indirect:m=!1,...d},f)=>{const p=S.useRef(null),h=o.useThree((e=>e.raycaster));return S.useImperativeHandle(f,(()=>p.current),[]),S.useEffect((()=>{if(t){const e={strategy:i,verbose:s,setBoundingBox:l,maxDepth:c,maxLeafTris:u,indirect:m},t=p.current;return h.firstHitOnly=r,t.traverse((t=>{Wt(t)&&!t.geometry.boundsTree&&t.raycast===n.Mesh.prototype.raycast&&(t.raycast=z.acceleratedRaycast,t.geometry.computeBoundsTree=z.computeBoundsTree,t.geometry.disposeBoundsTree=z.disposeBoundsTree,t.geometry.computeBoundsTree(e))})),()=>{delete h.firstHitOnly,t.traverse((e=>{Wt(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=n.Mesh.prototype.raycast)}))}}}),[]),S.createElement("group",e({ref:p},d),a)}));function Ht(e){const t=S.useRef(null),r=S.useRef(!1),n=S.useRef(!1),a=S.useRef(e);return S.useLayoutEffect((()=>{a.current=e}),[e]),S.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 $t="\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",qt="\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",Xt="\n#ifdef BOX_PROJECTED_ENV_MAP\n worldNormal = parallaxCorrectNormal( worldNormal, envMapSize, envMapPosition );\n#endif\n",Zt="\n#ifdef BOX_PROJECTED_ENV_MAP\n reflectVec = parallaxCorrectNormal( reflectVec, envMapSize, envMapPosition );\n#endif\n";const Yt=new C.Box3,Qt=new C.Vector3;const Kt=e=>Math.sqrt(1-Math.pow(e-1,2));class Jt{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=Kt}={}){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 er=S.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=S.useRef(null),g=S.useRef(null),z=S.useRef(null);return S.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,M=s?-x/2:l?x/2:0,E=m?w/2:d?-w/2:0;g.current.position.set(r||o?0:-t.x+M,r||a?0:-t.y+b,r||i?0:-t.z+E),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:M,depthAlignment:E})}),[h,f,c,s,m,r,o,a,i,p,l,u,d]),S.useImperativeHandle(y,(()=>v.current),[]),S.createElement("group",e({ref:v},x),S.createElement("group",{ref:g},S.createElement("group",{ref:z},t)))})),tr=S.forwardRef((({font:e,color:t="#cbcbcb",bevelSize:r=.04,debug:n=!1,children:o,...a},i)=>{const[s,l]=S.useState(0),c=S.useCallback(((e=1)=>l(s+e)),[s]),u=S.useCallback(((e=1)=>l(s-e)),[s]),m=S.useMemo((()=>({incr:c,decr:u})),[c,u]);return S.useImperativeHandle(i,(()=>m),[m]),S.createElement("group",a,S.createElement(S.Suspense,{fallback:null},S.createElement(er,{top:!0,cacheKey:JSON.stringify({counter:s,font:e})},S.createElement(le,{bevelEnabled:!0,bevelSize:r,font:e},n?S.createElement("meshNormalMaterial",{wireframe:!0}):S.createElement("meshStandardMaterial",{color:t}),s))),o)})),rr=(e,t)=>{"updateRanges"in e?e.updateRanges[0]=t:e.updateRange=t};const nr=new C.Matrix4,or=new C.Matrix4,ar=[],ir=new C.Mesh;class sr extends C.Group{constructor(){super(),this.color=new C.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;ir.geometry=r.geometry;const n=r.matrixWorld,o=r.userData.instances.indexOf(this.instanceKey);if(!(-1===o||o>r.count)){r.getMatrixAt(o,nr),or.multiplyMatrices(n,nr),ir.matrixWorld=or,r.material instanceof C.Material?ir.material.side=r.material.side:ir.material.side=r.material[0].side,ir.raycast(e,ar);for(let e=0,r=ar.length;e<r;e++){const r=ar[e];r.instanceId=o,r.object=this,t.push(r)}ar.length=0}}}const lr=S.createContext(null),cr=new C.Matrix4,ur=new C.Matrix4,mr=new C.Matrix4,dr=new C.Vector3,fr=new C.Quaternion,pr=new C.Vector3,hr=S.forwardRef((({context:t,children:r,...n},a)=>{S.useMemo((()=>o.extend({PositionMesh:sr})),[]);const s=S.useRef(),{subscribe:l,getParent:c}=S.useContext(t||lr);return S.useLayoutEffect((()=>l(s)),[]),S.createElement("positionMesh",e({instance:c(),instanceKey:s,ref:i([a,s])},n),r)})),xr=S.forwardRef((({children:t,range:r,limit:n=1e3,frames:a=1/0,...s},l)=>{const[{context:c,instance:u}]=S.useState((()=>{const t=S.createContext(null);return{context:t,instance:S.forwardRef(((r,n)=>S.createElement(hr,e({context:t},r,{ref:n}))))}})),m=S.useRef(null),[d,f]=S.useState([]),[[p,h]]=S.useState((()=>{const e=new Float32Array(16*n);for(let t=0;t<n;t++)mr.identity().toArray(e,16*t);return[e,new Float32Array([...new Array(3*n)].map((()=>1)))]}));S.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(),cr.copy(m.current.matrixWorld).invert(),y=Math.min(n,void 0!==r?r:n,d.length),m.current.count=y,rr(m.current.instanceMatrix,{offset:0,count:16*y}),rr(m.current.instanceColor,{offset:0,count:3*y});for(let e=0;e<d.length;e++){const t=d[e].current;t.matrixWorld.decompose(dr,fr,pr),ur.compose(dr,fr,pr).premultiply(cr),ur.toArray(p,16*e),m.current.instanceMatrix.needsUpdate=!0,t.color.toArray(h,3*e),m.current.instanceColor.needsUpdate=!0}x++}}));const v=S.useMemo((()=>({getParent:()=>m,subscribe:e=>(f((t=>[...t,e])),()=>f((t=>t.filter((t=>t.current!==e.current)))))})),[]);return S.createElement("instancedMesh",e({userData:{instances:d},matrixAutoUpdate:!1,ref:i([l,m]),args:[null,null,0],raycast:()=>null},s),S.createElement("instancedBufferAttribute",{attach:"instanceMatrix",count:p.length/16,array:p,itemSize:16,usage:C.DynamicDrawUsage}),S.createElement("instancedBufferAttribute",{attach:"instanceColor",count:h.length/3,array:h,itemSize:3,usage:C.DynamicDrawUsage}),"function"==typeof t?S.createElement(c.Provider,{value:v},t(u)):S.createElement(lr.Provider,{value:v},t))})),yr=S.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 S.createElement("group",{ref:o},S.createElement(w,{components:(a?t:Object.values(t)).map((({geometry:t,material:r})=>S.createElement(xr,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]})),{})))))})),vr=S.createContext(null);const gr=S.forwardRef((({startFrame:t,endFrame:r,fps:n,frameName:a,textureDataURL:i,textureImageURL:s,loop:l,numberOfFrames:c,autoPlay:u,animationNames:m,onStart:d,onEnd:f,onLoopEnd:p,onFrame:h,play:x,pause:y,flipX:v,alphaTest:g,children:z,asSprite:w,offset:b,playBackwards:M,resetOnEnd:E,maxItems:T,instanceItems:P,...R},D)=>{const F=S.useRef(),k=S.useRef(null),_=S.useRef(),A=S.useRef(),L=S.useRef(window.performance.now()),B=S.useRef(),U=S.useRef(t||0),I=S.useRef(a||""),V=1e3/(n||30),[N,O]=S.useState(new C.Texture),j=S.useRef(0),[W,G]=S.useState([1,1,1]),H=v?-1:1,[$,q]=S.useState(null==w||w),X=S.useRef(y),Z=S.useRef(b),Y=S.useRef(!1),Q=S.useRef([]);function K(){}const J=S.useMemo((()=>({current:Z.current,offset:Z.current,imageUrl:s,reset:K,hasEnded:!1,ref:D})),[s]);S.useImperativeHandle(D,(()=>F.current),[]),S.useLayoutEffect((()=>{Z.current=b}),[b]);const ee=(e,t)=>{const r=t/e;return A.current&&A.current.scale.set(1,r,1),[1,r,1]};S.useEffect((()=>{if(i&&s)!function(e,t,r){const n=new C.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])}))}(i,s,te);else if(s){const e=new C.TextureLoader;new Promise((t=>{e.load(s,t)})).then((e=>{te(null,e)}))}}),[]),S.useEffect((()=>{q(null==w||w)}),[w]),S.useEffect((()=>{J.hasEnded=!1,k.current&&!0===M?U.current=k.current.frames.length-1:U.current=0}),[M]),S.useLayoutEffect((()=>{ne()}),[N,v]),S.useEffect((()=>{u&&(X.current=!1)}),[u]),S.useEffect((()=>{if(I.current!==a&&a&&(U.current=0,I.current=a,J.hasEnded=!1,ne(),k.current)){const{w:e,h:t}=ae(k.current.frames).sourceSize,r=ee(e,t);G(r)}}),[a]);const te=(e,t)=>{if(null===e){if(c){const e=t.image.width,r=t.image.height,n=e/c,o=r;if(B.current=t,j.current=c,M&&(U.current=c-1),k.current={frames:[],meta:{version:"1.0",size:{w:e,h:r},scale:"1"}},parseInt(n.toString(),10)===n)for(let e=0;e<c;e++)k.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{k.current=e,k.current.frames=Array.isArray(e.frames)?e.frames:re(),j.current=Array.isArray(e.frames)?e.frames.length:Object.keys(e.frames).length,B.current=t,M&&(U.current=j.current-1);const{w:r,h:n}=ae(e.frames).sourceSize,o=ee(r,n);G(o),_.current&&(_.current.map=t)}if(P)for(var r=0;r<P.length;r++){const e=Object.keys(k.current.frames),t=e[Math.floor(Math.random()*e.length)];Q.current.push({key:r,frames:k.current.frames,selectedFrame:t,offset:{x:0,y:0}})}t.premultiplyAlpha=!1,O(t)},re=()=>{const e={},t=k.current,r=m;if(r){for(let n=0;n<r.length;n++){e[r[n]]=[];for(const 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;-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}if(a){const e=[];for(const r in t.frames)e.push(t.frames[r]);return e}},ne=()=>{if(!k.current)return;const{meta:{size:e},frames:t}=k.current,{w:r,h:n}=Array.isArray(t)?t[0].sourceSize:a&&t[a]?t[a][0].sourceSize:{w:0,h:0};_.current.map.wrapS=_.current.map.wrapT=C.RepeatWrapping,_.current.map.center.set(0,0),_.current.map.repeat.set(1*H/(e.w/r),1/(e.h/n));const o=1/((e.h-1)/n);_.current.map.offset.x=0,_.current.map.offset.y=1-o,d&&d({currentFrameName:a,currentFrame:U.current})},oe=(e,t,r,n)=>{var o=void 0===b?J.current:b;const a=U.current;let i=0,s=0;ee(e,t);const l=(r.w-1)/e,c=(r.h-1)/t;if(!n[a])return;const{frame:{x:u,y:m},sourceSize:{w:d,h:f}}=n[a],p=1/l,h=1/c;if(i=H>0?p*(u/d):p*(u/d)-_.current.map.repeat.x,s=Math.abs(1-h)-h*(m/f),_.current.map.offset.x=i,_.current.map.offset.y=s,null!=o){let e=Math.floor(o*n.length);e=Math.max(0,Math.min(e,n.length-1)),isNaN(e)&&(console.log("nan frame detected"),e=0),U.current=e}else M?U.current-=1:U.current+=1};o.useFrame(((e,n)=>{var o,i;null!=(o=k.current)&&o.frames&&null!=(i=_.current)&&i.map&&(X.current||J.hasEnded||!u&&!x||((()=>{const e=window.performance.now(),n=e-L.current,{meta:{size:o},frames:i}=k.current,{w:s,h:c}=ae(i).sourceSize,u=Array.isArray(i)?i:a?i[a]:[],m=r||u.length-1;var h=void 0===b?J.current:b,x=M?U.current<0:U.current>m,y=M?U.current===m:0===U.current,v=M?U.current<0:U.current>=m;if(x){if(U.current=l&&null!=t?t:0,M&&(U.current=m),l?null==p||p({currentFrameName:a,currentFrame:U.current}):(null==f||f({currentFrameName:a,currentFrame:U.current}),h||console.log("will end"),J.hasEnded=!E,E&&(X.current=!0)),!l)return}else y&&(null==d||d({currentFrameName:a,currentFrame:U.current}));void 0!==h&&v?!1===Y.current&&(null==f||f({currentFrameName:a,currentFrame:U.current}),Y.current=!0):Y.current=!1,n<=V||(L.current=e-n%V,oe(s,c,o,u))})(),h&&h({currentFrameName:I.current,currentFrame:U.current})))}));const ae=e=>{if(Array.isArray(e))return e[0];if("object"==typeof e&&null!==e){const t=Object.keys(e);return a?e[a][0]:e[t[0]][0]}return{w:0,h:0}};return S.createElement("group",e({},R,{ref:F}),S.createElement(vr.Provider,{value:J},S.createElement(S.Suspense,{fallback:null},$&&S.createElement("sprite",{ref:A,scale:W},S.createElement("spriteMaterial",{toneMapped:!1,ref:_,map:N,transparent:!0,alphaTest:null!=g?g:0})),!$&&S.createElement(xr,{limit:T},S.createElement("planeGeometry",{args:[1,1]}),S.createElement("meshBasicMaterial",{toneMapped:!1,side:C.DoubleSide,ref:_,map:N,transparent:!0,alphaTest:null!=g?g:0}),(null!=P?P:[0]).map(((e,t)=>{const r=N.clone();return _.current&&Q.current[t]&&r.offset.set(Q.current[t].offset.x,Q.current[t].offset.y),S.createElement(hr,{key:t,ref:A,position:e,scale:W},S.createElement("meshBasicMaterial",{toneMapped:!1,side:C.DoubleSide,map:r,transparent:!0,alphaTest:null!=g?g:0}))})))),z))})),zr=S.forwardRef((({children:e,curve:t},r)=>{const[n]=S.useState((()=>new C.Scene)),[a,i]=S.useState(),s=S.useRef();return S.useEffect((()=>{s.current=new m.Flow(n.children[0]),i(s.current.object3D)}),[e]),S.useEffect((()=>{var e;t&&(null==(e=s.current)||e.updateCurve(0,t))}),[t]),S.useImperativeHandle(r,(()=>({moveAlongCurve:e=>{var t;null==(t=s.current)||t.moveAlongCurve(e)}}))),S.createElement(S.Fragment,null,o.createPortal(e,n),a&&S.createElement("primitive",{object:a}))}));class wr 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 br=S.forwardRef((({speed:t=1,...r},n)=>{const[a]=S.useState((()=>new wr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),S.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class Mr 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 Er=S.forwardRef((({speed:t=1,...r},n)=>{const[a]=S.useState((()=>new Mr));return o.useFrame((e=>a&&(a.time=e.clock.getElapsedTime()*t))),S.createElement("primitive",e({object:a,ref:n,attach:"material"},r))}));class Sr extends C.ShaderMaterial{constructor(e=new C.Vector2){super({uniforms:{inputBuffer:new C.Uniform(null),depthBuffer:new C.Uniform(null),resolution:new C.Uniform(new C.Vector2),texelSize:new C.Uniform(new C.Vector2),halfTexelSize:new C.Uniform(new C.Vector2),kernel:new C.Uniform(0),scale:new C.Uniform(1),cameraNear:new C.Uniform(0),cameraFar:new C.Uniform(1),minDepthThreshold:new C.Uniform(0),maxDepthThreshold:new C.Uniform(1),depthScale:new C.Uniform(0),depthToBlurRatioBias:new C.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 <${pe>=154?"colorspace_fragment":"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:C.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 Tr{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 Sr,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 Cr=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}};const Pr=S.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)=>{o.extend({MeshReflectorMaterialImpl:Cr});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,M=S.useRef(null),[E]=S.useState((()=>new n.Plane)),[T]=S.useState((()=>new n.Vector3)),[C]=S.useState((()=>new n.Vector3)),[P]=S.useState((()=>new n.Vector3)),[R]=S.useState((()=>new n.Matrix4)),[D]=S.useState((()=>new n.Vector3(0,0,-1))),[F]=S.useState((()=>new n.Vector4)),[k]=S.useState((()=>new n.Vector3)),[_]=S.useState((()=>new n.Vector3)),[A]=S.useState((()=>new n.Vector4)),[L]=S.useState((()=>new n.Matrix4)),[B]=S.useState((()=>new n.PerspectiveCamera)),U=S.useCallback((()=>{var e;const t=M.current.parent||(null==(e=M.current)?void 0:e.__r3f.parent);if(!t)return;if(C.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(z.matrixWorld),R.extractRotation(t.matrixWorld),T.set(0,0,1),T.applyMatrix4(R),C.addScaledVector(T,x),k.subVectors(C,P),k.dot(T)>0)return;k.reflect(T).negate(),k.add(C),R.extractRotation(z.matrixWorld),D.set(0,0,-1),D.applyMatrix4(R),D.add(P),_.subVectors(C,D),_.reflect(T).negate(),_.add(C),B.position.copy(k),B.up.set(0,1,0),B.up.applyMatrix4(R),B.up.reflect(T),B.lookAt(_),B.far=z.far,B.updateMatrixWorld(),B.projectionMatrix.copy(z.projectionMatrix),L.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),L.multiply(B.projectionMatrix),L.multiply(B.matrixWorldInverse),L.multiply(t.matrixWorld),E.setFromNormalAndCoplanarPoint(T,C),E.applyMatrix4(B.matrixWorldInverse),F.set(E.normal.x,E.normal.y,E.normal.z,E.constant);const r=B.projectionMatrix;A.x=(Math.sign(F.x)+r.elements[8])/r.elements[0],A.y=(Math.sign(F.y)+r.elements[9])/r.elements[5],A.z=-1,A.w=(1+r.elements[10])/r.elements[14],F.multiplyScalar(2/F.dot(A)),r.elements[2]=F.x,r.elements[6]=F.y,r.elements[10]=F.z+1,r.elements[14]=F.w}),[z,x]),[I,V,N,O]=S.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 Tr({gl:g,resolution:a,width:s[0],height:s[1],minDepthThreshold:l,maxDepthThreshold:c,depthScale:u,depthToBlurRatioBias:m}),{mirror:d,textureMatrix:L,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,L,a,d,b,t,r,l,c,u,m,f,h,p]);return o.useFrame((()=>{var e;const t=M.current.parent||(null==(e=M.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(I),g.state.buffers.depth.setMask(!0),g.autoClear||g.clear(),g.render(w,B),b&&N.render(g,I,V),g.xr.enabled=r,g.shadowMap.autoUpdate=n,t.visible=!0,g.setRenderTarget(null)})),S.createElement("meshReflectorMaterialImpl",e({attach:"material",key:"key"+O["defines-USE_BLUR"]+O["defines-USE_DEPTH"]+O["defines-USE_DISTORTION"],ref:i([M,v])},O,y))})),Rr=me({envMap:null,bounces:3,ior:2.4,correctMips:!0,aberrationStrength:.01,fresnel:0,bvh:new z.MeshBVHUniformStruct,color:new C.Color("white"),resolution:new C.Vector2,viewMatrixInverse:new C.Matrix4,projectionMatrixInverse:new C.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 ${z.shaderStructs}\n ${z.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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);const Dr=me({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class Fr extends C.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 C.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},this.anisotropy>0&&(r.defines.USE_ANISOTROPY=""),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 kr=S.forwardRef((({buffer:t,transmissionSampler:r=!1,backside:n=!1,side:a=C.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:Fr});const y=S.useRef(null),[v]=S.useState((()=>new Dr)),g=Ge(m||u),z=Ge(u);let w,b,M;return o.useFrame((e=>{y.current.time=e.clock.getElapsedTime(),y.current.buffer!==z.texture||r||(M=y.current.__r3f.parent,M&&(b=e.gl.toneMapping,w=e.scene.background,e.gl.toneMapping=C.NoToneMapping,d&&(e.scene.background=d),M.material=v,n&&(e.gl.setRenderTarget(g),e.gl.render(e.scene,e.camera),M.material=y.current,M.material.buffer=g.texture,M.material.thickness=l,M.material.side=C.BackSide),e.gl.setRenderTarget(z),e.gl.render(e.scene,e.camera),M.material=y.current,M.material.thickness=s,M.material.side=a,M.material.buffer=z.texture,e.scene.background=w,e.gl.setRenderTarget(null),e.gl.toneMapping=b))})),S.useImperativeHandle(x,(()=>y.current),[]),S.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}))})),_r=S.forwardRef(((t,r)=>(o.extend({DiscardMaterialImpl:Dr}),S.createElement("discardMaterialImpl",e({ref:r},t))))),Ar=pe>=154?"opaque_fragment":"output_fragment";class Lr extends C.PointsMaterial{constructor(e){super(e),this.onBeforeCompile=(e,t)=>{const{isWebGL2:r}=t.capabilities;e.fragmentShader=e.fragmentShader.replace(`#include <${Ar}>`,`\n ${r?`#include <${Ar}>`:`#extension GL_OES_standard_derivatives : enable\n#include <${Ar}>`}\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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n `)}}}const Br=S.forwardRef(((t,r)=>{const[n]=S.useState((()=>new Lr(null)));return S.createElement("primitive",e({},t,{object:n,ref:r,attach:"material"}))}));function Ur(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 Ir(t,r){const n=t+"Geometry";return S.forwardRef((({args:t,children:o,...a},i)=>{const s=S.useRef(null);return S.useImperativeHandle(i,(()=>s.current)),S.useLayoutEffect((()=>{null==r||r(s.current)})),S.createElement("mesh",e({ref:s},a),S.createElement(n,{attach:"geometry",args:t}),o)}))}const Vr=Ir("box"),Nr=Ir("circle"),Or=Ir("cone"),jr=Ir("cylinder"),Wr=Ir("sphere"),Gr=Ir("plane"),Hr=Ir("tube"),$r=Ir("torus"),qr=Ir("torusKnot"),Xr=Ir("tetrahedron"),Zr=Ir("ring"),Yr=Ir("polyhedron"),Qr=Ir("icosahedron"),Kr=Ir("octahedron"),Jr=Ir("dodecahedron"),en=Ir("extrude"),tn=Ir("lathe"),rn=Ir("capsule"),nn=Ir("shape",(({geometry:e})=>{const t=e.attributes.position,r=(new C.Box3).setFromBufferAttribute(t),n=new C.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 C.Float32BufferAttribute(o,2))})),on=1e-5;const an=S.forwardRef((function({args:[t=1,r=1,o=1]=[],radius:a=.05,steps:i=1,smoothness:s=4,bevelSegments:l=4,creaseAngle:c=.4,children:u,...d},f){const p=S.useMemo((()=>function(e,t,r){const o=new n.Shape,a=r-on;return o.absarc(on,on,on,-Math.PI/2,-Math.PI,!0),o.absarc(on,t-2*a,on,Math.PI,Math.PI/2,!0),o.absarc(e-2*a,t-2*a,on,Math.PI/2,0,!0),o.absarc(e-2*a,on,on,0,-Math.PI/2,!0),o}(t,r,a)),[t,r,a]),h=S.useMemo((()=>({depth:o-2*a,bevelEnabled:!0,bevelSegments:2*l,steps:i,bevelSize:a-on,bevelThickness:a,curveSegments:s})),[o,a,s]),x=S.useRef(null);return S.useLayoutEffect((()=>{x.current&&(x.current.center(),m.toCreasedNormals(x.current,c))}),[p,h]),S.createElement("mesh",e({ref:f},d),S.createElement("extrudeGeometry",{ref:x,args:[p,h]}),u)}));function sn(){const e=new C.BufferGeometry,t=new Float32Array([-1,-1,3,-1,-1,3]);return e.boundingSphere=new C.Sphere,e.boundingSphere.set(new C.Vector3,1/0),e.setAttribute("position",new C.BufferAttribute(t,2)),e}const ln=S.forwardRef((function({children:t,...r},n){const o=S.useMemo(sn,[]);return S.createElement("mesh",e({ref:n,geometry:o,frustumCulled:!1},r),t)})),cn=S.forwardRef((({children:t,width:r,height:n,depth:o,box3:a,precise:i=!0,...s},l)=>{const c=S.useRef(null),u=S.useRef(null),m=S.useRef(null);return S.useLayoutEffect((()=>{u.current.matrixWorld.identity();let e=a||(new C.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]),S.useImperativeHandle(l,(()=>c.current),[]),S.createElement("group",e({ref:c},s),S.createElement("group",{ref:u},S.createElement("group",{ref:m},t)))}));var un=function(e){return e[e.NONE=0]="NONE",e[e.START=1]="START",e[e.ACTIVE=2]="ACTIVE",e}(un||{});const mn=e=>e&&e.isOrthographicCamera,dn=e=>e&&e.isBox3,fn=e=>1-Math.exp(-5*e)+.007*e,pn=S.createContext(null);function hn({children:e,maxDuration:t=1,margin:r=1.2,observe:n,fit:a,clip:i,interpolateFunc:s=fn,onFit:l}){const c=S.useRef(null),{camera:u,size:m,invalidate:d}=o.useThree(),f=o.useThree((e=>e.controls)),p=S.useRef(l);p.current=l;const h=S.useRef({camPos:new C.Vector3,camRot:new C.Quaternion,camZoom:1}),x=S.useRef({camPos:void 0,camRot:void 0,camZoom:void 0,camUp:void 0,target:void 0}),y=S.useRef(un.NONE),v=S.useRef(0),[g]=S.useState((()=>new C.Box3)),z=S.useMemo((()=>{function e(){const e=g.getSize(new C.Vector3),t=g.getCenter(new C.Vector3),n=Math.max(e.x,e.y,e.z),o=mn(u)?4*n:n/(2*Math.atan(Math.PI*u.fov/360)),a=mn(u)?4*n:o/u.aspect,i=r*Math.max(o,a);return{box:g,size:e,center:t,distance:i}}return{getSize:e,refresh(e){if(dn(e))g.copy(e);else{const t=e||c.current;if(!t)return this;t.updateWorldMatrix(!0,!0),g.setFromObject(t)}if(g.isEmpty()){const e=u.position.length()||10;g.setFromCenterAndSize(new C.Vector3,new C.Vector3(e,e,e))}return h.current.camPos.copy(u.position),h.current.camRot.copy(u.quaternion),mn(u)&&(h.current.camZoom=u.zoom),x.current.camPos=void 0,x.current.camRot=void 0,x.current.camZoom=void 0,x.current.camUp=void 0,x.current.target=void 0,this},reset(){const{center:t,distance:r}=e(),n=u.position.clone().sub(t).normalize();x.current.camPos=t.clone().addScaledVector(n,r),x.current.target=t.clone();const o=(new C.Matrix4).lookAt(x.current.camPos,x.current.target,u.up);return x.current.camRot=(new C.Quaternion).setFromRotationMatrix(o),y.current=un.START,v.current=0,this},moveTo(e){return x.current.camPos=Array.isArray(e)?new C.Vector3(...e):e.clone(),y.current=un.START,v.current=0,this},lookAt({target:e,up:t}){x.current.target=Array.isArray(e)?new C.Vector3(...e):e.clone(),x.current.camUp=t?Array.isArray(t)?new C.Vector3(...t):t.clone():u.up.clone();const r=(new C.Matrix4).lookAt(x.current.camPos||u.position,x.current.target,x.current.camUp);return x.current.camRot=(new C.Quaternion).setFromRotationMatrix(r),y.current=un.START,v.current=0,this},to({position:e,target:t}){return this.moveTo(e).lookAt({target:t})},fit(){if(!mn(u))return this.reset();let e=0,t=0;const n=[new C.Vector3(g.min.x,g.min.y,g.min.z),new C.Vector3(g.min.x,g.max.y,g.min.z),new C.Vector3(g.min.x,g.min.y,g.max.z),new C.Vector3(g.min.x,g.max.y,g.max.z),new C.Vector3(g.max.x,g.max.y,g.max.z),new C.Vector3(g.max.x,g.max.y,g.min.z),new C.Vector3(g.max.x,g.min.y,g.max.z),new C.Vector3(g.max.x,g.min.y,g.min.z)],o=x.current.camPos||u.position,a=x.current.target||(null==f?void 0:f.target),i=x.current.camUp||u.up,s=a?(new C.Matrix4).lookAt(o,a,i).setPosition(o).invert():u.matrixWorldInverse;for(const r of n)r.applyMatrix4(s),e=Math.max(e,Math.abs(r.y)),t=Math.max(t,Math.abs(r.x));e*=2,t*=2;const l=(u.top-u.bottom)/e,c=(u.right-u.left)/t;return x.current.camZoom=Math.min(l,c)/r,y.current=un.START,v.current=0,p.current&&p.current(this.getSize()),this},clip(){const{distance:t}=e();return u.near=t/100,u.far=100*t,u.updateProjectionMatrix(),f&&(f.maxDistance=10*t,f.update()),d(),this}}}),[g,u,f,r,d]);S.useLayoutEffect((()=>{if(f){const e=()=>{if(f&&x.current.target&&y.current!==un.NONE){const e=(new C.Vector3).setFromMatrixColumn(u.matrix,2),t=h.current.camPos.distanceTo(f.target),r=(x.current.camPos||h.current.camPos).distanceTo(x.current.target),n=(1-v.current)*t+v.current*r;f.target.copy(u.position).addScaledVector(e,-n),f.update()}y.current=un.NONE};return f.addEventListener("start",e),()=>f.removeEventListener("start",e)}}),[f]);const w=S.useRef(0);return S.useLayoutEffect((()=>{(n||0==w.current++)&&(z.refresh(),a&&z.reset().fit(),i&&z.clip())}),[m,i,a,n,u,f]),o.useFrame(((e,r)=>{if(y.current===un.START)y.current=un.ACTIVE,d();else if(y.current===un.ACTIVE){if(v.current+=r/t,v.current>=1)x.current.camPos&&u.position.copy(x.current.camPos),x.current.camRot&&u.quaternion.copy(x.current.camRot),x.current.camUp&&u.up.copy(x.current.camUp),x.current.camZoom&&mn(u)&&(u.zoom=x.current.camZoom),u.updateMatrixWorld(),u.updateProjectionMatrix(),f&&x.current.target&&(f.target.copy(x.current.target),f.update()),y.current=un.NONE;else{const e=s(v.current);x.current.camPos&&u.position.lerpVectors(h.current.camPos,x.current.camPos,e),x.current.camRot&&u.quaternion.slerpQuaternions(h.current.camRot,x.current.camRot,e),x.current.camUp&&u.up.set(0,1,0).applyQuaternion(u.quaternion),x.current.camZoom&&mn(u)&&(u.zoom=(1-e)*h.current.camZoom+e*x.current.camZoom),u.updateMatrixWorld(),u.updateProjectionMatrix()}d()}})),S.createElement("group",{ref:c},S.createElement(pn.Provider,{value:z},e))}function xn(){return S.useContext(pn)}const yn=S.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=S.useRef(e),h=S.useRef(d.rotation.clone()),[x]=S.useState((()=>new m.SimplexNoise)),[y]=S.useState((()=>new m.SimplexNoise)),[v]=S.useState((()=>new m.SimplexNoise)),g=()=>{(p.current<0||p.current>1)&&(p.current=p.current<0?0:1)};return S.useImperativeHandle(u,(()=>({getIntensity:()=>p.current,setIntensity:e=>{p.current=e,g()}})),[]),S.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})),vn=S.forwardRef((({children:e,enabled:t=!0,speed:r=1,rotationIntensity:n=1,floatIntensity:a=1,floatingRange:s=[-.1,.1],...l},c)=>{const u=S.useRef(null),m=S.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=C.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()})),S.createElement("group",l,S.createElement("group",{ref:i([u,c]),matrixAutoUpdate:!1},e))})),gn={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"},zn="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",wn=e=>Array.isArray(e);function bn({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 gn))throw new Error("Preset must be one of: "+Object.keys(gn).join(", "));e=gn[r],t=zn}if(u=wn(e),l=wn(e)?"cube":e.startsWith("data:application/exr")?"exr":e.startsWith("data:application/hdr")?"hdr":null==(s=e.split(".").pop())||null==(s=s.split("?"))||null==(s=s.shift())?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 Mn=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function En(e,t,r,n,o=0){const a=Mn(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 Sn({scene:e,background:t=!1,blur:r,map:n}){const a=o.useThree((e=>e.scene));return S.useLayoutEffect((()=>{if(n)return En(t,e,a,n,r)}),[a,e,n,t,r]),null}function Tn({background:e=!1,scene:t,blur:r,...n}){const a=bn(n),i=o.useThree((e=>e.scene));return S.useLayoutEffect((()=>En(e,t,i,a,r)),[a,e,t,i,r]),null}function Cn({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=S.useRef(null),[v]=S.useState((()=>new n.Scene)),g=S.useMemo((()=>{const e=new n.WebGLCubeRenderTarget(a);return e.texture.type=n.HalfFloatType,e}),[a]);S.useLayoutEffect((()=>(1===i&&y.current.update(h,v),En(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++)})),S.createElement(S.Fragment,null,o.createPortal(S.createElement(S.Fragment,null,e,S.createElement("cubeCamera",{ref:y,args:[t,r,g]}),m||f?S.createElement(Tn,{background:!0,files:m,preset:f,path:d,extensions:p}):s?S.createElement(Sn,{background:!0,map:s,extensions:p}):null),v))}function Pn(t){var r,n,a,i;const s=bn(t),l=t.map||s;S.useMemo((()=>o.extend({GroundProjectedEnvImpl:m.GroundProjectedEnv})),[]);const c=S.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 S.createElement(S.Fragment,null,S.createElement(Sn,e({},t,{map:l})),S.createElement("groundProjectedEnvImpl",{args:c,scale:f,height:u,radius:d}))}function Rn(e){return e.ground?S.createElement(Pn,e):e.map?S.createElement(Sn,e):e.children?S.createElement(Cn,e):S.createElement(Tn,e)}const Dn=S.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=S.useRef(null),g=o.useThree((e=>e.scene)),z=o.useThree((e=>e.gl)),w=S.useRef(null);a*=Array.isArray(t)?t[0]:t||1,i*=Array.isArray(t)?t[1]:t||1;const[b,M,E,T,P,R,D]=S.useMemo((()=>{const e=new C.WebGLRenderTarget(u,u),t=new C.WebGLRenderTarget(u,u);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const r=new C.PlaneGeometry(a,i).rotateX(Math.PI/2),n=new C.Mesh(r),o=new C.MeshDepthMaterial;o.depthTest=o.depthWrite=!1,o.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new C.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 C.ShaderMaterial(m.HorizontalBlurShader),l=new C.ShaderMaterial(m.VerticalBlurShader);return l.depthTest=s.depthTest=!1,[e,r,o,n,s,l,t]}),[u,a,i,t,f]),F=e=>{T.visible=!0,T.material=P,P.uniforms.tDiffuse.value=b.texture,P.uniforms.h.value=1*e/256,z.setRenderTarget(D),z.render(T,w.current),T.material=R,R.uniforms.tDiffuse.value=D.texture,R.uniforms.v.value=1*e/256,z.setRenderTarget(b),z.render(T,w.current),T.visible=!1};let k,_,A=0;return o.useFrame((()=>{w.current&&(r===1/0||A<r)&&(A++,k=g.background,_=g.overrideMaterial,v.current.visible=!1,g.background=null,g.overrideMaterial=E,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)})),S.useImperativeHandle(y,(()=>v.current),[]),S.createElement("group",e({"rotation-x":Math.PI/2},x,{ref:v}),S.createElement("mesh",{renderOrder:h,geometry:M,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},S.createElement("meshBasicMaterial",{transparent:!0,map:b.texture,opacity:n,depthWrite:p})),S.createElement("orthographicCamera",{ref:w,args:[-a/2,a/2,i/2,-i/2,l,c]}))}));const Fn=S.createContext(null),kn=me({color:new C.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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),_n=S.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:kn});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=S.useRef(null),z=S.useRef(null),[w]=S.useState((()=>new Ln(h,x,m)));S.useLayoutEffect((()=>{w.configure(g.current)}),[]);const b=S.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 S.useLayoutEffect((()=>{b.reset(),b.temporal||b.frames===1/0||b.update(b.blend)})),S.useImperativeHandle(p,(()=>b),[b]),o.useFrame((()=>{(b.temporal||b.frames===1/0)&&b.count<b.frames&&b.count<n&&(v(),b.update(),b.count++)})),S.createElement("group",f,S.createElement("group",{traverse:()=>null,ref:z},S.createElement(Fn.Provider,{value:b},e)),S.createElement("mesh",{receiveShadow:!0,ref:g,scale:i,rotation:[-Math.PI/2,0,0]},S.createElement("planeGeometry",null),S.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:d,color:c,blend:u,map:w.progressiveLightMap2.texture})))})),An=S.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=(pe>=155?Math.PI:1),ambient:d=.5,...f},p)=>{const h=S.useRef(null),x=new C.Vector3(...l).length(),y=S.useContext(Fn),v=S.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]+C.MathUtils.randFloatSpread(c),l[1]+C.MathUtils.randFloatSpread(c),l[2]+C.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=S.useMemo((()=>({update:v})),[v]);return S.useImperativeHandle(p,(()=>g),[g]),S.useLayoutEffect((()=>{var e;const t=h.current;return y&&(null==(e=y.lights)||e.set(t.uuid,g)),()=>{var e;null==y||null==(e=y.lights)||e.delete(t.uuid)}}),[y,g]),S.createElement("group",e({ref:h},f),Array.from({length:u},((e,s)=>S.createElement("directionalLight",{key:s,castShadow:t,"shadow-bias":r,"shadow-mapSize":[n,n],intensity:m/u},S.createElement("orthographicCamera",{attach:"shadow-camera",args:[-o,o,o,-o,a,i]})))))}));class Ln{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 C.Color,this.clearAlpha=0;const n={type:C.HalfFloatType,magFilter:C.NearestFilter,minFilter:C.NearestFilter};this.progressiveLightMap1=new C.WebGLRenderTarget(this.res,this.res,n),this.progressiveLightMap2=new C.WebGLRenderTarget(this.res,this.res,n),this.discardMat=new Dr,this.targetMat=new C.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 Bn={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 Un({radius:e,adjustCamera:t}){const r=xn();return S.useEffect((()=>{t&&r.refresh().clip().fit()}),[e,t]),null}const In=e=>0===e?0:Math.pow(2,10*e-10);const Vn=S.forwardRef((({fog:t=!1,renderOrder:r,depthWrite:o=!1,colorStop:a=0,color:i="black",opacity:s=.5,...l},c)=>{const u=S.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 S.createElement("mesh",e({renderOrder:r,ref:c,"rotation-x":-Math.PI/2},l),S.createElement("planeGeometry",null),S.createElement("meshBasicMaterial",{transparent:!0,opacity:s,fog:t,depthWrite:o,side:n.DoubleSide},S.createElement("canvasTexture",{attach:"map",args:[u]})))}));function Nn(e=C.FrontSide){const t={value:new C.Matrix4};return Object.assign(new C.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 On=me({causticsTexture:null,causticsTextureB:null,color:new C.Color,lightProjMatrix:new C.Matrix4,lightViewMatrix:new C.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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),jn=me({cameraMatrixWorld:new C.Matrix4,cameraProjectionMatrixInv:new C.Matrix4,normalTexture:null,depthTexture:null,lightDir:new C.Vector3(0,1,0),lightPlaneNormal:new C.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new C.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 }"),Wn={depth:!0,minFilter:C.LinearFilter,magFilter:C.LinearFilter,type:C.UnsignedByteType},Gn={minFilter:C.LinearMipmapLinearFilter,magFilter:C.LinearFilter,type:C.FloatType,generateMipmaps:!0},Hn=S.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:On});const y=S.useRef(null),v=S.useRef(null),g=S.useRef(null),z=S.useRef(null),w=o.useThree((e=>e.gl)),b=jt(t&&v,C.CameraHelper),M=Ge(f,f,Wn),E=Ge(f,f,Wn),T=Ge(f,f,Gn),P=Ge(f,f,Gn),[R]=S.useState((()=>Nn())),[D]=S.useState((()=>Nn(C.BackSide))),[F]=S.useState((()=>new jn)),[k]=S.useState((()=>new m.FullScreenQuad(F)));S.useLayoutEffect((()=>{y.current.updateWorldMatrix(!1,!0)}));let _=0;const A=new C.Vector3,L=new C.Frustum,B=new C.Matrix4,U=new C.Plane,I=new C.Vector3,V=new C.Vector3,N=new C.Box3,O=new C.Vector3,j=[],W=[],G=[],H=[],$=new C.Vector3;for(let e=0;e<8;e++)j.push(new C.Vector3),W.push(new C.Vector3),G.push(new C.Vector3),H.push(new C.Vector3);return o.useFrame((()=>{if(n===1/0||_++<n){var e,r;Array.isArray(p)?I.fromArray(p).normalize():I.copy(y.current.worldToLocal(p.current.getWorldPosition(A)).normalize()),V.copy(I).multiplyScalar(-1),null==(e=g.current.parent)||e.matrixWorld.identity(),N.setFromObject(g.current,!0),j[0].set(N.min.x,N.min.y,N.min.z),j[1].set(N.min.x,N.min.y,N.max.z),j[2].set(N.min.x,N.max.y,N.min.z),j[3].set(N.min.x,N.max.y,N.max.z),j[4].set(N.max.x,N.min.y,N.min.z),j[5].set(N.max.x,N.min.y,N.max.z),j[6].set(N.max.x,N.max.y,N.min.z),j[7].set(N.max.x,N.max.y,N.max.z);for(let e=0;e<8;e++)W[e].copy(j[e]);N.getCenter(O),j.map((e=>e.sub(O)));const n=U.set(V,0);j.map(((e,t)=>n.projectPoint(e,G[t])));const o=G.reduce(((e,t)=>e.add(t)),A.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(I))).reduce(((e,t)=>Math.max(e,t)));v.current.position.copy($.copy(I).multiplyScalar(m).add(O)),v.current.lookAt(g.current.localToWorld(O));const h=B.lookAt(v.current.position,O,A.set(0,1,0));v.current.left=-i,v.current.right=i,v.current.top=i,v.current.bottom=-i;const x=A.set(0,i,0).applyMatrix4(h),S=(v.current.position.y+x.y)/I.y;v.current.near=.1,v.current.far=S,v.current.updateProjectionMatrix(),v.current.updateMatrixWorld();const C=W.map(((e,t)=>e.add(H[t].copy(I).multiplyScalar(-e.y/I.y)))),_=C.reduce(((e,t)=>e.add(t)),A.set(0,0,0)).divideScalar(C.length),q=2*C.map((e=>Math.hypot(e.x-_.x,e.z-_.z))).reduce(((e,t)=>Math.max(e,t)));z.current.scale.setScalar(q),z.current.position.copy(_),t&&(null==(r=b.current)||r.update()),D.viewMatrix.value=R.viewMatrix.value=v.current.matrixWorldInverse;const X=L.setFromProjectionMatrix(B.multiplyMatrices(v.current.projectionMatrix,v.current.matrixWorldInverse)).planes[4];F.cameraMatrixWorld=v.current.matrixWorld,F.cameraProjectionMatrixInv=v.current.projectionMatrixInverse,F.lightDir=V,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(M),w.clear(),g.current.overrideMaterial=R,w.render(g.current,v.current),w.setRenderTarget(E),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=M.texture,F.depthTexture=M.depthTexture,w.setRenderTarget(T),w.clear(),k.render(w),F.ior=c,F.normalTexture=E.texture,F.depthTexture=E.depthTexture,w.setRenderTarget(P),w.clear(),l&&k.render(w),w.setRenderTarget(null),s&&(g.current.visible=!1)}})),S.useImperativeHandle(x,(()=>y.current),[]),S.createElement("group",e({ref:y},h),S.createElement("scene",{ref:g},S.createElement("orthographicCamera",{ref:v,up:[0,1,0]}),r),S.createElement("mesh",{renderOrder:2,ref:z,"rotation-x":-Math.PI/2},S.createElement("planeGeometry",null),S.createElement("causticsProjectionMaterial",{transparent:!0,color:i,causticsTexture:T.texture,causticsTextureB:P.texture,blending:C.CustomBlending,blendSrc:C.OneFactor,blendDst:C.SrcAlphaFactor,depthWrite:!1}),t&&S.createElement(ze,null,S.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))})),$n=S.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)=>{o.extend({MeshReflectorMaterial:Cr}),S.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)),M=o.useThree((({scene:e})=>e)),E=(s=Array.isArray(s)?s:[s,s])[0]+s[1]>0,T=S.useRef(null),[C]=S.useState((()=>new n.Plane)),[P]=S.useState((()=>new n.Vector3)),[R]=S.useState((()=>new n.Vector3)),[D]=S.useState((()=>new n.Vector3)),[F]=S.useState((()=>new n.Matrix4)),[k]=S.useState((()=>new n.Vector3(0,0,-1))),[_]=S.useState((()=>new n.Vector4)),[A]=S.useState((()=>new n.Vector3)),[L]=S.useState((()=>new n.Vector3)),[B]=S.useState((()=>new n.Vector4)),[U]=S.useState((()=>new n.Matrix4)),[I]=S.useState((()=>new n.PerspectiveCamera)),V=S.useCallback((()=>{if(R.setFromMatrixPosition(T.current.matrixWorld),D.setFromMatrixPosition(b.matrixWorld),F.extractRotation(T.current.matrixWorld),P.set(0,0,1),P.applyMatrix4(F),A.subVectors(R,D),A.dot(P)>0)return;A.reflect(P).negate(),A.add(R),F.extractRotation(b.matrixWorld),k.set(0,0,-1),k.applyMatrix4(F),k.add(D),L.subVectors(R,k),L.reflect(P).negate(),L.add(R),I.position.copy(A),I.up.set(0,1,0),I.up.applyMatrix4(F),I.up.reflect(P),I.lookAt(L),I.far=b.far,I.updateMatrixWorld(),I.projectionMatrix.copy(b.projectionMatrix),U.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),U.multiply(I.projectionMatrix),U.multiply(I.matrixWorldInverse),U.multiply(T.current.matrixWorld),C.setFromNormalAndCoplanarPoint(P,R),C.applyMatrix4(I.matrixWorldInverse),_.set(C.normal.x,C.normal.y,C.normal.z,C.constant);const e=I.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}),[]),[N,O,j,W]=S.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 Tr({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:E,mixStrength:r,minDepthThreshold:c,maxDepthThreshold:u,depthScale:m,depthToBlurRatioBias:d,transparent:!0,debug:h,distortion:x,distortionMap:v,mixContrast:y,"defines-USE_BLUR":E?"":void 0,"defines-USE_DEPTH":m>0?"":void 0,"defines-USE_DISTORTION":v?"":void 0}]}),[w,s,U,a,f,E,t,r,c,u,m,d,h,x,v,y]);return o.useFrame((()=>{if(null==T||!T.current)return;T.current.visible=!1;const e=w.xr.enabled,t=w.shadowMap.autoUpdate;V(),w.xr.enabled=!1,w.shadowMap.autoUpdate=!1,w.setRenderTarget(N),w.state.buffers.depth.setMask(!0),w.autoClear||w.clear(),w.render(M,I),E&&j.render(w,N,O),w.xr.enabled=e,w.shadowMap.autoUpdate=t,T.current.visible=!0,w.setRenderTarget(null)})),S.createElement("mesh",e({ref:i([T,z])},g),S.createElement("planeGeometry",{args:l}),p?p("meshReflectorMaterial",W):S.createElement("meshReflectorMaterial",W))}));class qn extends C.ShaderMaterial{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new C.Vector3(0,0,0)},lightColor:{value:new C.Color("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new C.Vector2(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main() {\n // compute intensity\n vNormal = normalize(normalMatrix * normal);\n vec4 worldPosition = modelMatrix * vec4(position, 1);\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n\n vIntensity = 1.0 - saturate(distance(worldPosition.xyz, spotPosition) / attenuation);\n\n gl_Position = projectionMatrix * viewPosition;\n\n #include <logdepthbuf_vertex>\n }\n ",fragmentShader:`\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n\n uniform vec3 lightColor;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float opacity;\n\n #include <packing>\n #include <logdepthbuf_pars_fragment>\n\n float readDepth(sampler2D depthSampler, vec2 uv) {\n float fragCoordZ = texture(depthSampler, uv).r;\n\n // https://github.com/mrdoob/three.js/issues/23072\n #ifdef USE_LOGDEPTHBUF\n float viewZ = 1.0 - exp2(fragCoordZ * log(cameraFar + 1.0) / log(2.0));\n #else\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n #endif\n\n return viewZ;\n }\n\n void main() {\n #include <logdepthbuf_fragment>\n\n vec3 normal = vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity = pow(dot(normal, vec3(0, 0, 1)), anglePower);\n float intensity = vIntensity * angleIntensity;\n\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 uv = gl_FragCoord.xy / resolution;\n intensity *= smoothstep(0.0, 1.0, vViewZ - readDepth(depth, uv));\n }\n\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n #include <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `})}}var Xn="#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 Zn=e=>null==e?void 0:e.isSpotLight;function Yn({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=S.useRef(null),d=o.useThree((e=>e.size)),f=o.useThree((e=>e.camera)),p=o.useThree((e=>e.viewport.dpr)),[h]=S.useState((()=>new qn)),[x]=S.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=S.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 S.createElement(S.Fragment,null,S.createElement("mesh",{ref:m,geometry:y,raycast:()=>null},S.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 Qn(e,t,r,a,i){const[[s,l]]=S.useState((()=>[new n.Vector3,new n.Vector3]));S.useLayoutEffect((()=>{if(!Zn(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 Kn({distance:e=.4,alphaTest:t=.5,map:r,shader:a=Xn,width:i=512,height:s=512,scale:l=1,children:c,...u}){const d=S.useRef(null),f=u.spotlightRef,p=u.debug;Qn(f,d,i,s,e);const h=S.useMemo((()=>new n.WebGLRenderTarget(i,s,{format:n.RGBAFormat,encoding:n.LinearEncoding,stencilBuffer:!1})),[i,s]),x=S.useRef({uShadowMap:{value:r},uTime:{value:0}});S.useEffect((()=>{x.current.uShadowMap.value=r}),[r]);const y=S.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 S.useEffect((()=>()=>{y.material.dispose(),y.dispose()}),[y]),S.useEffect((()=>()=>h.dispose()),[h]),o.useFrame((({gl:e},t)=>{x.current.uTime.value+=t,e.setRenderTarget(h),y.render(e),e.setRenderTarget(null)})),S.createElement(S.Fragment,null,S.createElement("mesh",{ref:d,scale:l,castShadow:!0},S.createElement("planeGeometry",null),S.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 Jn({distance:e=.4,alphaTest:t=.5,map:r,width:o=512,height:a=512,scale:i,children:s,...l}){const c=S.useRef(null),u=l.spotlightRef,m=l.debug;return Qn(u,c,o,a,e),S.createElement(S.Fragment,null,S.createElement("mesh",{ref:c,scale:i,castShadow:!0},S.createElement("planeGeometry",null),S.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 eo=S.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=S.useRef(null);return S.createElement("group",null,d&&x.current&&S.createElement("spotLightHelper",{args:[x.current]}),S.createElement("spotLight",e({ref:i([h,x]),angle:l,color:a,distance:s,castShadow:!0},p),m&&S.createElement(Yn,{debug:d,opacity:t,radiusTop:r,radiusBottom:n,depthBuffer:o,color:a,distance:s,angle:l,attenuation:c,anglePower:u})),f&&S.cloneElement(f,{spotlightRef:x,debug:d}))})),to=S.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=S.useRef(null);return S.useLayoutEffect((()=>{m||d.material||(o.applyProps(p.current.material,{color:a}),p.current.material.color.multiplyScalar(l))}),[a,l,m,d.material]),S.useLayoutEffect((()=>{u&&p.current.lookAt(Array.isArray(u)?new C.Vector3(...u):u)}),[u]),c=Array.isArray(c)&&2===c.length?[c[0],c[1],1]:c,S.createElement("mesh",e({ref:i([p,f]),scale:c},d),"circle"===s?S.createElement("ringGeometry",{args:[0,1,64]}):"ring"===s?S.createElement("ringGeometry",{args:[.5,1,64]}):"rect"===s?S.createElement("planeGeometry",null):S.createElement(s,{args:t}),m||(d.material?null:S.createElement("meshBasicMaterial",{toneMapped:n,map:r,side:C.DoubleSide})))}));function ro(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 no=S.forwardRef((({inclination:t=.6,azimuth:r=.1,distance:o=1e3,mieCoefficient:a=.005,mieDirectionalG:i=.8,rayleigh:s=.5,turbidity:l=10,sunPosition:c=ro(t,r),...u},d)=>{const f=S.useMemo((()=>(new n.Vector3).setScalar(o)),[o]),[p]=S.useState((()=>new m.Sky));return S.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 oo 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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`})}}const ao=e=>(new n.Vector3).setFromSpherical(new n.Spherical(e,Math.acos(1-2*Math.random()),2*Math.random()*Math.PI)),io=S.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=S.useRef(),[m,d,f]=S.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(...ao(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]=S.useState((()=>new oo));return S.createElement("points",{ref:c},S.createElement("bufferGeometry",null,S.createElement("bufferAttribute",{attach:"attributes-position",args:[m,3]}),S.createElement("bufferAttribute",{attach:"attributes-color",args:[d,3]}),S.createElement("bufferAttribute",{attach:"attributes-size",args:[f,1]})),S.createElement("primitive",{ref:u,object:p,attach:"material",blending:n.AdditiveBlending,"uniforms-fade-value":s,depthWrite:!1,transparent:!0,vertexColors:!0}))})),so=new n.Matrix4,lo=new n.Vector3,co=new n.Quaternion,uo=new n.Vector3,mo=new n.Quaternion,fo=new n.Vector3,po=S.createContext(null),ho=S.forwardRef((({children:t,material:r=n.MeshLambertMaterial,texture:a="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",range:i,limit:s=200,...l},c)=>{var u,m;const d=S.useMemo((()=>class extends r{constructor(){super();const e=parseInt(n.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader="attribute float opacity;\n varying float vOpacity;\n "+t.vertexShader.replace("#include <fog_vertex>","#include <fog_vertex>\n vOpacity = opacity;\n "),t.fragmentShader="varying float vOpacity;\n "+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>\n gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);\n `)}}}),[r]);o.extend({CloudMaterial:d});const f=S.useRef(null),p=S.useRef([]),h=S.useMemo((()=>new Float32Array(Array.from({length:s},(()=>1)))),[s]),x=S.useMemo((()=>new Float32Array(Array.from({length:s},(()=>[1,1,1])).flat())),[s]),y=fe(a);let v,g=0,z=0;const w=new n.Quaternion,b=new n.Vector3(0,0,1),M=new n.Vector3;o.useFrame(((e,t)=>{for(g=e.clock.getElapsedTime(),so.copy(f.current.matrixWorld).invert(),e.camera.matrixWorld.decompose(uo,mo,fo),z=0;z<p.current.length;z++)v=p.current[z],v.ref.current.matrixWorld.decompose(lo,co,fo),lo.add(M.copy(v.position).applyQuaternion(co).multiply(fo)),co.copy(mo).multiply(w.setFromAxisAngle(b,v.rotation+=t*v.rotationFactor)),fo.multiplyScalar(v.volume+(1+Math.sin(g*v.density*v.speed))/2*v.growth),v.matrix.compose(lo,co,fo).premultiply(so),v.dist=lo.distanceTo(uo);for(p.current.sort(((e,t)=>t.dist-e.dist)),z=0;z<p.current.length;z++)v=p.current[z],h[z]=v.opacity*(v.dist<v.fade-1?v.dist/v.fade:1),f.current.setMatrixAt(z,v.matrix),f.current.setColorAt(z,v.color);f.current.geometry.attributes.opacity.needsUpdate=!0,f.current.instanceMatrix.needsUpdate=!0,f.current.instanceColor&&(f.current.instanceColor.needsUpdate=!0)})),S.useLayoutEffect((()=>{const e=Math.min(s,void 0!==i?i:s,p.current.length);f.current.count=e,rr(f.current.instanceMatrix,{offset:0,count:16*e}),f.current.instanceColor&&rr(f.current.instanceColor,{offset:0,count:3*e}),rr(f.current.geometry.attributes.opacity,{offset:0,count:e})}));let E=[null!==(u=y.image.width)&&void 0!==u?u:1,null!==(m=y.image.height)&&void 0!==m?m:1],T=Math.max(E[0],E[1]);return E=[E[0]/T,E[1]/T],S.createElement("group",e({ref:c},l),S.createElement(po.Provider,{value:p},t,S.createElement("instancedMesh",{matrixAutoUpdate:!1,ref:f,args:[null,null,s]},S.createElement("instancedBufferAttribute",{usage:n.DynamicDrawUsage,attach:"instanceColor",args:[x,3]}),S.createElement("planeGeometry",{args:[...E]},S.createElement("instancedBufferAttribute",{usage:n.DynamicDrawUsage,attach:"attributes-opacity",args:[h,1]})),S.createElement("cloudMaterial",{key:r.name,map:y,transparent:!0,depthWrite:!1}))))})),xo=S.forwardRef((({opacity:t=1,speed:r=0,bounds:a=[5,1,1],segments:i=20,color:s="#ffffff",fade:l=10,volume:c=6,smallestVolume:u=.25,distribute:m=null,growth:d=4,concentrate:f="inside",seed:p=Math.random(),...h},x)=>{function y(){const e=1e4*Math.sin(p++);return e-Math.floor(e)}const v=S.useContext(po),g=S.useRef(null),[z]=S.useState((()=>b.v4())),w=S.useMemo((()=>[...new Array(i)].map(((e,t)=>({segments:i,bounds:new n.Vector3(1,1,1),position:new n.Vector3,uuid:z,index:t,ref:g,dist:0,matrix:new n.Matrix4,color:new n.Color,rotation:t*(Math.PI/i)})))),[i,z]);return S.useLayoutEffect((()=>{w.forEach(((e,n)=>{var p;o.applyProps(e,{volume:c,color:s,speed:r,growth:d,opacity:t,fade:l,bounds:a,density:Math.max(.5,y()),rotationFactor:Math.max(.2,.5*y())*r});const h=null==m?void 0:m(e,n);(h||i>1)&&e.position.copy(e.bounds).multiply(null!==(p=null==h?void 0:h.point)&&void 0!==p?p:{x:2*y()-1,y:2*y()-1,z:2*y()-1});const x=Math.abs(e.position.x),v=Math.abs(e.position.y),g=Math.abs(e.position.z),z=Math.max(x,v,g);e.length=1,x===z&&(e.length-=x/e.bounds.x),v===z&&(e.length-=v/e.bounds.y),g===z&&(e.length-=g/e.bounds.z),e.volume=(void 0!==(null==h?void 0:h.volume)?h.volume:Math.max(Math.max(0,u),"random"===f?y():"inside"===f?e.length:1-e.length))*c}))}),[f,a,l,s,t,d,c,p,i,r]),S.useLayoutEffect((()=>{const e=w;return v.current=[...v.current,...e],()=>{v.current=v.current.filter((e=>e.uuid!==z))}}),[w]),S.useImperativeHandle(x,(()=>g.current),[]),S.createElement("group",e({ref:g},h))})),yo=S.forwardRef(((t,r)=>S.useContext(po)?S.createElement(xo,e({ref:r},t)):S.createElement(ho,null,S.createElement(xo,e({ref:r},t))))),vo=me({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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),go=e=>e&&e.constructor===Float32Array,zo=e=>e instanceof C.Vector2||e instanceof C.Vector3||e instanceof C.Vector4,wo=e=>Array.isArray(e)?e:zo(e)?e.toArray():[e,e,e];function bo(e,t,r){return S.useMemo((()=>{if(void 0!==t){if(go(t))return t;if(t instanceof C.Color){const r=Array.from({length:3*e},(()=>(e=>[e.r,e.g,e.b])(t))).flat();return Float32Array.from(r)}if(zo(t)||Array.isArray(t)){const r=Array.from({length:3*e},(()=>wo(t))).flat();return Float32Array.from(r)}return Float32Array.from({length:e},(()=>t))}return Float32Array.from({length:e},r)}),[t])}const Mo=S.forwardRef((({noise:t=1,count:r=100,speed:n=1,opacity:a=1,scale:i=1,size:s,color:l,children:c,...u},m)=>{S.useMemo((()=>o.extend({SparklesImplMaterial:vo})),[]);const d=S.useRef(null),f=o.useThree((e=>e.viewport.dpr)),p=wo(i),h=S.useMemo((()=>Float32Array.from(Array.from({length:r},(()=>p.map(C.MathUtils.randFloatSpread))).flat())),[r,...p]),x=bo(r,s,Math.random),y=bo(r,a),v=bo(r,n),g=bo(3*r,t),z=bo(void 0===l?3*r:r,go(l)?l:new C.Color(l),(()=>1));return o.useFrame((e=>{d.current&&d.current.material&&(d.current.material.time=e.clock.elapsedTime)})),S.useImperativeHandle(m,(()=>d.current),[]),S.createElement("points",e({key:`particle-${r}-${JSON.stringify(i)}`},u,{ref:d}),S.createElement("bufferGeometry",null,S.createElement("bufferAttribute",{attach:"attributes-position",args:[h,3]}),S.createElement("bufferAttribute",{attach:"attributes-size",args:[x,1]}),S.createElement("bufferAttribute",{attach:"attributes-opacity",args:[y,1]}),S.createElement("bufferAttribute",{attach:"attributes-speed",args:[v,1]}),S.createElement("bufferAttribute",{attach:"attributes-color",args:[z,3]}),S.createElement("bufferAttribute",{attach:"attributes-noise",args:[g,3]})),c||S.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:f,depthWrite:!1}))}));const Eo={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 C.Color("#ff0000"),backfaceStroke:new C.Color("#0000ff"),fill:new C.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 "},So=me(Eo.uniforms,Eo.vertex+"\n \tvoid main() {\n\t\tinitWireframe();\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n\t}\n ",Eo.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 To(e){return void 0!==(null==e?void 0:e.current)}function Co(e){return"WireframeGeometry"===e.type}function Po(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(Co(t))throw new Error("Wireframe: WireframeGeometry is not supported.");const e=t.parent;if(function(e){return!(null==e||!e.geometry)}(e)){if(Co(e.geometry))throw new Error("Wireframe: WireframeGeometry is not supported.");return e.geometry}}}function Ro(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 C.BufferAttribute(Float32Array.from(n),3)}(e,t);e.setAttribute("barycentric",r)}function Do({geometry:t,simplify:r=!1,...n}){o.extend({MeshWireframeMaterial:So});const[a,i]=S.useState(null);S.useLayoutEffect((()=>{const e=Po(t);if(!e)throw new Error("Wireframe: geometry prop must be a BufferGeometry or a ref to a BufferGeometry.");Ro(e,r),To(t)&&i(e)}),[r,t]);const s=To(t)?a:t;return S.createElement(S.Fragment,null,s&&S.createElement("mesh",{geometry:s},S.createElement("meshWireframeMaterial",e({attach:"material",transparent:!0,side:C.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-4},n,{extensions:{derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1}}))))}function Fo({simplify:e=!1,...t}){const r=S.useRef(null),n=S.useMemo((()=>function(){const e={};for(const t in Eo.uniforms)e[t]={value:Eo.uniforms[t]};return e}()),[Eo.uniforms]);return function(e,t){S.useEffect((()=>{var r;e.fillOpacity.value=null!==(r=t.fillOpacity)&&void 0!==r?r:e.fillOpacity.value}),[t.fillOpacity]),S.useEffect((()=>{var r;e.fillMix.value=null!==(r=t.fillMix)&&void 0!==r?r:e.fillMix.value}),[t.fillMix]),S.useEffect((()=>{var r;e.strokeOpacity.value=null!==(r=t.strokeOpacity)&&void 0!==r?r:e.strokeOpacity.value}),[t.strokeOpacity]),S.useEffect((()=>{var r;e.thickness.value=null!==(r=t.thickness)&&void 0!==r?r:e.thickness.value}),[t.thickness]),S.useEffect((()=>{e.colorBackfaces.value=!!t.colorBackfaces}),[t.colorBackfaces]),S.useEffect((()=>{e.dash.value=!!t.dash}),[t.dash]),S.useEffect((()=>{e.dashInvert.value=!!t.dashInvert}),[t.dashInvert]),S.useEffect((()=>{var r;e.dashRepeats.value=null!==(r=t.dashRepeats)&&void 0!==r?r:e.dashRepeats.value}),[t.dashRepeats]),S.useEffect((()=>{var r;e.dashLength.value=null!==(r=t.dashLength)&&void 0!==r?r:e.dashLength.value}),[t.dashLength]),S.useEffect((()=>{e.squeeze.value=!!t.squeeze}),[t.squeeze]),S.useEffect((()=>{var r;e.squeezeMin.value=null!==(r=t.squeezeMin)&&void 0!==r?r:e.squeezeMin.value}),[t.squeezeMin]),S.useEffect((()=>{var r;e.squeezeMax.value=null!==(r=t.squeezeMax)&&void 0!==r?r:e.squeezeMax.value}),[t.squeezeMax]),S.useEffect((()=>{e.stroke.value=t.stroke?new C.Color(t.stroke):e.stroke.value}),[t.stroke]),S.useEffect((()=>{e.fill.value=t.fill?new C.Color(t.fill):e.fill.value}),[t.fill]),S.useEffect((()=>{e.backfaceStroke.value=t.backfaceStroke?new C.Color(t.backfaceStroke):e.backfaceStroke.value}),[t.backfaceStroke])}(n,t),S.useLayoutEffect((()=>{const t=Po(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 Ro(t,e),()=>{t.copy(n),n.dispose()}}),[e]),S.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 ${Eo.vertex}\n\t\t void main() {\n\t\t\tinitWireframe();\n\t\t`),e.fragmentShader=e.fragmentShader.replace("void main() {",`\n\t\t ${Eo.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=C.DoubleSide,e.transparent=!0}(e.material,n),()=>{e.material.dispose(),e.material=t}}),[]),S.createElement("object3D",{ref:r})}const ko=new C.Matrix4,_o=new C.Ray,Ao=new C.Sphere,Lo=new C.Vector3;class Bo extends C.Group{constructor(){super(),this.size=0,this.color=new C.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(Ao.set(this.getWorldPosition(Lo),i),!1===e.ray.intersectsSphere(Ao))return;ko.copy(o.matrixWorld).invert(),_o.copy(e.ray).applyMatrix4(ko);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),l=s*s,c=_o.distanceSqToPoint(this.position);if(c<l){const r=new C.Vector3;_o.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 Uo,Io;const Vo=S.createContext(null),No=new C.Matrix4,Oo=new C.Vector3,jo=S.forwardRef((({children:t,range:r,limit:n=1e3,...a},s)=>{const l=S.useRef(null),[c,u]=S.useState([]),[[m,d,f]]=S.useState((()=>[new Float32Array(3*n),Float32Array.from({length:3*n},(()=>1)),Float32Array.from({length:n},(()=>1))]));S.useEffect((()=>{l.current.geometry.attributes.position.needsUpdate=!0})),o.useFrame((()=>{for(l.current.updateMatrix(),l.current.updateMatrixWorld(),No.copy(l.current.matrixWorld).invert(),l.current.geometry.drawRange.count=Math.min(n,void 0!==r?r:n,c.length),Uo=0;Uo<c.length;Uo++)Io=c[Uo].current,Io.getWorldPosition(Oo).applyMatrix4(No),Oo.toArray(m,3*Uo),l.current.geometry.attributes.position.needsUpdate=!0,Io.matrixWorldNeedsUpdate=!0,Io.color.toArray(d,3*Uo),l.current.geometry.attributes.color.needsUpdate=!0,f.set([Io.size],Uo),l.current.geometry.attributes.size.needsUpdate=!0}));const p=S.useMemo((()=>({getParent:()=>l,subscribe:e=>(u((t=>[...t,e])),()=>u((t=>t.filter((t=>t.current!==e.current)))))})),[]);return S.createElement("points",e({userData:{instances:c},matrixAutoUpdate:!1,ref:i([s,l]),raycast:()=>null},a),S.createElement("bufferGeometry",null,S.createElement("bufferAttribute",{attach:"attributes-position",count:m.length/3,array:m,itemSize:3,usage:C.DynamicDrawUsage}),S.createElement("bufferAttribute",{attach:"attributes-color",count:d.length/3,array:d,itemSize:3,usage:C.DynamicDrawUsage}),S.createElement("bufferAttribute",{attach:"attributes-size",count:f.length,array:f,itemSize:1,usage:C.DynamicDrawUsage})),S.createElement(Vo.Provider,{value:p},t))})),Wo=S.forwardRef((({children:t,...r},n)=>{S.useMemo((()=>o.extend({PositionPoint:Bo})),[]);const a=S.useRef(),{subscribe:s,getParent:l}=S.useContext(Vo);return S.useLayoutEffect((()=>s(a)),[]),S.createElement("positionPoint",e({instance:l(),instanceKey:a,ref:i([n,a])},r),t)})),Go=S.forwardRef((({children:t,positions:r,colors:n,sizes:a,stride:s=3,...l},c)=>{const u=S.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)})),S.createElement("points",e({ref:i([c,u])},l),S.createElement("bufferGeometry",null,S.createElement("bufferAttribute",{attach:"attributes-position",count:r.length/s,array:r,itemSize:s,usage:C.DynamicDrawUsage}),n&&S.createElement("bufferAttribute",{attach:"attributes-color",count:n.length/s,array:n,itemSize:3,usage:C.DynamicDrawUsage}),a&&S.createElement("bufferAttribute",{attach:"attributes-size",count:a.length/s,array:a,itemSize:1,usage:C.DynamicDrawUsage})),t)})),Ho=S.forwardRef(((t,r)=>t.positions instanceof Float32Array?S.createElement(Go,e({},t,{ref:r})):S.createElement(jo,e({},t,{ref:r})))),$o=S.createContext(null),qo=S.forwardRef(((t,r)=>{S.useMemo((()=>o.extend({SegmentObject:Xo})),[]);const{limit:n=1e3,lineWidth:a=1,children:i,...s}=t,[l,c]=S.useState([]),[u]=S.useState((()=>new m.Line2)),[d]=S.useState((()=>new m.LineMaterial)),[f]=S.useState((()=>new m.LineSegmentsGeometry)),[p]=S.useState((()=>new C.Vector2(512,512))),[h]=S.useState((()=>Array(6*n).fill(0))),[x]=S.useState((()=>Array(6*n).fill(0))),y=S.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()})),S.createElement("primitive",{object:u,ref:r},S.createElement("primitive",{object:f,attach:"geometry"}),S.createElement("primitive",e({object:d,attach:"material",vertexColors:!0,resolution:p,linewidth:a},s)),S.createElement($o.Provider,{value:y},i))}));class Xo{constructor(){this.color=new C.Color("white"),this.start=new C.Vector3(0,0,0),this.end=new C.Vector3(0,0,0)}}const Zo=e=>e instanceof C.Vector3?e:new C.Vector3(..."number"==typeof e?[e,e,e]:e),Yo=S.forwardRef((({color:e,start:t,end:r},n)=>{const o=S.useContext($o);if(!o)throw"Segment must used inside Segments component.";const a=S.useRef(null);return S.useLayoutEffect((()=>o.subscribe(a)),[]),S.createElement("segmentObject",{ref:i([a,n]),color:e,start:Zo(t),end:Zo(r)})})),Qo=S.forwardRef((({children:t,hysteresis:r=0,distances:n,...a},s)=>{const l=S.useRef(null);return S.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)})),S.createElement("lOD",e({ref:i([l,s])},a),t)}));const Ko=new n.Matrix4,Jo=new n.Ray,ea=new n.Sphere,ta=new n.Vector3;const ra=t.createContext(null);const na=S.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=Ge((n||h.width)*x.dpr,(a||h.height)*x.dpr,{samples:i,stencilBuffer:u,depthBuffer:m,generateMipmaps:d}),[v]=S.useState((()=>new C.Scene)),g=S.useCallback(((e,t,r)=>{var n,o;let a=null==(n=y.texture)?void 0:n.__r3f.parent;for(;a&&!(a instanceof C.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 S.useImperativeHandle(p,(()=>y.texture),[y]),S.createElement(S.Fragment,null,o.createPortal(S.createElement(oa,{renderPriority:s,frames:c,fbo:y},t,S.createElement("group",{onPointerOver:()=>null})),v,{events:{compute:r||g,priority:l}}),S.createElement("primitive",e({object:y.texture},f)))}));function oa({frames:e,renderPriority:t,children:r,fbo:n}){let a,i,s=0;return o.useFrame((t=>{(e===1/0||s<e)&&(a=t.gl.autoClear,i=t.gl.xr.enabled,t.gl.autoClear=!0,t.gl.xr.enabled=!1,t.gl.setRenderTarget(n),t.gl.render(t.scene,t.camera),t.gl.setRenderTarget(null),t.gl.autoClear=a,t.gl.xr.enabled=i,s++)}),t),S.createElement(S.Fragment,null,r)}const aa=S.forwardRef((({children:t,compute:r,renderPriority:n=-1,eventPriority:a=0,frames:i=1/0,stencilBuffer:s=!1,depthBuffer:l=!0,generateMipmaps:c=!1,resolution:u=896,near:m=.1,far:d=1e3,flip:f=!1,position:p,rotation:h,scale:x,quaternion:y,matrix:v,matrixAutoUpdate:g,...z},w)=>{const{size:b,viewport:M}=o.useThree(),E=S.useRef(null),T=S.useMemo((()=>{const e=new C.WebGLCubeRenderTarget(Math.max((u||b.width)*M.dpr,(u||b.height)*M.dpr),{stencilBuffer:s,depthBuffer:l,generateMipmaps:c});return e.texture.isRenderTargetTexture=!f,e.texture.flipY=!0,e.texture.type=C.HalfFloatType,e}),[u,f]);S.useEffect((()=>()=>T.dispose()),[T]);const[P]=S.useState((()=>new C.Scene));return S.useImperativeHandle(w,(()=>({scene:P,fbo:T,camera:E.current})),[T]),S.createElement(S.Fragment,null,o.createPortal(S.createElement(ia,{renderPriority:n,frames:i,camera:E},t,S.createElement("group",{onPointerOver:()=>null})),P,{events:{compute:r,priority:a}}),S.createElement("primitive",e({object:T.texture},z)),S.createElement("cubeCamera",{ref:E,args:[m,d,T],position:p,rotation:h,scale:x,quaternion:y,matrix:v,matrixAutoUpdate:g}))}));function ia({frames:e,renderPriority:t,children:r,camera:n}){let a=0;return o.useFrame((t=>{(e===1/0||a<e)&&(n.current.update(t.gl,t.scene),a++)}),t),S.createElement(S.Fragment,null,r)}const sa=S.forwardRef((({id:t=1,colorWrite:r=!1,depthWrite:n=!1,...o},a)=>{const i=S.useRef(null),s=S.useMemo((()=>({colorWrite:r,depthWrite:n,stencilWrite:!0,stencilRef:t,stencilFunc:C.AlwaysStencilFunc,stencilFail:C.ReplaceStencilOp,stencilZFail:C.ReplaceStencilOp,stencilZPass:C.ReplaceStencilOp})),[t,r,n]);return S.useLayoutEffect((()=>{Object.assign(i.current.material,s)})),S.useImperativeHandle(a,(()=>i.current),[]),S.createElement("mesh",e({ref:i,renderOrder:-t},o))}));function la({api:e}){const t=new C.Vector3,r=new C.Quaternion,n=new C.Vector3,a=new C.Euler(0,Math.PI,0);return o.useFrame((o=>{o.camera.matrixWorld.decompose(t,r,n),e.current.camera.position.copy(t),e.current.camera.quaternion.setFromEuler(a).premultiply(r)})),null}const ca=me({blur:0,map:null,sdf:null,blend:0,size:0,resolution:new C.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 <${pe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),ua=S.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:ca});const m=S.useRef(null),{scene:d,gl:f,size:p,viewport:h,setEvents:x}=o.useThree(),y=Ge(l,l),[v,g]=S.useState(0);o.useFrame((()=>{const e=m.current.blend>0?Math.max(1,i):0;v!==e&&g(e)})),S.useEffect((()=>{void 0!==r&&x({enabled:!r})}),[r]);const[z,w]=S.useState(!0),b=Ht(w);S.useLayoutEffect((()=>{var e;b.current=null==(e=m.current)?void 0:e.__r3f.parent}),[]),S.useLayoutEffect((()=>{if(b.current&&n&&null===m.current.sdf){const e=new C.Mesh(b.current.geometry,new C.MeshBasicMaterial),t=(new C.Box3).setFromBufferAttribute(e.geometry.attributes.position),r=new C.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=da(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]),S.useImperativeHandle(u,(()=>m.current));const M=S.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 S.createElement("portalMaterialImpl",e({ref:m,blur:n,blend:0,resolution:[p.width*h.dpr,p.height*h.dpr],attach:"material"},c),S.createElement(na,{attach:"map",frames:z?1/0:0,eventPriority:a,renderPriority:i,compute:M},t,S.createElement(ma,{events:r,rootScene:d,priority:v,material:m,worldUnits:s})))}));function ma({events:e,rootScene:t,material:r,priority:n,worldUnits:a}){const i=o.useThree((e=>e.scene)),s=o.useThree((e=>e.setEvents)),l=Ge(),c=Ge();S.useLayoutEffect((()=>{i.matrixAutoUpdate=!1}),[]),S.useEffect((()=>{void 0!==e&&s({enabled:e})}),[e]);const[u,d]=S.useMemo((()=>{const e={value:0};return[new m.FullScreenQuad(new C.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 <tonemapping_fragment>\n #include <${pe>=154?"colorspace_fragment":"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),S.createElement(S.Fragment,null)}const da=(e,t,r)=>{let n=new C.WebGLRenderTarget(e,t,{minFilter:C.LinearMipmapLinearFilter,magFilter:C.LinearFilter,type:C.FloatType,format:C.RedFormat,generateMipmaps:!0}),o=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter}),a=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter}),i=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter}),s=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter}),l=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter,type:C.FloatType,format:C.RedFormat}),c=new C.WebGLRenderTarget(e,t,{minFilter:C.NearestFilter,magFilter:C.NearestFilter,type:C.FloatType,format:C.RedFormat});const u=new m.FullScreenQuad(new C.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 C.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 C.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 C.ShaderMaterial({uniforms:{tex:{value:null},size:{value:new C.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 C.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=C.NearestFilter,m.magFilter=C.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}},fa=e=>e&&e.isOrthographicCamera,pa=new C.Color,ha=M();function xa(e){return"top"in e}function ya(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(xa(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}}function va(e,{left:t,bottom:r,width:n,height:o}){let a;const i=n/o;return fa(e.camera)?e.camera.left===n/-2&&e.camera.right===n/2&&e.camera.top===o/2&&e.camera.bottom===o/-2||(Object.assign(e.camera,{left:n/-2,right:n/2,top:o/2,bottom:o/-2}),e.camera.updateProjectionMatrix()):e.camera.aspect!==i&&(e.camera.aspect=i,e.camera.updateProjectionMatrix()),a=e.gl.autoClear,e.gl.autoClear=!1,e.gl.setViewport(t,r,n,o),e.gl.setScissor(t,r,n,o),e.gl.setScissorTest(!0),a}function ga(e,t){e.gl.setScissorTest(!1),e.gl.autoClear=t}function za(e){e.gl.getClearColor(pa),e.gl.setClearColor(pa,e.gl.getClearAlpha()),e.gl.clear(!0,!0)}function wa({visible:e=!0,canvasSize:t,scene:r,index:n,children:a,frames:i,rect:s,track:l}){const c=o.useThree(),[u,m]=S.useState(!1);let d=0;return o.useFrame((n=>{var o;(i===1/0||d<=i)&&(s.current=null==(o=l.current)?void 0:o.getBoundingClientRect(),d++);if(s.current){const{position:o,isOffscreen:i}=ya(t,s.current);if(u!==i&&m(i),e&&!u&&s.current){const e=va(n,o);n.gl.render(a?n.scene:r,n.camera),ga(n,e)}}}),n),S.useLayoutEffect((()=>{const r=s.current;if(r&&(!e||!u)){const{position:e}=ya(t,r),n=va(c,e);za(c),ga(c,n)}}),[e,u]),S.useEffect((()=>{const e=s.current,r=c.get().events.connected;return c.setEvents({connected:l.current}),()=>{if(e){const{position:r}=ya(t,e),n=va(c,r);za(c),ga(c,n)}c.setEvents({connected:r})}}),[]),S.useEffect((()=>{xa(t)||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")}),[]),S.createElement(S.Fragment,null,a)}const ba=S.forwardRef((({track:t,visible:r=!0,index:n=1,id:a,style:i,className:s,frames:l=1/0,children:c,...u},m)=>{var d,f,p,h;const x=S.useRef(null),{size:y,scene:v}=o.useThree(),[g]=S.useState((()=>new C.Scene)),[z,w]=S.useReducer((()=>!0),!1),b=S.useCallback(((e,r)=>{if(x.current&&t.current&&e.target===t.current){const{width:t,height:n,left:o,top:a}=x.current,i=e.clientX-o,s=e.clientY-a;r.pointer.set(i/t*2-1,-s/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[x,t]);return S.useEffect((()=>{var e;x.current=null==(e=t.current)?void 0:e.getBoundingClientRect(),w()}),[t]),S.createElement("group",e({ref:m},u),z&&o.createPortal(S.createElement(wa,{visible:r,canvasSize:y,frames:l,scene:v,track:t,rect:x,index:n},c),g,{events:{compute:b,priority:n},size:{width:null==(d=x.current)?void 0:d.width,height:null==(f=x.current)?void 0:f.height,top:null==(p=x.current)?void 0:p.top,left:null==(h=x.current)?void 0:h.left}}))})),Ma=S.forwardRef((({as:t="div",id:r,visible:n,className:o,style:a,index:i=1,track:s,frames:l=1/0,children:c,...u},m)=>{const d=S.useId(),f=S.useRef(null);return S.useImperativeHandle(m,(()=>f.current)),S.createElement(S.Fragment,null,S.createElement(t,e({ref:f,id:r,className:o,style:a},u)),S.createElement(ha.In,null,S.createElement(ba,{visible:n,key:d,track:f,frames:l,index:i},c)))})),Ea=S.forwardRef(((t,r)=>S.useContext(o.context)?S.createElement(ba,e({ref:r},t)):S.createElement(Ma,e({ref:r},t))));Ea.Port=()=>S.createElement(ha.Out,null);const Sa=S.createContext(null),Ta=new C.Vector3,Ca=new C.Vector3,Pa=new C.Vector3(0,1,0),Ra=new C.Matrix4,Da=({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}=S.useContext(Sa),v=o.useThree((e=>e.controls)),g=S.useRef(null),z=S.useRef(null),w=S.useRef(null),b=S.useRef(0),[M,E]=S.useState(!1),T=S.useCallback((n=>{a&&(g.current.innerText=`${r.current[t].toFixed(2)}`,g.current.style.display="block"),n.stopPropagation();const o=(new C.Matrix4).extractRotation(z.current.matrixWorld),i=n.point.clone(),s=(new C.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]),P=S.useCallback((e=>{if(e.stopPropagation(),M||E(!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:(Ta.copy(n).multiplyScalar(o/i).sub(t),Ca.copy(n).multiplyScalar(a/i).add(r).sub(e),-Ta.dot(Ca)/Ta.dot(Ta))})(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)}`),Ra.makeTranslation(i.x*c,i.y*c,i.z*c),h(Ra)}}),[a,h,M,r,n,t]),R=S.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=S.useCallback((e=>{e.stopPropagation(),E(!1)}),[]),{cylinderLength:F,coneWidth:k,coneLength:_,matrixL:A}=S.useMemo((()=>{const t=u?c/l*1.6:l/20,r=u?.2:l/5,n=u?1-r:l-r,o=(new C.Quaternion).setFromUnitVectors(Pa,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new C.Matrix4).makeRotationFromQuaternion(o)}}),[e,l,c,u]),L=M?d:m[t];return S.createElement("group",{ref:z},S.createElement("group",{matrix:A,matrixAutoUpdate:!1,onPointerDown:T,onPointerMove:P,onPointerUp:R,onPointerOut:D},a&&S.createElement(U,{position:[0,-_,0]},S.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),S.createElement("mesh",{visible:!1,position:[0,(F+_)/2,0],userData:y},S.createElement("cylinderGeometry",{args:[1.4*k,1.4*k,F+_,8,1]})),S.createElement(Q,{transparent:!0,raycast:()=>null,depthTest:s,points:[0,0,0,0,F,0],lineWidth:c,color:L,opacity:f,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),S.createElement("mesh",{raycast:()=>null,position:[0,F+_/2,0],renderOrder:500},S.createElement("coneGeometry",{args:[k,_,24,1]}),S.createElement("meshBasicMaterial",{transparent:!0,depthTest:s,color:L,opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},Fa=new C.Ray,ka=new C.Vector3,_a=new C.Matrix4,Aa=({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}=S.useContext(Sa),g=o.useThree((e=>e.controls)),z=S.useRef(null),w=S.useRef(null),b=S.useRef(null),M=S.useRef(0),E=S.useRef(0),[T,P]=S.useState(!1),R=S.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 C.Vector3).setFromMatrixPosition(w.current.matrixWorld),a=(new C.Vector3).setFromMatrixColumn(w.current.matrixWorld,0).normalize(),s=(new C.Vector3).setFromMatrixColumn(w.current.matrixWorld,1).normalize(),l=(new C.Vector3).setFromMatrixColumn(w.current.matrixWorld,2).normalize(),c=(new C.Plane).setFromNormalAndCoplanarPoint(l,o);b.current={clickPoint:t,e1:a,e2:s,plane:c},M.current=n.current[(r+1)%3],E.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=S.useCallback((e=>{if(e.stopPropagation(),T||P(!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];Fa.copy(e.ray),Fa.intersectPlane(l,ka),Fa.direction.negate(),Fa.intersectPlane(l,ka),ka.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,ka);void 0!==c&&(f=Math.max(f,c-M.current)),void 0!==u&&(f=Math.min(f,u-M.current)),void 0!==m&&(p=Math.max(p,m-E.current)),void 0!==d&&(p=Math.min(p,d-E.current)),n.current[(r+1)%3]=M.current+f,n.current[(r+2)%3]=E.current+p,i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`),_a.makeTranslation(f*o.x+p*s.x,f*o.y+p*s.y,f*o.z+p*s.z),x(_a)}}),[i,x,T,n,a,r]),F=S.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=S.useCallback((e=>{e.stopPropagation(),P(!1)}),[]),_=S.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new C.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),A=m?1/7:c/7,L=m?.225:.225*c,B=T?f:d[r],I=S.useMemo((()=>[new C.Vector3(0,0,0),new C.Vector3(0,L,0),new C.Vector3(L,L,0),new C.Vector3(L,0,0),new C.Vector3(0,0,0)]),[L]);return S.createElement("group",{ref:w,matrix:_,matrixAutoUpdate:!1},i&&S.createElement(U,{position:[0,0,0]},S.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:s,ref:z})),S.createElement("group",{position:[1.7*A,1.7*A,0]},S.createElement("mesh",{visible:!0,onPointerDown:R,onPointerMove:D,onPointerUp:F,onPointerOut:k,scale:L,userData:v},S.createElement("planeGeometry",null),S.createElement("meshBasicMaterial",{transparent:!0,depthTest:l,color:B,polygonOffset:!0,polygonOffsetFactor:-10,side:C.DoubleSide,fog:!1})),S.createElement(Q,{position:[-L/2,-L/2,0],transparent:!0,depthTest:l,points:I,lineWidth:u,color:B,opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,userData:v,fog:!1})))},La=new C.Vector3,Ba=new C.Vector3,Ua=e=>180*e/Math.PI,Ia=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)},Va=new C.Matrix4,Na=new C.Vector3,Oa=new C.Ray,ja=new C.Vector3,Wa=({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}=S.useContext(Sa),v=o.useThree((e=>e.controls)),g=S.useRef(null),z=S.useRef(null),w=S.useRef(0),b=S.useRef(0),M=S.useRef(null),[E,T]=S.useState(!1),P=S.useCallback((e=>{a&&(g.current.innerText=`${Ua(b.current).toFixed(0)}º`,g.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),n=(new C.Vector3).setFromMatrixPosition(z.current.matrixWorld),o=(new C.Vector3).setFromMatrixColumn(z.current.matrixWorld,0).normalize(),i=(new C.Vector3).setFromMatrixColumn(z.current.matrixWorld,1).normalize(),s=(new C.Vector3).setFromMatrixColumn(z.current.matrixWorld,2).normalize(),l=(new C.Plane).setFromNormalAndCoplanarPoint(s,n);M.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]),R=S.useCallback((e=>{if(e.stopPropagation(),E||T(!0),M.current){const{clickPoint:t,origin:o,e1:i,e2:s,normal:l,plane:c}=M.current,[u,m]=(null==n?void 0:n[r])||[void 0,void 0];Oa.copy(e.ray),Oa.intersectPlane(c,ja),Oa.direction.negate(),Oa.intersectPlane(c,ja);let d=((e,t,r,n,o)=>{La.copy(e).sub(r),Ba.copy(t).sub(r);const a=n.dot(n),i=o.dot(o),s=La.dot(n)/a,l=La.dot(o)/i,c=Ba.dot(n)/a,u=Ba.dot(o)/i,m=Math.atan2(l,s);return Math.atan2(u,c)-m})(t,ja,o,i,s),f=Ua(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=Ia(d),d=d>Math.PI?d-2*Math.PI:d,d=C.MathUtils.clamp(d,u-w.current,m-w.current),b.current=w.current+d):(b.current=Ia(w.current+d),b.current=b.current>Math.PI?b.current-2*Math.PI:b.current),a&&(f=Ua(b.current),g.current.innerText=`${f.toFixed(0)}º`),Va.makeRotationAxis(l,d),Na.copy(o).applyMatrix4(Va).sub(o).negate(),Va.setPosition(Na),h(Va)}}),[a,h,E,n,r]),D=S.useCallback((e=>{a&&(g.current.style.display="none"),e.stopPropagation(),w.current=b.current,M.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[a,v,x]),F=S.useCallback((e=>{e.stopPropagation(),T(!1)}),[]),k=S.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new C.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),_=u?.65:.65*l,A=S.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new C.Vector3(Math.cos(r)*_,Math.sin(r)*_,0))}return e}),[_]);return S.createElement("group",{ref:z,onPointerDown:P,onPointerMove:R,onPointerUp:D,onPointerOut:F,matrix:k,matrixAutoUpdate:!1},a&&S.createElement(U,{position:[_,_,0]},S.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),S.createElement(Q,{points:A,lineWidth:4*c,visible:!1,userData:y}),S.createElement(Q,{transparent:!0,raycast:()=>null,depthTest:s,points:A,lineWidth:c,color:E?d:m[r],opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))},Ga=new C.Vector3,Ha=new C.Vector3,$a=new C.Vector3,qa=(e,t,r,n=1)=>{const o=Ga.set(e.x/r.width*2-1,-e.y/r.height*2+1,n);return o.unproject(t),o},Xa=(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})($a.copy(e),r,n);let a=0;for(let i=0;i<2;++i){const s=Ha.copy(o).setComponent(i,o.getComponent(i)+t),l=qa(s,r,n,s.z);a=Math.max(a,e.distanceTo(l))}return a},Za=new C.Matrix4,Ya=new C.Matrix4,Qa=new C.Matrix4,Ka=new C.Matrix4,Ja=new C.Matrix4,ei=new C.Matrix4,ti=new C.Matrix4,ri=new C.Matrix4,ni=new C.Box3,oi=new C.Box3,ai=new C.Vector3,ii=new C.Vector3,si=new C.Vector3,li=new C.Vector3,ci=new C.Vector3(1,0,0),ui=new C.Vector3(0,1,0),mi=new C.Vector3(0,0,1),di=S.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:M,opacity:E=1,visible:T=!0,userData:P,children:R,...D},F)=>{const k=o.useThree((e=>e.invalidate)),_=S.useRef(null),A=S.useRef(null),L=S.useRef(null),B=S.useRef(null),U=S.useRef([0,0,0]);S.useLayoutEffect((()=>{s&&(B.current.updateWorldMatrix(!0,!0),Ka.copy(B.current.matrixWorld).invert(),ni.makeEmpty(),B.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),ei.copy(e.matrixWorld).premultiply(Ka),oi.copy(e.geometry.boundingBox),oi.applyMatrix4(ei),ni.union(oi))})),ai.copy(ni.max).add(ni.min).multiplyScalar(.5),ii.copy(ni.max).sub(ni.min).multiplyScalar(.5),si.copy(ii).multiply(new C.Vector3(...s)).add(ai),li.set(...d).add(si),L.current.position.copy(li),k())}));const I=S.useMemo((()=>({onDragStart:e=>{Za.copy(A.current.matrix),Ya.copy(A.current.matrixWorld),r&&r(e),k()},onDrag:e=>{Qa.copy(_.current.matrixWorld),Ka.copy(Qa).invert(),Ja.copy(Ya).premultiply(e),ei.copy(Ja).premultiply(Ka),ti.copy(Za).invert(),ri.copy(ei).multiply(ti),i&&A.current.matrix.copy(ei),n&&n(ei,ri,Ja,e),k()},onDragEnd:()=>{a&&a(),k()},translation:U,translationLimits:y,rotationLimits:v,axisColors:z,hoveredColor:w,opacity:E,scale:p,lineWidth:h,fixed:x,depthTest:g,userData:P,annotations:b,annotationsClass:M})),[r,n,a,U,y,v,g,p,h,x,...z,w,E,P,i,b,M]),V=new C.Vector3;return o.useFrame((e=>{if(x){const o=Xa(L.current.getWorldPosition(V),p,e.camera,e.size);var t,r,n;if(L.current)(null==(t=L.current)?void 0:t.scale.x)===o&&(null==(r=L.current)?void 0:r.scale.y)===o&&(null==(n=L.current)?void 0:n.scale.z)===o||(L.current.scale.setScalar(o),e.invalidate())}})),S.useImperativeHandle(F,(()=>A.current),[]),S.useLayoutEffect((()=>{t&&t instanceof C.Matrix4&&(A.current.matrix=t)}),[t]),S.createElement(Sa.Provider,{value:I},S.createElement("group",{ref:_},S.createElement("group",e({ref:A,matrix:t,matrixAutoUpdate:!1},D),S.createElement("group",{visible:T,ref:L,position:d,rotation:f},!l&&m[0]&&S.createElement(Da,{axis:0,direction:ci}),!l&&m[1]&&S.createElement(Da,{axis:1,direction:ui}),!l&&m[2]&&S.createElement(Da,{axis:2,direction:mi}),!c&&m[0]&&m[1]&&S.createElement(Aa,{axis:2,dir1:ci,dir2:ui}),!c&&m[0]&&m[2]&&S.createElement(Aa,{axis:1,dir1:mi,dir2:ci}),!c&&m[2]&&m[1]&&S.createElement(Aa,{axis:0,dir1:ui,dir2:mi}),!u&&m[0]&&m[1]&&S.createElement(Wa,{axis:2,dir1:ci,dir2:ui}),!u&&m[0]&&m[2]&&S.createElement(Wa,{axis:1,dir1:mi,dir2:ci}),!u&&m[2]&&m[1]&&S.createElement(Wa,{axis:0,dir1:ui,dir2:mi})),S.createElement("group",{ref:B},R))))})),fi=new C.Vector3(0,0,-1),pi=function(){const e=new C.Vector3,t=new C.Vector3,r=new C.Vector3,n=new C.Vector3,o=new C.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 hi=S.forwardRef((({points:e=vi.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=S.useRef(null),z=S.useRef(null),w=S.useRef(null),b=S.useRef(null),M=S.useRef(null),E=S.useRef(null),T=S.useRef(null),[P]=S.useState((()=>new C.Vector3)),[R]=S.useState((()=>new C.Object3D)),[D]=S.useState((()=>new C.Quaternion)),[F]=S.useState((()=>new C.Vector3)),{invalidate:k}=o.useThree();S.useEffect((()=>{var e;null==(e=M.current)||e.geometry.setIndex(vi.TRIANGULATION)}),[]);const[_]=S.useState((()=>new C.Vector3));S.useEffect((()=>{var t,o;const h=null==(t=M.current)?void 0:t.geometry;if(!h)return;var x,y;(h.setFromPoints(e),h.setDrawRange(0,vi.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)):(pi(e[u[0]],e[u[1]],e[u[2]],P),D.setFromUnitVectors(fi,P));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(E.current&&T.current&&w.current)if(f){const e=E.current._computeSphere(h),t=T.current._computeSphere(h),r=function(e,t){return e.clone().add(t).multiplyScalar(.5)}(e.center,t.center);m=r.negate(),E.current._update(h,n,e),T.current._update(h,n,t)}else E.current._update(h,n),T.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,P,D,_,F]);const A=S.useMemo((()=>({outerRef:b,meshRef:M,eyeRightRef:E,eyeLeftRef:T})),[]);S.useImperativeHandle(y,(()=>A),[A]);const[L]=S.useState((()=>new C.Vector3)),B=null==(v=M.current)?void 0:v.geometry.boundingBox,U=(null==B?void 0:B.getSize(L).z)||1;return S.createElement("group",x,S.createElement("group",{ref:g},S.createElement("group",{ref:b},S.createElement("group",{ref:z},p?S.createElement(S.Fragment,null,S.createElement("axesHelper",{args:[U]}),S.createElement(Q,{points:[[0,0,0],[0,0,-U]],color:65535})):null,S.createElement("group",{ref:w},d&&n&&S.createElement("group",{name:"eyes"},S.createElement(yi,{side:"left",ref:E,debug:p}),S.createElement(yi,{side:"right",ref:T,debug:p})),S.createElement("mesh",{ref:M,name:"face"},h,p?S.createElement(S.Fragment,null,B&&S.createElement("box3Helper",{args:[B]})):null))))))})),xi={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}},yi=S.forwardRef((({side:e,debug:t=!0},r)=>{const n=S.useRef(null),o=S.useRef(null),[a]=S.useState((()=>new C.Sphere)),i=S.useCallback((t=>{const r=t.getAttribute("position"),n=xi.contourLandmarks[e].map((e=>new C.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]=S.useState((()=>new C.Euler)),l=S.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=xi.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*(xi.fov.horizontal*C.MathUtils.DEG2RAD)*(l-i),u=.5*(xi.fov.vertical*C.MathUtils.DEG2RAD)*(n-a)*("left"===e?1:-1);s.set(c,u,0),o.current.setRotationFromEuler(s)}}),[i,e,s]),c=S.useMemo((()=>({eyeMeshRef:n,irisDirRef:o,_computeSphere:i,_update:l})),[i,l]);S.useImperativeHandle(r,(()=>c),[c]);const u=xi.color[e];return S.createElement("group",null,S.createElement("group",{ref:n},t&&S.createElement("axesHelper",null),S.createElement("group",{ref:o},S.createElement(S.Fragment,null,t&&S.createElement(Q,{points:[[0,0,0],[0,0,-2]],lineWidth:1,color:u})))))})),vi={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]}]}},gi=t.createContext({}),zi={basePath:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.8/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 wi(){return t.useContext(gi)}function bi(e,t){return e.clone().add(t).multiplyScalar(.5)}function Mi(e,t,r){const n=e.localToWorld(t);return r.worldToLocal(n)}const Ei=t.createContext({}),Si=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 M=o.useThree((e=>e.scene)),E=o.useThree((e=>e.camera)),T=o.useThree((e=>e.set)),P=o.useThree((e=>e.get)),R=r||E,D=t.useRef(null),F=t.useRef(null),[k]=t.useState((()=>new C.Object3D)),[_]=t.useState((()=>new C.Vector3)),[A]=t.useState((()=>new C.Vector3)),[L]=t.useState((()=>new C.Vector3)),[B]=t.useState((()=>new C.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(Mi(e.current,new C.Vector3(0,0,0),t.current)),A.copy(Mi(o.current,new C.Vector3(0,0,0),t.current)),k.position.copy(Mi(t.current,bi(_,A),R.parent||M)),L.copy(Mi(e.current,new C.Vector3(0,0,1),t.current)),B.copy(Mi(o.current,new C.Vector3(0,0,1),t.current)),k.lookAt(t.current.localToWorld(bi(L,B))))}else t.current&&(k.position.copy(Mi(t.current,new C.Vector3(0,0,0),R.parent||M)),k.lookAt(t.current.localToWorld(new C.Vector3(0,0,1))))}return k}),[R,A,B,_,L,M,k]),[I]=t.useState((()=>new C.Object3D)),V=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(I.position,t.position,m,e,void 0,void 0,r),s.easing.dampE(I.rotation,t.rotation,m,e,void 0,void 0,r)}else I.position.copy(t.position),I.rotation.copy(t.rotation);R.position.copy(I.position),R.rotation.copy(I.rotation)}}),[R,U,m,I.position,I.rotation]),[N,O]=t.useState(),j=wi(),W=t.useCallback(((e,t)=>{const r=null==j?void 0:j.detectForVideo(e,t);O(r)}),[j]);o.useFrame(((e,t)=>{l||V(t)}));const G=t.useMemo((()=>Object.assign(Object.create(C.EventDispatcher.prototype),{detect:W,computeTarget:U,update:V,facemeshApiRef:F,webcamApiRef:D,play:()=>{var e;null==(e=D.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.play()},pause:()=>{var e;null==(e=D.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.pause()}})),[W,U,V]);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=P().controls;return T({controls:G}),()=>T({controls:e})}}),[g,G,P,T]);const H=null==N?void 0:N.faceLandmarks[0],$=null==N||null==(w=N.facialTransformationMatrixes)?void 0:w[0],q=null==N||null==(b=N.faceBlendshapes)?void 0:b[0];return S.createElement(Ei.Provider,{value:G},a&&S.createElement(t.Suspense,{fallback:null},S.createElement(Ci,{ref:D,autostart:n,videoTextureSrc:i})),S.createElement(hi,e({ref:F},v,{points:H,depth:x,facialTransformationMatrix:$,faceBlendshapes:q,eyes:p,eyesAsOrigin:h,offset:d,offsetScalar:f,debug:y,"rotation-z":Math.PI,visible:y}),S.createElement("meshBasicMaterial",{side:C.DoubleSide})))})),Ti=()=>t.useContext(Ei),Ci=t.forwardRef((({videoTextureSrc:e,autostart:r=!0},n)=>{const o=t.useRef(null),a=Ti(),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]),S.createElement(t.Suspense,{fallback:null},S.createElement(Pi,{ref:o,src:e||i,start:r}))})),Pi=t.forwardRef((({src:e,start:r},n)=>{const o=Nt(e,{start:r}),a=o.source.data,i=Ti(),s=t.useCallback((e=>{i.dispatchEvent({type:"videoFrame",texture:o,time:e})}),[o,i]);Ri(a,s);const l=t.useMemo((()=>({texture:o})),[o]);return t.useImperativeHandle(n,(()=>l),[l]),S.createElement(S.Fragment,null)})),Ri=(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])};exports.AccumulativeShadows=_n,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 S.useEffect((()=>{const n=t.domElement;return()=>{r&&i(a),e&&n&&(n.style.imageRendering="auto")}}),[]),S.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 S.useEffect((()=>{const r=e().events.enabled;return()=>t({enabled:r})}),[]),S.useEffect((()=>t({enabled:1===r})),[r]),null},exports.ArcballControls=Je,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=S.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 S.useLayoutEffect((()=>{f.domElement.style.color=r,f.domElement.style.backgroundColor=t}),[r,t]),S.useEffect((()=>(c.domElement.style.opacity="0",c.domElement.parentNode.appendChild(f.domElement),()=>{c.domElement.style.opacity="1",c.domElement.parentNode.removeChild(f.domElement)})),[f]),S.useEffect((()=>{f.setSize(l.width,l.height)}),[f,l]),o.useFrame((e=>{f.render(u,d)}),e),S.createElement(S.Fragment,null)},exports.BBAnchor=({anchor:t,...r})=>{const n=S.useRef(null),a=S.useRef(null);return S.useEffect((()=>{var e;null!=(e=n.current)&&null!=(e=e.parent)&&e.parent&&(a.current=n.current.parent,n.current.parent.parent.add(n.current))}),[]),o.useFrame((()=>{a.current&&(Yt.setFromObject(a.current),Yt.getSize(Qt),n.current.position.set(a.current.position.x+Qt.x*(Array.isArray(t)?t[0]:t.x)/2,a.current.position.y+Qt.y*(Array.isArray(t)?t[1]:t.y)/2,a.current.position.z+Qt.z*(Array.isArray(t)?t[2]:t.z)/2))})),S.createElement("group",e({ref:n},r))},exports.Backdrop=function({children:e,floor:t=.25,segments:r=20,receiveShadow:n,...o}){const a=S.useRef(null);return S.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,In(a/r));o.needsUpdate=!0,a.current.computeVertexNormals()}),[r,t]),S.createElement("group",o,S.createElement("mesh",{receiveShadow:n,rotation:[-Math.PI/2,0,Math.PI/2]},S.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=Z,exports.Bounds=hn,exports.Box=Vr,exports.Bvh=Gt,exports.CameraControls=nt,exports.CameraShake=yn,exports.Capsule=rn,exports.CatmullRomLine=te,exports.Caustics=Hn,exports.Center=er,exports.Circle=Nr,exports.Clone=Ce,exports.Cloud=yo,exports.CloudInstance=xo,exports.Clouds=ho,exports.ComputedAttribute=({compute:t,name:r,...o})=>{const[a]=S.useState((()=>new n.BufferAttribute(new Float32Array(0),1))),i=S.useRef(null);return S.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]),S.createElement("primitive",e({ref:i,object:a,attach:`attributes-${r}`},o))},exports.Cone=Or,exports.ContactShadows=Dn,exports.CubeCamera=function({children:e,frames:t=1/0,resolution:r,near:n,far:a,envMap:i,fog:s,...l}){const c=S.useRef(null),{fbo:u,camera:m,update:d}=qe({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++)})),S.createElement("group",l,S.createElement("primitive",{object:m}),S.createElement("group",{ref:c},e(u.texture)))},exports.CubicBezierLine=ee,exports.CurveModifier=zr,exports.CycleRaycast=function({onChanged:e,portal:t,preventDefault:r=!0,scroll:n=!0,keyCode:a=9}){const i=S.useRef(0),s=o.useThree((e=>e.setEvents)),l=o.useThree((e=>e.get)),c=o.useThree((e=>e.gl));return S.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=jr,exports.Decal=_e,exports.Detailed=Qo,exports.DeviceOrientationControls=Xe,exports.Dodecahedron=Jr,exports.Edges=ze,exports.Effects=ce,exports.Environment=Rn,exports.EnvironmentCube=Tn,exports.EnvironmentMap=Sn,exports.EnvironmentPortal=Cn,exports.Example=tr,exports.Extrude=en,exports.FaceControls=Si,exports.FaceLandmarker=function({basePath:e=zi.basePath,options:r=zi.options,children:n}){const o=JSON.stringify(r),a=p.suspend((async()=>{const{FilesetResolver:t,FaceLandmarker:n}=await import("@mediapipe/tasks-vision"),o=await t.forVisionTasks(e);return n.createFromOptions(o,r)}),[e,o]);return t.useEffect((()=>()=>{null==a||a.close(),p.clear([e,o])}),[a,e,o]),S.createElement(gi.Provider,{value:a},n)},exports.FaceLandmarkerDefaults=zi,exports.Facemesh=hi,exports.FacemeshDatas=vi,exports.FacemeshEye=yi,exports.FacemeshEyeDefaults=xi,exports.FirstPersonControls=rt,exports.Fisheye=function({renderPriority:t=1,zoom:r=0,segments:n=64,children:a,resolution:i=896,...s}){const l=S.useRef(null),c=S.useRef(null),{width:u,height:m}=o.useThree((e=>e.size)),[d]=S.useState((()=>new C.OrthographicCamera));S.useLayoutEffect((()=>{d.position.set(0,0,100),d.zoom=100,d.left=u/-2,d.right=u/2,d.top=m/2,d.bottom=m/-2,d.updateProjectionMatrix()}),[u,m]);const f=Math.sqrt(u*u+m*m)/100*(.5+r/2),p=new C.Vector3,h=new C.Sphere(new C.Vector3,f),x=new C.Matrix3,y=S.useCallback(((e,t,r)=>{t.pointer.set(e.offsetX/t.size.width*2-1,-e.offsetY/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,d),t.raycaster.ray.intersectSphere(h,p)&&(p.normalize(),x.getNormalMatrix(c.current.camera.matrixWorld),c.current.camera.getWorldPosition(t.raycaster.ray.origin),t.raycaster.ray.direction.set(0,0,1).reflect(p),t.raycaster.ray.direction.x*=-1,t.raycaster.ray.direction.applyNormalMatrix(x).multiplyScalar(-1))}),[]);return o.useFrame((e=>{t&&e.gl.render(l.current,d)}),t),S.createElement(S.Fragment,null,S.createElement("mesh",e({ref:l},s,{scale:f}),S.createElement("sphereGeometry",{args:[1,n,n]}),S.createElement("meshBasicMaterial",null,S.createElement(aa,{compute:y,attach:"envMap",flip:!0,resolution:i,ref:c},a,S.createElement(la,{api:c})))))},exports.Float=vn,exports.FlyControls=Ze,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=S.useRef(null),f=S.useRef(null),p=S.useRef(!1),h=S.useRef(0),x=S.useRef(new n.Vector3(0,0,0)),y=S.useRef(new n.Vector3(0,0,0));S.useEffect((()=>{y.current.copy(c.up)}),[c]);const v=S.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(yt),ht.copy(c.quaternion),vt.copy(e).multiplyScalar(h.current).add(yt),ft.lookAt(vt),ft.up.copy(c.up),xt.copy(ft.quaternion),m()}),[u,c,i,m]);o.useFrame(((e,t)=>{if(f.current&&d.current){var r;if(p.current)if(ht.angleTo(xt)<.01)p.current=!1,"minPolarAngle"in u&&c.up.copy(y.current);else{const e=t*dt;ht.rotateTowards(xt,e),c.position.set(0,0,1).applyQuaternion(ht).multiplyScalar(h.current).add(x.current),c.up.set(0,1,0).applyQuaternion(ht).normalize(),c.quaternion.copy(ht),a?a():u&&u.update(),m()}pt.copy(c.matrix).invert(),null==(r=d.current)||r.quaternion.setFromRotationMatrix(pt)}}));const g=S.useMemo((()=>({tweenCamera:v})),[v]),[z,w]=t,b=e.endsWith("-center")?0:e.endsWith("-left")?-l.width/2+z:l.width/2-z,M=e.startsWith("center-")?0:e.startsWith("top-")?l.height/2-w:-l.height/2+w;return S.createElement(ct,{renderPriority:r},S.createElement(ut.Provider,{value:g},S.createElement(He,{makeDefault:!0,ref:f,position:[0,0,200]}),S.createElement("group",{ref:d,position:[b,M,0]},s)))},exports.GizmoViewcube=t=>S.createElement("group",{scale:[60,60,60]},S.createElement(Dt,t),Ct.map(((r,n)=>S.createElement(Ft,e({key:n,position:r,dimensions:Pt[n]},t)))),St.map(((r,n)=>S.createElement(Ft,e({key:n,position:r,dimensions:Tt},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}=mt(),x={font:o,disabled:n,labelColor:c,onClick:u,axisHeadScale:i,onPointerDown:n?void 0:e=>{h(e.object.position),e.stopPropagation()}};return S.createElement("group",e({scale:40},m),S.createElement(kt,{color:d,rotation:[0,0,0],scale:s}),S.createElement(kt,{color:f,rotation:[0,0,Math.PI/2],scale:s}),S.createElement(kt,{color:p,rotation:[0,-Math.PI/2,0],scale:s}),!r&&S.createElement(S.Fragment,null,S.createElement(_t,e({arcStyle:d,position:[1,0,0],label:l[0]},x)),S.createElement(_t,e({arcStyle:f,position:[0,1,0],label:l[1]},x)),S.createElement(_t,e({arcStyle:p,position:[0,0,1],label:l[2]},x)),!t&&S.createElement(S.Fragment,null,S.createElement(_t,e({arcStyle:d,position:[-1,0,0]},x)),S.createElement(_t,e({arcStyle:f,position:[0,-1,0]},x)),S.createElement(_t,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=ue.Linear,innerCircleRadius:s=0,outerCircleRadius:l="auto",...c}){const u=o.useThree((e=>e.gl)),m=S.useMemo((()=>{const e=document.createElement("canvas"),o=e.getContext("2d");let c;if(e.width=a,e.height=n,i===ue.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 S.createElement("canvasTexture",e({colorSpace:u.outputColorSpace,args:[m],attach:"map"},c))},exports.GradientType=ue,exports.Grid=Lt,exports.Html=U,exports.Hud=ct,exports.Icosahedron=Qr,exports.Image=ge,exports.Instance=hr,exports.Instances=xr,exports.IsObject=de,exports.KeyboardControls=function({map:e,children:t,onChange:r,domElement:n}){const o=e.map((e=>e.name+e.keys)).join("-"),i=S.useMemo((()=>a(u.subscribeWithSelector((()=>e.reduce(((e,t)=>({...e,[t.name]:!1})),{}))))),[o]),s=S.useMemo((()=>[i.subscribe,i.getState,i]),[o]),l=i.setState;return S.useEffect((()=>{const t=e.map((({name:e,keys:t,up:n})=>({keys:t,up:n,fn:t=>{l({[e]:t}),r&&r(e,t,s[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)},i=n||window;return i.addEventListener("keydown",o,{passive:!0}),i.addEventListener("keyup",a,{passive:!0}),()=>{i.removeEventListener("keydown",o),i.removeEventListener("keyup",a)}}),[n,o]),S.createElement(q.Provider,{value:s,children:t})},exports.Lathe=tn,exports.Lightformer=to,exports.Line=Q,exports.Loader=function({containerStyles:e,innerStyles:t,barStyles:r,dataStyles:n,dataInterpolation:o=N,initialState:a=(e=>e)}){const{active:i,progress:s}=V(),l=S.useRef(0),c=S.useRef(0),u=S.useRef(null),[m,d]=S.useState(a(i));S.useEffect((()=>{let e;return i!==m&&(e=setTimeout((()=>d(i)),300)),()=>clearTimeout(e)}),[m,i]);const f=S.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 S.useEffect((()=>(f(),()=>cancelAnimationFrame(c.current))),[f]),m?S.createElement("div",{style:{...O.container,opacity:i?1:0,...e}},S.createElement("div",null,S.createElement("div",{style:{...O.inner,...t}},S.createElement("div",{style:{...O.bar,transform:`scaleX(${s/100})`,...r}}),S.createElement("span",{ref:u,style:{...O.data,...n}})))):null},exports.MapControls=Ye,exports.MarchingCube=De,exports.MarchingCubes=Re,exports.MarchingPlane=Fe,exports.Mask=sa,exports.Merged=yr,exports.MeshDiscardMaterial=_r,exports.MeshDistortMaterial=br,exports.MeshPortalMaterial=ua,exports.MeshReflectorMaterial=Pr,exports.MeshRefractionMaterial=function({aberrationStrength:r=0,fastChroma:n=!0,envMap:a,...i}){o.extend({MeshRefractionMaterial:Rr});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;const t=null==(e=s.current)||null==(e=e.__r3f)||null==(e=e.parent)?void 0:e.geometry;t&&(s.current.bvh=new z.MeshBVHUniformStruct,s.current.bvh.updateFrom(new z.MeshBVH(t.clone().toNonIndexed(),{lazyGeneration:!1,strategy:z.SAH})))}),[]),o.useFrame((({camera:e})=>{s.current.viewMatrixInverse=e.matrixWorld,s.current.projectionMatrixInverse=e.projectionMatrixInverse})),S.createElement("meshRefractionMaterial",e({key:JSON.stringify(c),defines:c,ref:s,resolution:[l.width,l.height],aberrationStrength:r,envMap:a},i))},exports.MeshTransmissionMaterial=kr,exports.MeshWobbleMaterial=Er,exports.MotionPathControls=st,exports.Octahedron=Kr,exports.OrbitControls=Qe,exports.OrthographicCamera=He,exports.Outlines=function({color:t="black",opacity:r=1,transparent:n=!1,screenspace:a=!1,toneMapped:i=!0,polygonOffset:s=!1,polygonOffsetFactor:l=0,renderOrder:c=0,thickness:u=.05,angle:d=Math.PI,...f}){const p=S.useRef(),[h]=S.useState((()=>new we({side:C.BackSide}))),{gl:x}=o.useThree(),y=x.getDrawingBufferSize(new C.Vector2);S.useMemo((()=>o.extend({OutlinesMaterial:we})),[]);const v=S.useRef(0),g=S.useRef();return S.useLayoutEffect((()=>{const e=p.current;if(!e)return;const t=e.parent;if(t&&t.geometry&&(v.current!==d||g.current!==t.geometry)){v.current=d,g.current=t.geometry;let r=e.children[0];r&&(d&&r.geometry.dispose(),e.remove(r)),t.skeleton?(r=new C.SkinnedMesh,r.material=h,r.bind(t.skeleton,t.bindMatrix),e.add(r)):t.isInstancedMesh?(r=new C.InstancedMesh(t.geometry,h,t.count),r.instanceMatrix=t.instanceMatrix,e.add(r)):(r=new C.Mesh,r.material=h,e.add(r)),r.geometry=d?m.toCreasedNormals(t.geometry,d):t.geometry}})),S.useLayoutEffect((()=>{const e=p.current;if(!e)return;const m=e.children[0];m&&(m.renderOrder=c,o.applyProps(m.material,{transparent:n,thickness:u,color:t,opacity:r,size:y,screenspace:a,toneMapped:i,polygonOffset:s,polygonOffsetFactor:l}))})),S.useEffect((()=>()=>{const e=p.current;if(!e)return;const t=e.children[0];t&&(d&&t.geometry.dispose(),e.remove(t))}),[]),S.createElement("group",e({ref:p},f))},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=[]}}})),S.createElement(ra.Provider,{value:h},f)},exports.PerspectiveCamera=$e,exports.PivotControls=di,exports.Plane=Gr,exports.Point=Wo,exports.PointMaterial=Br,exports.PointMaterialImpl=Lr,exports.PointerLockControls=tt,exports.Points=Ho,exports.PointsBuffer=Go,exports.Polyhedron=Yr,exports.PositionPoint=Bo,exports.PositionalAudio=re,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 S.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=S.useMemo((()=>[d[0]+p[0],d[0]+p[1]]),[d[0],p[0],p[1]]),b=S.useMemo((()=>[d[1]+h[0],d[1]+h[1]]),[d[1],h[0],h[1]]),M=S.useMemo((()=>[n.MathUtils.clamp(d[0],...w),n.MathUtils.clamp(d[1],...b),d[2]]),[d[0],d[1],d[2],w,b]),[E,T]=l.useSpring((()=>({scale:1,rotation:M,config:x})));S.useEffect((()=>{T.start({scale:1,rotation:M,config:x})}),[M]),S.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]=E.rotation.animation.to||M})=>{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 T.start({scale:e&&a>w[1]/2?f:1,rotation:r&&!e?M:[a,o,0],config:e=>"scale"===e?{...c,friction:3*c.friction}:c}),[a,o]}},{target:a?g:void 0});return S.createElement(l.a.group,e({},null==C?void 0:C(),E),u)},exports.QuadraticBezierLine=J,exports.RandomizedLight=An,exports.Reflector=$n,exports.RenderCubeTexture=aa,exports.RenderTexture=na,exports.Resize=cn,exports.Ring=Zr,exports.RoundedBox=an,exports.Sampler=function({children:t,weight:r,transform:n,instances:o,mesh:a,count:i=16,...s}){const l=S.useRef(null),c=S.useRef(null),u=S.useRef(null);return S.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]),Te(u,i,n,r,c),S.createElement("group",e({ref:l},s),t)},exports.ScreenQuad=ln,exports.ScreenSpace=Y,exports.Scroll=$,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]=S.useState((()=>document.createElement("div"))),[g]=S.useState((()=>document.createElement("div"))),[z]=S.useState((()=>document.createElement("div"))),w=p.domElement.parentNode,b=S.useRef(0),M=S.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]);S.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]),S.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-M.offset;v[n?"scrollLeft":"scrollTop"]=1,b.current=M.offset=-e,s=!0}else if(i<=0){const e=1+M.offset;v[n?"scrollLeft":"scrollTop"]=o,b.current=M.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,M,x,n,t]);let E=0;return o.useFrame(((t,r)=>{E=M.offset,s.easing.damp(M,"offset",b.current,l,r,c,void 0,e),s.easing.damp(M,"delta",Math.abs(E-M.offset),l,r,c,void 0,e),M.delta>e&&x()})),S.createElement(j.Provider,{value:M},m)},exports.Segment=Yo,exports.SegmentObject=Xo,exports.Segments=qo,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[f,p]=S.useState(!1),{setEvents:h,camera:x,raycaster:y,gl:v,controls:g,size:z,get:w}=o.useThree(),[b,M]=S.useState(!1),[E,T]=S.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]),[]);S.useEffect((()=>{f?null==a||a(E):null==i||i(E)}),[E,f]);const P=S.useCallback((e=>{e.stopPropagation(),T({object:c([e.object])[0],shift:r&&e.shiftKey})}),[]),R=S.useCallback((e=>!b&&T({})),[b]),D=S.useRef(null);return S.useEffect((()=>{if(!t||!r)return;const e=new m.SelectionBox(x,D.current),n=document.createElement("div");n.style.pointerEvents="none",n.style.border=s,n.style.backgroundColor=l,n.style.position="fixed";const o=new C.Vector2,a=new C.Vector2,i=new C.Vector2,u=w().events.enabled,f=null==g?void 0:g.enabled;let y=!1;function b(e,t){const{offsetX:r,offsetY:n}=e,{width:o,height:a}=z;t.set(r/o*2-1,-n/a*2+1)}function M(t){t.shiftKey&&(!function(e){var t;g&&(g.enabled=!1),h({enabled:!1}),p(y=!0),null==(t=v.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),b(t,e.startPoint))}let E=[];function S(t){if(y){!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),b(t,e.endPoint);const r=e.select().sort((e=>e.uuid)).filter((e=>e.isMesh));d(r,E)||(E=r,T({object:c(r)}))}}function P(e){var t;y&&y&&(g&&(g.enabled=f),h({enabled:u}),p(y=!1),null==(t=n.parentElement)||t.removeChild(n))}return document.addEventListener("pointerdown",M,{passive:!0}),document.addEventListener("pointermove",S,{passive:!0,capture:!0}),document.addEventListener("pointerup",P,{passive:!0}),()=>{document.removeEventListener("pointerdown",M),document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",P)}}),[z.width,z.height,y,x,g,v]),S.createElement("group",e({ref:D,onClick:P,onPointerOver:()=>M(!0),onPointerOut:()=>M(!1),onPointerMissed:R},u),S.createElement(X.Provider,{value:E},n))},exports.Shadow=Vn,exports.ShadowAlpha=function({opacity:e,alphaMap:t}){const r=S.useRef(null),n=S.useRef(null),a=S.useRef({value:1}),i=S.useRef({value:null}),s=S.useRef({value:!1});return S.useLayoutEffect((()=>{r.current.onBeforeCompile=n.current.onBeforeCompile=e=>{const t=e.fragmentShader.indexOf("void main");let r,n="",o=t;for(;"\n"!==r&&o<t+100;)r=e.fragmentShader.charAt(o),n+=r,o++;n=n.trim(),e.vertexShader=e.vertexShader.replace("void main() {","\n varying vec2 custom_vUv;\n\n void main() {\n custom_vUv = uv;\n \n "),e.fragmentShader=e.fragmentShader.replace(n,"\n uniform float uShadowOpacity;\n uniform sampler2D uAlphaMap;\n uniform bool uHasAlphaMap;\n\n varying vec2 custom_vUv;\n \n float bayerDither2x2( vec2 v ) {\n return mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n }\n \n float bayerDither4x4( vec2 v ) {\n vec2 P1 = mod( v, 2.0 );\n vec2 P2 = mod( floor( 0.5 * v ), 2.0 );\n return 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n }\n \n void main() {\n float alpha = \n uHasAlphaMap ? \n uShadowOpacity * texture2D(uAlphaMap, custom_vUv).x\n : uShadowOpacity;\n\n if( ( bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) ) ) / 16.0 >= alpha ) discard;\n \n "),e.uniforms.uShadowOpacity=a.current,e.uniforms.uAlphaMap=i.current,e.uniforms.uHasAlphaMap=s.current}}),[]),o.useFrame((()=>{var n;const o=null==(n=r.current.__r3f)?void 0:n.parent;if(o){const r=o.material;r&&(a.current.value=null!=e?e:r.opacity,!1===t?(i.current.value=null,s.current.value=!1):(i.current.value=t||r.alphaMap,s.current.value=!!i.current.value))}})),S.createElement(S.Fragment,null,S.createElement("meshDepthMaterial",{ref:r,attach:"customDepthMaterial",depthPacking:C.RGBADepthPacking}),S.createElement("meshDistanceMaterial",{ref:n,attach:"customDistanceMaterial"}))},exports.Shape=nn,exports.Sky=no,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 S.useEffect((()=>{const o=C.ShaderChunk.shadowmap_pars_fragment;return C.ShaderChunk.shadowmap_pars_fragment=C.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 )"),Ur(n,a,i),()=>{C.ShaderChunk.shadowmap_pars_fragment=o,Ur(n,a,i)}}),[e,r,t]),null},exports.Sparkles=Mo,exports.Sphere=Wr,exports.Splat=function({src:t,toneMapped:r=!1,alphaTest:n=0,alphaHash:a=!1,chunkSize:i=25e3,...s}){o.extend({SplatMaterial:Ne});const l=S.useRef(null),c=o.useThree((e=>e.gl)),u=o.useThree((e=>e.camera)),m=o.useLoader(je,t,(e=>{e.gl=c,e.chunkSize=i}));return S.useLayoutEffect((()=>m.connect(l.current)),[t]),o.useFrame((()=>m.update(l.current,u,a))),S.createElement("mesh",e({ref:l,frustumCulled:!1},s),S.createElement("splatMaterial",{key:`${t}/${n}/${a}${Ne.key}`,transparent:!a,depthTest:!0,alphaTest:a?0:n,centerAndScaleTexture:m.centerAndScaleTexture,covAndColorTexture:m.covAndColorTexture,depthWrite:!!a||n>0,blending:a?C.NormalBlending:C.CustomBlending,blendSrcAlpha:C.OneFactor,alphaHash:!!a,toneMapped:r}))},exports.SpotLight=eo,exports.SpotLightShadow=function(e){return e.shader?S.createElement(Kn,e):S.createElement(Jn,e)},exports.SpriteAnimator=gr,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?Bn[s]:s,[{radius:v,height:g},z]=S.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,M=null!==(m=null==a?void 0:a.size)&&void 0!==m?m:1024,E=null!==(d=null==a?void 0:a.offset)&&void 0!==d?d:0,T="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=S.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 S.createElement(S.Fragment,null,S.createElement("ambientLight",{intensity:o/3}),S.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":M}),S.createElement("pointLight",{position:[y.fill[0]*v,y.fill[1]*v,y.fill[2]*v],intensity:o}),S.createElement(hn,e({fit:!!n,clip:!!n,margin:Number(n),observe:!0},l),S.createElement(Un,{radius:v,adjustCamera:n}),S.createElement(er,e({},r,{position:[0,E/2,0],onCentered:D}),t)),S.createElement("group",{position:[0,-g/2-E/2,0]},T&&S.createElement(Dn,e({scale:4*v,far:v,blur:2},P)),C&&S.createElement(_n,e({temporal:!0,frames:100,alphaTest:.9,toneMapped:!0,scale:4*v},P),S.createElement(An,{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:M}))),i&&S.createElement(Rn,R))},exports.Stars=io,exports.Stats=function({showPanel:e=0,className:t,parent:r}){const n=function(e,t=[],r){const[n,o]=S.useState();return S.useLayoutEffect((()=>{const t=e();return o(t),Ot(r,t),()=>Ot(r,null)}),t),n}((()=>new y),[]);return S.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.StatsGl=function({className:e,parent:t,...r}){const n=o.useThree((e=>e.gl)),a=S.useMemo((()=>{const e=new v({...r});return e.init(n),e}),[n]);return S.useEffect((()=>{if(a){const r=t&&t.current||document.body;null==r||r.appendChild(a.dom),e&&a.container.classList.add(...e.split(" ").filter((e=>e)));const n=o.addAfterEffect((()=>a.update()));return()=>{null==r||r.removeChild(a.dom),n()}}}),[t,a,e]),null},exports.Svg=Ae,exports.Tetrahedron=Xr,exports.Text=ne,exports.Text3D=le,exports.Torus=$r,exports.TorusKnot=qr,exports.TrackballControls=Ke,exports.Trail=Se,exports.TransformControls=et,exports.Tube=Hr,exports.View=Ea,exports.Wireframe=function({geometry:t,...r}){return t?S.createElement(Do,e({geometry:t},r)):S.createElement(Fo,r)},exports.accumulativeContext=Fn,exports.calcPosFromAngles=ro,exports.calculateScaleFactor=Xa,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(),ea.copy(r.boundingSphere),ea.applyMatrix4(o),!1!==e.ray.intersectsSphere(ea)&&(Ko.copy(o).invert(),Jo.copy(e.ray).applyMatrix4(Ko),null!==r.boundingBox&&null===Jo.intersectBox(r.boundingBox,ta)||t.push({distance:ta.distanceTo(e.ray.origin),point:ta.clone(),object:this})))},exports.shaderMaterial=me,exports.useAnimations=function(e,t){const r=S.useRef(),[a]=S.useState((()=>t?t instanceof n.Object3D?{current:t}:t:r)),[i]=S.useState((()=>new n.AnimationMixer(void 0)));S.useLayoutEffect((()=>{t&&(a.current=t instanceof n.Object3D?t:t.current),i._root=a.current}));const s=S.useRef({}),l=S.useMemo((()=>{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}}),[e]);return o.useFrame(((e,t)=>i.update(t))),S.useEffect((()=>{const e=a.current;return()=>{s.current={},i.stopAllAction(),Object.values(l.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),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:z.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,indirect:!1,...t},S.useEffect((()=>{if(e.current){e.current.raycast=z.acceleratedRaycast;const r=e.current.geometry;return r.computeBoundsTree=z.computeBoundsTree,r.disposeBoundsTree=z.disposeBoundsTree,r.computeBoundsTree(t),()=>{r.boundsTree&&r.disposeBoundsTree()}}}),[e,JSON.stringify(t)])},exports.useBounds=xn,exports.useBoxProjectedEnv=function(e=new C.Vector3,t=new C.Vector3){const[r]=S.useState((()=>({position:new C.Vector3,size:new C.Vector3})));o.applyProps(r,{position:e,size:t});const n=S.useRef(null),a=S.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>",$t)}`,e.fragmentShader=`\n ${qt}\n ${e.fragmentShader.replace("#include <envmap_physical_pars_fragment>",C.ShaderChunk.envmap_physical_pars_fragment).replace("vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",`vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n ${Xt}\n `).replace("reflectVec = inverseTransformDirection( reflectVec, viewMatrix );",`reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n ${Zt}\n `)}`}(e,r.position,r.size),customProgramCacheKey:()=>JSON.stringify(r.position.toArray())+JSON.stringify(r.size.toArray())})),[...r.position.toArray(),...r.size.toArray()]);return S.useLayoutEffect((()=>{n.current.needsUpdate=!0}),[r]),a},exports.useCamera=function(e,t){const r=o.useThree((e=>e.pointer)),[a]=S.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=S.useRef([]);return t.current=e.map((e=>S.useContext(e))),S.useMemo((()=>({children:r})=>e.reduceRight(((e,r,n)=>S.createElement(r.Provider,{value:t.current[n],children:e})),r)),[])},exports.useCubeCamera=qe,exports.useCubeTexture=Bt,exports.useCursor=function(e,t="pointer",r="auto",n=document.body){S.useEffect((()=>{if(e)return n.style.cursor=t,()=>{n.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=S.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=Ge(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((()=>g.getGPUTier(e)),["useDetectGPU"]),exports.useEnvironment=bn,exports.useFBO=Ge,exports.useFBX=Ut,exports.useFaceControls=Ti,exports.useFaceLandmarker=wi,exports.useFont=ie,exports.useGLTF=Ie,exports.useGizmoContext=mt,exports.useHelper=jt,exports.useIntersect=Ht,exports.useKTX2=Vt,exports.useKeyboardControls=function(e){const[t,r,n]=S.useContext(q);return e?n(e):[t,r]},exports.useMask=function(e,t=!1){return{stencilWrite:!0,stencilRef:e,stencilFunc:t?C.NotEqualStencilFunc:C.EqualStencilFunc,stencilFail:C.KeepStencilOp,stencilZFail:C.KeepStencilOp,stencilZPass:C.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=S.useMemo((()=>Object.keys(n).length),[]),i=`${S.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[fe(s,r),s,a]},exports.useMotion=at,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=S.useMemo((()=>Object.keys(s).length),[]),c=s[0],u=`https://rawcdn.githack.com/pmndrs/drei-assets/7a3104997e1576f83472829815b00880d88b32fb/normals/${s[e]||c}`,m=fe(u,r);return S.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(ra),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=V,exports.useScroll=W,exports.useSelect=function(){return S.useContext(X)},exports.useSpriteAnimator=function(){return S.useContext(vr)},exports.useSurfaceSampler=Te,exports.useTexture=fe,exports.useTrail=Ee,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 Jt(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=Nt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/extends"),t=require("react"),r=require("react-dom/client"),n=require("three"),a=require("@react-three/fiber"),o=require("zustand"),i=require("react-merge-refs"),s=require("maath"),l=require("@react-spring/three"),c=require("@use-gesture/react"),u=require("zustand/middleware"),d=require("three-stdlib"),m=require("zustand/shallow"),f=require("troika-three-text"),p=require("suspend-react"),h=require("meshline"),x=require("camera-controls"),y=require("stats.js"),v=require("stats-gl"),g=require("detect-gpu"),z=require("three-mesh-bvh"),w=require("react-composer"),b=require("uuid"),M=require("tunnel-rat");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function S(e){if(e&&e.__esModule)return 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=E(e),C=S(t),P=S(r),R=S(n),D=E(o),F=E(i),k=E(m),_=E(x),A=E(y),L=E(v),B=E(w),U=E(M);const I=new n.Vector3,V=new n.Vector3,N=new n.Vector3;function O(e,t,r){const n=I.setFromMatrixPosition(e.matrixWorld);n.project(t);const a=r.width/2,o=r.height/2;return[n.x*a+a,-n.y*o+o]}const j=e=>Math.abs(e)<1e-10?0:e;function W(e,t,r=""){let n="matrix3d(";for(let r=0;16!==r;r++)n+=j(t[r]*e.elements[r])+(15!==r?",":")");return r+n}const G=(H=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>W(e,H));var H;const $=(e,t)=>{return W(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 q=C.forwardRef((({children:e,eps:t=.001,style:r,className:o,prepend:i,center:s,fullscreen:l,portal:c,distanceFactor:u,sprite:d=!1,transform:m=!1,occlude:f,onOcclude:p,castShadow:h,receiveShadow:x,material:y,geometry:v,zIndexRange:g=[16777271,0],calculatePosition:z=O,as:w="div",wrapperClass:b,pointerEvents:M="auto",...E},S)=>{const{gl:R,camera:D,scene:F,size:k,raycaster:_,events:A,viewport:L}=a.useThree(),[B]=C.useState((()=>document.createElement(w))),U=C.useRef(),W=C.useRef(null),H=C.useRef(0),q=C.useRef([0,0]),X=C.useRef(null),Z=C.useRef(null),Y=(null==c?void 0:c.current)||A.connected||R.domElement.parentNode,Q=C.useRef(null),K=C.useRef(!1),J=C.useMemo((()=>f&&"blending"!==f||Array.isArray(f)&&f.length&&function(e){return e&&"object"==typeof e&&"current"in e}(f[0])),[f]);C.useLayoutEffect((()=>{const e=R.domElement;f&&"blending"===f?(e.style.zIndex=`${Math.floor(g[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)}),[f]),C.useLayoutEffect((()=>{if(W.current){const e=U.current=P.createRoot(B);if(F.updateMatrixWorld(),m)B.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const e=z(W.current,D,k);B.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return Y&&(i?Y.prepend(B):Y.appendChild(B)),()=>{Y&&Y.removeChild(B),e.unmount()}}}),[Y,m]),C.useLayoutEffect((()=>{b&&(B.className=b)}),[b]);const ee=C.useMemo((()=>m?{position:"absolute",top:0,left:0,width:k.width,height:k.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:s?"translate3d(-50%,-50%,0)":"none",...l&&{top:-k.height/2,left:-k.width/2,width:k.width,height:k.height},...r}),[r,s,l,k,m]),te=C.useMemo((()=>({position:"absolute",pointerEvents:M})),[M]);C.useLayoutEffect((()=>{var t,n;(K.current=!1,m)?null==(t=U.current)||t.render(C.createElement("div",{ref:X,style:ee},C.createElement("div",{ref:Z,style:te},C.createElement("div",{ref:S,className:o,style:r,children:e})))):null==(n=U.current)||n.render(C.createElement("div",{ref:S,style:ee,className:o,children:e}))}));const re=C.useRef(!0);a.useFrame((e=>{if(W.current){D.updateMatrixWorld(),W.current.updateWorldMatrix(!0,!1);const e=m?q.current:z(W.current,D,k);if(m||Math.abs(H.current-D.zoom)>t||Math.abs(q.current[0]-e[0])>t||Math.abs(q.current[1]-e[1])>t){const t=function(e,t){const r=I.setFromMatrixPosition(e.matrixWorld),n=V.setFromMatrixPosition(t.matrixWorld),a=r.sub(n),o=t.getWorldDirection(N);return a.angleTo(o)>Math.PI/2}(W.current,D);let r=!1;J&&(Array.isArray(f)?r=f.map((e=>e.current)):"blending"!==f&&(r=[F]));const a=re.current;if(r){const e=function(e,t,r,n){const a=I.setFromMatrixPosition(e.matrixWorld),o=a.clone();o.project(t),r.setFromCamera(o,t);const i=r.intersectObjects(n,!0);if(i.length){const e=i[0].distance;return a.distanceTo(r.ray.origin)<e}return!0}(W.current,D,_,r);re.current=e&&!t}else re.current=!t;a!==re.current&&(p?p(!re.current):B.style.display=re.current?"block":"none");const o=Math.floor(g[0]/2),i=f?J?[g[0],o]:[o-1,0]:g;if(B.style.zIndex=`${function(e,t,r){if(t instanceof n.PerspectiveCamera||t instanceof n.OrthographicCamera){const n=I.setFromMatrixPosition(e.matrixWorld),a=V.setFromMatrixPosition(t.matrixWorld),o=n.distanceTo(a),i=(r[1]-r[0])/(t.far-t.near),s=r[1]-i*t.far;return Math.round(i*o+s)}}(W.current,D,i)}`,m){const[e,t]=[k.width/2,k.height/2],r=D.projectionMatrix.elements[5]*t,{isOrthographicCamera:n,top:a,left:o,bottom:i,right:s}=D,l=G(D.matrixWorldInverse),c=n?`scale(${r})translate(${j(-(s+o)/2)}px,${j((a+i)/2)}px)`:`translateZ(${r}px)`;let m=W.current.matrixWorld;d&&(m=D.matrixWorldInverse.clone().transpose().copyPosition(m).scale(W.current.scale),m.elements[3]=m.elements[7]=m.elements[11]=0,m.elements[15]=1),B.style.width=k.width+"px",B.style.height=k.height+"px",B.style.perspective=n?"":`${r}px`,X.current&&Z.current&&(X.current.style.transform=`${c}${l}translate(${e}px,${t}px)`,Z.current.style.transform=$(m,1/((u||10)/400)))}else{const t=void 0===u?1:function(e,t){if(t instanceof n.OrthographicCamera)return t.zoom;if(t instanceof n.PerspectiveCamera){const r=I.setFromMatrixPosition(e.matrixWorld),n=V.setFromMatrixPosition(t.matrixWorld),a=t.fov*Math.PI/180,o=r.distanceTo(n);return 1/(2*Math.tan(a/2)*o)}return 1}(W.current,D)*u;B.style.transform=`translate3d(${e[0]}px,${e[1]}px,0) scale(${t})`}q.current=e,H.current=D.zoom}}if(!J&&Q.current&&!K.current)if(m){if(X.current){const e=X.current.children[0];if(null!=e&&e.clientWidth&&null!=e&&e.clientHeight){const{isOrthographicCamera:t}=D;if(t||v)E.scale&&(Array.isArray(E.scale)?E.scale instanceof n.Vector3?Q.current.scale.copy(E.scale.clone().divideScalar(1)):Q.current.scale.set(1/E.scale[0],1/E.scale[1],1/E.scale[2]):Q.current.scale.setScalar(1/E.scale));else{const t=(u||10)/400,r=e.clientWidth*t,n=e.clientHeight*t;Q.current.scale.set(r,n,1)}K.current=!0}}}else{const t=B.children[0];if(null!=t&&t.clientWidth&&null!=t&&t.clientHeight){const e=1/L.factor,r=t.clientWidth*e,n=t.clientHeight*e;Q.current.scale.set(r,n,1),K.current=!0}Q.current.lookAt(e.camera.position)}}));const ne=C.useMemo((()=>({vertexShader:m?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 "})),[m]);return C.createElement("group",T.default({},E,{ref:W}),f&&!J&&C.createElement("mesh",{castShadow:h,receiveShadow:x,ref:Q},v||C.createElement("planeGeometry",null),y||C.createElement("shaderMaterial",{side:n.DoubleSide,vertexShader:ne.vertexShader,fragmentShader:ne.fragmentShader})))}));let X=0;const Z=D.default((e=>(n.DefaultLoadingManager.onStart=(t,r,n)=>{e({active:!0,item:t,loaded:r,total:n,progress:(r-X)/(n-X)*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&&(X=n),e({active:!0,item:t,loaded:r,total:n,progress:(r-X)/(n-X)*100||100})},{errors:[],active:!1,progress:0,item:"",loaded:0,total:0}))),Y=e=>`Loading ${e.toFixed(2)}%`;const Q={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"}},K=C.createContext(null);function J(){return C.useContext(K)}const ee=C.forwardRef((({children:e},t)=>{const r=C.useRef(null),n=J(),{width:o,height:i}=a.useThree((e=>e.viewport));return a.useFrame((()=>{r.current.position.x=n.horizontal?-o*(n.pages-1)*n.offset:0,r.current.position.y=n.horizontal?0:i*(n.pages-1)*n.offset})),C.createElement("group",{ref:F.default([t,r])},e)})),te=C.forwardRef((({children:e,style:t,...r},n)=>{const o=J(),i=C.useRef(null),{width:s,height:l}=a.useThree((e=>e.size)),c=C.useContext(a.context),u=C.useMemo((()=>P.createRoot(o.fixed)),[o.fixed]);return a.useFrame((()=>{o.delta>o.eps&&(i.current.style.transform=`translate3d(${o.horizontal?-s*(o.pages-1)*o.offset:0}px,${o.horizontal?0:l*(o.pages-1)*-o.offset}px,0)`)})),u.render(C.createElement("div",T.default({ref:F.default([n,i]),style:{...t,position:"absolute",top:0,left:0,willChange:"transform"}},r),C.createElement(K.Provider,{value:o},C.createElement(a.context.Provider,{value:c},e)))),null})),re=C.forwardRef((({html:e,...t},r)=>{const n=e?te:ee;return C.createElement(n,T.default({ref:r},t))}));const ne=C.createContext(null);const ae=C.createContext([]);const oe=C.forwardRef((function({children:e,follow:t=!0,lockX:r=!1,lockY:o=!1,lockZ:i=!1,...s},l){const c=C.useRef(null),u=C.useRef(null),d=new n.Quaternion;return a.useFrame((({camera:e})=>{if(!t||!u.current)return;const n=u.current.rotation.clone();u.current.updateMatrix(),u.current.updateWorldMatrix(!1,!1),u.current.getWorldQuaternion(d),e.getWorldQuaternion(c.current.quaternion).premultiply(d.invert()),r&&(u.current.rotation.x=n.x),o&&(u.current.rotation.y=n.y),i&&(u.current.rotation.z=n.z)})),C.useImperativeHandle(l,(()=>u.current),[]),C.createElement("group",T.default({ref:u,matrixAutoUpdate:!1,matrixWorldAutoUpdate:!1},s),C.createElement("group",{ref:c},e))})),ie=C.forwardRef((({children:e,depth:t=-1,...r},n)=>{const o=C.useRef(null);return a.useFrame((({camera:e})=>{o.current.quaternion.copy(e.quaternion),o.current.position.copy(e.position)})),C.createElement("group",T.default({ref:F.default([n,o])},r),C.createElement("group",{"position-z":-t},e))})),se=new R.Vector3,le=new R.Vector3,ce=new R.Vector3,ue=(e,t,r,n=1)=>{const a=se.set(e.x/r.width*2-1,-e.y/r.height*2+1,n);return a.unproject(t),a},de=(e,t,r,n)=>{const a=((e,t,r)=>{const n=r.width/2,a=r.height/2;t.updateMatrixWorld(!1);const o=e.project(t);return o.x=o.x*n+n,o.y=-o.y*a+a,o})(ce.copy(e),r,n);let o=0;for(let i=0;i<2;++i){const s=le.copy(a).setComponent(i,a.getComponent(i)+t),l=ue(s,r,n,s.z);o=Math.max(o,e.distanceTo(l))}return o},me=new n.Vector3,fe=t.forwardRef((({scale:e=1,...r},n)=>{const o=t.useRef(null);return a.useFrame((t=>{const r=o.current;if(!r)return;const n=de(r.getWorldPosition(me),e,t.camera,t.size);r.scale.setScalar(n*e)})),C.createElement("object3D",T.default({ref:F.default([o,n])},r))})),pe=C.forwardRef((function({points:e,color:t="black",vertexColors:r,linewidth:o,lineWidth:i,segments:s,dashed:l,...c},u){var m;const f=a.useThree((e=>e.size)),p=C.useMemo((()=>s?new d.LineSegments2:new d.Line2),[s]),[h]=C.useState((()=>new d.LineMaterial)),x=4===(null==r||null==(m=r[0])?void 0:m.length)?4:3,y=C.useMemo((()=>{const t=s?new d.LineSegmentsGeometry:new d.LineGeometry,a=e.map((e=>{const t=Array.isArray(e);return e instanceof n.Vector3||e instanceof n.Vector4?[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(t.setPositions(a.flat()),r){const e=r.map((e=>e instanceof n.Color?e.toArray():e));t.setColors(e.flat(),x)}return t}),[e,s,r,x]);return C.useLayoutEffect((()=>{p.computeLineDistances()}),[e,p]),C.useLayoutEffect((()=>{l?h.defines.USE_DASH="":delete h.defines.USE_DASH,h.needsUpdate=!0}),[l,h]),C.useEffect((()=>()=>y.dispose()),[y]),C.createElement("primitive",T.default({object:p,ref:u},c),C.createElement("primitive",{object:y,attach:"geometry"}),C.createElement("primitive",T.default({object:h,attach:"material",color:t,vertexColors:Boolean(r),resolution:[f.width,f.height],linewidth:null!=o?o:i,dashed:l,transparent:4===x},c)))})),he=new n.Vector3,xe=C.forwardRef((function({start:e=[0,0,0],end:t=[0,0,0],mid:r,segments:a=20,...o},i){const s=C.useRef(null),[l]=C.useState((()=>new n.QuadraticBezierCurve3(void 0,void 0,void 0))),c=C.useCallback(((e,t,r,a=20)=>(e instanceof n.Vector3?l.v0.copy(e):l.v0.set(...e),t instanceof n.Vector3?l.v2.copy(t):l.v2.set(...t),r instanceof n.Vector3?l.v1.copy(r):Array.isArray(r)?l.v1.set(...r):l.v1.copy(l.v0.clone().add(l.v2.clone().sub(l.v0)).add(he.set(0,l.v0.y-l.v2.y,0))),l.getPoints(a))),[]);C.useLayoutEffect((()=>{s.current.setPoints=(e,t,r)=>{const n=c(e,t,r);s.current.geometry&&s.current.geometry.setPositions(n.map((e=>e.toArray())).flat())}}),[]);const u=C.useMemo((()=>c(e,t,r,a)),[e,t,r,a]);return C.createElement(pe,T.default({ref:F.default([s,i]),points:u},o))})),ye=C.forwardRef((function({start:e,end:t,midA:r,midB:a,segments:o=20,...i},s){const l=C.useMemo((()=>{const i=e instanceof n.Vector3?e:new n.Vector3(...e),s=t instanceof n.Vector3?t:new n.Vector3(...t),l=r instanceof n.Vector3?r:new n.Vector3(...r),c=a instanceof n.Vector3?a:new n.Vector3(...a);return new n.CubicBezierCurve3(i,l,c,s).getPoints(o)}),[e,t,r,a,o]);return C.createElement(pe,T.default({ref:s,points:l},i))})),ve=C.forwardRef((function({points:e,closed:t=!1,curveType:r="centripetal",tension:a=.5,segments:o=20,vertexColors:i,...s},l){const c=C.useMemo((()=>{const o=e.map((e=>e instanceof n.Vector3?e:new n.Vector3(...e)));return new n.CatmullRomCurve3(o,t,r,a)}),[e,t,r,a]),u=C.useMemo((()=>c.getPoints(o)),[c,o]),d=C.useMemo((()=>{if(!i||i.length<2)return;if(i.length===o+1)return i;const e=i.map((e=>e instanceof n.Color?e:new n.Color(...e)));t&&e.push(e[0].clone());const r=[e[0]],a=o/(e.length-1);for(let t=1;t<o;t++){const n=t%a/a,o=Math.floor(t/a);r.push(e[o].clone().lerp(e[o+1],n))}return r.push(e[e.length-1]),r}),[i,o]);return C.createElement(pe,T.default({ref:l,points:u,vertexColors:d},s))})),ge=C.forwardRef((({url:e,distance:t=1,loop:r=!0,autoplay:o,...i},s)=>{const l=C.useRef(),c=a.useThree((({camera:e})=>e)),[u]=C.useState((()=>new n.AudioListener)),d=a.useLoader(n.AudioLoader,e);return C.useEffect((()=>{const e=l.current;e&&(e.setBuffer(d),e.setRefDistance(t),e.setLoop(r),o&&!e.isPlaying&&e.play())}),[d,c,t,r]),C.useEffect((()=>{const e=l.current;return c.add(u),()=>{c.remove(u),e&&(e.isPlaying&&e.stop(),e.source&&e.source._connected&&e.disconnect())}}),[]),C.createElement("positionalAudio",T.default({ref:F.default([l,s]),args:[u]},i))})),ze=C.forwardRef((({sdfGlyphSize:e=64,anchorX:t="center",anchorY:r="middle",font:n,fontSize:o=1,children:i,characters:s,onSync:l,...c},u)=>{const d=a.useThree((({invalidate:e})=>e)),[m]=C.useState((()=>new f.Text)),[h,x]=C.useMemo((()=>{const e=[];let t="";return C.Children.forEach(i,(r=>{"string"==typeof r||"number"==typeof r?t+=r:e.push(r)})),[e,t]}),[i]);return p.suspend((()=>new Promise((e=>f.preloadFont({font:n,characters:s},e)))),["troika-text",n,s]),C.useLayoutEffect((()=>{m.sync((()=>{d(),l&&l(m)}))})),C.useEffect((()=>()=>m.dispose()),[m]),C.createElement("primitive",T.default({object:m,ref:u,font:n,text:x,anchorX:t,anchorY:r,fontSize:o,sdfGlyphSize:e},c),h)}));let we=null;async function be(e){we||(we=new d.FontLoader);let t="string"==typeof e?await(await fetch(e)).json():e;return we.parse(t)}function Me(e){return p.suspend(be,[e])}Me.preload=e=>p.preload(be,[e]),Me.clear=e=>p.clear([e]);const Ee=["string","number"],Se=C.forwardRef((({font:e,letterSpacing:r=0,lineHeight:n=1,size:o=1,height:i=.2,bevelThickness:s=.1,bevelSize:l=.01,bevelEnabled:c=!1,bevelOffset:u=0,bevelSegments:m=4,curveSegments:f=8,smooth:p,children:h,...x},y)=>{C.useMemo((()=>a.extend({RenamedTextGeometry:d.TextGeometry})),[]);const v=C.useRef(null),g=Me(e),z=t.useMemo((()=>({font:g,size:o,height:i,bevelThickness:s,bevelSize:l,bevelEnabled:c,bevelSegments:m,bevelOffset:u,curveSegments:f,letterSpacing:r,lineHeight:n})),[g,o,i,s,l,c,m,u,f,r,n]),[w,...b]=t.useMemo((()=>(e=>{let t="";const r=[];return C.Children.forEach(e,(e=>{Ee.includes(typeof e)?t+=e+"":r.push(e)})),[t,...r]})(h)),[h]),M=C.useMemo((()=>[w,z]),[w,z]);return C.useLayoutEffect((()=>{p&&(v.current.geometry=d.mergeVertices(v.current.geometry,p),v.current.geometry.computeVertexNormals())}),[M,p]),C.useImperativeHandle(y,(()=>v.current),[]),C.createElement("mesh",T.default({},x,{ref:v}),C.createElement("renamedTextGeometry",{args:M}),b)})),Te=C.forwardRef((({children:e,multisamping:t=8,renderIndex:r=1,disableRender:o,disableGamma:i,disableRenderPass:s,depthBuffer:l=!0,stencilBuffer:c=!1,anisotropy:u=1,encoding:m,type:f,...p},h)=>{C.useMemo((()=>a.extend({EffectComposer:d.EffectComposer,RenderPass:d.RenderPass,ShaderPass:d.ShaderPass})),[]);const x=C.useRef(),{scene:y,camera:v,gl:g,size:z,viewport:w}=a.useThree(),[b]=C.useState((()=>{const e=new n.WebGLRenderTarget(z.width,z.height,{type:f||n.HalfFloatType,format:n.RGBAFormat,depthBuffer:l,stencilBuffer:c,anisotropy:u});return f===n.UnsignedByteType&&null!=m&&("colorSpace"in e?e.texture.colorSpace=m:e.texture.encoding=m),e.samples=t,e}));C.useEffect((()=>{var e,t;null==(e=x.current)||e.setSize(z.width,z.height),null==(t=x.current)||t.setPixelRatio(w.dpr)}),[g,z,w.dpr]),a.useFrame((()=>{var e;o||null==(e=x.current)||e.render()}),r);const M=[];return s||M.push(C.createElement("renderPass",{key:"renderpass",attach:`passes-${M.length}`,args:[y,v]})),i||M.push(C.createElement("shaderPass",{attach:`passes-${M.length}`,key:"gammapass",args:[d.GammaCorrectionShader]})),C.Children.forEach(e,(e=>{e&&M.push(C.cloneElement(e,{key:M.length,attach:`passes-${M.length}`}))})),C.createElement("effectComposer",T.default({ref:F.default([h,x]),args:[g,b]},p),M)}));let Ce=function(e){return e.Linear="linear",e.Radial="radial",e}({});function Pe(e,t,r,n){const a=class extends R.ShaderMaterial{constructor(a={}){const o=Object.entries(e);super({uniforms:o.reduce(((e,[t,r])=>({...e,...R.UniformsUtils.clone({[t]:{value:r}})})),{}),vertexShader:t,fragmentShader:r}),this.key="",o.forEach((([e])=>Object.defineProperty(this,e,{get:()=>this.uniforms[e].value,set:t=>this.uniforms[e].value=t}))),Object.assign(this,a),n&&n(this)}};return a.key=R.MathUtils.generateUUID(),a}const Re=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function De(e,r){const o=a.useThree((e=>e.gl)),i=a.useLoader(n.TextureLoader,Re(e)?Object.values(e):e);if(t.useLayoutEffect((()=>{null==r||r(i)}),[r]),t.useEffect((()=>{if("initTexture"in o){(Array.isArray(i)?i:[i]).forEach(o.initTexture)}}),[o,i]),Re(e)){const t={};let r=0;for(const n in e)t[n]=i[r++];return t}return i}De.preload=e=>a.useLoader.preload(n.TextureLoader,e),De.clear=e=>a.useLoader.clear(n.TextureLoader,e);const Fe=(()=>parseInt(n.REVISION.replace(/\D+/g,"")))(),ke=Pe({color:new R.Color("white"),scale:new R.Vector2(1,1),imageBounds:new R.Vector2(1,1),resolution:1024,map:null,zoom:1,radius:0,grayscale:0,opacity:1},"\n varying vec2 vUv;\n varying vec2 vPos;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n vPos = position.xy;\n }\n",`\n // mostly from https://gist.github.com/statico/df64c5d167362ecf7b34fca0b1459a44\n varying vec2 vUv;\n varying vec2 vPos;\n uniform vec2 scale;\n uniform vec2 imageBounds;\n uniform float resolution;\n uniform vec3 color;\n uniform sampler2D map;\n uniform float radius;\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 \n const float PI = 3.14159265;\n \n // from https://iquilezles.org/articles/distfunctions\n float udRoundBox( vec2 p, vec2 b, float r ) {\n return length(max(abs(p)-b+r,0.0))-r;\n }\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\n vec2 res = vec2(scale * resolution);\n vec2 halfRes = 0.5 * res;\n float b = udRoundBox(vUv.xy * res - halfRes, halfRes, resolution * radius); \n\t vec3 a = mix(vec3(1.0,0.0,0.0), vec3(0.0,0.0,0.0), smoothstep(0.0, 1.0, b));\n gl_FragColor = toGrayscale(texture2D(map, zUv) * vec4(color, opacity * a), grayscale);\n \n #include <tonemapping_fragment>\n #include <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n`),_e=C.forwardRef((({children:e,color:t,segments:r=1,scale:n=1,zoom:o=1,grayscale:i=0,opacity:s=1,radius:l=0,texture:c,toneMapped:u,transparent:d,side:m,...f},p)=>{a.extend({ImageMaterial:ke});const h=C.useRef(null),x=a.useThree((e=>e.size)),y=Array.isArray(n)?[n[0],n[1]]:[n,n],v=[c.image.width,c.image.height],g=Math.max(x.width,x.height);return C.useImperativeHandle(p,(()=>h.current),[]),C.useLayoutEffect((()=>{h.current.geometry.parameters&&h.current.material.scale.set(y[0]*h.current.geometry.parameters.width,y[1]*h.current.geometry.parameters.height)}),[]),C.createElement("mesh",T.default({ref:h,scale:Array.isArray(n)?[...n,1]:n},f),C.createElement("planeGeometry",{args:[1,1,r,r]}),C.createElement("imageMaterial",{color:t,map:c,zoom:o,grayscale:i,opacity:s,scale:y,imageBounds:v,resolution:g,radius:l,toneMapped:u,transparent:d,side:m,key:ke.key}),e)})),Ae=C.forwardRef((({url:e,...t},r)=>{const n=De(e);return C.createElement(_e,T.default({},t,{texture:n,ref:r}))})),Le=C.forwardRef((({url:e,...t},r)=>C.createElement(_e,T.default({},t,{ref:r})))),Be=C.forwardRef(((e,t)=>{if(e.url)return C.createElement(Ae,T.default({},e,{ref:t}));if(e.texture)return C.createElement(Le,T.default({},e,{ref:t}));throw new Error("<Image /> requires a url or texture")})),Ue=C.forwardRef((({userData:e,children:t,geometry:r,threshold:n=15,color:a="black",...o},i)=>{const s=C.useRef(null);return C.useLayoutEffect((()=>{const e=s.current.parent;if(e){const t=r||e.geometry;t===s.current.userData.currentGeom&&n===s.current.userData.currentThreshold||(s.current.userData.currentGeom=t,s.current.userData.currentThreshold=n,s.current.geometry=new R.EdgesGeometry(t,n))}})),C.useImperativeHandle(i,(()=>s.current)),C.createElement("lineSegments",T.default({ref:s,raycast:()=>null},o),t||C.createElement("lineBasicMaterial",{color:a}))})),Ie=Pe({screenspace:!1,color:new R.Color("black"),opacity:1,thickness:.05,size:new R.Vector2},"#include <common>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n uniform float thickness;\n uniform float screenspace;\n uniform vec2 size;\n void main() {\n #if defined (USE_SKINNING)\n\t #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n\t #include <morphtarget_vertex>\n\t #include <skinning_vertex>\n #include <project_vertex>\n vec4 tNormal = vec4(normal, 0.0);\n vec4 tPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n tNormal = instanceMatrix * tNormal;\n tPosition = instanceMatrix * tPosition;\n #endif\n if (screenspace == 0.0) {\n vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); \n } else {\n vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;\n vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;\n vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;\n clipPosition.xy += offset;\n gl_Position = clipPosition;\n }\n }",`uniform vec3 color;\n uniform float opacity;\n void main(){\n gl_FragColor = vec4(color, opacity);\n #include <tonemapping_fragment>\n #include <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);const Ve={width:.2,length:1,decay:1,local:!1,stride:0,interval:1},Ne=(e,t=1)=>(e.set(e.subarray(t)),e.fill(-1/0,-t),e);function Oe(e,t){const{length:r,local:o,decay:i,interval:s,stride:l}={...Ve,...t},c=C.useRef(),[u]=C.useState((()=>new n.Vector3));C.useLayoutEffect((()=>{e&&(c.current=Float32Array.from({length:10*r*3},((t,r)=>e.position.getComponent(r%3))))}),[r,e]);const d=C.useRef(new n.Vector3),m=C.useRef(0);return a.useFrame((()=>{if(e&&c.current){if(0===m.current){let t;o?t=e.position:(e.getWorldPosition(u),t=u);const r=1*i;for(let e=0;e<r;e++)t.distanceTo(d.current)<l||(Ne(c.current,3),c.current.set(t.toArray(),c.current.length-3));d.current.copy(t)}m.current++,m.current=m.current%s}})),c}const je=C.forwardRef(((e,t)=>{const{children:r}=e,{width:o,length:i,decay:s,local:l,stride:c,interval:u}={...Ve,...e},{color:d="hotpink",attenuation:m,target:f}=e,p=a.useThree((e=>e.size)),x=a.useThree((e=>e.scene)),y=C.useRef(null),[v,g]=C.useState(null),z=Oe(v,{length:i,decay:s,local:l,stride:c,interval:u});C.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=C.useMemo((()=>new h.MeshLineGeometry),[]),b=C.useMemo((()=>{var e;const t=new h.MeshLineMaterial({lineWidth:.1*o,color:d,sizeAttenuation:1,resolution:new n.Vector2(p.width,p.height)});let a;if(r)if(Array.isArray(r))a=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&&(a=e)}return"object"==typeof(null==(e=a)?void 0:e.props)&&t.setValues(a.props),t}),[o,d,p,r]);return C.useEffect((()=>{b.uniforms.resolution.value.set(p.width,p.height)}),[p]),a.useFrame((()=>{z.current&&w.setPoints(z.current,m)})),C.createElement("group",null,a.createPortal(C.createElement("mesh",{ref:t,geometry:w,material:b}),x),C.createElement("group",{ref:y},r))}));function We(e,t=16,r,a,o){const[i,s]=C.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 C.useLayoutEffect((()=>{if(void 0===e.current)return;const l=new d.MeshSurfaceSampler(e.current);a&&l.setWeightAttribute(a),l.build();const c=new n.Vector3,u=new n.Vector3,m=new n.Color,f=new n.Object3D;e.current.updateMatrixWorld(!0);for(let n=0;n<t;n++)l.sample(c,u,m),"function"==typeof r?r({dummy:f,sampledMesh:e.current,position:c,normal:u,color:m},n):f.position.copy(c),f.updateMatrix(),null!=o&&o.current&&o.current.setMatrixAt(n,f.matrix),f.matrix.toArray(i.array,16*n);null!=o&&o.current&&(o.current.instanceMatrix.needsUpdate=!0),i.needsUpdate=!0,s(i.clone())}),[e,o,a,t,r]),i}const Ge=C.forwardRef((({isChild:e=!1,object:t,children:r,deep:n,castShadow:a,receiveShadow:o,inject:i,keys:s,...l},c)=>{const u={keys:s,deep:n,inject:i,castShadow:a,receiveShadow:o};if(t=C.useMemo((()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse((t=>{t.isSkinnedMesh&&(e=!0)})),e)return d.SkeletonUtils.clone(t)}return t}),[t,e]),Array.isArray(t))return C.createElement("group",T.default({},l,{ref:c}),t.map((e=>C.createElement(Ge,T.default({key:e.uuid,object:e},u)))),r);const{children:m,...f}=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:a,receiveShadow:o}){let i={};for(const r of t)i[r]=e[r];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)}:C.isValidElement(n)?{...i,children:n}:{...i,...n}),e instanceof R.Mesh&&(a&&(i.castShadow=!0),o&&(i.receiveShadow=!0)),i}(t,u),p=t.type[0].toLowerCase()+t.type.slice(1);return C.createElement(p,T.default({},f,l,{ref:c}),t.children.map((e=>"Bone"===e.type?C.createElement("primitive",T.default({key:e.uuid,object:e},u)):C.createElement(Ge,T.default({key:e.uuid,object:e},u,{isChild:!0})))),r,m)})),He=C.createContext(null),$e=C.forwardRef((({resolution:e=28,maxPolyCount:t=1e4,enableUvs:r=!1,enableColors:n=!1,children:o,...i},s)=>{const l=C.useRef(null),c=C.useMemo((()=>new d.MarchingCubes(e,null,r,n,t)),[e,t,r,n]),u=C.useMemo((()=>({getParent:()=>l})),[]);return a.useFrame((()=>{c.update(),c.reset()}),-1),C.createElement(C.Fragment,null,C.createElement("primitive",T.default({object:c,ref:F.default([l,s])},i),C.createElement(He.Provider,{value:u},o)))})),qe=C.forwardRef((({strength:e=.5,subtract:t=12,color:r,...n},o)=>{const{getParent:i}=C.useContext(He),s=C.useMemo((()=>i()),[i]),l=C.useRef(),c=new R.Vector3;return a.useFrame((n=>{s.current&&l.current&&(l.current.getWorldPosition(c),s.current.addBall(.5+.5*c.x,.5+.5*c.y,.5+.5*c.z,e,t,r))})),C.createElement("group",T.default({ref:F.default([o,l])},n))})),Xe=C.forwardRef((({planeType:e="x",strength:t=.5,subtract:r=12,...n},o)=>{const{getParent:i}=C.useContext(He),s=C.useMemo((()=>i()),[i]),l=C.useRef(),c=C.useMemo((()=>"x"===e?"addPlaneX":"y"===e?"addPlaneY":"addPlaneZ"),[e]);return a.useFrame((()=>{s.current&&l.current&&s.current[c](t,r)})),C.createElement("group",T.default({ref:F.default([o,l])},n))}));function Ze(e=[0,0,0]){return function(e){return Array.isArray(e)}(e)?e:e instanceof R.Vector3||e instanceof R.Euler?[e.x,e.y,e.z]:[e,e,e]}const Ye=C.forwardRef((function({debug:e,depthTest:t=!1,polygonOffsetFactor:r=-10,map:n,mesh:o,children:i,position:s,rotation:l,scale:c,...u},m){const f=C.useRef(null);C.useImperativeHandle(m,(()=>f.current));const p=C.useRef(null);return C.useLayoutEffect((()=>{const e=(null==o?void 0:o.current)||f.current.parent,t=f.current;if(!(e instanceof R.Mesh))throw new Error('Decal must have a Mesh as parent or specify its "mesh" prop');const r={position:new R.Vector3,rotation:new R.Euler,scale:new R.Vector3(1,1,1)};if(e){a.applyProps(r,{position:s,scale:c});const n=e.matrixWorld.clone();if(e.matrixWorld.identity(),l&&"number"!=typeof l)a.applyProps(r,{rotation:l});else{const t=new R.Object3D;t.position.copy(r.position),t.lookAt(e.position),"number"==typeof l&&t.rotateZ(l),a.applyProps(r,{rotation:t.rotation})}return t.geometry=new d.DecalGeometry(e,r.position,r.rotation,r.scale),p.current&&(a.applyProps(p.current,r),p.current.traverse((e=>e.raycast=()=>null))),e.matrixWorld=n,()=>{t.geometry.dispose()}}}),[o,...Ze(s),...Ze(c),...Ze(l)]),C.createElement("mesh",T.default({ref:f,"material-transparent":!0,"material-polygonOffset":!0,"material-polygonOffsetFactor":r,"material-depthTest":t,"material-map":n},u),i,e&&C.createElement("mesh",{ref:p},C.createElement("boxGeometry",null),C.createElement("meshNormalMaterial",{wireframe:!0}),C.createElement("axesHelper",null)))})),Qe=t.forwardRef((function({src:e,skipFill:r,skipStrokes:o,fillMaterial:i,strokeMaterial:s,fillMeshProps:l,strokeMeshProps:c,...u},m){const f=a.useLoader(d.SVGLoader,e.startsWith("<svg")?`data:image/svg+xml;utf8,${e}`:e),p=t.useMemo((()=>o?[]:f.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=>d.SVGLoader.pointsToStroke(t.getPoints(),e.userData.style)))}))),[f,o]);return t.useEffect((()=>()=>p.forEach((e=>e&&e.map((e=>e.dispose()))))),[p]),C.createElement("object3D",T.default({ref:m},u),C.createElement("object3D",{scale:[1,-1,1]},f.paths.map(((e,a)=>{var u,m;return C.createElement(t.Fragment,{key:a},!r&&void 0!==(null==(u=e.userData)?void 0:u.style.fill)&&"none"!==e.userData.style.fill&&d.SVGLoader.createShapes(e).map(((t,r)=>C.createElement("mesh",T.default({key:r},l),C.createElement("shapeGeometry",{args:[t]}),C.createElement("meshBasicMaterial",T.default({color:e.userData.style.fill,opacity:e.userData.style.fillOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},i))))),!o&&void 0!==(null==(m=e.userData)?void 0:m.style.stroke)&&"none"!==e.userData.style.stroke&&e.subPaths.map(((t,r)=>C.createElement("mesh",T.default({key:r,geometry:p[a][r]},c),C.createElement("meshBasicMaterial",T.default({color:e.userData.style.stroke,opacity:e.userData.style.strokeOpacity,transparent:!0,side:n.DoubleSide,depthWrite:!1},s))))))}))))}));let Ke=null,Je="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function et(e,t,r){return n=>{r&&r(n),e&&(Ke||(Ke=new d.DRACOLoader),Ke.setDecoderPath("string"==typeof e?e:Je),n.setDRACOLoader(Ke)),t&&n.setMeshoptDecoder("function"==typeof d.MeshoptDecoder?d.MeshoptDecoder():d.MeshoptDecoder)}}function tt(e,t=!0,r=!0,n){return a.useLoader(d.GLTFLoader,e,et(t,r,n))}tt.preload=(e,t=!0,r=!0,n)=>a.useLoader.preload(d.GLTFLoader,e,et(t,r,n)),tt.clear=e=>a.useLoader.clear(d.GLTFLoader,e),tt.setDecoderPath=e=>{Je=e};const rt=C.forwardRef((({src:e,...t},r)=>{const{scene:n}=tt(e);return C.createElement(Ge,T.default({ref:r},t,{object:n}))}));const nt=Pe({alphaTest:0,viewport:new R.Vector2(1980,1080),focal:1e3,centerAndScaleTexture:null,covAndColorTexture:null},"\n precision highp sampler2D;\n precision highp usampler2D;\n out vec4 vColor;\n out vec3 vPosition;\n uniform vec2 resolution;\n uniform vec2 viewport;\n uniform float focal;\n attribute uint splatIndex;\n uniform sampler2D centerAndScaleTexture;\n uniform usampler2D covAndColorTexture; \n\n vec2 unpackInt16(in uint value) {\n int v = int(value);\n int v0 = v >> 16;\n int v1 = (v & 0xFFFF);\n if((v & 0x8000) != 0)\n v1 |= 0xFFFF0000;\n return vec2(float(v1), float(v0));\n }\n\n void main () {\n ivec2 texSize = textureSize(centerAndScaleTexture, 0);\n ivec2 texPos = ivec2(splatIndex%uint(texSize.x), splatIndex/uint(texSize.x));\n vec4 centerAndScaleData = texelFetch(centerAndScaleTexture, texPos, 0);\n vec4 center = vec4(centerAndScaleData.xyz, 1);\n vec4 camspace = modelViewMatrix * center;\n vec4 pos2d = projectionMatrix * camspace;\n\n float bounds = 1.2 * pos2d.w;\n if (pos2d.z < -pos2d.w || pos2d.x < -bounds || pos2d.x > bounds\n || pos2d.y < -bounds || pos2d.y > bounds) {\n gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n return;\n }\n\n uvec4 covAndColorData = texelFetch(covAndColorTexture, texPos, 0);\n vec2 cov3D_M11_M12 = unpackInt16(covAndColorData.x) * centerAndScaleData.w;\n vec2 cov3D_M13_M22 = unpackInt16(covAndColorData.y) * centerAndScaleData.w;\n vec2 cov3D_M23_M33 = unpackInt16(covAndColorData.z) * centerAndScaleData.w;\n mat3 Vrk = mat3(\n cov3D_M11_M12.x, cov3D_M11_M12.y, cov3D_M13_M22.x,\n cov3D_M11_M12.y, cov3D_M13_M22.y, cov3D_M23_M33.x,\n cov3D_M13_M22.x, cov3D_M23_M33.x, cov3D_M23_M33.y\n );\n\n mat3 J = mat3(\n focal / camspace.z, 0., -(focal * camspace.x) / (camspace.z * camspace.z),\n 0., focal / camspace.z, -(focal * camspace.y) / (camspace.z * camspace.z),\n 0., 0., 0.\n );\n\n mat3 W = transpose(mat3(modelViewMatrix));\n mat3 T = W * J;\n mat3 cov = transpose(T) * Vrk * T;\n vec2 vCenter = vec2(pos2d) / pos2d.w;\n float diagonal1 = cov[0][0] + 0.3;\n float offDiagonal = cov[0][1];\n float diagonal2 = cov[1][1] + 0.3;\n float mid = 0.5 * (diagonal1 + diagonal2);\n float radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));\n float lambda1 = mid + radius;\n float lambda2 = max(mid - radius, 0.1);\n vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n vec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n vec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n uint colorUint = covAndColorData.w;\n vColor = vec4(\n float(colorUint & uint(0xFF)) / 255.0,\n float((colorUint >> uint(8)) & uint(0xFF)) / 255.0,\n float((colorUint >> uint(16)) & uint(0xFF)) / 255.0,\n float(colorUint >> uint(24)) / 255.0\n );\n vPosition = position;\n\n gl_Position = vec4(\n vCenter \n + position.x * v2 / viewport * 2.0 \n + position.y * v1 / viewport * 2.0, pos2d.z / pos2d.w, 1.0);\n }\n ",`\n #include <alphatest_pars_fragment>\n #include <alphahash_pars_fragment>\n in vec4 vColor;\n in vec3 vPosition;\n void main () {\n float A = -dot(vPosition.xy, vPosition.xy);\n if (A < -4.0) discard;\n float B = exp(A) * vColor.a;\n vec4 diffuseColor = vec4(vColor.rgb, B);\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <tonemapping_fragment>\n #include <${parseInt(R.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `);function at(e){let t=null,r=0;e.onmessage=n=>{if("push"==n.data.method){0===r&&(t=new Float32Array(n.data.length));const e=new Float32Array(n.data.matrices);t.set(e,r),r+=e.length}else if("sort"==n.data.method&&null!==t){const r=function(e,r=!1){const n=t.length/16;let a=-1/0,o=1/0;const i=new Float32Array(n),s=new Int32Array(i.buffer),l=new Int32Array(n);let c=0;for(let s=0;s<n;s++){const n=e[0]*t[16*s+12]+e[1]*t[16*s+13]+e[2]*t[16*s+14]+e[3];(r||n<0&&t[16*s+15]>-1e-4*n)&&(i[c]=n,l[c]=s,c++,n>a&&(a=n),n<o&&(o=n))}const u=65535/(a-o),d=new Uint32Array(65536);for(let e=0;e<c;e++)s[e]=(i[e]-o)*u|0,d[s[e]]++;const m=new Uint32Array(65536);for(let e=1;e<65536;e++)m[e]=m[e-1]+d[e-1];const f=new Uint32Array(c);for(let e=0;e<c;e++)f[m[s[e]]++]=l[e];return f}(new Float32Array(n.data.view),n.data.hashed);e.postMessage({indices:r,key:n.data.key},[r.buffer])}}}class ot extends R.Loader{constructor(...e){super(...e),this.gl=null,this.chunkSize=25e3}load(e,t,r,n){const a={gl:this.gl,url:this.manager.resolveURL(e),worker:new Worker(URL.createObjectURL(new Blob(["(",at.toString(),")(self)"],{type:"application/javascript"}))),manager:this.manager,update:(e,t,r)=>function(e,t,r,n){if(e.updateMatrixWorld(),t.gl.getCurrentViewport(r.viewport),r.material.viewport.x=r.viewport.z,r.material.viewport.y=r.viewport.w,r.material.focal=r.viewport.w/2*Math.abs(e.projectionMatrix.elements[5]),r.ready){if(n&&r.sorted)return;r.ready=!1;const e=new Float32Array([r.modelViewMatrix.elements[2],-r.modelViewMatrix.elements[6],r.modelViewMatrix.elements[10],r.modelViewMatrix.elements[14]]);t.worker.postMessage({method:"sort",src:t.url,key:r.uuid,view:e.buffer,hashed:n},[e.buffer]),n&&t.loaded&&(r.sorted=!0)}}(t,a,e,r),connect:e=>function(e,t){e.loading||async function(e){e.loading=!0;let t=0,r=0;const n=[];let a=0;const o=0!==e.totalDownloadBytes;for(;;)try{const{value:i,done:s}=await e.stream.read();if(s)break;if(t+=i.length,null!=e.totalDownloadBytes){const r=t/e.totalDownloadBytes*100;if(e.onProgress&&r-a>1){const n=new ProgressEvent("progress",{lengthComputable:o,loaded:t,total:e.totalDownloadBytes});e.onProgress(n),a=r}}n.push(i);const l=t-r;if(null!=e.totalDownloadBytes&&l>e.rowLength*e.chunkSize){let t=Math.floor(l/e.rowLength);const a=new Uint8Array(l);let i=0;for(const e of n)a.set(e,i),i+=e.length;if(n.length=0,l>t*e.rowLength){const r=new Uint8Array(l-t*e.rowLength);r.set(a.subarray(l-r.length,l),0),n.push(r)}const s=new Uint8Array(t*e.rowLength);s.set(a.subarray(0,s.byteLength),0);const c=it(e,s.buffer,t);if(e.worker.postMessage({method:"push",src:e.url,length:16*e.numVertices,matrices:c.buffer},[c.buffer]),r+=t*e.rowLength,e.onProgress){const t=new ProgressEvent("progress",{lengthComputable:o,loaded:e.totalDownloadBytes,total:e.totalDownloadBytes});e.onProgress(t)}}}catch(e){console.error(e);break}if(t-r>0){let t=new Uint8Array(n.reduce(((e,t)=>e+t.length),0)),r=0;for(const e of n)t.set(e,r),r+=e.length;let a=Math.floor(t.byteLength/e.rowLength);const o=it(e,t.buffer,a);e.worker.postMessage({method:"push",src:e.url,length:16*a,matrices:o.buffer},[o.buffer])}e.loaded=!0,e.manager.itemEnd(e.url)}(e);t.ready=!1,t.pm=new R.Matrix4,t.vm1=new R.Matrix4,t.vm2=new R.Matrix4,t.viewport=new R.Vector4;let r=new Uint32Array(e.bufferTextureWidth*e.bufferTextureHeight);const n=new R.InstancedBufferAttribute(r,1,!1);n.setUsage(R.DynamicDrawUsage);const a=t.geometry=new R.InstancedBufferGeometry,o=new Float32Array(18),i=new R.BufferAttribute(o,3);function s(e){if(t&&e.data.key===t.uuid){let r=new Uint32Array(e.data.indices);a.attributes.splatIndex.set(r),a.attributes.splatIndex.needsUpdate=!0,a.instanceCount=r.length,t.ready=!0}}async function l(){for(;;){const t=e.gl.properties.get(e.centerAndScaleTexture),r=e.gl.properties.get(e.covAndColorTexture);if(null!=t&&t.__webglTexture&&null!=r&&r.__webglTexture&&e.loadedVertexCount>0)break;await new Promise((e=>setTimeout(e,10)))}t.ready=!0}return a.setAttribute("position",i),i.setXYZ(2,-2,2,0),i.setXYZ(1,2,2,0),i.setXYZ(0,-2,-2,0),i.setXYZ(5,-2,-2,0),i.setXYZ(4,2,2,0),i.setXYZ(3,2,-2,0),i.needsUpdate=!0,a.setAttribute("splatIndex",n),a.instanceCount=1,e.worker.addEventListener("message",s),l(),()=>e.worker.removeEventListener("message",s)}(a,e),loading:!1,loaded:!1,loadedVertexCount:0,chunkSize:this.chunkSize,totalDownloadBytes:0,numVertices:0,rowLength:32,maxVertexes:0,bufferTextureWidth:0,bufferTextureHeight:0,stream:null,centerAndScaleData:null,covAndColorData:null,covAndColorTexture:null,centerAndScaleTexture:null,onProgress:r};(async function(e){e.manager.itemStart(e.url);const t=await fetch(e.url);if(null===t.body)throw"Failed to fetch file";let r=t.headers.get("Content-Length");const n=r?parseInt(r):void 0;if(null==n)throw"Failed to get content length";e.stream=t.body.getReader(),e.totalDownloadBytes=n,e.numVertices=Math.floor(e.totalDownloadBytes/e.rowLength);const a=e.gl.getContext();let o=a.getParameter(a.MAX_TEXTURE_SIZE);e.maxVertexes=o*o,e.numVertices>e.maxVertexes&&(e.numVertices=e.maxVertexes);return e.bufferTextureWidth=o,e.bufferTextureHeight=Math.floor((e.numVertices-1)/o)+1,e.centerAndScaleData=new Float32Array(e.bufferTextureWidth*e.bufferTextureHeight*4),e.covAndColorData=new Uint32Array(e.bufferTextureWidth*e.bufferTextureHeight*4),e.centerAndScaleTexture=new R.DataTexture(e.centerAndScaleData,e.bufferTextureWidth,e.bufferTextureHeight,R.RGBAFormat,R.FloatType),e.centerAndScaleTexture.needsUpdate=!0,e.covAndColorTexture=new R.DataTexture(e.covAndColorData,e.bufferTextureWidth,e.bufferTextureHeight,R.RGBAIntegerFormat,R.UnsignedIntType),e.covAndColorTexture.internalFormat="RGBA32UI",e.covAndColorTexture.needsUpdate=!0,e})(a).then(t).catch((e=>{null==n||n(e),a.manager.itemError(a.url)}))}}function it(e,t,r){const n=e.gl.getContext();if(e.loadedVertexCount+r>e.maxVertexes&&(r=e.maxVertexes-e.loadedVertexCount),r<=0)throw"Failed to parse file";const a=new Uint8Array(t),o=new Float32Array(t),i=new Float32Array(16*r),s=new Uint8Array(e.covAndColorData.buffer),l=new Int16Array(e.covAndColorData.buffer);for(let t=0;t<r;t++){const r=new R.Quaternion(-(a[32*t+28+1]-128)/128,(a[32*t+28+2]-128)/128,(a[32*t+28+3]-128)/128,-(a[32*t+28+0]-128)/128);r.invert();const n=new R.Vector3(o[8*t+0],o[8*t+1],-o[8*t+2]),c=new R.Vector3(o[8*t+3+0],o[8*t+3+1],o[8*t+3+2]),u=new R.Matrix4;u.makeRotationFromQuaternion(r),u.transpose(),u.scale(c);const d=u.clone();u.transpose(),u.premultiply(d),u.setPosition(n);const m=[0,1,2,5,6,10];let f=0;for(let e=0;e<m.length;e++)Math.abs(u.elements[m[e]])>f&&(f=Math.abs(u.elements[m[e]]));let p=4*e.loadedVertexCount+4*t;e.centerAndScaleData[p+0]=n.x,e.centerAndScaleData[p+1]=-n.y,e.centerAndScaleData[p+2]=n.z,e.centerAndScaleData[p+3]=f/32767,p=8*e.loadedVertexCount+4*t*2;for(let e=0;e<m.length;e++)l[p+e]=32767*u.elements[m[e]]/f;p=16*e.loadedVertexCount+4*(4*t+3);const h=new R.Color(a[32*t+24+0]/255,a[32*t+24+1]/255,a[32*t+24+2]/255);h.convertSRGBToLinear(),s[p+0]=255*h.r,s[p+1]=255*h.g,s[p+2]=255*h.b,s[p+3]=a[32*t+24+3],u.elements[15]=Math.max(c.x,c.y,c.z)*a[32*t+24+3]/255;for(let e=0;e<16;e++)i[16*t+e]=u.elements[e]}for(;r>0;){let t=0,a=0;const o=e.loadedVertexCount%e.bufferTextureWidth,i=Math.floor(e.loadedVertexCount/e.bufferTextureWidth);e.loadedVertexCount%e.bufferTextureWidth!=0?(t=Math.min(e.bufferTextureWidth,o+r)-o,a=1):Math.floor(r/e.bufferTextureWidth)>0?(t=e.bufferTextureWidth,a=Math.floor(r/e.bufferTextureWidth)):(t=r%e.bufferTextureWidth,a=1);const s=e.gl.properties.get(e.centerAndScaleTexture);n.bindTexture(n.TEXTURE_2D,s.__webglTexture),n.texSubImage2D(n.TEXTURE_2D,0,o,i,t,a,n.RGBA,n.FLOAT,e.centerAndScaleData,4*e.loadedVertexCount);const l=e.gl.properties.get(e.covAndColorTexture);n.bindTexture(n.TEXTURE_2D,l.__webglTexture),n.texSubImage2D(n.TEXTURE_2D,0,o,i,t,a,n.RGBA_INTEGER,n.UNSIGNED_INT,e.covAndColorData,4*e.loadedVertexCount),e.gl.resetState(),e.loadedVertexCount+=t*a,r-=t*a}return i}function st(e,t,r){const n=a.useThree((e=>e.size)),o=a.useThree((e=>e.viewport)),i="number"==typeof e?e:n.width*o.dpr,s="number"==typeof t?t:n.height*o.dpr,l=("number"==typeof e?r:e)||{},{samples:c=0,depth:u,...d}=l,m=C.useMemo((()=>{const e=new R.WebGLRenderTarget(i,s,{minFilter:R.LinearFilter,magFilter:R.LinearFilter,type:R.HalfFloatType,...d});return u&&(e.depthTexture=new R.DepthTexture(i,s,R.FloatType)),e.samples=c,e}),[]);return C.useLayoutEffect((()=>{m.setSize(i,s),c&&(m.samples=c)}),[c,m,i,s]),C.useEffect((()=>()=>m.dispose()),[]),m}const lt=C.forwardRef((({envMap:e,resolution:t=256,frames:r=1/0,children:n,makeDefault:o,...i},s)=>{const l=a.useThree((({set:e})=>e)),c=a.useThree((({camera:e})=>e)),u=a.useThree((({size:e})=>e)),d=C.useRef(null),m=C.useRef(null),f=st(t);C.useLayoutEffect((()=>{i.manual||d.current.updateProjectionMatrix()}),[u,i]),C.useLayoutEffect((()=>{d.current.updateProjectionMatrix()})),C.useLayoutEffect((()=>{if(o){const e=c;return l((()=>({camera:d.current}))),()=>l((()=>({camera:e})))}}),[d,o,l]);let p=0,h=null;const x="function"==typeof n;return a.useFrame((t=>{x&&(r===1/0||p<r)&&(m.current.visible=!1,t.gl.setRenderTarget(f),h=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,d.current),t.scene.background=h,t.gl.setRenderTarget(null),m.current.visible=!0,p++)})),C.createElement(C.Fragment,null,C.createElement("orthographicCamera",T.default({left:u.width/-2,right:u.width/2,top:u.height/2,bottom:u.height/-2,ref:F.default([d,s])},i),!x&&n),C.createElement("group",{ref:m},x&&n(f.texture)))})),ct=C.forwardRef((({envMap:e,resolution:t=256,frames:r=1/0,makeDefault:n,children:o,...i},s)=>{const l=a.useThree((({set:e})=>e)),c=a.useThree((({camera:e})=>e)),u=a.useThree((({size:e})=>e)),d=C.useRef(null),m=C.useRef(null),f=st(t);C.useLayoutEffect((()=>{i.manual||(d.current.aspect=u.width/u.height)}),[u,i]),C.useLayoutEffect((()=>{d.current.updateProjectionMatrix()}));let p=0,h=null;const x="function"==typeof o;return a.useFrame((t=>{x&&(r===1/0||p<r)&&(m.current.visible=!1,t.gl.setRenderTarget(f),h=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,d.current),t.scene.background=h,t.gl.setRenderTarget(null),m.current.visible=!0,p++)})),C.useLayoutEffect((()=>{if(n){const e=c;return l((()=>({camera:d.current}))),()=>l((()=>({camera:e})))}}),[d,n,l]),C.createElement(C.Fragment,null,C.createElement("perspectiveCamera",T.default({ref:F.default([d,s])},i),!x&&o),C.createElement("group",{ref:m},x&&o(f.texture)))}));function ut({resolution:e=256,near:r=.1,far:o=1e3,envMap:i,fog:s}={}){const l=a.useThree((({gl:e})=>e)),c=a.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 d=t.useMemo((()=>new R.CubeCamera(r,o,u)),[r,o,u]);let m,f;const p=C.useCallback((()=>{m=c.fog,f=c.background,c.background=i||f,c.fog=s||m,d.update(l,c),c.fog=m,c.background=f}),[l,c,d]);return{fbo:u,camera:d,update:p}}const dt=C.forwardRef(((e,t)=>{const{camera:r,onChange:n,makeDefault:o,...i}=e,s=a.useThree((e=>e.camera)),l=a.useThree((e=>e.invalidate)),c=a.useThree((e=>e.get)),u=a.useThree((e=>e.set)),m=r||s,f=C.useMemo((()=>new d.DeviceOrientationControls(m)),[m]);return C.useEffect((()=>{const e=e=>{l(),n&&n(e)};return null==f||null==f.addEventListener||f.addEventListener("change",e),()=>null==f||null==f.removeEventListener?void 0:f.removeEventListener("change",e)}),[n,f,l]),a.useFrame((()=>null==f?void 0:f.update()),-1),C.useEffect((()=>{const e=f;return null==e||e.connect(),()=>null==e?void 0:e.dispose()}),[f]),C.useEffect((()=>{if(o){const e=c().controls;return u({controls:f}),()=>u({controls:e})}}),[o,f]),f?C.createElement("primitive",T.default({ref:t,object:f},i)):null})),mt=C.forwardRef((({domElement:e,...t},r)=>{const{onChange:n,makeDefault:o,...i}=t,s=a.useThree((e=>e.invalidate)),l=a.useThree((e=>e.camera)),c=a.useThree((e=>e.gl)),u=a.useThree((e=>e.events)),m=a.useThree((e=>e.get)),f=a.useThree((e=>e.set)),p=e||u.connected||c.domElement,h=C.useMemo((()=>new d.FlyControls(l)),[l]);return C.useEffect((()=>(h.connect(p),()=>{h.dispose()})),[p,h,s]),C.useEffect((()=>{const e=e=>{s(),n&&n(e)};return null==h.addEventListener||h.addEventListener("change",e),()=>null==h.removeEventListener?void 0:h.removeEventListener("change",e)}),[n,s]),C.useEffect((()=>{if(o){const e=m().controls;return f({controls:h}),()=>f({controls:e})}}),[o,h]),a.useFrame(((e,t)=>h.update(t))),C.createElement("primitive",T.default({ref:r,object:h,args:[l,p]},i))})),ft=C.forwardRef(((e={enableDamping:!0},t)=>{const{domElement:r,camera:n,makeDefault:o,onChange:i,onStart:s,onEnd:l,...c}=e,u=a.useThree((e=>e.invalidate)),m=a.useThree((e=>e.camera)),f=a.useThree((e=>e.gl)),p=a.useThree((e=>e.events)),h=a.useThree((e=>e.set)),x=a.useThree((e=>e.get)),y=r||p.connected||f.domElement,v=n||m,g=C.useMemo((()=>new d.MapControls(v)),[v]);return C.useEffect((()=>{g.connect(y);const e=e=>{u(),i&&i(e)};return g.addEventListener("change",e),s&&g.addEventListener("start",s),l&&g.addEventListener("end",l),()=>{g.dispose(),g.removeEventListener("change",e),s&&g.removeEventListener("start",s),l&&g.removeEventListener("end",l)}}),[i,s,l,g,u,y]),C.useEffect((()=>{if(o){const e=x().controls;return h({controls:g}),()=>h({controls:e})}}),[o,g]),a.useFrame((()=>g.update()),-1),C.createElement("primitive",T.default({ref:t,object:g,enableDamping:!0},c))})),pt=C.forwardRef((({makeDefault:e,camera:t,regress:r,domElement:n,enableDamping:o=!0,keyEvents:i=!1,onChange:s,onStart:l,onEnd:c,...u},m)=>{const f=a.useThree((e=>e.invalidate)),p=a.useThree((e=>e.camera)),h=a.useThree((e=>e.gl)),x=a.useThree((e=>e.events)),y=a.useThree((e=>e.setEvents)),v=a.useThree((e=>e.set)),g=a.useThree((e=>e.get)),z=a.useThree((e=>e.performance)),w=t||p,b=n||x.connected||h.domElement,M=C.useMemo((()=>new d.OrbitControls(w)),[w]);return a.useFrame((()=>{M.enabled&&M.update()}),-1),C.useEffect((()=>(i&&M.connect(!0===i?b:i),M.connect(b),()=>{M.dispose()})),[i,b,r,M,f]),C.useEffect((()=>{const e=e=>{f(),r&&z.regress(),s&&s(e)},t=e=>{l&&l(e)},n=e=>{c&&c(e)};return M.addEventListener("change",e),M.addEventListener("start",t),M.addEventListener("end",n),()=>{M.removeEventListener("start",t),M.removeEventListener("end",n),M.removeEventListener("change",e)}}),[s,l,c,M,f,y]),C.useEffect((()=>{if(e){const e=g().controls;return v({controls:M}),()=>v({controls:e})}}),[e,M]),C.createElement("primitive",T.default({ref:m,object:M,enableDamping:o},u))})),ht=C.forwardRef((({makeDefault:e,camera:t,domElement:r,regress:n,onChange:o,onStart:i,onEnd:s,...l},c)=>{const{invalidate:u,camera:m,gl:f,events:p,set:h,get:x,performance:y,viewport:v}=a.useThree(),g=t||m,z=r||p.connected||f.domElement,w=C.useMemo((()=>new d.TrackballControls(g)),[g]);return a.useFrame((()=>{w.enabled&&w.update()}),-1),C.useEffect((()=>(w.connect(z),()=>{w.dispose()})),[z,n,w,u]),C.useEffect((()=>{const e=e=>{u(),n&&y.regress(),o&&o(e)};return w.addEventListener("change",e),i&&w.addEventListener("start",i),s&&w.addEventListener("end",s),()=>{i&&w.removeEventListener("start",i),s&&w.removeEventListener("end",s),w.removeEventListener("change",e)}}),[o,i,s,w,u]),C.useEffect((()=>{w.handleResize()}),[v]),C.useEffect((()=>{if(e){const e=x().controls;return h({controls:w}),()=>h({controls:e})}}),[e,w]),C.createElement("primitive",T.default({ref:c,object:w},l))})),xt=t.forwardRef((({camera:e,makeDefault:r,regress:n,domElement:o,onChange:i,onStart:s,onEnd:l,...c},u)=>{const m=a.useThree((e=>e.invalidate)),f=a.useThree((e=>e.camera)),p=a.useThree((e=>e.gl)),h=a.useThree((e=>e.events)),x=a.useThree((e=>e.set)),y=a.useThree((e=>e.get)),v=a.useThree((e=>e.performance)),g=e||f,z=o||h.connected||p.domElement,w=t.useMemo((()=>new d.ArcballControls(g)),[g]);return a.useFrame((()=>{w.enabled&&w.update()}),-1),t.useEffect((()=>(w.connect(z),()=>{w.dispose()})),[z,n,w,m]),t.useEffect((()=>{const e=e=>{m(),n&&v.regress(),i&&i(e)};return w.addEventListener("change",e),s&&w.addEventListener("start",s),l&&w.addEventListener("end",l),()=>{w.removeEventListener("change",e),s&&w.removeEventListener("start",s),l&&w.removeEventListener("end",l)}}),[i,s,l]),t.useEffect((()=>{if(r){const e=y().controls;return x({controls:w}),()=>x({controls:e})}}),[r,w]),C.createElement("primitive",T.default({ref:u,object:w},c))})),yt=C.forwardRef((({children:e,domElement:t,onChange:r,onMouseDown:n,onMouseUp:o,onObjectChange:i,object:s,makeDefault:l,camera:c,enabled:u,axis:m,mode:f,translationSnap:p,rotationSnap:h,scaleSnap:x,space:y,size:v,showX:g,showY:z,showZ:w,...b},M)=>{const E=a.useThree((e=>e.controls)),S=a.useThree((e=>e.gl)),P=a.useThree((e=>e.events)),D=a.useThree((e=>e.camera)),F=a.useThree((e=>e.invalidate)),k=a.useThree((e=>e.get)),_=a.useThree((e=>e.set)),A=c||D,L=t||P.connected||S.domElement,B=C.useMemo((()=>new d.TransformControls(A,L)),[A,L]),U=C.useRef(null);C.useLayoutEffect((()=>(s?B.attach(s instanceof R.Object3D?s:s.current):U.current instanceof R.Object3D&&B.attach(U.current),()=>{B.detach()})),[s,e,B]),C.useEffect((()=>{if(E){const e=e=>E.enabled=!e.value;return B.addEventListener("dragging-changed",e),()=>B.removeEventListener("dragging-changed",e)}}),[B,E]);const I=C.useRef(),V=C.useRef(),N=C.useRef(),O=C.useRef();return C.useLayoutEffect((()=>{I.current=r}),[r]),C.useLayoutEffect((()=>{V.current=n}),[n]),C.useLayoutEffect((()=>{N.current=o}),[o]),C.useLayoutEffect((()=>{O.current=i}),[i]),C.useEffect((()=>{const e=e=>{F(),null==I.current||I.current(e)},t=e=>null==V.current?void 0:V.current(e),r=e=>null==N.current?void 0:N.current(e),n=e=>null==O.current?void 0:O.current(e);return B.addEventListener("change",e),B.addEventListener("mouseDown",t),B.addEventListener("mouseUp",r),B.addEventListener("objectChange",n),()=>{B.removeEventListener("change",e),B.removeEventListener("mouseDown",t),B.removeEventListener("mouseUp",r),B.removeEventListener("objectChange",n)}}),[F,B]),C.useEffect((()=>{if(l){const e=k().controls;return _({controls:B}),()=>_({controls:e})}}),[l,B]),C.createElement(C.Fragment,null,C.createElement("primitive",{ref:M,object:B,enabled:u,axis:m,mode:f,translationSnap:p,rotationSnap:h,scaleSnap:x,space:y,size:v,showX:g,showY:z,showZ:w}),C.createElement("group",T.default({ref:U},b),e))})),vt=C.forwardRef((({domElement:e,selector:t,onChange:r,onLock:n,onUnlock:o,enabled:i=!0,makeDefault:s,...l},c)=>{const{camera:u,...m}=l,f=a.useThree((e=>e.setEvents)),p=a.useThree((e=>e.gl)),h=a.useThree((e=>e.camera)),x=a.useThree((e=>e.invalidate)),y=a.useThree((e=>e.events)),v=a.useThree((e=>e.get)),g=a.useThree((e=>e.set)),z=u||h,w=e||y.connected||p.domElement,b=C.useMemo((()=>new d.PointerLockControls(z)),[z]);return C.useEffect((()=>{if(i){b.connect(w);const e=v().events.compute;return f({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)}}),()=>{b.disconnect(),f({compute:e})}}}),[i,b]),C.useEffect((()=>{const e=e=>{x(),r&&r(e)};b.addEventListener("change",e),n&&b.addEventListener("lock",n),o&&b.addEventListener("unlock",o);const a=()=>b.lock(),i=t?Array.from(document.querySelectorAll(t)):[document];return i.forEach((e=>e&&e.addEventListener("click",a))),()=>{b.removeEventListener("change",e),n&&b.removeEventListener("lock",n),o&&b.removeEventListener("unlock",o),i.forEach((e=>e?e.removeEventListener("click",a):void 0))}}),[r,n,o,t,b,x]),C.useEffect((()=>{if(s){const e=v().controls;return g({controls:b}),()=>g({controls:e})}}),[s,b]),C.createElement("primitive",T.default({ref:c,object:b},m))})),gt=C.forwardRef((({domElement:e,makeDefault:t,...r},n)=>{const o=a.useThree((e=>e.camera)),i=a.useThree((e=>e.gl)),s=a.useThree((e=>e.events)),l=a.useThree((e=>e.get)),c=a.useThree((e=>e.set)),u=e||s.connected||i.domElement,[m]=C.useState((()=>new d.FirstPersonControls(o,u)));return C.useEffect((()=>{if(t){const e=l().controls;return c({controls:m}),()=>c({controls:e})}}),[t,m]),a.useFrame(((e,t)=>{m.update(t)}),-1),m?C.createElement("primitive",T.default({ref:n,object:m},r)):null})),zt=t.forwardRef(((e,r)=>{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};_.default.install({THREE:e}),a.extend({CameraControlsImpl:_.default})}),[]);const{camera:o,domElement:i,makeDefault:s,onStart:l,onEnd:c,onChange:u,regress:d,...m}=e,f=a.useThree((e=>e.camera)),p=a.useThree((e=>e.gl)),h=a.useThree((e=>e.invalidate)),x=a.useThree((e=>e.events)),y=a.useThree((e=>e.setEvents)),v=a.useThree((e=>e.set)),g=a.useThree((e=>e.get)),z=a.useThree((e=>e.performance)),w=o||f,b=i||x.connected||p.domElement,M=t.useMemo((()=>new _.default(w)),[w]);return a.useFrame(((e,t)=>{M.enabled&&M.update(t)}),-1),t.useEffect((()=>(M.connect(b),()=>{M.disconnect()})),[b,M]),t.useEffect((()=>{const e=e=>{h(),d&&z.regress(),u&&u(e)},t=e=>{l&&l(e)},r=e=>{c&&c(e)};return M.addEventListener("update",e),M.addEventListener("controlstart",t),M.addEventListener("controlend",r),M.addEventListener("control",e),M.addEventListener("transitionstart",e),M.addEventListener("wake",e),()=>{M.removeEventListener("update",e),M.removeEventListener("controlstart",t),M.removeEventListener("controlend",r),M.removeEventListener("control",e),M.removeEventListener("transitionstart",e),M.removeEventListener("wake",e)}}),[M,l,c,h,y,d,u]),t.useEffect((()=>{if(s){const e=g().controls;return v({controls:M}),()=>v({controls:e})}}),[s,M]),C.createElement("primitive",T.default({ref:r,object:M},m))})),wt=C.createContext(null);function bt(){return C.useContext(wt)}function Mt({points:e=50}){const{path:t}=bt(),[r,n]=C.useState([]),[a]=C.useState((()=>new R.MeshBasicMaterial({color:"black"}))),[o]=C.useState((()=>new R.SphereGeometry(.025,16,16))),i=C.useRef([]);return C.useEffect((()=>{t.curves!==i.current&&(n(t.getPoints(e)),i.current=t.curves)})),C.createElement(C.Fragment,null,r.map(((e,t)=>C.createElement("mesh",{key:t,material:a,geometry:o,position:[e.x,e.y,e.z]}))))}const Et=C.forwardRef((({children:e,curves:t=[],object:r,debug:n=!1,smooth:o=!1,focus:i,offset:l,eps:c=1e-5,damping:u=.1,focusDamping:d=.1,maxSpeed:m=1/0,...f},p)=>{const{camera:h}=a.useThree(),x=C.useRef(),[y]=C.useState((()=>new R.CurvePath)),v=C.useRef(null!=l?l:0),g=C.useMemo((()=>({focus:i,object:(null==r?void 0:r.current)instanceof R.Object3D?r:{current:h},path:y,current:v.current,offset:v.current,point:new R.Vector3,tangent:new R.Vector3,next:new R.Vector3})),[i,r]);C.useLayoutEffect((()=>{var e;y.curves=[];const r=t.length>0?t:null==(e=x.current)?void 0:e.__r3f.objects;for(var n=0;n<r.length;n++)y.add(r[n]);if(o){const e=y.getPoints("number"==typeof o?o:1),t=new R.CatmullRomCurve3(e);y.curves=[t]}y.updateArcLengths()})),C.useImperativeHandle(p,(()=>x.current),[]),C.useLayoutEffect((()=>{v.current=s.misc.repeat(v.current,1)}),[l]);let z=0;const[w]=C.useState((()=>new R.Vector3));return a.useFrame(((e,t)=>{if(z=g.offset,s.easing.damp(v,"current",void 0!==l?l:g.current,u,t,m,void 0,c),g.offset=s.misc.repeat(v.current,1),y.getCurveLengths().length>0){y.getPointAt(g.offset,g.point),y.getTangentAt(g.offset,g.tangent).normalize(),y.getPointAt(s.misc.repeat(v.current-(z-g.offset),1),g.next);const e=(null==r?void 0:r.current)instanceof R.Object3D?r.current:h;e.position.copy(g.point),i&&s.easing.dampLookAt(e,(e=>(null==e?void 0:e.current)instanceof R.Object3D)(i)?i.current.getWorldPosition(w):i,d,t,m,void 0,c)}})),C.createElement("group",T.default({ref:x},f),C.createElement(wt.Provider,{value:g},e,n&&C.createElement(Mt,null)))}));function St({defaultScene:e,defaultCamera:t,renderPriority:r=1}){const{gl:n,scene:o,camera:i}=a.useThree();let s;return a.useFrame((()=>{s=n.autoClear,1===r&&(n.autoClear=!0,n.render(e,t)),n.autoClear=!1,n.clearDepth(),n.render(o,i),n.autoClear=s}),r),C.createElement("group",{onPointerOver:()=>null})}function Tt({children:e,renderPriority:t=1}){const{scene:r,camera:n}=a.useThree(),[o]=C.useState((()=>new R.Scene));return C.createElement(C.Fragment,null,a.createPortal(C.createElement(C.Fragment,null,e,C.createElement(St,{defaultScene:r,defaultCamera:n,renderPriority:t})),o,{events:{priority:t+1}}))}const Ct=C.createContext({}),Pt=()=>C.useContext(Ct),Rt=2*Math.PI,Dt=new n.Object3D,Ft=new n.Matrix4,[kt,_t]=[new n.Quaternion,new n.Quaternion],At=new n.Vector3,Lt=new n.Vector3,Bt="#f0f0f0",Ut="#999",It="black",Vt="black",Nt=["Right","Left","Top","Bottom","Front","Back"],Ot=e=>new n.Vector3(...e).multiplyScalar(.38),jt=[[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(Ot),Wt=[.25,.25,.25],Gt=[[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(Ot),Ht=Gt.map((e=>e.toArray().map((e=>0==e?.5:.25)))),$t=({hover:e,index:t,font:r="20px Inter var, Arial, sans-serif",faces:o=Nt,color:i=Bt,hoverColor:s=Ut,textColor:l=It,strokeColor:c=Vt,opacity:u=1})=>{const d=a.useThree((e=>e.gl)),m=C.useMemo((()=>{const e=document.createElement("canvas");e.width=128,e.height=128;const a=e.getContext("2d");return a.fillStyle=i,a.fillRect(0,0,e.width,e.height),a.strokeStyle=c,a.strokeRect(0,0,e.width,e.height),a.font=r,a.textAlign="center",a.fillStyle=l,a.fillText(o[t].toUpperCase(),64,76),new n.CanvasTexture(e)}),[t,o,r,i,l,c]);return C.createElement("meshBasicMaterial",{map:m,"map-anisotropy":d.capabilities.getMaxAnisotropy()||1,attach:`material-${t}`,color:e?s:"white",transparent:!0,opacity:u})},qt=e=>{const{tweenCamera:t}=Pt(),[r,n]=C.useState(null);return C.createElement("mesh",{onPointerOut:e=>{e.stopPropagation(),n(null)},onPointerMove:e=>{e.stopPropagation(),n(Math.floor(e.faceIndex/2))},onClick:e.onClick||(e=>{e.stopPropagation(),t(e.face.normal)})},[...Array(6)].map(((t,n)=>C.createElement($t,T.default({key:n,index:n,hover:r===n},e)))),C.createElement("boxGeometry",null))},Xt=({onClick:e,dimensions:t,position:r,hoverColor:n=Ut})=>{const{tweenCamera:a}=Pt(),[o,i]=C.useState(!1);return C.createElement("mesh",{scale:1.01,position:r,onPointerOver:e=>{e.stopPropagation(),i(!0)},onPointerOut:e=>{e.stopPropagation(),i(!1)},onClick:e||(e=>{e.stopPropagation(),a(r)})},C.createElement("meshBasicMaterial",{color:o?n:"white",transparent:!0,opacity:.6,visible:o}),C.createElement("boxGeometry",{args:t}))};function Zt({scale:e=[.8,.05,.05],color:t,rotation:r}){return C.createElement("group",{rotation:r},C.createElement("mesh",{position:[.4,0,0]},C.createElement("boxGeometry",{args:e}),C.createElement("meshBasicMaterial",{color:t,toneMapped:!1})))}function Yt({onClick:e,font:t,disabled:r,arcStyle:o,label:i,labelColor:s,axisHeadScale:l=1,...c}){const u=a.useThree((e=>e.gl)),d=C.useMemo((()=>{const e=document.createElement("canvas");e.width=64,e.height=64;const r=e.getContext("2d");return r.beginPath(),r.arc(32,32,16,0,2*Math.PI),r.closePath(),r.fillStyle=o,r.fill(),i&&(r.font=t,r.textAlign="center",r.fillStyle=s,r.fillText(i,32,41)),new n.CanvasTexture(e)}),[o,i,s,t]),[m,f]=C.useState(!1),p=(i?1:.75)*(m?1.2:1)*l;return C.createElement("sprite",T.default({scale:p,onPointerOver:r?void 0:e=>{e.stopPropagation(),f(!0)},onPointerOut:r?void 0:e||(e=>{e.stopPropagation(),f(!1)})},c),C.createElement("spriteMaterial",{map:d,"map-anisotropy":u.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:i?1:.75,toneMapped:!1}))}const Qt=Pe({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new R.Color,sectionColor:new R.Color,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new R.Vector3,worldPlanePosition:new R.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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `),Kt=C.forwardRef((({args:e,cellColor:t="#000000",sectionColor:r="#2080ff",cellSize:n=.5,sectionSize:o=1,followCamera:i=!1,infiniteGrid:s=!1,fadeDistance:l=100,fadeStrength:c=1,cellThickness:u=.5,sectionThickness:d=1,side:m=R.BackSide,...f},p)=>{a.extend({GridMaterial:Qt});const h=C.useRef(null),x=new R.Plane,y=new R.Vector3(0,1,0),v=new R.Vector3(0,0,0);a.useFrame((e=>{x.setFromNormalAndCoplanarPoint(y,v).applyMatrix4(h.current.matrixWorld);const t=h.current.material,r=t.uniforms.worldCamProjPosition,n=t.uniforms.worldPlanePosition;x.projectPoint(e.camera.position,r.value),n.value.set(0,0,0).applyMatrix4(h.current.matrixWorld)}));const g={cellSize:n,sectionSize:o,cellColor:t,sectionColor:r,cellThickness:u,sectionThickness:d},z={fadeDistance:l,fadeStrength:c,infiniteGrid:s,followCamera:i};return C.createElement("mesh",T.default({ref:F.default([h,p]),frustumCulled:!1},f),C.createElement("gridMaterial",T.default({transparent:!0,"extensions-derivatives":!0,side:m},g,z)),C.createElement("planeGeometry",{args:e}))}));function Jt(e,{path:t}){const[r]=a.useLoader(n.CubeTextureLoader,[e],(e=>e.setPath(t)));return r}function er(e){return a.useLoader(d.FBXLoader,e)}Jt.preload=(e,{path:t})=>a.useLoader.preload(n.CubeTextureLoader,[e],(e=>e.setPath(t))),er.preload=e=>a.useLoader.preload(d.FBXLoader,e),er.clear=e=>a.useLoader.clear(d.FBXLoader,e);const tr="https://cdn.jsdelivr.net/gh/pmndrs/drei-assets@master";function rr(e,r=`${tr}/basis/`){const n=a.useThree((e=>e.gl)),o=a.useLoader(d.KTX2Loader,Re(e)?Object.values(e):e,(e=>{e.detectSupport(n),e.setTranscoderPath(r)}));if(t.useEffect((()=>{(Array.isArray(o)?o:[o]).forEach(n.initTexture)}),[n,o]),Re(e)){const t=Object.keys(e),r={};return t.forEach((e=>Object.assign(r,{[e]:o[t.indexOf(e)]}))),r}return o}function nr(e,r){const{unsuspend:n,start:o,crossOrigin:i,muted:s,loop:l,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...r},u=a.useThree((e=>e.gl)),d=p.suspend((()=>new Promise(((t,r)=>{const a=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}),o=new R.VideoTexture(a);"colorSpace"in o?o.colorSpace=u.outputColorSpace:o.encoding=u.outputEncoding,a.addEventListener(n,(()=>t(o)))}))),[e]);return t.useEffect((()=>{if(o)return d.image.play(),()=>d.image.pause()}),[d,o]),d}rr.preload=(e,t=`${tr}/basis/`)=>a.useLoader.preload(d.KTX2Loader,e,(e=>{e.setTranscoderPath(t)})),rr.clear=e=>a.useLoader.clear(d.KTX2Loader,e);const ar=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}},or=(e,t,r,n)=>{const a=t*(n.aspect>e/t?n.width/e:n.height/t),o=e*(n.aspect>e/t?n.width/e:n.height/t)*r,i=a*r;let s=Math.min(1,o),l=Math.min(1,i);return o>1&&(s=1,l=i/o*1),new R.Vector3(s,l,1)};function ir(e,r,o,i,s){const l=a.useThree((e=>e.viewport)),c=a.useThree((e=>e.gl)),u=C.useRef(null),d=C.useRef(0),[m,f]=t.useState(null),[p,h]=C.useState(new R.Texture),x=new R.TextureLoader,[y,v]=t.useState(null);function g(t){(t||e)&&new Promise((r=>{x.load(null!=t?t:e,r)})).then((e=>{w(null,e)}))}function z(e,t,r){const n=fetch(e).then((e=>e.json())),a=new Promise((e=>{x.load(t,e)}));Promise.all([n,a]).then((e=>{r(e[0],e[1])}))}C.useLayoutEffect((()=>(r&&e?z(r,e,w):e&&g(),()=>{e&&a.useLoader.clear(n.TextureLoader,e)})),[]);const w=(e,t)=>{let r=new R.Vector3(1,1,1);if(null===e){if(t&&i){const e=t.image.width,n=t.image.height,a=e/i,o=n;if(d.current=i,u.current={frames:[],meta:{version:"1.0",size:{w:e,h:n},scale:"1"}},parseInt(a.toString(),10)===a)for(let e=0;e<i;e++)u.current.frames.push({frame:{x:e*a,y:0,w:a,h:o},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:a,h:o},sourceSize:{w:a,h:n}});r=or(a,o,.1,l)}}else if(t){u.current=e,u.current.frames=Array.isArray(e.frames)?e.frames:b(),d.current=Array.isArray(e.frames)?e.frames.length:Object.keys(e.frames).length;const{w:t,h:n}=ar(e.frames).sourceSize;r=or(t,n,.1,l)}f(u.current),t.encoding=R.sRGBEncoding,h(t),v({spriteTexture:t,spriteData:u.current,aspect:r})},b=()=>{const e={},t=u.current,r=o;if(r)for(let n=0;n<r.length;n++){e[r[n]]=[];for(const a in t.frames){const o=t.frames[a],i=o.frame,s=i.x,l=i.y,c=i.w,u=i.h,d=o.sourceSize.w,m=o.sourceSize.h;"string"==typeof a&&-1!==a.toLowerCase().indexOf(r[n].toLowerCase())&&e[r[n]].push({x:s,y:l,w:c,h:u,frame:i,sourceSize:{w:d,h:m}})}}return e};return C.useLayoutEffect((()=>{null==s||s(p,m)}),[p,m]),t.useEffect((()=>{if("initTexture"in c){(Array.isArray(p)?p:[p]).forEach(c.initTexture)}}),[c,p]),{spriteObj:y,loadJsonAndTexture:function(e,t){t&&e?z(t,e,w):g(e)}}}function sr(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}ir.preload=e=>a.useLoader.preload(n.TextureLoader,e),ir.clear=e=>a.useLoader.clear(n.TextureLoader,e);function lr(e,t,...r){const n=C.useRef(),o=a.useThree((e=>e.scene));return C.useLayoutEffect((()=>{let a;if(e&&null!=e&&e.current&&t&&(n.current=a=new t(e.current,...r)),a)return a.traverse((e=>e.raycast=()=>null)),o.add(a),()=>{n.current=void 0,o.remove(a),null==a.dispose||a.dispose()}}),[o,t,e,...r]),a.useFrame((()=>{var e;null==(e=n.current)||null==e.update||e.update()})),n}const cr=e=>e.isMesh;const ur=C.forwardRef((({enabled:e=!0,firstHitOnly:t=!1,children:r,strategy:o=z.SAH,verbose:i=!1,setBoundingBox:s=!0,maxDepth:l=40,maxLeafTris:c=10,indirect:u=!1,...d},m)=>{const f=C.useRef(null),p=a.useThree((e=>e.raycaster));return C.useImperativeHandle(m,(()=>f.current),[]),C.useEffect((()=>{if(e){const e={strategy:o,verbose:i,setBoundingBox:s,maxDepth:l,maxLeafTris:c,indirect:u},r=f.current;return p.firstHitOnly=t,r.traverse((t=>{cr(t)&&!t.geometry.boundsTree&&t.raycast===n.Mesh.prototype.raycast&&(t.raycast=z.acceleratedRaycast,t.geometry.computeBoundsTree=z.computeBoundsTree,t.geometry.disposeBoundsTree=z.disposeBoundsTree,t.geometry.computeBoundsTree(e))})),()=>{delete p.firstHitOnly,r.traverse((e=>{cr(e)&&e.geometry.boundsTree&&(e.geometry.disposeBoundsTree(),e.raycast=n.Mesh.prototype.raycast)}))}}}),[]),C.createElement("group",T.default({ref:f},d),r)}));function dr(e){const t=C.useRef(null),r=C.useRef(!1),n=C.useRef(!1),o=C.useRef(e);return C.useLayoutEffect((()=>{o.current=e}),[e]),C.useEffect((()=>{const e=t.current;if(e){const t=a.addEffect((()=>(r.current=!1,!0))),i=e.onBeforeRender;e.onBeforeRender=()=>r.current=!0;const s=a.addAfterEffect((()=>(r.current!==n.current&&(null==o.current||o.current(n.current=r.current)),!0)));return()=>{e.onBeforeRender=i,t(),s()}}}),[]),t}const mr="\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",fr="\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",pr="\n#ifdef BOX_PROJECTED_ENV_MAP\n worldNormal = parallaxCorrectNormal( worldNormal, envMapSize, envMapPosition );\n#endif\n",hr="\n#ifdef BOX_PROJECTED_ENV_MAP\n reflectVec = parallaxCorrectNormal( reflectVec, envMapSize, envMapPosition );\n#endif\n";const xr=new R.Box3,yr=new R.Vector3;const vr=e=>Math.sqrt(1-Math.pow(e-1,2));class gr{constructor({size:e=256,maxAge:t=750,radius:r=.3,intensity:n=.2,interpolate:a=0,smoothing:o=0,minForce:i=.3,blend:s="screen",ease:l=vr}={}){this.size=e,this.maxAge=t,this.radius=r,this.intensity=n,this.ease=l,this.interpolate=a,this.smoothing=o,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,a=r*r+n*n,o=Math.max(this.minForce,Math.min(1e4*a,1));if(this.force=function(e,t,r=.9){return t*r+e*(1-r)}(o,this.force,this.smoothing),this.interpolate){const e=Math.ceil(a/Math.pow(.5*this.radius/this.interpolate,2));if(e>1)for(let a=1;a<e;a++)this.trail.push({x:t.x-r/e*a,y:t.y-n/e*a,age:0,force:o})}}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,a=this.ctx.createRadialGradient(t.x,t.y,Math.max(0,.25*n),t.x,t.y,Math.max(0,n));a.addColorStop(0,`rgba(255, 255, 255, ${this.intensity})`),a.addColorStop(1,"rgba(0, 0, 0, 0.0)"),this.ctx.beginPath(),this.ctx.fillStyle=a,this.ctx.arc(t.x,t.y,Math.max(0,n),0,2*Math.PI),this.ctx.fill()}}const zr=C.forwardRef((function({children:e,disable:t,disableX:r,disableY:a,disableZ:o,left:i,right:s,top:l,bottom:c,front:u,back:d,onCentered:m,precise:f=!0,cacheKey:p=0,...h},x){const y=C.useRef(null),v=C.useRef(null),g=C.useRef(null);return C.useLayoutEffect((()=>{v.current.matrixWorld.identity();const e=(new n.Box3).setFromObject(g.current,f),p=new n.Vector3,h=new n.Sphere,x=e.max.x-e.min.x,z=e.max.y-e.min.y,w=e.max.z-e.min.z;e.getCenter(p),e.getBoundingSphere(h);const b=l?z/2:c?-z/2:0,M=i?-x/2:s?x/2:0,E=u?w/2:d?-w/2:0;v.current.position.set(t||r?0:-p.x+M,t||a?0:-p.y+b,t||o?0:-p.z+E),void 0!==m&&m({parent:y.current.parent,container:y.current,width:x,height:z,depth:w,boundingBox:e,boundingSphere:h,center:p,verticalAlignment:b,horizontalAlignment:M,depthAlignment:E})}),[p,m,l,i,u,t,r,a,o,f,s,c,d]),C.useImperativeHandle(x,(()=>y.current),[]),C.createElement("group",T.default({ref:y},h),C.createElement("group",{ref:v},C.createElement("group",{ref:g},e)))})),wr=C.forwardRef((({font:e,color:t="#cbcbcb",bevelSize:r=.04,debug:n=!1,children:a,...o},i)=>{const[s,l]=C.useState(0),c=C.useCallback(((e=1)=>l(s+e)),[s]),u=C.useCallback(((e=1)=>l(s-e)),[s]),d=C.useMemo((()=>({incr:c,decr:u})),[c,u]);return C.useImperativeHandle(i,(()=>d),[d]),C.createElement("group",o,C.createElement(C.Suspense,{fallback:null},C.createElement(zr,{top:!0,cacheKey:JSON.stringify({counter:s,font:e})},C.createElement(Se,{bevelEnabled:!0,bevelSize:r,font:e},n?C.createElement("meshNormalMaterial",{wireframe:!0}):C.createElement("meshStandardMaterial",{color:t}),s))),a)})),br=(e,t)=>{"updateRanges"in e?e.updateRanges[0]=t:e.updateRange=t};const Mr=new R.Matrix4,Er=new R.Matrix4,Sr=[],Tr=new R.Mesh;class Cr extends R.Group{constructor(){super(),this.color=new R.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;Tr.geometry=r.geometry;const n=r.matrixWorld,a=r.userData.instances.indexOf(this.instanceKey);if(!(-1===a||a>r.count)){r.getMatrixAt(a,Mr),Er.multiplyMatrices(n,Mr),Tr.matrixWorld=Er,r.material instanceof R.Material?Tr.material.side=r.material.side:Tr.material.side=r.material[0].side,Tr.raycast(e,Sr);for(let e=0,r=Sr.length;e<r;e++){const r=Sr[e];r.instanceId=a,r.object=this,t.push(r)}Sr.length=0}}}const Pr=C.createContext(null),Rr=new R.Matrix4,Dr=new R.Matrix4,Fr=new R.Matrix4,kr=new R.Vector3,_r=new R.Quaternion,Ar=new R.Vector3,Lr=C.forwardRef((({context:e,children:t,...r},n)=>{C.useMemo((()=>a.extend({PositionMesh:Cr})),[]);const o=C.useRef(),{subscribe:i,getParent:s}=C.useContext(e||Pr);return C.useLayoutEffect((()=>i(o)),[]),C.createElement("positionMesh",T.default({instance:s(),instanceKey:o,ref:F.default([n,o])},r),t)})),Br=C.forwardRef((({children:e,range:t,limit:r=1e3,frames:n=1/0,...o},i)=>{const[{context:s,instance:l}]=C.useState((()=>{const e=C.createContext(null);return{context:e,instance:C.forwardRef(((t,r)=>C.createElement(Lr,T.default({context:e},t,{ref:r}))))}})),c=C.useRef(null),[u,d]=C.useState([]),[[m,f]]=C.useState((()=>{const e=new Float32Array(16*r);for(let t=0;t<r;t++)Fr.identity().toArray(e,16*t);return[e,new Float32Array([...new Array(3*r)].map((()=>1)))]}));C.useEffect((()=>{c.current.instanceMatrix.needsUpdate=!0}));let p=0,h=0;a.useFrame((()=>{if(n===1/0||p<n){c.current.updateMatrix(),c.current.updateMatrixWorld(),Rr.copy(c.current.matrixWorld).invert(),h=Math.min(r,void 0!==t?t:r,u.length),c.current.count=h,br(c.current.instanceMatrix,{offset:0,count:16*h}),br(c.current.instanceColor,{offset:0,count:3*h});for(let e=0;e<u.length;e++){const t=u[e].current;t.matrixWorld.decompose(kr,_r,Ar),Dr.compose(kr,_r,Ar).premultiply(Rr),Dr.toArray(m,16*e),c.current.instanceMatrix.needsUpdate=!0,t.color.toArray(f,3*e),c.current.instanceColor.needsUpdate=!0}p++}}));const x=C.useMemo((()=>({getParent:()=>c,subscribe:e=>(d((t=>[...t,e])),()=>d((t=>t.filter((t=>t.current!==e.current)))))})),[]);return C.createElement("instancedMesh",T.default({userData:{instances:u},matrixAutoUpdate:!1,ref:F.default([i,c]),args:[null,null,0],raycast:()=>null},o),C.createElement("instancedBufferAttribute",{attach:"instanceMatrix",count:m.length/16,array:m,itemSize:16,usage:R.DynamicDrawUsage}),C.createElement("instancedBufferAttribute",{attach:"instanceColor",count:f.length/3,array:f,itemSize:3,usage:R.DynamicDrawUsage}),"function"==typeof e?C.createElement(s.Provider,{value:x},e(l)):C.createElement(Pr.Provider,{value:x},e))})),Ur=C.forwardRef((function({meshes:e,children:t,...r},n){const a=Array.isArray(e);if(!a)for(const t of Object.keys(e))e[t].isMesh||delete e[t];return C.createElement("group",{ref:n},C.createElement(B.default,{components:(a?e:Object.values(e)).map((({geometry:e,material:t})=>C.createElement(Br,T.default({key:e.uuid,geometry:e,material:t},r))))},(r=>a?t(...r):t(Object.keys(e).filter((t=>e[t].isMesh)).reduce(((e,t,n)=>({...e,[t]:r[n]})),{})))))})),Ir=C.createContext(null);const Vr=C.forwardRef((({startFrame:e,endFrame:t,fps:r,frameName:n,textureDataURL:o,textureImageURL:i,loop:s,numberOfFrames:l,autoPlay:c,animationNames:u,onStart:d,onEnd:m,onLoopEnd:f,onFrame:p,play:h,pause:x,flipX:y,alphaTest:v,children:g,asSprite:z,offset:w,playBackwards:b,resetOnEnd:M,maxItems:E,instanceItems:S,spriteDataset:P,...D},F)=>{const k=C.useRef(),_=C.useRef(null),A=C.useRef(),L=C.useRef(),B=C.useRef(window.performance.now()),U=C.useRef(e||0),I=C.useRef(n||""),V=1e3/(r||30),[N,O]=C.useState(new R.Texture),j=C.useRef(0),[W,G]=C.useState([1,1,1]),H=y?-1:1,[$,q]=C.useState(null==z||z),X=C.useRef(x),Z=C.useRef(w),Y=C.useRef(!1),Q=C.useRef([]),{spriteObj:K,loadJsonAndTexture:J}=ir(null,null,u,l);function ee(){}const te=C.useMemo((()=>({current:Z.current,offset:Z.current,imageUrl:i,reset:ee,hasEnded:!1,ref:F})),[i,P]);C.useImperativeHandle(F,(()=>k.current),[]),C.useLayoutEffect((()=>{Z.current=w}),[w]);const re=(e,t)=>{const r=t/e;return L.current&&L.current.scale.set(1,r,1),[1,r,1]};C.useEffect((()=>{var e;P?ne(null==P||null==(e=P.spriteTexture)?void 0:e.clone(),P.spriteData):J(i,o)}),[P]),C.useEffect((()=>{var e;K&&ne(null==K||null==(e=K.spriteTexture)?void 0:e.clone(),null==K?void 0:K.spriteData)}),[K]),C.useEffect((()=>{q(null==z||z)}),[z]),C.useEffect((()=>{te.hasEnded=!1,_.current&&!0===b?U.current=_.current.frames.length-1:U.current=0}),[b]),C.useLayoutEffect((()=>{ae()}),[N,y]),C.useEffect((()=>{c&&(X.current=!1)}),[c]),C.useEffect((()=>{if(I.current!==n&&n&&(U.current=0,I.current=n,te.hasEnded=!1,ae(),_.current)){const{w:e,h:t}=ie(_.current.frames).sourceSize,r=re(e,t);G(r)}}),[n]);const ne=(e,t=null)=>{if(null===t){if(l){const r=e.image.width,n=e.image.height;j.current=l,b&&(U.current=l-1),_.current={frames:[],meta:{version:"1.0",size:{w:r,h:n},scale:"1"}},_.current.frames=t}}else{_.current=t,j.current=_.current.frames.length,b&&(U.current=j.current-1);const{w:r,h:n}=ie(_.current.frames).sourceSize,a=re(r,n);G(a),A.current&&(A.current.map=e)}if(S)for(var r=0;r<S.length;r++){const e=Object.keys(_.current.frames),t=e[Math.floor(Math.random()*e.length)];Q.current.push({key:r,frames:_.current.frames,selectedFrame:t,offset:{x:0,y:0}})}O(e)},ae=()=>{if(!_.current)return;const{meta:{size:e},frames:t}=_.current,{w:r,h:a}=Array.isArray(t)?t[0].sourceSize:n&&t[n]?t[n][0].sourceSize:{w:0,h:0};A.current.map.wrapS=A.current.map.wrapT=R.RepeatWrapping,A.current.map.center.set(0,0),A.current.map.repeat.set(1*H/(e.w/r),1/(e.h/a));const o=1/((e.h-1)/a);A.current.map.offset.x=0,A.current.map.offset.y=1-o,d&&d({currentFrameName:n,currentFrame:U.current})},oe=(e,t,r,n)=>{var a=void 0===w?te.current:w;const o=U.current;let i=0,s=0;re(e,t);const l=(r.w-1)/e,c=(r.h-1)/t;if(!n[o])return;const{frame:{x:u,y:d},sourceSize:{w:m,h:f}}=n[o],p=1/l,h=1/c;if(i=H>0?p*(u/m):p*(u/m)-A.current.map.repeat.x,s=Math.abs(1-h)-h*(d/f),A.current.map.offset.x=i,A.current.map.offset.y=s,null!=a){let e=Math.floor(a*n.length);e=Math.max(0,Math.min(e,n.length-1)),isNaN(e)&&(console.log("nan frame detected"),e=0),U.current=e}else b?U.current-=1:U.current+=1};a.useFrame(((r,a)=>{var o,i;null!=(o=_.current)&&o.frames&&null!=(i=A.current)&&i.map&&(X.current||te.hasEnded||!c&&!h||((()=>{const r=window.performance.now(),a=r-B.current,{meta:{size:o},frames:i}=_.current,{w:l,h:c}=ie(i).sourceSize,u=Array.isArray(i)?i:n?i[n]:[],p=t||u.length-1;var h=void 0===w?te.current:w,x=b?U.current<0:U.current>p,y=b?U.current===p:0===U.current,v=b?U.current<0:U.current>=p;if(x){if(U.current=s&&null!=e?e:0,b&&(U.current=p),s?null==f||f({currentFrameName:n,currentFrame:U.current}):(null==m||m({currentFrameName:n,currentFrame:U.current}),te.hasEnded=!M,M&&(X.current=!0)),!s)return}else y&&(null==d||d({currentFrameName:n,currentFrame:U.current}));void 0!==h&&v?!1===Y.current&&(null==m||m({currentFrameName:n,currentFrame:U.current}),Y.current=!0):Y.current=!1,a<=V||(B.current=r-a%V,oe(l,c,o,u))})(),p&&p({currentFrameName:I.current,currentFrame:U.current})))}));const ie=e=>{if(Array.isArray(e))return e[0];if("object"==typeof e&&null!==e){const t=Object.keys(e);return n?e[n][0]:e[t[0]][0]}return{w:0,h:0}};return C.createElement("group",T.default({},D,{ref:k}),C.createElement(Ir.Provider,{value:te},C.createElement(C.Suspense,{fallback:null},$&&C.createElement("sprite",{ref:L,scale:W},C.createElement("spriteMaterial",{premultipliedAlpha:!1,toneMapped:!1,ref:A,map:N,transparent:!0,alphaTest:null!=v?v:0})),!$&&C.createElement(Br,{limit:E},C.createElement("planeGeometry",{args:[1,1]}),C.createElement("meshBasicMaterial",{premultipliedAlpha:!1,toneMapped:!1,side:R.DoubleSide,ref:A,map:N,transparent:!0,alphaTest:null!=v?v:0}),(null!=S?S:[0]).map(((e,t)=>C.createElement(Lr,{key:t,ref:L,position:e,scale:W}))))),g))})),Nr=C.forwardRef((({children:e,curve:t},r)=>{const[n]=C.useState((()=>new R.Scene)),[o,i]=C.useState(),s=C.useRef();return C.useEffect((()=>{s.current=new d.Flow(n.children[0]),i(s.current.object3D)}),[e]),C.useEffect((()=>{var e;t&&(null==(e=s.current)||e.updateCurve(0,t))}),[t]),C.useImperativeHandle(r,(()=>({moveAlongCurve:e=>{var t;null==(t=s.current)||t.moveAlongCurve(e)}}))),C.createElement(C.Fragment,null,a.createPortal(e,n),o&&C.createElement("primitive",{object:o}))}));class Or 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 jr=C.forwardRef((({speed:e=1,...t},r)=>{const[n]=C.useState((()=>new Or));return a.useFrame((t=>n&&(n.time=t.clock.getElapsedTime()*e))),C.createElement("primitive",T.default({object:n,ref:r,attach:"material"},t))}));class Wr 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 Gr=C.forwardRef((({speed:e=1,...t},r)=>{const[n]=C.useState((()=>new Wr));return a.useFrame((t=>n&&(n.time=t.clock.getElapsedTime()*e))),C.createElement("primitive",T.default({object:n,ref:r,attach:"material"},t))}));class Hr extends R.ShaderMaterial{constructor(e=new R.Vector2){super({uniforms:{inputBuffer:new R.Uniform(null),depthBuffer:new R.Uniform(null),resolution:new R.Uniform(new R.Vector2),texelSize:new R.Uniform(new R.Vector2),halfTexelSize:new R.Uniform(new R.Vector2),kernel:new R.Uniform(0),scale:new R.Uniform(1),cameraNear:new R.Uniform(0),cameraFar:new R.Uniform(1),minDepthThreshold:new R.Uniform(0),maxDepthThreshold:new R.Uniform(1),depthScale:new R.Uniform(0),depthToBlurRatioBias:new R.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 <${Fe>=154?"colorspace_fragment":"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:R.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 $r{constructor({gl:e,resolution:t,width:r=500,height:a=500,minDepthThreshold:o=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 Hr,this.convolutionMaterial.setTexelSize(1/r,1/a),this.convolutionMaterial.setResolution(new n.Vector2(r,a)),this.scene=new n.Scene,this.camera=new n.Camera,this.convolutionMaterial.uniforms.minDepthThreshold.value=o,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]),d=new n.BufferGeometry;d.setAttribute("position",new n.BufferAttribute(c,3)),d.setAttribute("uv",new n.BufferAttribute(u,2)),this.screen=new n.Mesh(d,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(e,t,r){const n=this.scene,a=this.camera,o=this.renderTargetA,i=this.renderTargetB;let s=this.convolutionMaterial,l=s.uniforms;l.depthBuffer.value=t.depthTexture;const c=s.kernel;let u,d,m,f=t;for(d=0,m=c.length-1;d<m;++d)u=0==(1&d)?o:i,l.kernel.value=c[d],l.inputBuffer.value=f.texture,e.setRenderTarget(u),e.render(n,a),f=u;l.kernel.value=c[d],l.inputBuffer.value=f.texture,e.setRenderTarget(this.renderToScreen?null:r),e.render(n,a)}}class qr 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}}const Xr=C.forwardRef((({mixBlur:e=0,mixStrength:t=1,resolution:r=256,blur:o=[0,0],minDepthThreshold:i=.9,maxDepthThreshold:s=1,depthScale:l=0,depthToBlurRatioBias:c=.25,mirror:u=0,distortion:d=1,mixContrast:m=1,distortionMap:f,reflectorOffset:p=0,...h},x)=>{a.extend({MeshReflectorMaterialImpl:qr});const y=a.useThree((({gl:e})=>e)),v=a.useThree((({camera:e})=>e)),g=a.useThree((({scene:e})=>e)),z=(o=Array.isArray(o)?o:[o,o])[0]+o[1]>0,w=C.useRef(null),[b]=C.useState((()=>new n.Plane)),[M]=C.useState((()=>new n.Vector3)),[E]=C.useState((()=>new n.Vector3)),[S]=C.useState((()=>new n.Vector3)),[P]=C.useState((()=>new n.Matrix4)),[R]=C.useState((()=>new n.Vector3(0,0,-1))),[D]=C.useState((()=>new n.Vector4)),[k]=C.useState((()=>new n.Vector3)),[_]=C.useState((()=>new n.Vector3)),[A]=C.useState((()=>new n.Vector4)),[L]=C.useState((()=>new n.Matrix4)),[B]=C.useState((()=>new n.PerspectiveCamera)),U=C.useCallback((()=>{var e;const t=w.current.parent||(null==(e=w.current)?void 0:e.__r3f.parent);if(!t)return;if(E.setFromMatrixPosition(t.matrixWorld),S.setFromMatrixPosition(v.matrixWorld),P.extractRotation(t.matrixWorld),M.set(0,0,1),M.applyMatrix4(P),E.addScaledVector(M,p),k.subVectors(E,S),k.dot(M)>0)return;k.reflect(M).negate(),k.add(E),P.extractRotation(v.matrixWorld),R.set(0,0,-1),R.applyMatrix4(P),R.add(S),_.subVectors(E,R),_.reflect(M).negate(),_.add(E),B.position.copy(k),B.up.set(0,1,0),B.up.applyMatrix4(P),B.up.reflect(M),B.lookAt(_),B.far=v.far,B.updateMatrixWorld(),B.projectionMatrix.copy(v.projectionMatrix),L.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),L.multiply(B.projectionMatrix),L.multiply(B.matrixWorldInverse),L.multiply(t.matrixWorld),b.setFromNormalAndCoplanarPoint(M,E),b.applyMatrix4(B.matrixWorldInverse),D.set(b.normal.x,b.normal.y,b.normal.z,b.constant);const r=B.projectionMatrix;A.x=(Math.sign(D.x)+r.elements[8])/r.elements[0],A.y=(Math.sign(D.y)+r.elements[9])/r.elements[5],A.z=-1,A.w=(1+r.elements[10])/r.elements[14],D.multiplyScalar(2/D.dot(A)),r.elements[2]=D.x,r.elements[6]=D.y,r.elements[10]=D.z+1,r.elements[14]=D.w}),[v,p]),[I,V,N,O]=C.useMemo((()=>{const a={minFilter:n.LinearFilter,magFilter:n.LinearFilter,type:n.HalfFloatType},p=new n.WebGLRenderTarget(r,r,a);p.depthBuffer=!0,p.depthTexture=new n.DepthTexture(r,r),p.depthTexture.format=n.DepthFormat,p.depthTexture.type=n.UnsignedShortType;const h=new n.WebGLRenderTarget(r,r,a);return[p,h,new $r({gl:y,resolution:r,width:o[0],height:o[1],minDepthThreshold:i,maxDepthThreshold:s,depthScale:l,depthToBlurRatioBias:c}),{mirror:u,textureMatrix:L,mixBlur:e,tDiffuse:p.texture,tDepth:p.depthTexture,tDiffuseBlur:h.texture,hasBlur:z,mixStrength:t,minDepthThreshold:i,maxDepthThreshold:s,depthScale:l,depthToBlurRatioBias:c,distortion:d,distortionMap:f,mixContrast:m,"defines-USE_BLUR":z?"":void 0,"defines-USE_DEPTH":l>0?"":void 0,"defines-USE_DISTORTION":f?"":void 0}]}),[y,o,L,r,u,z,e,t,i,s,l,c,d,f,m]);return a.useFrame((()=>{var e;const t=w.current.parent||(null==(e=w.current)?void 0:e.__r3f.parent);if(!t)return;t.visible=!1;const r=y.xr.enabled,n=y.shadowMap.autoUpdate;U(),y.xr.enabled=!1,y.shadowMap.autoUpdate=!1,y.setRenderTarget(I),y.state.buffers.depth.setMask(!0),y.autoClear||y.clear(),y.render(g,B),z&&N.render(y,I,V),y.xr.enabled=r,y.shadowMap.autoUpdate=n,t.visible=!0,y.setRenderTarget(null)})),C.createElement("meshReflectorMaterialImpl",T.default({attach:"material",key:"key"+O["defines-USE_BLUR"]+O["defines-USE_DEPTH"]+O["defines-USE_DISTORTION"],ref:F.default([w,x])},O,h))})),Zr=Pe({envMap:null,bounces:3,ior:2.4,correctMips:!0,aberrationStrength:.01,fresnel:0,bvh:new z.MeshBVHUniformStruct,color:new R.Color("white"),resolution:new R.Vector2,viewMatrixInverse:new R.Matrix4,projectionMatrixInverse:new R.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 ${z.shaderStructs}\n ${z.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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);const Yr=Pe({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");class Qr extends R.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 R.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},this.anisotropy>0&&(r.defines.USE_ANISOTROPY=""),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 Kr=C.forwardRef((({buffer:e,transmissionSampler:t=!1,backside:r=!1,side:n=R.FrontSide,transmission:o=1,thickness:i=0,backsideThickness:s=0,samples:l=10,resolution:c,backsideResolution:u,background:d,anisotropy:m,anisotropicBlur:f,...p},h)=>{a.extend({MeshTransmissionMaterial:Qr});const x=C.useRef(null),[y]=C.useState((()=>new Yr)),v=st(u||c),g=st(c);let z,w,b;return a.useFrame((e=>{x.current.time=e.clock.getElapsedTime(),x.current.buffer!==g.texture||t||(b=x.current.__r3f.parent,b&&(w=e.gl.toneMapping,z=e.scene.background,e.gl.toneMapping=R.NoToneMapping,d&&(e.scene.background=d),b.material=y,r&&(e.gl.setRenderTarget(v),e.gl.render(e.scene,e.camera),b.material=x.current,b.material.buffer=v.texture,b.material.thickness=s,b.material.side=R.BackSide),e.gl.setRenderTarget(g),e.gl.render(e.scene,e.camera),b.material=x.current,b.material.thickness=i,b.material.side=n,b.material.buffer=g.texture,e.scene.background=z,e.gl.setRenderTarget(null),e.gl.toneMapping=w))})),C.useImperativeHandle(h,(()=>x.current),[]),C.createElement("meshTransmissionMaterial",T.default({args:[l,t],ref:x},p,{buffer:e||g.texture,_transmission:o,anisotropicBlur:null!=f?f:m,transmission:t?o:0,thickness:i,side:n}))})),Jr=C.forwardRef(((e,t)=>(a.extend({DiscardMaterialImpl:Yr}),C.createElement("discardMaterialImpl",T.default({ref:t},e))))),en=Fe>=154?"opaque_fragment":"output_fragment";class tn extends R.PointsMaterial{constructor(e){super(e),this.onBeforeCompile=(e,t)=>{const{isWebGL2:r}=t.capabilities;e.fragmentShader=e.fragmentShader.replace(`#include <${en}>`,`\n ${r?`#include <${en}>`:`#extension GL_OES_standard_derivatives : enable\n#include <${en}>`}\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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n `)}}}const rn=C.forwardRef(((e,t)=>{const[r]=C.useState((()=>new tn(null)));return C.createElement("primitive",T.default({},e,{object:r,ref:t,attach:"material"}))}));function nn(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 an(e,t){const r=e+"Geometry";return C.forwardRef((({args:e,children:n,...a},o)=>{const i=C.useRef(null);return C.useImperativeHandle(o,(()=>i.current)),C.useLayoutEffect((()=>{null==t||t(i.current)})),C.createElement("mesh",T.default({ref:i},a),C.createElement(r,{attach:"geometry",args:e}),n)}))}const on=an("box"),sn=an("circle"),ln=an("cone"),cn=an("cylinder"),un=an("sphere"),dn=an("plane"),mn=an("tube"),fn=an("torus"),pn=an("torusKnot"),hn=an("tetrahedron"),xn=an("ring"),yn=an("polyhedron"),vn=an("icosahedron"),gn=an("octahedron"),zn=an("dodecahedron"),wn=an("extrude"),bn=an("lathe"),Mn=an("capsule"),En=an("shape",(({geometry:e})=>{const t=e.attributes.position,r=(new R.Box3).setFromBufferAttribute(t),n=new R.Vector3;r.getSize(n);const a=[];let o=0,i=0,s=0,l=0;for(let e=0;e<t.count;e++)o=t.getX(e),i=t.getY(e),s=(o-r.min.x)/n.x,l=(i-r.min.y)/n.y,a.push(s,l);e.setAttribute("uv",new R.Float32BufferAttribute(a,2))})),Sn=1e-5;const Tn=C.forwardRef((function({args:[e=1,t=1,r=1]=[],radius:a=.05,steps:o=1,smoothness:i=4,bevelSegments:s=4,creaseAngle:l=.4,children:c,...u},m){const f=C.useMemo((()=>function(e,t,r){const a=new n.Shape,o=r-Sn;return a.absarc(Sn,Sn,Sn,-Math.PI/2,-Math.PI,!0),a.absarc(Sn,t-2*o,Sn,Math.PI,Math.PI/2,!0),a.absarc(e-2*o,t-2*o,Sn,Math.PI/2,0,!0),a.absarc(e-2*o,Sn,Sn,0,-Math.PI/2,!0),a}(e,t,a)),[e,t,a]),p=C.useMemo((()=>({depth:r-2*a,bevelEnabled:!0,bevelSegments:2*s,steps:o,bevelSize:a-Sn,bevelThickness:a,curveSegments:i})),[r,a,i]),h=C.useRef(null);return C.useLayoutEffect((()=>{h.current&&(h.current.center(),d.toCreasedNormals(h.current,l))}),[f,p]),C.createElement("mesh",T.default({ref:m},u),C.createElement("extrudeGeometry",{ref:h,args:[f,p]}),c)}));function Cn(){const e=new R.BufferGeometry,t=new Float32Array([-1,-1,3,-1,-1,3]);return e.boundingSphere=new R.Sphere,e.boundingSphere.set(new R.Vector3,1/0),e.setAttribute("position",new R.BufferAttribute(t,2)),e}const Pn=C.forwardRef((function({children:e,...t},r){const n=C.useMemo(Cn,[]);return C.createElement("mesh",T.default({ref:r,geometry:n,frustumCulled:!1},t),e)})),Rn=C.forwardRef((({children:e,width:t,height:r,depth:n,box3:a,precise:o=!0,...i},s)=>{const l=C.useRef(null),c=C.useRef(null),u=C.useRef(null);return C.useLayoutEffect((()=>{c.current.matrixWorld.identity();let e=a||(new R.Box3).setFromObject(u.current,o);const i=e.max.x-e.min.x,s=e.max.y-e.min.y,l=e.max.z-e.min.z;let d=Math.max(i,s,l);t&&(d=i),r&&(d=s),n&&(d=l),c.current.scale.setScalar(1/d)}),[t,r,n,a,o]),C.useImperativeHandle(s,(()=>l.current),[]),C.createElement("group",T.default({ref:l},i),C.createElement("group",{ref:c},C.createElement("group",{ref:u},e)))}));var Dn=function(e){return e[e.NONE=0]="NONE",e[e.START=1]="START",e[e.ACTIVE=2]="ACTIVE",e}(Dn||{});const Fn=e=>e&&e.isOrthographicCamera,kn=e=>e&&e.isBox3,_n=e=>1-Math.exp(-5*e)+.007*e,An=C.createContext(null);function Ln({children:e,maxDuration:t=1,margin:r=1.2,observe:n,fit:o,clip:i,interpolateFunc:s=_n,onFit:l}){const c=C.useRef(null),{camera:u,size:d,invalidate:m}=a.useThree(),f=a.useThree((e=>e.controls)),p=C.useRef(l);p.current=l;const h=C.useRef({camPos:new R.Vector3,camRot:new R.Quaternion,camZoom:1}),x=C.useRef({camPos:void 0,camRot:void 0,camZoom:void 0,camUp:void 0,target:void 0}),y=C.useRef(Dn.NONE),v=C.useRef(0),[g]=C.useState((()=>new R.Box3)),z=C.useMemo((()=>{function e(){const e=g.getSize(new R.Vector3),t=g.getCenter(new R.Vector3),n=Math.max(e.x,e.y,e.z),a=Fn(u)?4*n:n/(2*Math.atan(Math.PI*u.fov/360)),o=Fn(u)?4*n:a/u.aspect,i=r*Math.max(a,o);return{box:g,size:e,center:t,distance:i}}return{getSize:e,refresh(e){if(kn(e))g.copy(e);else{const t=e||c.current;if(!t)return this;t.updateWorldMatrix(!0,!0),g.setFromObject(t)}if(g.isEmpty()){const e=u.position.length()||10;g.setFromCenterAndSize(new R.Vector3,new R.Vector3(e,e,e))}return h.current.camPos.copy(u.position),h.current.camRot.copy(u.quaternion),Fn(u)&&(h.current.camZoom=u.zoom),x.current.camPos=void 0,x.current.camRot=void 0,x.current.camZoom=void 0,x.current.camUp=void 0,x.current.target=void 0,this},reset(){const{center:t,distance:r}=e(),n=u.position.clone().sub(t).normalize();x.current.camPos=t.clone().addScaledVector(n,r),x.current.target=t.clone();const a=(new R.Matrix4).lookAt(x.current.camPos,x.current.target,u.up);return x.current.camRot=(new R.Quaternion).setFromRotationMatrix(a),y.current=Dn.START,v.current=0,this},moveTo(e){return x.current.camPos=Array.isArray(e)?new R.Vector3(...e):e.clone(),y.current=Dn.START,v.current=0,this},lookAt({target:e,up:t}){x.current.target=Array.isArray(e)?new R.Vector3(...e):e.clone(),x.current.camUp=t?Array.isArray(t)?new R.Vector3(...t):t.clone():u.up.clone();const r=(new R.Matrix4).lookAt(x.current.camPos||u.position,x.current.target,x.current.camUp);return x.current.camRot=(new R.Quaternion).setFromRotationMatrix(r),y.current=Dn.START,v.current=0,this},to({position:e,target:t}){return this.moveTo(e).lookAt({target:t})},fit(){if(!Fn(u))return this.reset();let e=0,t=0;const n=[new R.Vector3(g.min.x,g.min.y,g.min.z),new R.Vector3(g.min.x,g.max.y,g.min.z),new R.Vector3(g.min.x,g.min.y,g.max.z),new R.Vector3(g.min.x,g.max.y,g.max.z),new R.Vector3(g.max.x,g.max.y,g.max.z),new R.Vector3(g.max.x,g.max.y,g.min.z),new R.Vector3(g.max.x,g.min.y,g.max.z),new R.Vector3(g.max.x,g.min.y,g.min.z)],a=x.current.camPos||u.position,o=x.current.target||(null==f?void 0:f.target),i=x.current.camUp||u.up,s=o?(new R.Matrix4).lookAt(a,o,i).setPosition(a).invert():u.matrixWorldInverse;for(const r of n)r.applyMatrix4(s),e=Math.max(e,Math.abs(r.y)),t=Math.max(t,Math.abs(r.x));e*=2,t*=2;const l=(u.top-u.bottom)/e,c=(u.right-u.left)/t;return x.current.camZoom=Math.min(l,c)/r,y.current=Dn.START,v.current=0,p.current&&p.current(this.getSize()),this},clip(){const{distance:t}=e();return u.near=t/100,u.far=100*t,u.updateProjectionMatrix(),f&&(f.maxDistance=10*t,f.update()),m(),this}}}),[g,u,f,r,m]);C.useLayoutEffect((()=>{if(f){const e=()=>{if(f&&x.current.target&&y.current!==Dn.NONE){const e=(new R.Vector3).setFromMatrixColumn(u.matrix,2),t=h.current.camPos.distanceTo(f.target),r=(x.current.camPos||h.current.camPos).distanceTo(x.current.target),n=(1-v.current)*t+v.current*r;f.target.copy(u.position).addScaledVector(e,-n),f.update()}y.current=Dn.NONE};return f.addEventListener("start",e),()=>f.removeEventListener("start",e)}}),[f]);const w=C.useRef(0);return C.useLayoutEffect((()=>{(n||0==w.current++)&&(z.refresh(),o&&z.reset().fit(),i&&z.clip())}),[d,i,o,n,u,f]),a.useFrame(((e,r)=>{if(y.current===Dn.START)y.current=Dn.ACTIVE,m();else if(y.current===Dn.ACTIVE){if(v.current+=r/t,v.current>=1)x.current.camPos&&u.position.copy(x.current.camPos),x.current.camRot&&u.quaternion.copy(x.current.camRot),x.current.camUp&&u.up.copy(x.current.camUp),x.current.camZoom&&Fn(u)&&(u.zoom=x.current.camZoom),u.updateMatrixWorld(),u.updateProjectionMatrix(),f&&x.current.target&&(f.target.copy(x.current.target),f.update()),y.current=Dn.NONE;else{const e=s(v.current);x.current.camPos&&u.position.lerpVectors(h.current.camPos,x.current.camPos,e),x.current.camRot&&u.quaternion.slerpQuaternions(h.current.camRot,x.current.camRot,e),x.current.camUp&&u.up.set(0,1,0).applyQuaternion(u.quaternion),x.current.camZoom&&Fn(u)&&(u.zoom=(1-e)*h.current.camZoom+e*x.current.camZoom),u.updateMatrixWorld(),u.updateProjectionMatrix()}m()}})),C.createElement("group",{ref:c},C.createElement(An.Provider,{value:z},e))}function Bn(){return C.useContext(An)}const Un=C.forwardRef((({intensity:e=1,decay:t,decayRate:r=.65,maxYaw:n=.1,maxPitch:o=.1,maxRoll:i=.1,yawFrequency:s=.1,pitchFrequency:l=.1,rollFrequency:c=.1},u)=>{const m=a.useThree((e=>e.camera)),f=a.useThree((e=>e.controls)),p=C.useRef(e),h=C.useRef(m.rotation.clone()),[x]=C.useState((()=>new d.SimplexNoise)),[y]=C.useState((()=>new d.SimplexNoise)),[v]=C.useState((()=>new d.SimplexNoise)),g=()=>{(p.current<0||p.current>1)&&(p.current=p.current<0?0:1)};return C.useImperativeHandle(u,(()=>({getIntensity:()=>p.current,setIntensity:e=>{p.current=e,g()}})),[]),C.useEffect((()=>{if(f){const e=()=>{h.current=m.rotation.clone()};return f.addEventListener("change",e),e(),()=>{f.removeEventListener("change",e)}}}),[m,f]),a.useFrame(((e,a)=>{const u=Math.pow(p.current,2),d=n*u*x.noise(e.clock.elapsedTime*s,1),f=o*u*y.noise(e.clock.elapsedTime*l,1),z=i*u*v.noise(e.clock.elapsedTime*c,1);m.rotation.set(h.current.x+f,h.current.y+d,h.current.z+z),t&&p.current>0&&(p.current-=r*a,g())})),null})),In=C.forwardRef((({children:e,enabled:t=!0,speed:r=1,rotationIntensity:n=1,floatIntensity:o=1,floatingRange:i=[-.1,.1],...s},l)=>{const c=C.useRef(null),u=C.useRef(1e4*Math.random());return a.useFrame((e=>{var a,s;if(!t||0===r)return;const l=u.current+e.clock.getElapsedTime();c.current.rotation.x=Math.cos(l/4*r)/8*n,c.current.rotation.y=Math.sin(l/4*r)/8*n,c.current.rotation.z=Math.sin(l/4*r)/20*n;let d=Math.sin(l/4*r)/10;d=R.MathUtils.mapLinear(d,-.1,.1,null!==(a=null==i?void 0:i[0])&&void 0!==a?a:-.1,null!==(s=null==i?void 0:i[1])&&void 0!==s?s:.1),c.current.position.y=d*o,c.current.updateMatrix()})),C.createElement("group",s,C.createElement("group",{ref:F.default([c,l]),matrixAutoUpdate:!1},e))})),Vn={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"},Nn="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",On=e=>Array.isArray(e);function jn({files:e=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"],path:t="",preset:r,encoding:o,extensions:i}={}){var s;let l,c=null,u=!1;if(r){if(!(r in Vn))throw new Error("Preset must be one of: "+Object.keys(Vn).join(", "));e=Vn[r],t=Nn}if(u=On(e),l=On(e)?"cube":e.startsWith("data:application/exr")?"exr":e.startsWith("data:application/hdr")?"hdr":null==(s=e.split(".").pop())||null==(s=s.split("?"))||null==(s=s.shift())?void 0:s.toLowerCase(),c=u?n.CubeTextureLoader:"hdr"===l?d.RGBELoader:"exr"===l?d.EXRLoader:null,!c)throw new Error("useEnvironment: Unrecognized file extension: "+e);const m=a.useLoader(c,u?[e]:e,(e=>{null==e.setPath||e.setPath(t),i&&i(e)})),f=u?m[0]:m;f.mapping=u?n.CubeReflectionMapping:n.EquirectangularReflectionMapping;return"colorSpace"in f?f.colorSpace=(null!=o?o:u)?"srgb":"srgb-linear":f.encoding=(null!=o?o:u)?3001:3e3,f}const Wn=e=>{return(t=e).current&&t.current.isScene?e.current:e;var t};function Gn(e,t,r,n,a=0){const o=Wn(t||r),i=o.background,s=o.environment,l=o.backgroundBlurriness||0;return"only"!==e&&(o.environment=n),e&&(o.background=n),e&&void 0!==o.backgroundBlurriness&&(o.backgroundBlurriness=a),()=>{"only"!==e&&(o.environment=s),e&&(o.background=i),e&&void 0!==o.backgroundBlurriness&&(o.backgroundBlurriness=l)}}function Hn({scene:e,background:t=!1,blur:r,map:n}){const o=a.useThree((e=>e.scene));return C.useLayoutEffect((()=>{if(n)return Gn(t,e,o,n,r)}),[o,e,n,t,r]),null}function $n({background:e=!1,scene:t,blur:r,...n}){const o=jn(n),i=a.useThree((e=>e.scene));return C.useLayoutEffect((()=>Gn(e,t,i,o,r)),[o,e,t,i,r]),null}function qn({children:e,near:t=1,far:r=1e3,resolution:o=256,frames:i=1,map:s,background:l=!1,blur:c,scene:u,files:d,path:m,preset:f,extensions:p}){const h=a.useThree((e=>e.gl)),x=a.useThree((e=>e.scene)),y=C.useRef(null),[v]=C.useState((()=>new n.Scene)),g=C.useMemo((()=>{const e=new n.WebGLCubeRenderTarget(o);return e.texture.type=n.HalfFloatType,e}),[o]);C.useLayoutEffect((()=>(1===i&&y.current.update(h,v),Gn(l,u,x,g.texture,c))),[e,v,g.texture,u,x,l,i,h]);let z=1;return a.useFrame((()=>{(i===1/0||z<i)&&(y.current.update(h,v),z++)})),C.createElement(C.Fragment,null,a.createPortal(C.createElement(C.Fragment,null,e,C.createElement("cubeCamera",{ref:y,args:[t,r,g]}),d||f?C.createElement($n,{background:!0,files:d,preset:f,path:m,extensions:p}):s?C.createElement(Hn,{background:!0,map:s,extensions:p}):null),v))}function Xn(e){var t,r,n,o;const i=jn(e),s=e.map||i;C.useMemo((()=>a.extend({GroundProjectedEnvImpl:d.GroundProjectedEnv})),[]);const l=C.useMemo((()=>[s]),[s]),c=null==(t=e.ground)?void 0:t.height,u=null==(r=e.ground)?void 0:r.radius,m=null!==(n=null==(o=e.ground)?void 0:o.scale)&&void 0!==n?n:1e3;return C.createElement(C.Fragment,null,C.createElement(Hn,T.default({},e,{map:s})),C.createElement("groundProjectedEnvImpl",{args:l,scale:m,height:c,radius:u}))}function Zn(e){return e.ground?C.createElement(Xn,e):e.map?C.createElement(Hn,e):e.children?C.createElement(qn,e):C.createElement($n,e)}const Yn=C.forwardRef((({scale:e=10,frames:t=1/0,opacity:r=1,width:n=1,height:o=1,blur:i=1,near:s=0,far:l=10,resolution:c=512,smooth:u=!0,color:m="#000000",depthWrite:f=!1,renderOrder:p,...h},x)=>{const y=C.useRef(null),v=a.useThree((e=>e.scene)),g=a.useThree((e=>e.gl)),z=C.useRef(null);n*=Array.isArray(e)?e[0]:e||1,o*=Array.isArray(e)?e[1]:e||1;const[w,b,M,E,S,P,D]=C.useMemo((()=>{const e=new R.WebGLRenderTarget(c,c),t=new R.WebGLRenderTarget(c,c);t.texture.generateMipmaps=e.texture.generateMipmaps=!1;const r=new R.PlaneGeometry(n,o).rotateX(Math.PI/2),a=new R.Mesh(r),i=new R.MeshDepthMaterial;i.depthTest=i.depthWrite=!1,i.onBeforeCompile=e=>{e.uniforms={...e.uniforms,ucolor:{value:new R.Color(m)}},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 R.ShaderMaterial(d.HorizontalBlurShader),l=new R.ShaderMaterial(d.VerticalBlurShader);return l.depthTest=s.depthTest=!1,[e,r,i,a,s,l,t]}),[c,n,o,e,m]),F=e=>{E.visible=!0,E.material=S,S.uniforms.tDiffuse.value=w.texture,S.uniforms.h.value=1*e/256,g.setRenderTarget(D),g.render(E,z.current),E.material=P,P.uniforms.tDiffuse.value=D.texture,P.uniforms.v.value=1*e/256,g.setRenderTarget(w),g.render(E,z.current),E.visible=!1};let k,_,A=0;return a.useFrame((()=>{z.current&&(t===1/0||A<t)&&(A++,k=v.background,_=v.overrideMaterial,y.current.visible=!1,v.background=null,v.overrideMaterial=M,g.setRenderTarget(w),g.render(v,z.current),F(i),u&&F(.4*i),g.setRenderTarget(null),y.current.visible=!0,v.overrideMaterial=_,v.background=k)})),C.useImperativeHandle(x,(()=>y.current),[]),C.createElement("group",T.default({"rotation-x":Math.PI/2},h,{ref:y}),C.createElement("mesh",{renderOrder:p,geometry:b,scale:[1,-1,1],rotation:[-Math.PI/2,0,0]},C.createElement("meshBasicMaterial",{transparent:!0,map:w.texture,opacity:r,depthWrite:f})),C.createElement("orthographicCamera",{ref:z,args:[-n/2,n/2,o/2,-o/2,s,l]}))}));const Qn=C.createContext(null),Kn=Pe({color:new R.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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),Jn=C.forwardRef((({children:e,temporal:t,frames:r=40,limit:n=1/0,blend:o=20,scale:i=10,opacity:s=1,alphaTest:l=.75,color:c="black",colorBlend:u=2,resolution:d=1024,toneMapped:m=!0,...f},p)=>{a.extend({SoftShadowMaterial:Kn});const h=a.useThree((e=>e.gl)),x=a.useThree((e=>e.scene)),y=a.useThree((e=>e.camera)),v=a.useThree((e=>e.invalidate)),g=C.useRef(null),z=C.useRef(null),[w]=C.useState((()=>new ta(h,x,d)));C.useLayoutEffect((()=>{w.configure(g.current)}),[]);const b=C.useMemo((()=>({lights:new Map,temporal:!!t,frames:Math.max(2,r),blend:Math.max(2,r===1/0?o: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,o,s,l]);return C.useLayoutEffect((()=>{b.reset(),b.temporal||b.frames===1/0||b.update(b.blend)})),C.useImperativeHandle(p,(()=>b),[b]),a.useFrame((()=>{(b.temporal||b.frames===1/0)&&b.count<b.frames&&b.count<n&&(v(),b.update(),b.count++)})),C.createElement("group",f,C.createElement("group",{traverse:()=>null,ref:z},C.createElement(Qn.Provider,{value:b},e)),C.createElement("mesh",{receiveShadow:!0,ref:g,scale:i,rotation:[-Math.PI/2,0,0]},C.createElement("planeGeometry",null),C.createElement("softShadowMaterial",{transparent:!0,depthWrite:!1,toneMapped:m,color:c,blend:u,map:w.progressiveLightMap2.texture})))})),ea=C.forwardRef((({castShadow:e=!0,bias:t=.001,mapSize:r=512,size:n=5,near:a=.5,far:o=500,frames:i=1,position:s=[0,0,0],radius:l=1,amount:c=8,intensity:u=(Fe>=155?Math.PI:1),ambient:d=.5,...m},f)=>{const p=C.useRef(null),h=new R.Vector3(...s).length(),x=C.useContext(Qn),y=C.useCallback((()=>{let e;if(p.current)for(let t=0;t<p.current.children.length;t++)if(e=p.current.children[t],Math.random()>d)e.position.set(s[0]+R.MathUtils.randFloatSpread(l),s[1]+R.MathUtils.randFloatSpread(l),s[2]+R.MathUtils.randFloatSpread(l));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)*h,Math.abs(Math.cos(t)*Math.sin(r)*h),Math.sin(t)*h)}}),[l,d,h,...s]),v=C.useMemo((()=>({update:y})),[y]);return C.useImperativeHandle(f,(()=>v),[v]),C.useLayoutEffect((()=>{var e;const t=p.current;return x&&(null==(e=x.lights)||e.set(t.uuid,v)),()=>{var e;null==x||null==(e=x.lights)||e.delete(t.uuid)}}),[x,v]),C.createElement("group",T.default({ref:p},m),Array.from({length:c},((i,s)=>C.createElement("directionalLight",{key:s,castShadow:e,"shadow-bias":t,"shadow-mapSize":[r,r],intensity:u/c},C.createElement("orthographicCamera",{attach:"shadow-camera",args:[-n,n,n,-n,a,o]})))))}));class ta{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 R.Color,this.clearAlpha=0;const n={type:R.HalfFloatType,magFilter:R.NearestFilter,minFilter:R.NearestFilter};this.progressiveLightMap1=new R.WebGLRenderTarget(this.res,this.res,n),this.progressiveLightMap2=new R.WebGLRenderTarget(this.res,this.res,n),this.discardMat=new Yr,this.targetMat=new R.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,a=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=a}}const ra={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 na({radius:e,adjustCamera:t}){const r=Bn();return C.useEffect((()=>{t&&r.refresh().clip().fit()}),[e,t]),null}const aa=e=>0===e?0:Math.pow(2,10*e-10);const oa=C.forwardRef((({fog:e=!1,renderOrder:t,depthWrite:r=!1,colorStop:a=0,color:o="black",opacity:i=.5,...s},l)=>{const c=C.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(o).getStyle()),r.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=r,t.fillRect(0,0,e.width,e.height),e}),[o,a]);return C.createElement("mesh",T.default({renderOrder:t,ref:l,"rotation-x":-Math.PI/2},s),C.createElement("planeGeometry",null),C.createElement("meshBasicMaterial",{transparent:!0,opacity:i,fog:e,depthWrite:r,side:n.DoubleSide},C.createElement("canvasTexture",{attach:"map",args:[c]})))}));function ia(e=R.FrontSide){const t={value:new R.Matrix4};return Object.assign(new R.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 sa=Pe({causticsTexture:null,causticsTextureB:null,color:new R.Color,lightProjMatrix:new R.Matrix4,lightViewMatrix:new R.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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),la=Pe({cameraMatrixWorld:new R.Matrix4,cameraProjectionMatrixInv:new R.Matrix4,normalTexture:null,depthTexture:null,lightDir:new R.Vector3(0,1,0),lightPlaneNormal:new R.Vector3(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new R.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 }"),ca={depth:!0,minFilter:R.LinearFilter,magFilter:R.LinearFilter,type:R.UnsignedByteType},ua={minFilter:R.LinearMipmapLinearFilter,magFilter:R.LinearFilter,type:R.FloatType,generateMipmaps:!0},da=C.forwardRef((({debug:e,children:t,frames:r=1,ior:n=1.1,color:o="white",causticsOnly:i=!1,backside:s=!1,backsideIOR:l=1.1,worldRadius:c=.3125,intensity:u=.05,resolution:m=2024,lightSource:f=[5,5,5],...p},h)=>{a.extend({CausticsProjectionMaterial:sa});const x=C.useRef(null),y=C.useRef(null),v=C.useRef(null),g=C.useRef(null),z=a.useThree((e=>e.gl)),w=lr(e&&y,R.CameraHelper),b=st(m,m,ca),M=st(m,m,ca),E=st(m,m,ua),S=st(m,m,ua),[P]=C.useState((()=>ia())),[D]=C.useState((()=>ia(R.BackSide))),[F]=C.useState((()=>new la)),[k]=C.useState((()=>new d.FullScreenQuad(F)));C.useLayoutEffect((()=>{x.current.updateWorldMatrix(!1,!0)}));let _=0;const A=new R.Vector3,L=new R.Frustum,B=new R.Matrix4,U=new R.Plane,I=new R.Vector3,V=new R.Vector3,N=new R.Box3,O=new R.Vector3,j=[],W=[],G=[],H=[],$=new R.Vector3;for(let e=0;e<8;e++)j.push(new R.Vector3),W.push(new R.Vector3),G.push(new R.Vector3),H.push(new R.Vector3);return a.useFrame((()=>{if(r===1/0||_++<r){var t,a;Array.isArray(f)?I.fromArray(f).normalize():I.copy(x.current.worldToLocal(f.current.getWorldPosition(A)).normalize()),V.copy(I).multiplyScalar(-1),null==(t=v.current.parent)||t.matrixWorld.identity(),N.setFromObject(v.current,!0),j[0].set(N.min.x,N.min.y,N.min.z),j[1].set(N.min.x,N.min.y,N.max.z),j[2].set(N.min.x,N.max.y,N.min.z),j[3].set(N.min.x,N.max.y,N.max.z),j[4].set(N.max.x,N.min.y,N.min.z),j[5].set(N.max.x,N.min.y,N.max.z),j[6].set(N.max.x,N.max.y,N.min.z),j[7].set(N.max.x,N.max.y,N.max.z);for(let e=0;e<8;e++)W[e].copy(j[e]);N.getCenter(O),j.map((e=>e.sub(O)));const r=U.set(V,0);j.map(((e,t)=>r.projectPoint(e,G[t])));const o=G.reduce(((e,t)=>e.add(t)),A.set(0,0,0)).divideScalar(G.length),d=G.map((e=>e.distanceTo(o))).reduce(((e,t)=>Math.max(e,t))),p=j.map((e=>e.dot(I))).reduce(((e,t)=>Math.max(e,t)));y.current.position.copy($.copy(I).multiplyScalar(p).add(O)),y.current.lookAt(v.current.localToWorld(O));const h=B.lookAt(y.current.position,O,A.set(0,1,0));y.current.left=-d,y.current.right=d,y.current.top=d,y.current.bottom=-d;const T=A.set(0,d,0).applyMatrix4(h),C=(y.current.position.y+T.y)/I.y;y.current.near=.1,y.current.far=C,y.current.updateProjectionMatrix(),y.current.updateMatrixWorld();const R=W.map(((e,t)=>e.add(H[t].copy(I).multiplyScalar(-e.y/I.y)))),_=R.reduce(((e,t)=>e.add(t)),A.set(0,0,0)).divideScalar(R.length),q=2*R.map((e=>Math.hypot(e.x-_.x,e.z-_.z))).reduce(((e,t)=>Math.max(e,t)));g.current.scale.setScalar(q),g.current.position.copy(_),e&&(null==(a=w.current)||a.update()),D.viewMatrix.value=P.viewMatrix.value=y.current.matrixWorldInverse;const X=L.setFromProjectionMatrix(B.multiplyMatrices(y.current.projectionMatrix,y.current.matrixWorldInverse)).planes[4];F.cameraMatrixWorld=y.current.matrixWorld,F.cameraProjectionMatrixInv=y.current.projectionMatrixInverse,F.lightDir=V,F.lightPlaneNormal=X.normal,F.lightPlaneConstant=X.constant,F.near=y.current.near,F.far=y.current.far,F.resolution=m,F.size=d,F.intensity=u,F.worldRadius=c,v.current.visible=!0,z.setRenderTarget(b),z.clear(),v.current.overrideMaterial=P,z.render(v.current,y.current),z.setRenderTarget(M),z.clear(),s&&(v.current.overrideMaterial=D,z.render(v.current,y.current)),v.current.overrideMaterial=null,F.ior=n,g.current.material.lightProjMatrix=y.current.projectionMatrix,g.current.material.lightViewMatrix=y.current.matrixWorldInverse,F.normalTexture=b.texture,F.depthTexture=b.depthTexture,z.setRenderTarget(E),z.clear(),k.render(z),F.ior=l,F.normalTexture=M.texture,F.depthTexture=M.depthTexture,z.setRenderTarget(S),z.clear(),s&&k.render(z),z.setRenderTarget(null),i&&(v.current.visible=!1)}})),C.useImperativeHandle(h,(()=>x.current),[]),C.createElement("group",T.default({ref:x},p),C.createElement("scene",{ref:v},C.createElement("orthographicCamera",{ref:y,up:[0,1,0]}),t),C.createElement("mesh",{renderOrder:2,ref:g,"rotation-x":-Math.PI/2},C.createElement("planeGeometry",null),C.createElement("causticsProjectionMaterial",{transparent:!0,color:o,causticsTexture:E.texture,causticsTextureB:S.texture,blending:R.CustomBlending,blendSrc:R.OneFactor,blendDst:R.SrcAlphaFactor,depthWrite:!1}),e&&C.createElement(Ue,null,C.createElement("lineBasicMaterial",{color:"#ffff00",toneMapped:!1}))))})),ma=C.forwardRef((({mixBlur:e=0,mixStrength:t=.5,resolution:r=256,blur:o=[0,0],args:i=[1,1],minDepthThreshold:s=.9,maxDepthThreshold:l=1,depthScale:c=0,depthToBlurRatioBias:u=.25,mirror:d=0,children:m,debug:f=0,distortion:p=1,mixContrast:h=1,distortionMap:x,...y},v)=>{a.extend({MeshReflectorMaterial:qr}),C.useEffect((()=>{console.warn("Reflector has been deprecated and will be removed next major. Replace it with <MeshReflectorMaterial />!")}),[]);const g=a.useThree((({gl:e})=>e)),z=a.useThree((({camera:e})=>e)),w=a.useThree((({scene:e})=>e)),b=(o=Array.isArray(o)?o:[o,o])[0]+o[1]>0,M=C.useRef(null),[E]=C.useState((()=>new n.Plane)),[S]=C.useState((()=>new n.Vector3)),[P]=C.useState((()=>new n.Vector3)),[R]=C.useState((()=>new n.Vector3)),[D]=C.useState((()=>new n.Matrix4)),[k]=C.useState((()=>new n.Vector3(0,0,-1))),[_]=C.useState((()=>new n.Vector4)),[A]=C.useState((()=>new n.Vector3)),[L]=C.useState((()=>new n.Vector3)),[B]=C.useState((()=>new n.Vector4)),[U]=C.useState((()=>new n.Matrix4)),[I]=C.useState((()=>new n.PerspectiveCamera)),V=C.useCallback((()=>{if(P.setFromMatrixPosition(M.current.matrixWorld),R.setFromMatrixPosition(z.matrixWorld),D.extractRotation(M.current.matrixWorld),S.set(0,0,1),S.applyMatrix4(D),A.subVectors(P,R),A.dot(S)>0)return;A.reflect(S).negate(),A.add(P),D.extractRotation(z.matrixWorld),k.set(0,0,-1),k.applyMatrix4(D),k.add(R),L.subVectors(P,k),L.reflect(S).negate(),L.add(P),I.position.copy(A),I.up.set(0,1,0),I.up.applyMatrix4(D),I.up.reflect(S),I.lookAt(L),I.far=z.far,I.updateMatrixWorld(),I.projectionMatrix.copy(z.projectionMatrix),U.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),U.multiply(I.projectionMatrix),U.multiply(I.matrixWorldInverse),U.multiply(M.current.matrixWorld),E.setFromNormalAndCoplanarPoint(S,P),E.applyMatrix4(I.matrixWorldInverse),_.set(E.normal.x,E.normal.y,E.normal.z,E.constant);const e=I.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}),[]),[N,O,j,W]=C.useMemo((()=>{const a={type:n.HalfFloatType,minFilter:n.LinearFilter,magFilter:n.LinearFilter},i=new n.WebGLRenderTarget(r,r,a);i.depthBuffer=!0,i.depthTexture=new n.DepthTexture(r,r),i.depthTexture.format=n.DepthFormat,i.depthTexture.type=n.UnsignedShortType;const m=new n.WebGLRenderTarget(r,r,a);return[i,m,new $r({gl:g,resolution:r,width:o[0],height:o[1],minDepthThreshold:s,maxDepthThreshold:l,depthScale:c,depthToBlurRatioBias:u}),{mirror:d,textureMatrix:U,mixBlur:e,tDiffuse:i.texture,tDepth:i.depthTexture,tDiffuseBlur:m.texture,hasBlur:b,mixStrength:t,minDepthThreshold:s,maxDepthThreshold:l,depthScale:c,depthToBlurRatioBias:u,transparent:!0,debug:f,distortion:p,distortionMap:x,mixContrast:h,"defines-USE_BLUR":b?"":void 0,"defines-USE_DEPTH":c>0?"":void 0,"defines-USE_DISTORTION":x?"":void 0}]}),[g,o,U,r,d,b,e,t,s,l,c,u,f,p,x,h]);return a.useFrame((()=>{if(null==M||!M.current)return;M.current.visible=!1;const e=g.xr.enabled,t=g.shadowMap.autoUpdate;V(),g.xr.enabled=!1,g.shadowMap.autoUpdate=!1,g.setRenderTarget(N),g.state.buffers.depth.setMask(!0),g.autoClear||g.clear(),g.render(w,I),b&&j.render(g,N,O),g.xr.enabled=e,g.shadowMap.autoUpdate=t,M.current.visible=!0,g.setRenderTarget(null)})),C.createElement("mesh",T.default({ref:F.default([M,v])},y),C.createElement("planeGeometry",{args:i}),m?m("meshReflectorMaterial",W):C.createElement("meshReflectorMaterial",W))}));class fa extends R.ShaderMaterial{constructor(){super({uniforms:{depth:{value:null},opacity:{value:1},attenuation:{value:2.5},anglePower:{value:12},spotPosition:{value:new R.Vector3(0,0,0)},lightColor:{value:new R.Color("white")},cameraNear:{value:0},cameraFar:{value:1},resolution:{value:new R.Vector2(0,0)}},transparent:!0,depthWrite:!1,vertexShader:"\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main() {\n // compute intensity\n vNormal = normalize(normalMatrix * normal);\n vec4 worldPosition = modelMatrix * vec4(position, 1);\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n\n vIntensity = 1.0 - saturate(distance(worldPosition.xyz, spotPosition) / attenuation);\n\n gl_Position = projectionMatrix * viewPosition;\n\n #include <logdepthbuf_vertex>\n }\n ",fragmentShader:`\n varying vec3 vNormal;\n varying float vViewZ;\n varying float vIntensity;\n\n uniform vec3 lightColor;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float opacity;\n\n #include <packing>\n #include <logdepthbuf_pars_fragment>\n\n float readDepth(sampler2D depthSampler, vec2 uv) {\n float fragCoordZ = texture(depthSampler, uv).r;\n\n // https://github.com/mrdoob/three.js/issues/23072\n #ifdef USE_LOGDEPTHBUF\n float viewZ = 1.0 - exp2(fragCoordZ * log(cameraFar + 1.0) / log(2.0));\n #else\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n #endif\n\n return viewZ;\n }\n\n void main() {\n #include <logdepthbuf_fragment>\n\n vec3 normal = vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity = pow(dot(normal, vec3(0, 0, 1)), anglePower);\n float intensity = vIntensity * angleIntensity;\n\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 uv = gl_FragCoord.xy / resolution;\n intensity *= smoothstep(0.0, 1.0, vViewZ - readDepth(depth, uv));\n }\n\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n #include <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `})}}var pa="#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 ha=e=>null==e?void 0:e.isSpotLight;function xa({opacity:e=1,radiusTop:t,radiusBottom:r,depthBuffer:o,color:i="white",distance:s=5,angle:l=.15,attenuation:c=5,anglePower:u=5}){const d=C.useRef(null),m=a.useThree((e=>e.size)),f=a.useThree((e=>e.camera)),p=a.useThree((e=>e.viewport.dpr)),[h]=C.useState((()=>new fa)),[x]=C.useState((()=>new n.Vector3));t=void 0===t?.1:t,r=void 0===r?7*l:r,a.useFrame((()=>{h.uniforms.spotPosition.value.copy(d.current.getWorldPosition(x)),d.current.lookAt(d.current.parent.target.getWorldPosition(x))}));const y=C.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 C.createElement(C.Fragment,null,C.createElement("mesh",{ref:d,geometry:y,raycast:()=>null},C.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":o,"uniforms-cameraNear-value":f.near,"uniforms-cameraFar-value":f.far,"uniforms-resolution-value":o?[m.width*p,m.height*p]:[0,0]})))}function ya(e,t,r,o,i){const[[s,l]]=C.useState((()=>[new n.Vector3,new n.Vector3]));C.useLayoutEffect((()=>{if(!ha(e.current))throw new Error("SpotlightShadow must be a child of a SpotLight");e.current.shadow.mapSize.set(r,o),e.current.shadow.needsUpdate=!0}),[e,r,o]),a.useFrame((()=>{if(!e.current)return;const r=e.current.position,n=e.current.target.position;l.copy(n).sub(r);var a=l.length();l.normalize().multiplyScalar(a*i),s.copy(r).add(l),t.current.position.copy(s),t.current.lookAt(e.current.target.position)}))}function va({distance:e=.4,alphaTest:t=.5,map:r,shader:o=pa,width:i=512,height:s=512,scale:l=1,children:c,...u}){const m=C.useRef(null),f=u.spotlightRef,p=u.debug;ya(f,m,i,s,e);const h=C.useMemo((()=>new n.WebGLRenderTarget(i,s,{format:n.RGBAFormat,encoding:n.LinearEncoding,stencilBuffer:!1})),[i,s]),x=C.useRef({uShadowMap:{value:r},uTime:{value:0}});C.useEffect((()=>{x.current.uShadowMap.value=r}),[r]);const y=C.useMemo((()=>new d.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:o}))),[o]);return C.useEffect((()=>()=>{y.material.dispose(),y.dispose()}),[y]),C.useEffect((()=>()=>h.dispose()),[h]),a.useFrame((({gl:e},t)=>{x.current.uTime.value+=t,e.setRenderTarget(h),y.render(e),e.setRenderTarget(null)})),C.createElement(C.Fragment,null,C.createElement("mesh",{ref:m,scale:l,castShadow:!0},C.createElement("planeGeometry",null),C.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 ga({distance:e=.4,alphaTest:t=.5,map:r,width:a=512,height:o=512,scale:i,children:s,...l}){const c=C.useRef(null),u=l.spotlightRef,d=l.debug;return ya(u,c,a,o,e),C.createElement(C.Fragment,null,C.createElement("mesh",{ref:c,scale:i,castShadow:!0},C.createElement("planeGeometry",null),C.createElement("meshBasicMaterial",{transparent:!0,side:n.DoubleSide,alphaTest:t,alphaMap:r,"alphaMap-wrapS":n.RepeatWrapping,"alphaMap-wrapT":n.RepeatWrapping,opacity:d?1:0},s)))}const za=C.forwardRef((({opacity:e=1,radiusTop:t,radiusBottom:r,depthBuffer:n,color:a="white",distance:o=5,angle:i=.15,attenuation:s=5,anglePower:l=5,volumetric:c=!0,debug:u=!1,children:d,...m},f)=>{const p=C.useRef(null);return C.createElement("group",null,u&&p.current&&C.createElement("spotLightHelper",{args:[p.current]}),C.createElement("spotLight",T.default({ref:F.default([f,p]),angle:i,color:a,distance:o,castShadow:!0},m),c&&C.createElement(xa,{debug:u,opacity:e,radiusTop:t,radiusBottom:r,depthBuffer:n,color:a,distance:o,angle:i,attenuation:s,anglePower:l})),d&&C.cloneElement(d,{spotlightRef:p,debug:u}))})),wa=C.forwardRef((({args:e,map:t,toneMapped:r=!1,color:n="white",form:o="rect",intensity:i=1,scale:s=1,target:l,children:c,...u},d)=>{const m=C.useRef(null);return C.useLayoutEffect((()=>{c||u.material||(a.applyProps(m.current.material,{color:n}),m.current.material.color.multiplyScalar(i))}),[n,i,c,u.material]),C.useLayoutEffect((()=>{l&&m.current.lookAt(Array.isArray(l)?new R.Vector3(...l):l)}),[l]),s=Array.isArray(s)&&2===s.length?[s[0],s[1],1]:s,C.createElement("mesh",T.default({ref:F.default([m,d]),scale:s},u),"circle"===o?C.createElement("ringGeometry",{args:[0,1,64]}):"ring"===o?C.createElement("ringGeometry",{args:[.5,1,64]}):"rect"===o?C.createElement("planeGeometry",null):C.createElement(o,{args:e}),c||(u.material?null:C.createElement("meshBasicMaterial",{toneMapped:r,map:t,side:R.DoubleSide})))}));function ba(e,t,r=new n.Vector3){const a=Math.PI*(e-.5),o=2*Math.PI*(t-.5);return r.x=Math.cos(o),r.y=Math.sin(a),r.z=Math.sin(o),r}const Ma=C.forwardRef((({inclination:e=.6,azimuth:t=.1,distance:r=1e3,mieCoefficient:a=.005,mieDirectionalG:o=.8,rayleigh:i=.5,turbidity:s=10,sunPosition:l=ba(e,t),...c},u)=>{const m=C.useMemo((()=>(new n.Vector3).setScalar(r)),[r]),[f]=C.useState((()=>new d.Sky));return C.createElement("primitive",T.default({object:f,ref:u,"material-uniforms-mieCoefficient-value":a,"material-uniforms-mieDirectionalG-value":o,"material-uniforms-rayleigh-value":i,"material-uniforms-sunPosition-value":l,"material-uniforms-turbidity-value":s,scale:m},c))}));class Ea 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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`})}}const Sa=e=>(new n.Vector3).setFromSpherical(new n.Spherical(e,Math.acos(1-2*Math.random()),2*Math.random()*Math.PI)),Ta=C.forwardRef((({radius:e=100,depth:t=50,count:r=5e3,saturation:o=0,factor:i=4,fade:s=!1,speed:l=1},c)=>{const u=C.useRef(),[d,m,f]=C.useMemo((()=>{const a=[],s=[],l=Array.from({length:r},(()=>(.5+.5*Math.random())*i)),c=new n.Color;let u=e+t;const d=t/r;for(let e=0;e<r;e++)u-=d*Math.random(),a.push(...Sa(u).toArray()),c.setHSL(e/r,o,.9),s.push(c.r,c.g,c.b);return[new Float32Array(a),new Float32Array(s),new Float32Array(l)]}),[r,t,i,e,o]);a.useFrame((e=>u.current&&(u.current.uniforms.time.value=e.clock.getElapsedTime()*l)));const[p]=C.useState((()=>new Ea));return C.createElement("points",{ref:c},C.createElement("bufferGeometry",null,C.createElement("bufferAttribute",{attach:"attributes-position",args:[d,3]}),C.createElement("bufferAttribute",{attach:"attributes-color",args:[m,3]}),C.createElement("bufferAttribute",{attach:"attributes-size",args:[f,1]})),C.createElement("primitive",{ref:u,object:p,attach:"material",blending:n.AdditiveBlending,"uniforms-fade-value":s,depthWrite:!1,transparent:!0,vertexColors:!0}))})),Ca=new n.Matrix4,Pa=new n.Vector3,Ra=new n.Quaternion,Da=new n.Vector3,Fa=new n.Quaternion,ka=new n.Vector3,_a=C.createContext(null),Aa=C.forwardRef((({children:e,material:t=n.MeshLambertMaterial,texture:r="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",range:o,limit:i=200,...s},l)=>{var c,u;const d=C.useMemo((()=>class extends t{constructor(){super();const e=parseInt(n.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader="attribute float opacity;\n varying float vOpacity;\n "+t.vertexShader.replace("#include <fog_vertex>","#include <fog_vertex>\n vOpacity = opacity;\n "),t.fragmentShader="varying float vOpacity;\n "+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>\n gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);\n `)}}}),[t]);a.extend({CloudMaterial:d});const m=C.useRef(null),f=C.useRef([]),p=C.useMemo((()=>new Float32Array(Array.from({length:i},(()=>1)))),[i]),h=C.useMemo((()=>new Float32Array(Array.from({length:i},(()=>[1,1,1])).flat())),[i]),x=De(r);let y,v=0,g=0;const z=new n.Quaternion,w=new n.Vector3(0,0,1),b=new n.Vector3;a.useFrame(((e,t)=>{for(v=e.clock.getElapsedTime(),Ca.copy(m.current.matrixWorld).invert(),e.camera.matrixWorld.decompose(Da,Fa,ka),g=0;g<f.current.length;g++)y=f.current[g],y.ref.current.matrixWorld.decompose(Pa,Ra,ka),Pa.add(b.copy(y.position).applyQuaternion(Ra).multiply(ka)),Ra.copy(Fa).multiply(z.setFromAxisAngle(w,y.rotation+=t*y.rotationFactor)),ka.multiplyScalar(y.volume+(1+Math.sin(v*y.density*y.speed))/2*y.growth),y.matrix.compose(Pa,Ra,ka).premultiply(Ca),y.dist=Pa.distanceTo(Da);for(f.current.sort(((e,t)=>t.dist-e.dist)),g=0;g<f.current.length;g++)y=f.current[g],p[g]=y.opacity*(y.dist<y.fade-1?y.dist/y.fade:1),m.current.setMatrixAt(g,y.matrix),m.current.setColorAt(g,y.color);m.current.geometry.attributes.opacity.needsUpdate=!0,m.current.instanceMatrix.needsUpdate=!0,m.current.instanceColor&&(m.current.instanceColor.needsUpdate=!0)})),C.useLayoutEffect((()=>{const e=Math.min(i,void 0!==o?o:i,f.current.length);m.current.count=e,br(m.current.instanceMatrix,{offset:0,count:16*e}),m.current.instanceColor&&br(m.current.instanceColor,{offset:0,count:3*e}),br(m.current.geometry.attributes.opacity,{offset:0,count:e})}));let M=[null!==(c=x.image.width)&&void 0!==c?c:1,null!==(u=x.image.height)&&void 0!==u?u:1],E=Math.max(M[0],M[1]);return M=[M[0]/E,M[1]/E],C.createElement("group",T.default({ref:l},s),C.createElement(_a.Provider,{value:f},e,C.createElement("instancedMesh",{matrixAutoUpdate:!1,ref:m,args:[null,null,i]},C.createElement("instancedBufferAttribute",{usage:n.DynamicDrawUsage,attach:"instanceColor",args:[h,3]}),C.createElement("planeGeometry",{args:[...M]},C.createElement("instancedBufferAttribute",{usage:n.DynamicDrawUsage,attach:"attributes-opacity",args:[p,1]})),C.createElement("cloudMaterial",{key:t.name,map:x,transparent:!0,depthWrite:!1}))))})),La=C.forwardRef((({opacity:e=1,speed:t=0,bounds:r=[5,1,1],segments:o=20,color:i="#ffffff",fade:s=10,volume:l=6,smallestVolume:c=.25,distribute:u=null,growth:d=4,concentrate:m="inside",seed:f=Math.random(),...p},h)=>{function x(){const e=1e4*Math.sin(f++);return e-Math.floor(e)}const y=C.useContext(_a),v=C.useRef(null),[g]=C.useState((()=>b.v4())),z=C.useMemo((()=>[...new Array(o)].map(((e,t)=>({segments:o,bounds:new n.Vector3(1,1,1),position:new n.Vector3,uuid:g,index:t,ref:v,dist:0,matrix:new n.Matrix4,color:new n.Color,rotation:t*(Math.PI/o)})))),[o,g]);return C.useLayoutEffect((()=>{z.forEach(((n,f)=>{var p;a.applyProps(n,{volume:l,color:i,speed:t,growth:d,opacity:e,fade:s,bounds:r,density:Math.max(.5,x()),rotationFactor:Math.max(.2,.5*x())*t});const h=null==u?void 0:u(n,f);(h||o>1)&&n.position.copy(n.bounds).multiply(null!==(p=null==h?void 0:h.point)&&void 0!==p?p:{x:2*x()-1,y:2*x()-1,z:2*x()-1});const y=Math.abs(n.position.x),v=Math.abs(n.position.y),g=Math.abs(n.position.z),z=Math.max(y,v,g);n.length=1,y===z&&(n.length-=y/n.bounds.x),v===z&&(n.length-=v/n.bounds.y),g===z&&(n.length-=g/n.bounds.z),n.volume=(void 0!==(null==h?void 0:h.volume)?h.volume:Math.max(Math.max(0,c),"random"===m?x():"inside"===m?n.length:1-n.length))*l}))}),[m,r,s,i,e,d,l,f,o,t]),C.useLayoutEffect((()=>{const e=z;return y.current=[...y.current,...e],()=>{y.current=y.current.filter((e=>e.uuid!==g))}}),[z]),C.useImperativeHandle(h,(()=>v.current),[]),C.createElement("group",T.default({ref:v},p))})),Ba=C.forwardRef(((e,t)=>C.useContext(_a)?C.createElement(La,T.default({ref:t},e)):C.createElement(Aa,null,C.createElement(La,T.default({ref:t},e))))),Ua=Pe({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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),Ia=e=>e&&e.constructor===Float32Array,Va=e=>e instanceof R.Vector2||e instanceof R.Vector3||e instanceof R.Vector4,Na=e=>Array.isArray(e)?e:Va(e)?e.toArray():[e,e,e];function Oa(e,t,r){return C.useMemo((()=>{if(void 0!==t){if(Ia(t))return t;if(t instanceof R.Color){const r=Array.from({length:3*e},(()=>(e=>[e.r,e.g,e.b])(t))).flat();return Float32Array.from(r)}if(Va(t)||Array.isArray(t)){const r=Array.from({length:3*e},(()=>Na(t))).flat();return Float32Array.from(r)}return Float32Array.from({length:e},(()=>t))}return Float32Array.from({length:e},r)}),[t])}const ja=C.forwardRef((({noise:e=1,count:t=100,speed:r=1,opacity:n=1,scale:o=1,size:i,color:s,children:l,...c},u)=>{C.useMemo((()=>a.extend({SparklesImplMaterial:Ua})),[]);const d=C.useRef(null),m=a.useThree((e=>e.viewport.dpr)),f=Na(o),p=C.useMemo((()=>Float32Array.from(Array.from({length:t},(()=>f.map(R.MathUtils.randFloatSpread))).flat())),[t,...f]),h=Oa(t,i,Math.random),x=Oa(t,n),y=Oa(t,r),v=Oa(3*t,e),g=Oa(void 0===s?3*t:t,Ia(s)?s:new R.Color(s),(()=>1));return a.useFrame((e=>{d.current&&d.current.material&&(d.current.material.time=e.clock.elapsedTime)})),C.useImperativeHandle(u,(()=>d.current),[]),C.createElement("points",T.default({key:`particle-${t}-${JSON.stringify(o)}`},c,{ref:d}),C.createElement("bufferGeometry",null,C.createElement("bufferAttribute",{attach:"attributes-position",args:[p,3]}),C.createElement("bufferAttribute",{attach:"attributes-size",args:[h,1]}),C.createElement("bufferAttribute",{attach:"attributes-opacity",args:[x,1]}),C.createElement("bufferAttribute",{attach:"attributes-speed",args:[y,1]}),C.createElement("bufferAttribute",{attach:"attributes-color",args:[g,3]}),C.createElement("bufferAttribute",{attach:"attributes-noise",args:[v,3]})),l||C.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:m,depthWrite:!1}))}));const Wa={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 R.Color("#ff0000"),backfaceStroke:new R.Color("#0000ff"),fill:new R.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 "},Ga=Pe(Wa.uniforms,Wa.vertex+"\n \tvoid main() {\n\t\tinitWireframe();\n\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n\t}\n ",Wa.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 Ha(e){return void 0!==(null==e?void 0:e.current)}function $a(e){return"WireframeGeometry"===e.type}function qa(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($a(t))throw new Error("Wireframe: WireframeGeometry is not supported.");const e=t.parent;if(function(e){return!(null==e||!e.geometry)}(e)){if($a(e.geometry))throw new Error("Wireframe: WireframeGeometry is not supported.");return e.geometry}}}function Xa(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 R.BufferAttribute(Float32Array.from(n),3)}(e,t);e.setAttribute("barycentric",r)}function Za({geometry:e,simplify:t=!1,...r}){a.extend({MeshWireframeMaterial:Ga});const[n,o]=C.useState(null);C.useLayoutEffect((()=>{const r=qa(e);if(!r)throw new Error("Wireframe: geometry prop must be a BufferGeometry or a ref to a BufferGeometry.");Xa(r,t),Ha(e)&&o(r)}),[t,e]);const i=Ha(e)?n:e;return C.createElement(C.Fragment,null,i&&C.createElement("mesh",{geometry:i},C.createElement("meshWireframeMaterial",T.default({attach:"material",transparent:!0,side:R.DoubleSide,polygonOffset:!0,polygonOffsetFactor:-4},r,{extensions:{derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1}}))))}function Ya({simplify:e=!1,...t}){const r=C.useRef(null),n=C.useMemo((()=>function(){const e={};for(const t in Wa.uniforms)e[t]={value:Wa.uniforms[t]};return e}()),[Wa.uniforms]);return function(e,t){C.useEffect((()=>{var r;e.fillOpacity.value=null!==(r=t.fillOpacity)&&void 0!==r?r:e.fillOpacity.value}),[t.fillOpacity]),C.useEffect((()=>{var r;e.fillMix.value=null!==(r=t.fillMix)&&void 0!==r?r:e.fillMix.value}),[t.fillMix]),C.useEffect((()=>{var r;e.strokeOpacity.value=null!==(r=t.strokeOpacity)&&void 0!==r?r:e.strokeOpacity.value}),[t.strokeOpacity]),C.useEffect((()=>{var r;e.thickness.value=null!==(r=t.thickness)&&void 0!==r?r:e.thickness.value}),[t.thickness]),C.useEffect((()=>{e.colorBackfaces.value=!!t.colorBackfaces}),[t.colorBackfaces]),C.useEffect((()=>{e.dash.value=!!t.dash}),[t.dash]),C.useEffect((()=>{e.dashInvert.value=!!t.dashInvert}),[t.dashInvert]),C.useEffect((()=>{var r;e.dashRepeats.value=null!==(r=t.dashRepeats)&&void 0!==r?r:e.dashRepeats.value}),[t.dashRepeats]),C.useEffect((()=>{var r;e.dashLength.value=null!==(r=t.dashLength)&&void 0!==r?r:e.dashLength.value}),[t.dashLength]),C.useEffect((()=>{e.squeeze.value=!!t.squeeze}),[t.squeeze]),C.useEffect((()=>{var r;e.squeezeMin.value=null!==(r=t.squeezeMin)&&void 0!==r?r:e.squeezeMin.value}),[t.squeezeMin]),C.useEffect((()=>{var r;e.squeezeMax.value=null!==(r=t.squeezeMax)&&void 0!==r?r:e.squeezeMax.value}),[t.squeezeMax]),C.useEffect((()=>{e.stroke.value=t.stroke?new R.Color(t.stroke):e.stroke.value}),[t.stroke]),C.useEffect((()=>{e.fill.value=t.fill?new R.Color(t.fill):e.fill.value}),[t.fill]),C.useEffect((()=>{e.backfaceStroke.value=t.backfaceStroke?new R.Color(t.backfaceStroke):e.backfaceStroke.value}),[t.backfaceStroke])}(n,t),C.useLayoutEffect((()=>{const t=qa(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 Xa(t,e),()=>{t.copy(n),n.dispose()}}),[e]),C.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 ${Wa.vertex}\n\t\t void main() {\n\t\t\tinitWireframe();\n\t\t`),e.fragmentShader=e.fragmentShader.replace("void main() {",`\n\t\t ${Wa.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=R.DoubleSide,e.transparent=!0}(e.material,n),()=>{e.material.dispose(),e.material=t}}),[]),C.createElement("object3D",{ref:r})}const Qa=new R.Matrix4,Ka=new R.Ray,Ja=new R.Sphere,eo=new R.Vector3;class to extends R.Group{constructor(){super(),this.size=0,this.color=new R.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 a=this.instance.current;if(!a||!a.geometry)return;const o=a.userData.instances.indexOf(this.instanceKey);if(-1===o||o>a.geometry.drawRange.count)return;const i=null!==(r=null==(n=e.params.Points)?void 0:n.threshold)&&void 0!==r?r:1;if(Ja.set(this.getWorldPosition(eo),i),!1===e.ray.intersectsSphere(Ja))return;Qa.copy(a.matrixWorld).invert(),Ka.copy(e.ray).applyMatrix4(Qa);const s=i/((this.scale.x+this.scale.y+this.scale.z)/3),l=s*s,c=Ka.distanceSqToPoint(this.position);if(c<l){const r=new R.Vector3;Ka.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:o,face:null,object:this})}}}let ro,no;const ao=C.createContext(null),oo=new R.Matrix4,io=new R.Vector3,so=C.forwardRef((({children:e,range:t,limit:r=1e3,...n},o)=>{const i=C.useRef(null),[s,l]=C.useState([]),[[c,u,d]]=C.useState((()=>[new Float32Array(3*r),Float32Array.from({length:3*r},(()=>1)),Float32Array.from({length:r},(()=>1))]));C.useEffect((()=>{i.current.geometry.attributes.position.needsUpdate=!0})),a.useFrame((()=>{for(i.current.updateMatrix(),i.current.updateMatrixWorld(),oo.copy(i.current.matrixWorld).invert(),i.current.geometry.drawRange.count=Math.min(r,void 0!==t?t:r,s.length),ro=0;ro<s.length;ro++)no=s[ro].current,no.getWorldPosition(io).applyMatrix4(oo),io.toArray(c,3*ro),i.current.geometry.attributes.position.needsUpdate=!0,no.matrixWorldNeedsUpdate=!0,no.color.toArray(u,3*ro),i.current.geometry.attributes.color.needsUpdate=!0,d.set([no.size],ro),i.current.geometry.attributes.size.needsUpdate=!0}));const m=C.useMemo((()=>({getParent:()=>i,subscribe:e=>(l((t=>[...t,e])),()=>l((t=>t.filter((t=>t.current!==e.current)))))})),[]);return C.createElement("points",T.default({userData:{instances:s},matrixAutoUpdate:!1,ref:F.default([o,i]),raycast:()=>null},n),C.createElement("bufferGeometry",null,C.createElement("bufferAttribute",{attach:"attributes-position",count:c.length/3,array:c,itemSize:3,usage:R.DynamicDrawUsage}),C.createElement("bufferAttribute",{attach:"attributes-color",count:u.length/3,array:u,itemSize:3,usage:R.DynamicDrawUsage}),C.createElement("bufferAttribute",{attach:"attributes-size",count:d.length,array:d,itemSize:1,usage:R.DynamicDrawUsage})),C.createElement(ao.Provider,{value:m},e))})),lo=C.forwardRef((({children:e,...t},r)=>{C.useMemo((()=>a.extend({PositionPoint:to})),[]);const n=C.useRef(),{subscribe:o,getParent:i}=C.useContext(ao);return C.useLayoutEffect((()=>o(n)),[]),C.createElement("positionPoint",T.default({instance:i(),instanceKey:n,ref:F.default([r,n])},t),e)})),co=C.forwardRef((({children:e,positions:t,colors:r,sizes:n,stride:o=3,...i},s)=>{const l=C.useRef(null);return a.useFrame((()=>{const e=l.current.geometry.attributes;e.position.needsUpdate=!0,r&&(e.color.needsUpdate=!0),n&&(e.size.needsUpdate=!0)})),C.createElement("points",T.default({ref:F.default([s,l])},i),C.createElement("bufferGeometry",null,C.createElement("bufferAttribute",{attach:"attributes-position",count:t.length/o,array:t,itemSize:o,usage:R.DynamicDrawUsage}),r&&C.createElement("bufferAttribute",{attach:"attributes-color",count:r.length/o,array:r,itemSize:3,usage:R.DynamicDrawUsage}),n&&C.createElement("bufferAttribute",{attach:"attributes-size",count:n.length/o,array:n,itemSize:1,usage:R.DynamicDrawUsage})),e)})),uo=C.forwardRef(((e,t)=>e.positions instanceof Float32Array?C.createElement(co,T.default({},e,{ref:t})):C.createElement(so,T.default({},e,{ref:t})))),mo=C.createContext(null),fo=C.forwardRef(((e,t)=>{C.useMemo((()=>a.extend({SegmentObject:po})),[]);const{limit:r=1e3,lineWidth:n=1,children:o,...i}=e,[s,l]=C.useState([]),[c]=C.useState((()=>new d.Line2)),[u]=C.useState((()=>new d.LineMaterial)),[m]=C.useState((()=>new d.LineSegmentsGeometry)),[f]=C.useState((()=>new R.Vector2(512,512))),[p]=C.useState((()=>Array(6*r).fill(0))),[h]=C.useState((()=>Array(6*r).fill(0))),x=C.useMemo((()=>({subscribe:e=>(l((t=>[...t,e])),()=>l((t=>t.filter((t=>t.current!==e.current)))))})),[]);return a.useFrame((()=>{for(let t=0;t<r;t++){var e;const r=null==(e=s[t])?void 0:e.current;r&&(p[6*t+0]=r.start.x,p[6*t+1]=r.start.y,p[6*t+2]=r.start.z,p[6*t+3]=r.end.x,p[6*t+4]=r.end.y,p[6*t+5]=r.end.z,h[6*t+0]=r.color.r,h[6*t+1]=r.color.g,h[6*t+2]=r.color.b,h[6*t+3]=r.color.r,h[6*t+4]=r.color.g,h[6*t+5]=r.color.b)}m.setColors(h),m.setPositions(p),c.computeLineDistances()})),C.createElement("primitive",{object:c,ref:t},C.createElement("primitive",{object:m,attach:"geometry"}),C.createElement("primitive",T.default({object:u,attach:"material",vertexColors:!0,resolution:f,linewidth:n},i)),C.createElement(mo.Provider,{value:x},o))}));class po{constructor(){this.color=new R.Color("white"),this.start=new R.Vector3(0,0,0),this.end=new R.Vector3(0,0,0)}}const ho=e=>e instanceof R.Vector3?e:new R.Vector3(..."number"==typeof e?[e,e,e]:e),xo=C.forwardRef((({color:e,start:t,end:r},n)=>{const a=C.useContext(mo);if(!a)throw"Segment must used inside Segments component.";const o=C.useRef(null);return C.useLayoutEffect((()=>a.subscribe(o)),[]),C.createElement("segmentObject",{ref:F.default([o,n]),color:e,start:ho(t),end:ho(r)})})),yo=C.forwardRef((({children:e,hysteresis:t=0,distances:r,...n},o)=>{const i=C.useRef(null);return C.useLayoutEffect((()=>{const{current:e}=i;e.levels.length=0,e.children.forEach(((n,a)=>e.levels.push({object:n,hysteresis:t,distance:r[a]})))})),a.useFrame((e=>{var t;return null==(t=i.current)?void 0:t.update(e.camera)})),C.createElement("lOD",T.default({ref:F.default([i,o])},n),e)}));const vo=new n.Matrix4,go=new n.Ray,zo=new n.Sphere,wo=new n.Vector3;const bo=t.createContext(null);const Mo=C.forwardRef((({children:e,compute:t,width:r,height:n,samples:o=8,renderPriority:i=0,eventPriority:s=0,frames:l=1/0,stencilBuffer:c=!1,depthBuffer:u=!0,generateMipmaps:d=!1,...m},f)=>{const{size:p,viewport:h}=a.useThree(),x=st((r||p.width)*h.dpr,(n||p.height)*h.dpr,{samples:o,stencilBuffer:c,depthBuffer:u,generateMipmaps:d}),[y]=C.useState((()=>new R.Scene)),v=C.useCallback(((e,t,r)=>{var n,a;let o=null==(n=x.texture)?void 0:n.__r3f.parent;for(;o&&!(o instanceof R.Object3D);)o=o.__r3f.parent;if(!o)return!1;r.raycaster.camera||r.events.compute(e,r,null==(a=r.previousRoot)?void 0:a.getState());const[i]=r.raycaster.intersectObject(o);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 C.useImperativeHandle(f,(()=>x.texture),[x]),C.createElement(C.Fragment,null,a.createPortal(C.createElement(Eo,{renderPriority:i,frames:l,fbo:x},e,C.createElement("group",{onPointerOver:()=>null})),y,{events:{compute:t||v,priority:s}}),C.createElement("primitive",T.default({object:x.texture},m)))}));function Eo({frames:e,renderPriority:t,children:r,fbo:n}){let o,i,s=0;return a.useFrame((t=>{(e===1/0||s<e)&&(o=t.gl.autoClear,i=t.gl.xr.enabled,t.gl.autoClear=!0,t.gl.xr.enabled=!1,t.gl.setRenderTarget(n),t.gl.render(t.scene,t.camera),t.gl.setRenderTarget(null),t.gl.autoClear=o,t.gl.xr.enabled=i,s++)}),t),C.createElement(C.Fragment,null,r)}const So=C.forwardRef((({children:e,compute:t,renderPriority:r=-1,eventPriority:n=0,frames:o=1/0,stencilBuffer:i=!1,depthBuffer:s=!0,generateMipmaps:l=!1,resolution:c=896,near:u=.1,far:d=1e3,flip:m=!1,position:f,rotation:p,scale:h,quaternion:x,matrix:y,matrixAutoUpdate:v,...g},z)=>{const{size:w,viewport:b}=a.useThree(),M=C.useRef(null),E=C.useMemo((()=>{const e=new R.WebGLCubeRenderTarget(Math.max((c||w.width)*b.dpr,(c||w.height)*b.dpr),{stencilBuffer:i,depthBuffer:s,generateMipmaps:l});return e.texture.isRenderTargetTexture=!m,e.texture.flipY=!0,e.texture.type=R.HalfFloatType,e}),[c,m]);C.useEffect((()=>()=>E.dispose()),[E]);const[S]=C.useState((()=>new R.Scene));return C.useImperativeHandle(z,(()=>({scene:S,fbo:E,camera:M.current})),[E]),C.createElement(C.Fragment,null,a.createPortal(C.createElement(To,{renderPriority:r,frames:o,camera:M},e,C.createElement("group",{onPointerOver:()=>null})),S,{events:{compute:t,priority:n}}),C.createElement("primitive",T.default({object:E.texture},g)),C.createElement("cubeCamera",{ref:M,args:[u,d,E],position:f,rotation:p,scale:h,quaternion:x,matrix:y,matrixAutoUpdate:v}))}));function To({frames:e,renderPriority:t,children:r,camera:n}){let o=0;return a.useFrame((t=>{(e===1/0||o<e)&&(n.current.update(t.gl,t.scene),o++)}),t),C.createElement(C.Fragment,null,r)}const Co=C.forwardRef((({id:e=1,colorWrite:t=!1,depthWrite:r=!1,...n},a)=>{const o=C.useRef(null),i=C.useMemo((()=>({colorWrite:t,depthWrite:r,stencilWrite:!0,stencilRef:e,stencilFunc:R.AlwaysStencilFunc,stencilFail:R.ReplaceStencilOp,stencilZFail:R.ReplaceStencilOp,stencilZPass:R.ReplaceStencilOp})),[e,t,r]);return C.useLayoutEffect((()=>{Object.assign(o.current.material,i)})),C.useImperativeHandle(a,(()=>o.current),[]),C.createElement("mesh",T.default({ref:o,renderOrder:-e},n))}));function Po({api:e}){const t=new R.Vector3,r=new R.Quaternion,n=new R.Vector3,o=new R.Euler(0,Math.PI,0);return a.useFrame((a=>{a.camera.matrixWorld.decompose(t,r,n),e.current.camera.position.copy(t),e.current.camera.quaternion.setFromEuler(o).premultiply(r)})),null}const Ro=Pe({blur:0,map:null,sdf:null,blend:0,size:0,resolution:new R.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 <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),Do=C.forwardRef((({children:e,events:t,blur:r=0,eventPriority:n=0,renderPriority:o=0,worldUnits:i=!1,resolution:s=512,...l},c)=>{a.extend({PortalMaterialImpl:Ro});const u=C.useRef(null),{scene:d,gl:m,size:f,viewport:p,setEvents:h}=a.useThree(),x=st(s,s),[y,v]=C.useState(0);a.useFrame((()=>{const e=u.current.blend>0?Math.max(1,o):0;y!==e&&v(e)})),C.useEffect((()=>{void 0!==t&&h({enabled:!t})}),[t]);const[g,z]=C.useState(!0),w=dr(z);C.useLayoutEffect((()=>{var e;w.current=null==(e=u.current)?void 0:e.__r3f.parent}),[]),C.useLayoutEffect((()=>{if(w.current&&r&&null===u.current.sdf){const e=new R.Mesh(w.current.geometry,new R.MeshBasicMaterial),t=(new R.Box3).setFromBufferAttribute(e.geometry.attributes.position),r=new R.OrthographicCamera(t.min.x*(1+2/s),t.max.x*(1+2/s),t.max.y*(1+2/s),t.min.y*(1+2/s),.1,1e3);r.position.set(0,0,1),r.lookAt(0,0,0),m.setRenderTarget(x),m.render(e,r);const n=ko(s,s,m)(x.texture),a=new Float32Array(s*s);m.readRenderTargetPixels(n,0,0,s,s,a);let o=1/0;for(let e=0;e<a.length;e++)a[e]<o&&(o=a[e]);o=-o,u.current.size=o,u.current.sdf=n.texture,m.setRenderTarget(null)}}),[s,r]),C.useImperativeHandle(c,(()=>u.current));const b=C.useCallback(((e,t,r)=>{var n;if(!w.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=u.current)?void 0:n.blend)){const[e]=t.raycaster.intersectObject(w.current);if(!e)return t.raycaster.camera=void 0,!1}}),[]);return C.createElement("portalMaterialImpl",T.default({ref:u,blur:r,blend:0,resolution:[f.width*p.dpr,f.height*p.dpr],attach:"material"},l),C.createElement(Mo,{attach:"map",frames:g?1/0:0,eventPriority:n,renderPriority:o,compute:b},e,C.createElement(Fo,{events:t,rootScene:d,priority:y,material:u,worldUnits:i})))}));function Fo({events:e,rootScene:t,material:r,priority:n,worldUnits:o}){const i=a.useThree((e=>e.scene)),s=a.useThree((e=>e.setEvents)),l=st(),c=st();C.useLayoutEffect((()=>{i.matrixAutoUpdate=!1}),[]),C.useEffect((()=>{void 0!==e&&s({enabled:e})}),[e]);const[u,m]=C.useMemo((()=>{const e={value:0};return[new d.FullScreenQuad(new R.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 <tonemapping_fragment>\n #include <${Fe>=154?"colorspace_fragment":"encodings_fragment"}>\n }`})),e]}),[]);return a.useFrame((e=>{var a;let s=null==r||null==(a=r.current)?void 0:a.__r3f.parent;if(s){var d,f,p,h;if(o)i.matrixWorld.identity();else n&&1===(null==(d=r.current)?void 0:d.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?(m.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),C.createElement(C.Fragment,null)}const ko=(e,t,r)=>{let n=new R.WebGLRenderTarget(e,t,{minFilter:R.LinearMipmapLinearFilter,magFilter:R.LinearFilter,type:R.FloatType,format:R.RedFormat,generateMipmaps:!0}),a=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter}),o=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter}),i=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter}),s=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter}),l=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter,type:R.FloatType,format:R.RedFormat}),c=new R.WebGLRenderTarget(e,t,{minFilter:R.NearestFilter,magFilter:R.NearestFilter,type:R.FloatType,format:R.RedFormat});const u=new d.FullScreenQuad(new R.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 }"})),m=new d.FullScreenQuad(new R.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 d.FullScreenQuad(new R.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 d.FullScreenQuad(new R.ShaderMaterial({uniforms:{tex:{value:null},size:{value:new R.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 d.FullScreenQuad(new R.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 d=>{let x=n;d.minFilter=R.NearestFilter,d.magFilter=R.NearestFilter,u.material.uniforms.tex.value=d,r.setRenderTarget(a),u.render(r);const y=Math.ceil(Math.log(Math.max(e,t))/Math.log(2));let v=a,g=null;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===a?i: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}r.setRenderTarget(l),p.material.uniforms.tex.value=g.texture,p.render(r),m.material.uniforms.tex.value=d,r.setRenderTarget(o),m.render(r),v=o;for(let e=0;e<y;e++){const t=Math.pow(2,y-e-1);g=v===o?s: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}return r.setRenderTarget(c),p.material.uniforms.tex.value=g.texture,p.render(r),r.setRenderTarget(x),h.material.uniforms.tex.value=d,h.render(r),r.setRenderTarget(null),x}},_o=e=>e&&e.isOrthographicCamera,Ao=new R.Color,Lo=U.default();function Bo(e){return"top"in e}function Uo(e,t){const{right:r,top:n,left:a,bottom:o,width:i,height:s}=t,l=t.bottom<0||n>e.height||r<0||t.left>e.width;if(Bo(e)){const t=e.top+e.height-o;return{position:{width:i,height:s,left:a-e.left,top:n,bottom:t,right:r},isOffscreen:l}}return{position:{width:i,height:s,top:n,left:a,bottom:e.height-o,right:r},isOffscreen:l}}function Io(e,{left:t,bottom:r,width:n,height:a}){let o;const i=n/a;return _o(e.camera)?e.camera.left===n/-2&&e.camera.right===n/2&&e.camera.top===a/2&&e.camera.bottom===a/-2||(Object.assign(e.camera,{left:n/-2,right:n/2,top:a/2,bottom:a/-2}),e.camera.updateProjectionMatrix()):e.camera.aspect!==i&&(e.camera.aspect=i,e.camera.updateProjectionMatrix()),o=e.gl.autoClear,e.gl.autoClear=!1,e.gl.setViewport(t,r,n,a),e.gl.setScissor(t,r,n,a),e.gl.setScissorTest(!0),o}function Vo(e,t){e.gl.setScissorTest(!1),e.gl.autoClear=t}function No(e){e.gl.getClearColor(Ao),e.gl.setClearColor(Ao,e.gl.getClearAlpha()),e.gl.clear(!0,!0)}function Oo({visible:e=!0,canvasSize:t,scene:r,index:n,children:o,frames:i,rect:s,track:l}){const c=a.useThree(),[u,d]=C.useState(!1);let m=0;return a.useFrame((n=>{var a;(i===1/0||m<=i)&&(s.current=null==(a=l.current)?void 0:a.getBoundingClientRect(),m++);if(s.current){const{position:a,isOffscreen:i}=Uo(t,s.current);if(u!==i&&d(i),e&&!u&&s.current){const e=Io(n,a);n.gl.render(o?n.scene:r,n.camera),Vo(n,e)}}}),n),C.useLayoutEffect((()=>{const r=s.current;if(r&&(!e||!u)){const{position:e}=Uo(t,r),n=Io(c,e);No(c),Vo(c,n)}}),[e,u]),C.useEffect((()=>{const e=s.current,r=c.get().events.connected;return c.setEvents({connected:l.current}),()=>{if(e){const{position:r}=Uo(t,e),n=Io(c,r);No(c),Vo(c,n)}c.setEvents({connected:r})}}),[]),C.useEffect((()=>{Bo(t)||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")}),[]),C.createElement(C.Fragment,null,o)}const jo=C.forwardRef((({track:e,visible:t=!0,index:r=1,id:n,style:o,className:i,frames:s=1/0,children:l,...c},u)=>{var d,m,f,p;const h=C.useRef(null),{size:x,scene:y}=a.useThree(),[v]=C.useState((()=>new R.Scene)),[g,z]=C.useReducer((()=>!0),!1),w=C.useCallback(((t,r)=>{if(h.current&&e.current&&t.target===e.current){const{width:e,height:n,left:a,top:o}=h.current,i=t.clientX-a,s=t.clientY-o;r.pointer.set(i/e*2-1,-s/n*2+1),r.raycaster.setFromCamera(r.pointer,r.camera)}}),[h,e]);return C.useEffect((()=>{var t;h.current=null==(t=e.current)?void 0:t.getBoundingClientRect(),z()}),[e]),C.createElement("group",T.default({ref:u},c),g&&a.createPortal(C.createElement(Oo,{visible:t,canvasSize:x,frames:s,scene:y,track:e,rect:h,index:r},l),v,{events:{compute:w,priority:r},size:{width:null==(d=h.current)?void 0:d.width,height:null==(m=h.current)?void 0:m.height,top:null==(f=h.current)?void 0:f.top,left:null==(p=h.current)?void 0:p.left}}))})),Wo=C.forwardRef((({as:e="div",id:t,visible:r,className:n,style:a,index:o=1,track:i,frames:s=1/0,children:l,...c},u)=>{const d=C.useId(),m=C.useRef(null);return C.useImperativeHandle(u,(()=>m.current)),C.createElement(C.Fragment,null,C.createElement(e,T.default({ref:m,id:t,className:n,style:a},c)),C.createElement(Lo.In,null,C.createElement(jo,{visible:r,key:d,track:m,frames:s,index:o},l)))})),Go=C.forwardRef(((e,t)=>C.useContext(a.context)?C.createElement(jo,T.default({ref:t},e)):C.createElement(Wo,T.default({ref:t},e))));Go.Port=()=>C.createElement(Lo.Out,null);const Ho=C.createContext(null),$o=new R.Vector3,qo=new R.Vector3,Xo=new R.Vector3(0,1,0),Zo=new R.Matrix4,Yo=({direction:e,axis:t})=>{const{translation:r,translationLimits:n,annotations:o,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:d,hoveredColor:m,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=C.useContext(Ho),v=a.useThree((e=>e.controls)),g=C.useRef(null),z=C.useRef(null),w=C.useRef(null),b=C.useRef(0),[M,E]=C.useState(!1),S=C.useCallback((n=>{o&&(g.current.innerText=`${r.current[t].toFixed(2)}`,g.current.style.display="block"),n.stopPropagation();const a=(new R.Matrix4).extractRotation(z.current.matrixWorld),i=n.point.clone(),s=(new R.Vector3).setFromMatrixPosition(z.current.matrixWorld),l=e.clone().applyMatrix4(a).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)}),[o,e,v,p,r,t]),T=C.useCallback((e=>{if(e.stopPropagation(),M||E(!0),w.current){const{clickPoint:a,dir:i}=w.current,[s,l]=(null==n?void 0:n[t])||[void 0,void 0];let c=((e,t,r,n)=>{const a=t.dot(t),o=t.dot(e)-t.dot(r),i=t.dot(n);return 0===i?-o/a:($o.copy(n).multiplyScalar(a/i).sub(t),qo.copy(n).multiplyScalar(o/i).add(r).sub(e),-$o.dot(qo)/$o.dot($o))})(a,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,o&&(g.current.innerText=`${r.current[t].toFixed(2)}`),Zo.makeTranslation(i.x*c,i.y*c,i.z*c),h(Zo)}}),[o,h,M,r,n,t]),P=C.useCallback((e=>{o&&(g.current.style.display="none"),e.stopPropagation(),w.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[o,v,x]),D=C.useCallback((e=>{e.stopPropagation(),E(!1)}),[]),{cylinderLength:F,coneWidth:k,coneLength:_,matrixL:A}=C.useMemo((()=>{const t=u?c/l*1.6:l/20,r=u?.2:l/5,n=u?1-r:l-r,a=(new R.Quaternion).setFromUnitVectors(Xo,e.clone().normalize());return{cylinderLength:n,coneWidth:t,coneLength:r,matrixL:(new R.Matrix4).makeRotationFromQuaternion(a)}}),[e,l,c,u]),L=M?m:d[t];return C.createElement("group",{ref:z},C.createElement("group",{matrix:A,matrixAutoUpdate:!1,onPointerDown:S,onPointerMove:T,onPointerUp:P,onPointerOut:D},o&&C.createElement(q,{position:[0,-_,0]},C.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),C.createElement("mesh",{visible:!1,position:[0,(F+_)/2,0],userData:y},C.createElement("cylinderGeometry",{args:[1.4*k,1.4*k,F+_,8,1]})),C.createElement(pe,{transparent:!0,raycast:()=>null,depthTest:s,points:[0,0,0,0,F,0],lineWidth:c,color:L,opacity:f,polygonOffset:!0,renderOrder:1,polygonOffsetFactor:-10,fog:!1}),C.createElement("mesh",{raycast:()=>null,position:[0,F+_/2,0],renderOrder:500},C.createElement("coneGeometry",{args:[k,_,24,1]}),C.createElement("meshBasicMaterial",{transparent:!0,depthTest:s,color:L,opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))))},Qo=new R.Vector3,Ko=new R.Vector3,Jo=e=>180*e/Math.PI,ei=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)},ti=new R.Matrix4,ri=new R.Vector3,ni=new R.Ray,ai=new R.Vector3,oi=({dir1:e,dir2:t,axis:r})=>{const{rotationLimits:n,annotations:o,annotationsClass:i,depthTest:s,scale:l,lineWidth:c,fixed:u,axisColors:d,hoveredColor:m,opacity:f,onDragStart:p,onDrag:h,onDragEnd:x,userData:y}=C.useContext(Ho),v=a.useThree((e=>e.controls)),g=C.useRef(null),z=C.useRef(null),w=C.useRef(0),b=C.useRef(0),M=C.useRef(null),[E,S]=C.useState(!1),T=C.useCallback((e=>{o&&(g.current.innerText=`${Jo(b.current).toFixed(0)}º`,g.current.style.display="block"),e.stopPropagation();const t=e.point.clone(),n=(new R.Vector3).setFromMatrixPosition(z.current.matrixWorld),a=(new R.Vector3).setFromMatrixColumn(z.current.matrixWorld,0).normalize(),i=(new R.Vector3).setFromMatrixColumn(z.current.matrixWorld,1).normalize(),s=(new R.Vector3).setFromMatrixColumn(z.current.matrixWorld,2).normalize(),l=(new R.Plane).setFromNormalAndCoplanarPoint(s,n);M.current={clickPoint:t,origin:n,e1:a,e2:i,normal:s,plane:l},p({component:"Rotator",axis:r,origin:n,directions:[a,i,s]}),v&&(v.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[o,v,p,r]),P=C.useCallback((e=>{if(e.stopPropagation(),E||S(!0),M.current){const{clickPoint:t,origin:a,e1:i,e2:s,normal:l,plane:c}=M.current,[u,d]=(null==n?void 0:n[r])||[void 0,void 0];ni.copy(e.ray),ni.intersectPlane(c,ai),ni.direction.negate(),ni.intersectPlane(c,ai);let m=((e,t,r,n,a)=>{Qo.copy(e).sub(r),Ko.copy(t).sub(r);const o=n.dot(n),i=a.dot(a),s=Qo.dot(n)/o,l=Qo.dot(a)/i,c=Ko.dot(n)/o,u=Ko.dot(a)/i,d=Math.atan2(l,s);return Math.atan2(u,c)-d})(t,ai,a,i,s),f=Jo(m);e.shiftKey&&(f=10*Math.round(f/10),m=(e=>e*Math.PI/180)(f)),void 0!==u&&void 0!==d&&d-u<2*Math.PI?(m=ei(m),m=m>Math.PI?m-2*Math.PI:m,m=R.MathUtils.clamp(m,u-w.current,d-w.current),b.current=w.current+m):(b.current=ei(w.current+m),b.current=b.current>Math.PI?b.current-2*Math.PI:b.current),o&&(f=Jo(b.current),g.current.innerText=`${f.toFixed(0)}º`),ti.makeRotationAxis(l,m),ri.copy(a).applyMatrix4(ti).sub(a).negate(),ti.setPosition(ri),h(ti)}}),[o,h,E,n,r]),D=C.useCallback((e=>{o&&(g.current.style.display="none"),e.stopPropagation(),w.current=b.current,M.current=null,x(),v&&(v.enabled=!0),e.target.releasePointerCapture(e.pointerId)}),[o,v,x]),F=C.useCallback((e=>{e.stopPropagation(),S(!1)}),[]),k=C.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new R.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),_=u?.65:.65*l,A=C.useMemo((()=>{const e=[];for(let t=0;t<=32;t++){const r=t*(Math.PI/2)/32;e.push(new R.Vector3(Math.cos(r)*_,Math.sin(r)*_,0))}return e}),[_]);return C.createElement("group",{ref:z,onPointerDown:T,onPointerMove:P,onPointerUp:D,onPointerOut:F,matrix:k,matrixAutoUpdate:!1},o&&C.createElement(q,{position:[_,_,0]},C.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:i,ref:g})),C.createElement(pe,{points:A,lineWidth:4*c,visible:!1,userData:y}),C.createElement(pe,{transparent:!0,raycast:()=>null,depthTest:s,points:A,lineWidth:c,color:E?m:d[r],opacity:f,polygonOffset:!0,polygonOffsetFactor:-10,fog:!1}))},ii=new R.Ray,si=new R.Vector3,li=new R.Matrix4,ci=({dir1:e,dir2:t,axis:r})=>{const{translation:n,translationLimits:o,annotations:i,annotationsClass:s,depthTest:l,scale:c,lineWidth:u,fixed:d,axisColors:m,hoveredColor:f,opacity:p,onDragStart:h,onDrag:x,onDragEnd:y,userData:v}=C.useContext(Ho),g=a.useThree((e=>e.controls)),z=C.useRef(null),w=C.useRef(null),b=C.useRef(null),M=C.useRef(0),E=C.useRef(0),[S,T]=C.useState(!1),P=C.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(),a=(new R.Vector3).setFromMatrixPosition(w.current.matrixWorld),o=(new R.Vector3).setFromMatrixColumn(w.current.matrixWorld,0).normalize(),s=(new R.Vector3).setFromMatrixColumn(w.current.matrixWorld,1).normalize(),l=(new R.Vector3).setFromMatrixColumn(w.current.matrixWorld,2).normalize(),c=(new R.Plane).setFromNormalAndCoplanarPoint(l,a);b.current={clickPoint:t,e1:o,e2:s,plane:c},M.current=n.current[(r+1)%3],E.current=n.current[(r+2)%3],h({component:"Slider",axis:r,origin:a,directions:[o,s,l]}),g&&(g.enabled=!1),e.target.setPointerCapture(e.pointerId)}),[i,g,h,r]),D=C.useCallback((e=>{if(e.stopPropagation(),S||T(!0),b.current){const{clickPoint:t,e1:a,e2:s,plane:l}=b.current,[c,u]=(null==o?void 0:o[(r+1)%3])||[void 0,void 0],[d,m]=(null==o?void 0:o[(r+2)%3])||[void 0,void 0];ii.copy(e.ray),ii.intersectPlane(l,si),ii.direction.negate(),ii.intersectPlane(l,si),si.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,a=[0,1,2].sort(((e,r)=>Math.abs(t.getComponent(r))-Math.abs(t.getComponent(e)))),o=n===a[0]?a[1]:a[0],i=e.getComponent(n),s=e.getComponent(o),l=t.getComponent(n),c=t.getComponent(o),u=r.getComponent(n),d=(r.getComponent(o)-u*(s/i))/(c-l*(s/i));return[(u-d*l)/i,d]})(a,s,si);void 0!==c&&(f=Math.max(f,c-M.current)),void 0!==u&&(f=Math.min(f,u-M.current)),void 0!==d&&(p=Math.max(p,d-E.current)),void 0!==m&&(p=Math.min(p,m-E.current)),n.current[(r+1)%3]=M.current+f,n.current[(r+2)%3]=E.current+p,i&&(z.current.innerText=`${n.current[(r+1)%3].toFixed(2)}, ${n.current[(r+2)%3].toFixed(2)}`),li.makeTranslation(f*a.x+p*s.x,f*a.y+p*s.y,f*a.z+p*s.z),x(li)}}),[i,x,S,n,o,r]),F=C.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=C.useCallback((e=>{e.stopPropagation(),T(!1)}),[]),_=C.useMemo((()=>{const r=e.clone().normalize(),n=t.clone().normalize();return(new R.Matrix4).makeBasis(r,n,r.clone().cross(n))}),[e,t]),A=d?1/7:c/7,L=d?.225:.225*c,B=S?f:m[r],U=C.useMemo((()=>[new R.Vector3(0,0,0),new R.Vector3(0,L,0),new R.Vector3(L,L,0),new R.Vector3(L,0,0),new R.Vector3(0,0,0)]),[L]);return C.createElement("group",{ref:w,matrix:_,matrixAutoUpdate:!1},i&&C.createElement(q,{position:[0,0,0]},C.createElement("div",{style:{display:"none",background:"#151520",color:"white",padding:"6px 8px",borderRadius:7,whiteSpace:"nowrap"},className:s,ref:z})),C.createElement("group",{position:[1.7*A,1.7*A,0]},C.createElement("mesh",{visible:!0,onPointerDown:P,onPointerMove:D,onPointerUp:F,onPointerOut:k,scale:L,userData:v},C.createElement("planeGeometry",null),C.createElement("meshBasicMaterial",{transparent:!0,depthTest:l,color:B,polygonOffset:!0,polygonOffsetFactor:-10,side:R.DoubleSide,fog:!1})),C.createElement(pe,{position:[-L/2,-L/2,0],transparent:!0,depthTest:l,points:U,lineWidth:u,color:B,opacity:p,polygonOffset:!0,polygonOffsetFactor:-10,userData:v,fog:!1})))},ui=new R.Matrix4,di=new R.Matrix4,mi=new R.Matrix4,fi=new R.Matrix4,pi=new R.Matrix4,hi=new R.Matrix4,xi=new R.Matrix4,yi=new R.Matrix4,vi=new R.Box3,gi=new R.Box3,zi=new R.Vector3,wi=new R.Vector3,bi=new R.Vector3,Mi=new R.Vector3,Ei=new R.Vector3(1,0,0),Si=new R.Vector3(0,1,0),Ti=new R.Vector3(0,0,1),Ci=C.forwardRef((({matrix:e,onDragStart:t,onDrag:r,onDragEnd:n,autoTransform:o=!0,anchor:i,disableAxes:s=!1,disableSliders:l=!1,disableRotations:c=!1,activeAxes:u=[!0,!0,!0],offset:d=[0,0,0],rotation:m=[0,0,0],scale:f=1,lineWidth:p=4,fixed:h=!1,translationLimits:x,rotationLimits:y,depthTest:v=!0,axisColors:g=["#ff2060","#20df80","#2080ff"],hoveredColor:z="#ffff40",annotations:w=!1,annotationsClass:b,opacity:M=1,visible:E=!0,userData:S,children:P,...D},F)=>{const k=a.useThree((e=>e.invalidate)),_=C.useRef(null),A=C.useRef(null),L=C.useRef(null),B=C.useRef(null),U=C.useRef([0,0,0]);C.useLayoutEffect((()=>{i&&(B.current.updateWorldMatrix(!0,!0),fi.copy(B.current.matrixWorld).invert(),vi.makeEmpty(),B.current.traverse((e=>{e.geometry&&(e.geometry.boundingBox||e.geometry.computeBoundingBox(),hi.copy(e.matrixWorld).premultiply(fi),gi.copy(e.geometry.boundingBox),gi.applyMatrix4(hi),vi.union(gi))})),zi.copy(vi.max).add(vi.min).multiplyScalar(.5),wi.copy(vi.max).sub(vi.min).multiplyScalar(.5),bi.copy(wi).multiply(new R.Vector3(...i)).add(zi),Mi.set(...d).add(bi),L.current.position.copy(Mi),k())}));const I=C.useMemo((()=>({onDragStart:e=>{ui.copy(A.current.matrix),di.copy(A.current.matrixWorld),t&&t(e),k()},onDrag:e=>{mi.copy(_.current.matrixWorld),fi.copy(mi).invert(),pi.copy(di).premultiply(e),hi.copy(pi).premultiply(fi),xi.copy(ui).invert(),yi.copy(hi).multiply(xi),o&&A.current.matrix.copy(hi),r&&r(hi,yi,pi,e),k()},onDragEnd:()=>{n&&n(),k()},translation:U,translationLimits:x,rotationLimits:y,axisColors:g,hoveredColor:z,opacity:M,scale:f,lineWidth:p,fixed:h,depthTest:v,userData:S,annotations:w,annotationsClass:b})),[t,r,n,U,x,y,v,f,p,h,...g,z,M,S,o,w,b]),V=new R.Vector3;return a.useFrame((e=>{if(h){const a=de(L.current.getWorldPosition(V),f,e.camera,e.size);var t,r,n;if(L.current)(null==(t=L.current)?void 0:t.scale.x)===a&&(null==(r=L.current)?void 0:r.scale.y)===a&&(null==(n=L.current)?void 0:n.scale.z)===a||(L.current.scale.setScalar(a),e.invalidate())}})),C.useImperativeHandle(F,(()=>A.current),[]),C.useLayoutEffect((()=>{e&&e instanceof R.Matrix4&&(A.current.matrix=e)}),[e]),C.createElement(Ho.Provider,{value:I},C.createElement("group",{ref:_},C.createElement("group",T.default({ref:A,matrix:e,matrixAutoUpdate:!1},D),C.createElement("group",{visible:E,ref:L,position:d,rotation:m},!s&&u[0]&&C.createElement(Yo,{axis:0,direction:Ei}),!s&&u[1]&&C.createElement(Yo,{axis:1,direction:Si}),!s&&u[2]&&C.createElement(Yo,{axis:2,direction:Ti}),!l&&u[0]&&u[1]&&C.createElement(ci,{axis:2,dir1:Ei,dir2:Si}),!l&&u[0]&&u[2]&&C.createElement(ci,{axis:1,dir1:Ti,dir2:Ei}),!l&&u[2]&&u[1]&&C.createElement(ci,{axis:0,dir1:Si,dir2:Ti}),!c&&u[0]&&u[1]&&C.createElement(oi,{axis:2,dir1:Ei,dir2:Si}),!c&&u[0]&&u[2]&&C.createElement(oi,{axis:1,dir1:Ti,dir2:Ei}),!c&&u[2]&&u[1]&&C.createElement(oi,{axis:0,dir1:Si,dir2:Ti})),C.createElement("group",{ref:B},P))))})),Pi=new R.Vector3(0,0,-1),Ri=function(){const e=new R.Vector3,t=new R.Vector3,r=new R.Vector3,n=new R.Vector3,a=new R.Vector3;return function(o,i,s,l){return e.copy(o),t.copy(i),r.copy(s),n.copy(t).sub(e),a.copy(r).sub(e),l.crossVectors(a,n).normalize()}}();const Di=C.forwardRef((({points:e=_i.SAMPLE_FACELANDMARKER_RESULT.faceLandmarks[0],face:t,facialTransformationMatrix:r,faceBlendshapes:n,offset:o,offsetScalar:i=80,width:s,height:l,depth:c=1,verticalTri:u=[159,386,152],origin:d,eyes:m=!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=C.useRef(null),z=C.useRef(null),w=C.useRef(null),b=C.useRef(null),M=C.useRef(null),E=C.useRef(null),S=C.useRef(null),[T]=C.useState((()=>new R.Vector3)),[P]=C.useState((()=>new R.Object3D)),[D]=C.useState((()=>new R.Quaternion)),[F]=C.useState((()=>new R.Vector3)),{invalidate:k}=a.useThree();C.useEffect((()=>{var e;null==(e=M.current)||e.geometry.setIndex(_i.TRIANGULATION)}),[]);const[_]=C.useState((()=>new R.Vector3));C.useEffect((()=>{var t,a;const h=null==(t=M.current)?void 0:t.geometry;if(!h)return;var x,y;(h.setFromPoints(e),h.setDrawRange(0,_i.TRIANGULATION.length),r)?(P.matrix.fromArray(r.data),P.matrix.decompose(P.position,P.quaternion,P.scale),P.rotation.y*=-1,P.rotation.z*=-1,D.setFromEuler(P.rotation),o?(P.position.y*=-1,P.position.z*=-1,null==(x=g.current)||x.position.copy(P.position.divideScalar(i))):null==(y=g.current)||y.position.set(0,0,0)):(Ri(e[u[0]],e[u[1]],e[u[2]],T),D.setFromUnitVectors(Pi,T));const v=D.clone().invert();if(h.computeBoundingBox(),p&&k(),h.center(),h.applyQuaternion(v),null==(a=b.current)||a.setRotationFromQuaternion(D),m)if(n){if(E.current&&S.current&&w.current)if(f){const e=E.current._computeSphere(h),t=S.current._computeSphere(h),r=function(e,t){return e.clone().add(t).multiplyScalar(.5)}(e.center,t.center);d=r.negate(),E.current._update(h,n,e),S.current._update(h,n,t)}else E.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!==d)if("number"==typeof d){const e=h.getAttribute("position");F.set(-e.getX(d),-e.getY(d),-e.getZ(d))}else d.isVector3&&F.copy(d);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,P,o,i,s,l,c,u,d,m,p,k,T,D,_,F]);const A=C.useMemo((()=>({outerRef:b,meshRef:M,eyeRightRef:E,eyeLeftRef:S})),[]);C.useImperativeHandle(y,(()=>A),[A]);const[L]=C.useState((()=>new R.Vector3)),B=null==(v=M.current)?void 0:v.geometry.boundingBox,U=(null==B?void 0:B.getSize(L).z)||1;return C.createElement("group",x,C.createElement("group",{ref:g},C.createElement("group",{ref:b},C.createElement("group",{ref:z},p?C.createElement(C.Fragment,null,C.createElement("axesHelper",{args:[U]}),C.createElement(pe,{points:[[0,0,0],[0,0,-U]],color:65535})):null,C.createElement("group",{ref:w},m&&n&&C.createElement("group",{name:"eyes"},C.createElement(ki,{side:"left",ref:E,debug:p}),C.createElement(ki,{side:"right",ref:S,debug:p})),C.createElement("mesh",{ref:M,name:"face"},h,p?C.createElement(C.Fragment,null,B&&C.createElement("box3Helper",{args:[B]})):null))))))})),Fi={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}},ki=C.forwardRef((({side:e,debug:t=!0},r)=>{const n=C.useRef(null),a=C.useRef(null),[o]=C.useState((()=>new R.Sphere)),i=C.useCallback((t=>{const r=t.getAttribute("position"),n=Fi.contourLandmarks[e].map((e=>new R.Vector3(r.getX(e),r.getY(e),r.getZ(e))));return o.center.set(0,0,0),n.forEach((e=>o.center.add(e))),o.center.divideScalar(n.length),o.radius=n[0].sub(n[1]).length()/2,o}),[o,e]),[s]=C.useState((()=>new R.Euler)),l=C.useCallback(((t,r,o)=>{var l;n.current&&(null!==(l=o)&&void 0!==l||(o=i(t)),n.current.position.copy(o.center),n.current.scale.setScalar(o.radius));if(r&&a.current){const t=Fi.blendshapes[e],n=r.categories[t[0]].score,o=r.categories[t[1]].score,i=r.categories[t[2]].score,l=r.categories[t[3]].score,c=.5*(Fi.fov.horizontal*R.MathUtils.DEG2RAD)*(l-i),u=.5*(Fi.fov.vertical*R.MathUtils.DEG2RAD)*(n-o)*("left"===e?1:-1);s.set(c,u,0),a.current.setRotationFromEuler(s)}}),[i,e,s]),c=C.useMemo((()=>({eyeMeshRef:n,irisDirRef:a,_computeSphere:i,_update:l})),[i,l]);C.useImperativeHandle(r,(()=>c),[c]);const u=Fi.color[e];return C.createElement("group",null,C.createElement("group",{ref:n},t&&C.createElement("axesHelper",null),C.createElement("group",{ref:a},C.createElement(C.Fragment,null,t&&C.createElement(pe,{points:[[0,0,0],[0,0,-2]],lineWidth:1,color:u})))))})),_i={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]}]}},Ai=t.createContext({}),Li={basePath:"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@0.10.8/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 Bi(){return t.useContext(Ai)}function Ui(e,t){return e.clone().add(t).multiplyScalar(.5)}function Ii(e,t,r){const n=e.localToWorld(t);return r.worldToLocal(n)}const Vi=t.createContext({}),Ni=t.forwardRef((({camera:e,autostart:r=!0,webcam:n=!0,webcamVideoTextureSrc:o,manualUpdate:i=!1,manualDetect:l=!1,onVideoFrame:c,smoothTime:u=.25,offset:d=!0,offsetScalar:m=80,eyes:f=!1,eyesAsOrigin:p=!0,depth:h=.15,debug:x=!1,facemesh:y,makeDefault:v},g)=>{var z,w;const b=a.useThree((e=>e.scene)),M=a.useThree((e=>e.camera)),E=a.useThree((e=>e.set)),S=a.useThree((e=>e.get)),P=e||M,D=t.useRef(null),F=t.useRef(null),[k]=t.useState((()=>new R.Object3D)),[_]=t.useState((()=>new R.Vector3)),[A]=t.useState((()=>new R.Vector3)),[L]=t.useState((()=>new R.Vector3)),[B]=t.useState((()=>new R.Vector3)),U=t.useCallback((()=>{k.parent=P.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:a}=n.current;e.current&&a.current&&t.current&&(_.copy(Ii(e.current,new R.Vector3(0,0,0),t.current)),A.copy(Ii(a.current,new R.Vector3(0,0,0),t.current)),k.position.copy(Ii(t.current,Ui(_,A),P.parent||b)),L.copy(Ii(e.current,new R.Vector3(0,0,1),t.current)),B.copy(Ii(a.current,new R.Vector3(0,0,1),t.current)),k.lookAt(t.current.localToWorld(Ui(L,B))))}else t.current&&(k.position.copy(Ii(t.current,new R.Vector3(0,0,0),P.parent||b)),k.lookAt(t.current.localToWorld(new R.Vector3(0,0,1))))}return k}),[P,A,B,_,L,b,k]),[I]=t.useState((()=>new R.Object3D)),V=t.useCallback((function(e,t){if(P){var r;if(null!==(r=t)&&void 0!==r||(t=U()),u>0){const r=1e-9;s.easing.damp3(I.position,t.position,u,e,void 0,void 0,r),s.easing.dampE(I.rotation,t.rotation,u,e,void 0,void 0,r)}else I.position.copy(t.position),I.rotation.copy(t.rotation);P.position.copy(I.position),P.rotation.copy(I.rotation)}}),[P,U,u,I.position,I.rotation]),[N,O]=t.useState(),j=Bi(),W=t.useCallback(((e,t)=>{const r=null==j?void 0:j.detectForVideo(e,t);O(r)}),[j]);a.useFrame(((e,t)=>{i||V(t)}));const G=t.useMemo((()=>Object.assign(Object.create(R.EventDispatcher.prototype),{detect:W,computeTarget:U,update:V,facemeshApiRef:F,webcamApiRef:D,play:()=>{var e;null==(e=D.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.play()},pause:()=>{var e;null==(e=D.current)||null==(e=e.videoTextureApiRef.current)||e.texture.source.data.pause()}})),[W,U,V]);t.useImperativeHandle(g,(()=>G),[G]),t.useEffect((()=>{const e=e=>{l||W(e.texture.source.data,e.time),c&&c(e)};return G.addEventListener("videoFrame",e),()=>{G.removeEventListener("videoFrame",e)}}),[G,W,j,l,c]),t.useEffect((()=>{if(v){const e=S().controls;return E({controls:G}),()=>E({controls:e})}}),[v,G,S,E]);const H=null==N?void 0:N.faceLandmarks[0],$=null==N||null==(z=N.facialTransformationMatrixes)?void 0:z[0],q=null==N||null==(w=N.faceBlendshapes)?void 0:w[0];return C.createElement(Vi.Provider,{value:G},n&&C.createElement(t.Suspense,{fallback:null},C.createElement(ji,{ref:D,autostart:r,videoTextureSrc:o})),C.createElement(Di,T.default({ref:F},y,{points:H,depth:h,facialTransformationMatrix:$,faceBlendshapes:q,eyes:f,eyesAsOrigin:p,offset:d,offsetScalar:m,debug:x,"rotation-z":Math.PI,visible:x}),C.createElement("meshBasicMaterial",{side:R.DoubleSide})))})),Oi=()=>t.useContext(Vi),ji=t.forwardRef((({videoTextureSrc:e,autostart:r=!0},n)=>{const a=t.useRef(null),o=Oi(),i=p.suspend((async()=>e?Promise.resolve(null):await navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:"user"}})),[e]);t.useEffect((()=>(o.dispatchEvent({type:"stream",stream:i}),()=>{null==i||i.getTracks().forEach((e=>e.stop())),p.clear([e])})),[i,o,e]);const s=t.useMemo((()=>({videoTextureApiRef:a})),[]);return t.useImperativeHandle(n,(()=>s),[s]),C.createElement(t.Suspense,{fallback:null},C.createElement(Wi,{ref:a,src:e||i,start:r}))})),Wi=t.forwardRef((({src:e,start:r},n)=>{const a=nr(e,{start:r}),o=a.source.data,i=Oi(),s=t.useCallback((e=>{i.dispatchEvent({type:"videoFrame",texture:a,time:e})}),[a,i]);Gi(o,s);const l=t.useMemo((()=>({texture:a})),[a]);return t.useImperativeHandle(n,(()=>l),[l]),C.createElement(C.Fragment,null)})),Gi=(e,r)=>{t.useEffect((()=>{if(!e||!e.requestVideoFrameCallback)return;let t;return e.requestVideoFrameCallback((function n(...a){r(...a),t=e.requestVideoFrameCallback(n)})),()=>e.cancelVideoFrameCallback(t)}),[e,r])};exports.AccumulativeShadows=Jn,exports.AdaptiveDpr=function({pixelated:e}){const t=a.useThree((e=>e.gl)),r=a.useThree((e=>e.internal.active)),n=a.useThree((e=>e.performance.current)),o=a.useThree((e=>e.viewport.initialDpr)),i=a.useThree((e=>e.setDpr));return C.useEffect((()=>{const n=t.domElement;return()=>{r&&i(o),e&&n&&(n.style.imageRendering="auto")}}),[]),C.useEffect((()=>{i(n*o),e&&t.domElement&&(t.domElement.style.imageRendering=1===n?"auto":"pixelated")}),[n]),null},exports.AdaptiveEvents=function(){const e=a.useThree((e=>e.get)),t=a.useThree((e=>e.setEvents)),r=a.useThree((e=>e.performance.current));return C.useEffect((()=>{const r=e().events.enabled;return()=>t({enabled:r})}),[]),C.useEffect((()=>t({enabled:1===r})),[r]),null},exports.ArcballControls=xt,exports.AsciiRenderer=function({renderIndex:e=1,bgColor:t="black",fgColor:r="white",characters:n=" .:-+*=%@#",invert:o=!0,color:i=!1,resolution:s=.15}){const{size:l,gl:c,scene:u,camera:m}=a.useThree(),f=C.useMemo((()=>{const e=new d.AsciiEffect(c,n,{invert:o,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,o,i,s]);return C.useLayoutEffect((()=>{f.domElement.style.color=r,f.domElement.style.backgroundColor=t}),[r,t]),C.useEffect((()=>(c.domElement.style.opacity="0",c.domElement.parentNode.appendChild(f.domElement),()=>{c.domElement.style.opacity="1",c.domElement.parentNode.removeChild(f.domElement)})),[f]),C.useEffect((()=>{f.setSize(l.width,l.height)}),[f,l]),a.useFrame((e=>{f.render(u,m)}),e),C.createElement(C.Fragment,null)},exports.BBAnchor=({anchor:e,...t})=>{const r=C.useRef(null),n=C.useRef(null);return C.useEffect((()=>{var e;null!=(e=r.current)&&null!=(e=e.parent)&&e.parent&&(n.current=r.current.parent,r.current.parent.parent.add(r.current))}),[]),a.useFrame((()=>{n.current&&(xr.setFromObject(n.current),xr.getSize(yr),r.current.position.set(n.current.position.x+yr.x*(Array.isArray(e)?e[0]:e.x)/2,n.current.position.y+yr.y*(Array.isArray(e)?e[1]:e.y)/2,n.current.position.z+yr.z*(Array.isArray(e)?e[2]:e.z)/2))})),C.createElement("group",T.default({ref:r},t))},exports.Backdrop=function({children:e,floor:t=.25,segments:r=20,receiveShadow:n,...a}){const o=C.useRef(null);return C.useLayoutEffect((()=>{let e=0;const n=r/r/2,a=o.current.attributes.position;for(let o=0;o<r+1;o++)for(let i=0;i<r+1;i++)a.setXYZ(e++,o/r-n+(0===o?-t:0),i/r-n,aa(o/r));a.needsUpdate=!0,o.current.computeVertexNormals()}),[r,t]),C.createElement("group",a,C.createElement("mesh",{receiveShadow:n,rotation:[-Math.PI/2,0,Math.PI/2]},C.createElement("planeGeometry",{ref:o,args:[1,1,r,r]}),e))},exports.BakeShadows=function(){const e=a.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=oe,exports.Bounds=Ln,exports.Box=on,exports.Bvh=ur,exports.CameraControls=zt,exports.CameraShake=Un,exports.Capsule=Mn,exports.CatmullRomLine=ve,exports.Caustics=da,exports.Center=zr,exports.Circle=sn,exports.Clone=Ge,exports.Cloud=Ba,exports.CloudInstance=La,exports.Clouds=Aa,exports.ComputedAttribute=({compute:e,name:t,...r})=>{const[a]=C.useState((()=>new n.BufferAttribute(new Float32Array(0),1))),o=C.useRef(null);return C.useLayoutEffect((()=>{if(o.current){var t;const r=null!==(t=o.current.parent)&&void 0!==t?t:o.current.__r3f.parent,n=e(r);o.current.copy(n)}}),[e]),C.createElement("primitive",T.default({ref:o,object:a,attach:`attributes-${t}`},r))},exports.Cone=ln,exports.ContactShadows=Yn,exports.CubeCamera=function({children:e,frames:t=1/0,resolution:r,near:n,far:o,envMap:i,fog:s,...l}){const c=C.useRef(null),{fbo:u,camera:d,update:m}=ut({resolution:r,near:n,far:o,envMap:i,fog:s});let f=0;return a.useFrame((()=>{c.current&&(t===1/0||f<t)&&(c.current.visible=!1,m(),c.current.visible=!0,f++)})),C.createElement("group",l,C.createElement("primitive",{object:d}),C.createElement("group",{ref:c},e(u.texture)))},exports.CubicBezierLine=ye,exports.CurveModifier=Nr,exports.CycleRaycast=function({onChanged:e,portal:t,preventDefault:r=!0,scroll:n=!0,keyCode:o=9}){const i=C.useRef(0),s=a.useThree((e=>e.setEvents)),l=a.useThree((e=>e.get)),c=a.useThree((e=>e.gl));return C.useEffect((()=>{var a;let u,d=[];const m=l().events.filter,f=null!==(a=null==t?void 0:t.current)&&void 0!==a?a:c.domElement.parentNode,p=()=>f&&e&&e(d,Math.round(i.current)%d.length);s({filter:(e,t)=>{let r=[...e];r.length===d.length&&d.every((e=>r.map((e=>e.object.uuid)).includes(e.object.uuid)))||(i.current=0,d=r,p()),m&&(r=m(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)===o&&(r&&e.preventDefault(),d.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),d.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!==o&&document.addEventListener("keydown",x),()=>{s({filter:m}),void 0!==o&&document.removeEventListener("keydown",x),n&&document.removeEventListener("wheel",y),document.removeEventListener("pointermove",v)}}),[c,l,s,r,n,o]),null},exports.Cylinder=cn,exports.Decal=Ye,exports.Detailed=yo,exports.DeviceOrientationControls=dt,exports.Dodecahedron=zn,exports.Edges=Ue,exports.Effects=Te,exports.Environment=Zn,exports.EnvironmentCube=$n,exports.EnvironmentMap=Hn,exports.EnvironmentPortal=qn,exports.Example=wr,exports.Extrude=wn,exports.FaceControls=Ni,exports.FaceLandmarker=function({basePath:e=Li.basePath,options:r=Li.options,children:n}){const a=JSON.stringify(r),o=p.suspend((async()=>{const{FilesetResolver:t,FaceLandmarker:n}=await Promise.resolve().then((function(){return S(require("@mediapipe/tasks-vision"))})),a=await t.forVisionTasks(e);return n.createFromOptions(a,r)}),[e,a]);return t.useEffect((()=>()=>{null==o||o.close(),p.clear([e,a])}),[o,e,a]),C.createElement(Ai.Provider,{value:o},n)},exports.FaceLandmarkerDefaults=Li,exports.Facemesh=Di,exports.FacemeshDatas=_i,exports.FacemeshEye=ki,exports.FacemeshEyeDefaults=Fi,exports.FirstPersonControls=gt,exports.Fisheye=function({renderPriority:e=1,zoom:t=0,segments:r=64,children:n,resolution:o=896,...i}){const s=C.useRef(null),l=C.useRef(null),{width:c,height:u}=a.useThree((e=>e.size)),[d]=C.useState((()=>new R.OrthographicCamera));C.useLayoutEffect((()=>{d.position.set(0,0,100),d.zoom=100,d.left=c/-2,d.right=c/2,d.top=u/2,d.bottom=u/-2,d.updateProjectionMatrix()}),[c,u]);const m=Math.sqrt(c*c+u*u)/100*(.5+t/2),f=new R.Vector3,p=new R.Sphere(new R.Vector3,m),h=new R.Matrix3,x=C.useCallback(((e,t,r)=>{t.pointer.set(e.offsetX/t.size.width*2-1,-e.offsetY/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,d),t.raycaster.ray.intersectSphere(p,f)&&(f.normalize(),h.getNormalMatrix(l.current.camera.matrixWorld),l.current.camera.getWorldPosition(t.raycaster.ray.origin),t.raycaster.ray.direction.set(0,0,1).reflect(f),t.raycaster.ray.direction.x*=-1,t.raycaster.ray.direction.applyNormalMatrix(h).multiplyScalar(-1))}),[]);return a.useFrame((t=>{e&&t.gl.render(s.current,d)}),e),C.createElement(C.Fragment,null,C.createElement("mesh",T.default({ref:s},i,{scale:m}),C.createElement("sphereGeometry",{args:[1,r,r]}),C.createElement("meshBasicMaterial",null,C.createElement(So,{compute:x,attach:"envMap",flip:!0,resolution:o,ref:l},n,C.createElement(Po,{api:l})))))},exports.Float=In,exports.FlyControls=mt,exports.GizmoHelper=({alignment:e="bottom-right",margin:t=[80,80],renderPriority:r=1,onUpdate:o,onTarget:i,children:s})=>{const l=a.useThree((e=>e.size)),c=a.useThree((e=>e.camera)),u=a.useThree((e=>e.controls)),d=a.useThree((e=>e.invalidate)),m=C.useRef(null),f=C.useRef(null),p=C.useRef(!1),h=C.useRef(0),x=C.useRef(new n.Vector3(0,0,0)),y=C.useRef(new n.Vector3(0,0,0));C.useEffect((()=>{y.current.copy(c.up)}),[c]);const v=C.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(At),kt.copy(c.quaternion),Lt.copy(e).multiplyScalar(h.current).add(At),Dt.lookAt(Lt),Dt.up.copy(c.up),_t.copy(Dt.quaternion),d()}),[u,c,i,d]);a.useFrame(((e,t)=>{if(f.current&&m.current){var r;if(p.current)if(kt.angleTo(_t)<.01)p.current=!1,"minPolarAngle"in u&&c.up.copy(y.current);else{const e=t*Rt;kt.rotateTowards(_t,e),c.position.set(0,0,1).applyQuaternion(kt).multiplyScalar(h.current).add(x.current),c.up.set(0,1,0).applyQuaternion(kt).normalize(),c.quaternion.copy(kt),o?o():u&&u.update(),d()}Ft.copy(c.matrix).invert(),null==(r=m.current)||r.quaternion.setFromRotationMatrix(Ft)}}));const g=C.useMemo((()=>({tweenCamera:v})),[v]),[z,w]=t,b=e.endsWith("-center")?0:e.endsWith("-left")?-l.width/2+z:l.width/2-z,M=e.startsWith("center-")?0:e.startsWith("top-")?l.height/2-w:-l.height/2+w;return C.createElement(Tt,{renderPriority:r},C.createElement(Ct.Provider,{value:g},C.createElement(lt,{makeDefault:!0,ref:f,position:[0,0,200]}),C.createElement("group",{ref:m,position:[b,M,0]},s)))},exports.GizmoViewcube=e=>C.createElement("group",{scale:[60,60,60]},C.createElement(qt,e),Gt.map(((t,r)=>C.createElement(Xt,T.default({key:r,position:t,dimensions:Ht[r]},e)))),jt.map(((t,r)=>C.createElement(Xt,T.default({key:r,position:t,dimensions:Wt},e))))),exports.GizmoViewport=({hideNegativeAxes:e,hideAxisHeads:t,disabled:r,font:n="18px Inter var, Arial, sans-serif",axisColors:a=["#ff2060","#20df80","#2080ff"],axisHeadScale:o=1,axisScale:i,labels:s=["X","Y","Z"],labelColor:l="#000",onClick:c,...u})=>{const[d,m,f]=a,{tweenCamera:p}=Pt(),h={font:n,disabled:r,labelColor:l,onClick:c,axisHeadScale:o,onPointerDown:r?void 0:e=>{p(e.object.position),e.stopPropagation()}};return C.createElement("group",T.default({scale:40},u),C.createElement(Zt,{color:d,rotation:[0,0,0],scale:i}),C.createElement(Zt,{color:m,rotation:[0,0,Math.PI/2],scale:i}),C.createElement(Zt,{color:f,rotation:[0,-Math.PI/2,0],scale:i}),!t&&C.createElement(C.Fragment,null,C.createElement(Yt,T.default({arcStyle:d,position:[1,0,0],label:s[0]},h)),C.createElement(Yt,T.default({arcStyle:m,position:[0,1,0],label:s[1]},h)),C.createElement(Yt,T.default({arcStyle:f,position:[0,0,1],label:s[2]},h)),!e&&C.createElement(C.Fragment,null,C.createElement(Yt,T.default({arcStyle:d,position:[-1,0,0]},h)),C.createElement(Yt,T.default({arcStyle:m,position:[0,-1,0]},h)),C.createElement(Yt,T.default({arcStyle:f,position:[0,0,-1]},h)))))},exports.Gltf=rt,exports.GradientTexture=function({stops:e,colors:t,size:r=1024,width:n=16,type:o=Ce.Linear,innerCircleRadius:i=0,outerCircleRadius:s="auto",...l}){const c=a.useThree((e=>e.gl)),u=C.useMemo((()=>{const a=document.createElement("canvas"),l=a.getContext("2d");let c;if(a.width=n,a.height=r,o===Ce.Linear)c=l.createLinearGradient(0,0,0,r);else{const e=a.width/2,t=a.height/2,r="auto"!==s?Math.abs(Number(s)):Math.sqrt(e**2+t**2);c=l.createRadialGradient(e,t,Math.abs(i),e,t,r)}let u=e.length;for(;u--;)c.addColorStop(e[u],t[u]);return l.save(),l.fillStyle=c,l.fillRect(0,0,n,r),l.restore(),a}),[e]);return C.createElement("canvasTexture",T.default({colorSpace:c.outputColorSpace,args:[u],attach:"map"},l))},exports.GradientType=Ce,exports.Grid=Kt,exports.Html=q,exports.Hud=Tt,exports.Icosahedron=vn,exports.Image=Be,exports.Instance=Lr,exports.Instances=Br,exports.IsObject=Re,exports.KeyboardControls=function({map:e,children:t,onChange:r,domElement:n}){const a=e.map((e=>e.name+e.keys)).join("-"),o=C.useMemo((()=>D.default(u.subscribeWithSelector((()=>e.reduce(((e,t)=>({...e,[t.name]:!1})),{}))))),[a]),i=C.useMemo((()=>[o.subscribe,o.getState,o]),[a]),s=o.setState;return C.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)),{}),a=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:a,pressed:o,up:i}=n;n.pressed=!0,!i&&o||a(!0)},o=({key:e,code:r})=>{const n=t[e]||t[r];if(!n)return;const{fn:a,up:o}=n;n.pressed=!1,o&&a(!1)},l=n||window;return l.addEventListener("keydown",a,{passive:!0}),l.addEventListener("keyup",o,{passive:!0}),()=>{l.removeEventListener("keydown",a),l.removeEventListener("keyup",o)}}),[n,a]),C.createElement(ne.Provider,{value:i,children:t})},exports.Lathe=bn,exports.Lightformer=wa,exports.Line=pe,exports.Loader=function({containerStyles:e,innerStyles:t,barStyles:r,dataStyles:n,dataInterpolation:a=Y,initialState:o=(e=>e)}){const{active:i,progress:s}=Z(),l=C.useRef(0),c=C.useRef(0),u=C.useRef(null),[d,m]=C.useState(o(i));C.useEffect((()=>{let e;return i!==d&&(e=setTimeout((()=>m(i)),300)),()=>clearTimeout(e)}),[d,i]);const f=C.useCallback((()=>{u.current&&(l.current+=(s-l.current)/2,(l.current>.95*s||100===s)&&(l.current=s),u.current.innerText=a(l.current),l.current<s&&(c.current=requestAnimationFrame(f)))}),[a,s]);return C.useEffect((()=>(f(),()=>cancelAnimationFrame(c.current))),[f]),d?C.createElement("div",{style:{...Q.container,opacity:i?1:0,...e}},C.createElement("div",null,C.createElement("div",{style:{...Q.inner,...t}},C.createElement("div",{style:{...Q.bar,transform:`scaleX(${s/100})`,...r}}),C.createElement("span",{ref:u,style:{...Q.data,...n}})))):null},exports.MapControls=ft,exports.MarchingCube=qe,exports.MarchingCubes=$e,exports.MarchingPlane=Xe,exports.Mask=Co,exports.Merged=Ur,exports.MeshDiscardMaterial=Jr,exports.MeshDistortMaterial=jr,exports.MeshPortalMaterial=Do,exports.MeshReflectorMaterial=Xr,exports.MeshRefractionMaterial=function({aberrationStrength:e=0,fastChroma:r=!0,envMap:n,...o}){a.extend({MeshRefractionMaterial:Zr});const i=t.useRef(),{size:s}=a.useThree(),l=t.useMemo((()=>{var t,a;const o={},i=(s=n)&&s.isCubeTexture;var s;const l=(null!==(t=i?null==(a=n.image[0])?void 0:a.width:n.image.width)&&void 0!==t?t:1024)/4,c=Math.floor(Math.log2(l)),u=Math.pow(2,c),d=3*Math.max(u,112),m=4*u;return i&&(o.ENVMAP_TYPE_CUBEM=""),o.CUBEUV_TEXEL_WIDTH=""+1/d,o.CUBEUV_TEXEL_HEIGHT=""+1/m,o.CUBEUV_MAX_MIP=`${c}.0`,e>0&&(o.CHROMATIC_ABERRATIONS=""),r&&(o.FAST_CHROMA=""),o}),[e,r]);return t.useLayoutEffect((()=>{var e;const t=null==(e=i.current)||null==(e=e.__r3f)||null==(e=e.parent)?void 0:e.geometry;t&&(i.current.bvh=new z.MeshBVHUniformStruct,i.current.bvh.updateFrom(new z.MeshBVH(t.clone().toNonIndexed(),{lazyGeneration:!1,strategy:z.SAH})))}),[]),a.useFrame((({camera:e})=>{i.current.viewMatrixInverse=e.matrixWorld,i.current.projectionMatrixInverse=e.projectionMatrixInverse})),C.createElement("meshRefractionMaterial",T.default({key:JSON.stringify(l),defines:l,ref:i,resolution:[s.width,s.height],aberrationStrength:e,envMap:n},o))},exports.MeshTransmissionMaterial=Kr,exports.MeshWobbleMaterial=Gr,exports.MotionPathControls=Et,exports.Octahedron=gn,exports.OrbitControls=pt,exports.OrthographicCamera=lt,exports.Outlines=function({color:e="black",opacity:t=1,transparent:r=!1,screenspace:n=!1,toneMapped:o=!0,polygonOffset:i=!1,polygonOffsetFactor:s=0,renderOrder:l=0,thickness:c=.05,angle:u=Math.PI,...m}){const f=C.useRef(),[p]=C.useState((()=>new Ie({side:R.BackSide}))),{gl:h}=a.useThree(),x=h.getDrawingBufferSize(new R.Vector2);C.useMemo((()=>a.extend({OutlinesMaterial:Ie})),[]);const y=C.useRef(0),v=C.useRef();return C.useLayoutEffect((()=>{const e=f.current;if(!e)return;const t=e.parent;if(t&&t.geometry&&(y.current!==u||v.current!==t.geometry)){y.current=u,v.current=t.geometry;let r=e.children[0];r&&(u&&r.geometry.dispose(),e.remove(r)),t.skeleton?(r=new R.SkinnedMesh,r.material=p,r.bind(t.skeleton,t.bindMatrix),e.add(r)):t.isInstancedMesh?(r=new R.InstancedMesh(t.geometry,p,t.count),r.instanceMatrix=t.instanceMatrix,e.add(r)):(r=new R.Mesh,r.material=p,e.add(r)),r.geometry=u?d.toCreasedNormals(t.geometry,u):t.geometry}})),C.useLayoutEffect((()=>{const u=f.current;if(!u)return;const d=u.children[0];d&&(d.renderOrder=l,a.applyProps(d.material,{transparent:r,thickness:c,color:e,opacity:t,size:x,screenspace:n,toneMapped:o,polygonOffset:i,polygonOffsetFactor:s}))})),C.useEffect((()=>()=>{const e=f.current;if(!e)return;const t=e.children[0];t&&(u&&t.geometry.dispose(),e.remove(t))}),[]),C.createElement("group",T.default({ref:f},m))},exports.PerformanceMonitor=function({iterations:e=10,ms:r=250,threshold:n=.75,step:o=.1,factor:i=.5,flipflops:s=1/0,bounds:l=(e=>e>100?[60,100]:[40,60]),onIncline:c,onDecline:u,onChange:d,onFallback:m,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 a.useFrame((()=>{const{frames:t,averages:a}=h;if(!h.fallback&&a.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),a[h.index++%e]=h.fps,a.length===e){const[t,r]=l(h.refreshrate),i=a.filter((e=>e>=r)),f=a.filter((e=>e<t));i.length>e*n&&(h.factor=Math.min(1,h.factor+o),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-o),h.flipped++,u&&u(h),h.subscriptions.forEach((e=>e.onDecline&&e.onDecline(h)))),y!==h.factor&&(y=h.factor,d&&d(h),h.subscriptions.forEach((e=>e.onChange&&e.onChange(h)))),h.flipped>s&&!h.fallback&&(h.fallback=!0,m&&m(h),h.subscriptions.forEach((e=>e.onFallback&&e.onFallback(h)))),h.averages=[]}h.frames=[]}}})),C.createElement(bo.Provider,{value:h},f)},exports.PerspectiveCamera=ct,exports.PivotControls=Ci,exports.Plane=dn,exports.Point=lo,exports.PointMaterial=rn,exports.PointMaterialImpl=tn,exports.PointerLockControls=vt,exports.Points=uo,exports.PointsBuffer=co,exports.Polyhedron=yn,exports.PositionPoint=to,exports.PositionalAudio=ge,exports.Preload=function({all:e,scene:t,camera:r}){const o=a.useThree((({gl:e})=>e)),i=a.useThree((({camera:e})=>e)),s=a.useThree((({scene:e})=>e));return C.useLayoutEffect((()=>{const a=[];e&&(t||s).traverse((e=>{!1===e.visible&&(a.push(e),e.visible=!0)})),o.compile(t||s,r||i);const l=new n.WebGLCubeRenderTarget(128);new n.CubeCamera(.01,1e5,l).update(o,t||s),l.dispose(),a.forEach((e=>e.visible=!1))}),[]),null},exports.PresentationControls=function({enabled:e=!0,snap:t,global:r,domElement:o,cursor:i=!0,children:s,speed:u=1,rotation:d=[0,0,0],zoom:m=1,polar:f=[0,Math.PI/2],azimuth:p=[-1/0,1/0],config:h={mass:1,tension:170,friction:26}}){const x=a.useThree((e=>e.events)),y=a.useThree((e=>e.gl)),v=o||x.connected||y.domElement,{size:g}=a.useThree(),z=C.useMemo((()=>[d[0]+f[0],d[0]+f[1]]),[d[0],f[0],f[1]]),w=C.useMemo((()=>[d[1]+p[0],d[1]+p[1]]),[d[1],p[0],p[1]]),b=C.useMemo((()=>[n.MathUtils.clamp(d[0],...z),n.MathUtils.clamp(d[1],...w),d[2]]),[d[0],d[1],d[2],z,w]),[M,E]=l.useSpring((()=>({scale:1,rotation:b,config:h})));C.useEffect((()=>{E.start({scale:1,rotation:b,config:h})}),[b]),C.useEffect((()=>{if(r&&i&&e)return v.style.cursor="grab",y.domElement.style.cursor="",()=>{v.style.cursor="default",y.domElement.style.cursor="default"}}),[r,i,v,e]);const S=c.useGesture({onHover:({last:t})=>{i&&!r&&e&&(v.style.cursor=t?"auto":"grab")},onDrag:({down:r,delta:[a,o],memo:[s,l]=M.rotation.animation.to||b})=>{if(!e)return[o,a];i&&(v.style.cursor=r?"grabbing":"grab"),a=n.MathUtils.clamp(l+a/g.width*Math.PI*u,...w),o=n.MathUtils.clamp(s+o/g.height*Math.PI*u,...z);const c=t&&!r&&"boolean"!=typeof t?t:h;return E.start({scale:r&&o>z[1]/2?m:1,rotation:t&&!r?b:[o,a,0],config:e=>"scale"===e?{...c,friction:3*c.friction}:c}),[o,a]}},{target:r?v:void 0});return C.createElement(l.a.group,T.default({},null==S?void 0:S(),M),s)},exports.QuadraticBezierLine=xe,exports.RandomizedLight=ea,exports.Reflector=ma,exports.RenderCubeTexture=So,exports.RenderTexture=Mo,exports.Resize=Rn,exports.Ring=xn,exports.RoundedBox=Tn,exports.Sampler=function({children:e,weight:t,transform:r,instances:n,mesh:a,count:o=16,...i}){const s=C.useRef(null),l=C.useRef(null),c=C.useRef(null);return C.useLayoutEffect((()=>{var e,t;l.current=null!==(e=null==n?void 0:n.current)&&void 0!==e?e:s.current.children.find((e=>e.hasOwnProperty("instanceMatrix"))),c.current=null!==(t=null==a?void 0:a.current)&&void 0!==t?t:s.current.children.find((e=>"Mesh"===e.type))}),[e,null==a?void 0:a.current,null==n?void 0:n.current]),We(c,o,r,t,l),C.createElement("group",T.default({ref:s},i),e)},exports.ScreenQuad=Pn,exports.ScreenSizer=fe,exports.ScreenSpace=ie,exports.Scroll=re,exports.ScrollControls=function({eps:e=1e-5,enabled:t=!0,infinite:r,horizontal:n,pages:o=1,distance:i=1,damping:l=.25,maxSpeed:c=1/0,style:u={},children:d}){const{get:m,setEvents:f,gl:p,size:h,invalidate:x,events:y}=a.useThree(),[v]=C.useState((()=>document.createElement("div"))),[g]=C.useState((()=>document.createElement("div"))),[z]=C.useState((()=>document.createElement("div"))),w=p.domElement.parentNode,b=C.useRef(0),M=C.useMemo((()=>{const t={el:v,eps:e,fill:g,fixed:z,horizontal:n,damping:l,offset:0,delta:0,scroll:b,pages:o,range(e,t,r=0){const n=e-r,a=n+t+2*r;return this.offset<n?0:this.offset>a?1:(this.offset-n)/(a-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,a=n+t+2*r;return this.offset>=n&&this.offset<=a}};return t}),[e,l,n,o]);C.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%":o*i*100+"%",g.style.width=n?o*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=m().events.compute;return f({compute(e,t){const{left:r,top:n}=w.getBoundingClientRect(),a=e.clientX-r,o=e.clientY-n;t.pointer.set(a/t.size.width*2-1,-o/t.size.height*2+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),()=>{w.removeChild(v),f({compute:t}),null==y.connect||y.connect(e)}}),[o,i,n,v,g,z,w]),C.useEffect((()=>{if(y.connected===v){const e=h[n?"width":"height"],a=v[n?"scrollWidth":"scrollHeight"],o=a-e;let i=0,s=!0,l=!0;const c=()=>{if(t&&!l&&(x(),i=v[n?"scrollLeft":"scrollTop"],b.current=i/o,r)){if(!s)if(i>=o){const e=1-M.offset;v[n?"scrollLeft":"scrollTop"]=1,b.current=M.offset=-e,s=!0}else if(i<=0){const e=1+M.offset;v[n?"scrollLeft":"scrollTop"]=a,b.current=M.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,M,x,n,t]);let E=0;return a.useFrame(((t,r)=>{E=M.offset,s.easing.damp(M,"offset",b.current,l,r,c,void 0,e),s.easing.damp(M,"delta",Math.abs(E-M.offset),l,r,c,void 0,e),M.delta>e&&x()})),C.createElement(K.Provider,{value:M},d)},exports.Segment=xo,exports.SegmentObject=po,exports.Segments=fo,exports.Select=function({box:e,multiple:t,children:r,onChange:n,onChangePointerUp:o,border:i="1px solid #55aaff",backgroundColor:s="rgba(75, 160, 255, 0.1)",filter:l=(e=>e),...c}){const[u,m]=C.useState(!1),{setEvents:f,camera:p,raycaster:h,gl:x,controls:y,size:v,get:g}=a.useThree(),[z,w]=C.useState(!1),[b,M]=C.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]),[]);C.useEffect((()=>{u?null==n||n(b):null==o||o(b)}),[b,u]);const E=C.useCallback((e=>{e.stopPropagation(),M({object:l([e.object])[0],shift:t&&e.shiftKey})}),[]),S=C.useCallback((e=>!z&&M({})),[z]),P=C.useRef(null);return C.useEffect((()=>{if(!e||!t)return;const r=new d.SelectionBox(p,P.current),n=document.createElement("div");n.style.pointerEvents="none",n.style.border=i,n.style.backgroundColor=s,n.style.position="fixed";const a=new R.Vector2,o=new R.Vector2,c=new R.Vector2,u=g().events.enabled,h=null==y?void 0:y.enabled;let z=!1;function w(e,t){const{offsetX:r,offsetY:n}=e,{width:a,height:o}=v;t.set(r/a*2-1,-n/o*2+1)}function b(e){e.shiftKey&&(!function(e){var t;y&&(y.enabled=!1),f({enabled:!1}),m(z=!0),null==(t=x.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",a.x=e.clientX,a.y=e.clientY}(e),w(e,r.startPoint))}let E=[];function S(e){if(z){!function(e){c.x=Math.max(a.x,e.clientX),c.y=Math.max(a.y,e.clientY),o.x=Math.min(a.x,e.clientX),o.y=Math.min(a.y,e.clientY),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=c.x-o.x+"px",n.style.height=c.y-o.y+"px"}(e),w(e,r.endPoint);const t=r.select().sort((e=>e.uuid)).filter((e=>e.isMesh));k.default(t,E)||(E=t,M({object:l(t)}))}}function T(e){var t;z&&z&&(y&&(y.enabled=h),f({enabled:u}),m(z=!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)}}),[v.width,v.height,h,p,y,x]),C.createElement("group",T.default({ref:P,onClick:E,onPointerOver:()=>w(!0),onPointerOut:()=>w(!1),onPointerMissed:S},c),C.createElement(ae.Provider,{value:b},r))},exports.Shadow=oa,exports.ShadowAlpha=function({opacity:e,alphaMap:t}){const r=C.useRef(null),n=C.useRef(null),o=C.useRef({value:1}),i=C.useRef({value:null}),s=C.useRef({value:!1});return C.useLayoutEffect((()=>{r.current.onBeforeCompile=n.current.onBeforeCompile=e=>{const t=e.fragmentShader.indexOf("void main");let r,n="",a=t;for(;"\n"!==r&&a<t+100;)r=e.fragmentShader.charAt(a),n+=r,a++;n=n.trim(),e.vertexShader=e.vertexShader.replace("void main() {","\n varying vec2 custom_vUv;\n\n void main() {\n custom_vUv = uv;\n \n "),e.fragmentShader=e.fragmentShader.replace(n,"\n uniform float uShadowOpacity;\n uniform sampler2D uAlphaMap;\n uniform bool uHasAlphaMap;\n\n varying vec2 custom_vUv;\n \n float bayerDither2x2( vec2 v ) {\n return mod( 3.0 * v.y + 2.0 * v.x, 4.0 );\n }\n \n float bayerDither4x4( vec2 v ) {\n vec2 P1 = mod( v, 2.0 );\n vec2 P2 = mod( floor( 0.5 * v ), 2.0 );\n return 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 );\n }\n \n void main() {\n float alpha = \n uHasAlphaMap ? \n uShadowOpacity * texture2D(uAlphaMap, custom_vUv).x\n : uShadowOpacity;\n\n if( ( bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) ) ) / 16.0 >= alpha ) discard;\n \n "),e.uniforms.uShadowOpacity=o.current,e.uniforms.uAlphaMap=i.current,e.uniforms.uHasAlphaMap=s.current}}),[]),a.useFrame((()=>{var n;const a=null==(n=r.current.__r3f)?void 0:n.parent;if(a){const r=a.material;r&&(o.current.value=null!=e?e:r.opacity,!1===t?(i.current.value=null,s.current.value=!1):(i.current.value=t||r.alphaMap,s.current.value=!!i.current.value))}})),C.createElement(C.Fragment,null,C.createElement("meshDepthMaterial",{ref:r,attach:"customDepthMaterial",depthPacking:R.RGBADepthPacking}),C.createElement("meshDistanceMaterial",{ref:n,attach:"customDistanceMaterial"}))},exports.Shape=En,exports.Sky=Ma,exports.SoftShadows=function({focus:e=0,samples:t=10,size:r=25}){const n=a.useThree((e=>e.gl)),o=a.useThree((e=>e.scene)),i=a.useThree((e=>e.camera));return C.useEffect((()=>{const a=R.ShaderChunk.shadowmap_pars_fragment;return R.ShaderChunk.shadowmap_pars_fragment=R.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 )"),nn(n,o,i),()=>{R.ShaderChunk.shadowmap_pars_fragment=a,nn(n,o,i)}}),[e,r,t]),null},exports.Sparkles=ja,exports.Sphere=un,exports.Splat=function({src:e,toneMapped:t=!1,alphaTest:r=0,alphaHash:n=!1,chunkSize:o=25e3,...i}){a.extend({SplatMaterial:nt});const s=C.useRef(null),l=a.useThree((e=>e.gl)),c=a.useThree((e=>e.camera)),u=a.useLoader(ot,e,(e=>{e.gl=l,e.chunkSize=o}));return C.useLayoutEffect((()=>u.connect(s.current)),[e]),a.useFrame((()=>u.update(s.current,c,n))),C.createElement("mesh",T.default({ref:s,frustumCulled:!1},i),C.createElement("splatMaterial",{key:`${e}/${r}/${n}${nt.key}`,transparent:!n,depthTest:!0,alphaTest:n?0:r,centerAndScaleTexture:u.centerAndScaleTexture,covAndColorTexture:u.covAndColorTexture,depthWrite:!!n||r>0,blending:n?R.NormalBlending:R.CustomBlending,blendSrcAlpha:R.OneFactor,alphaHash:!!n,toneMapped:t}))},exports.SpotLight=za,exports.SpotLightShadow=function(e){return e.shader?C.createElement(va,e):C.createElement(ga,e)},exports.SpriteAnimator=Vr,exports.Stage=function({children:e,center:t,adjustCamera:r=!0,intensity:n=.5,shadows:a="contact",environment:o="city",preset:i="rembrandt",...s}){var l,c,u,d,m,f,p,h;const x="string"==typeof i?ra[i]:i,[{radius:y,height:v},g]=C.useState({radius:0,width:0,height:0,depth:0}),z=null!==(l=null==a?void 0:a.bias)&&void 0!==l?l:-1e-4,w=null!==(c=null==a?void 0:a.normalBias)&&void 0!==c?c:0,b=null!==(u=null==a?void 0:a.size)&&void 0!==u?u:1024,M=null!==(d=null==a?void 0:a.offset)&&void 0!==d?d:0,E="contact"===a||"contact"===(null==a?void 0:a.type),S="accumulative"===a||"accumulative"===(null==a?void 0:a.type),P={..."object"==typeof a?a:{}},R=o?"string"==typeof o?{preset:o}:o:null,D=C.useCallback((e=>{const{width:r,height:n,depth:a,boundingSphere:o}=e;g({radius:o.radius,width:r,height:n,depth:a}),null!=t&&t.onCentered&&t.onCentered(e)}),[]);return C.createElement(C.Fragment,null,C.createElement("ambientLight",{intensity:n/3}),C.createElement("spotLight",{penumbra:1,position:[x.main[0]*y,x.main[1]*y,x.main[2]*y],intensity:2*n,castShadow:!!a,"shadow-bias":z,"shadow-normalBias":w,"shadow-mapSize":b}),C.createElement("pointLight",{position:[x.fill[0]*y,x.fill[1]*y,x.fill[2]*y],intensity:n}),C.createElement(Ln,T.default({fit:!!r,clip:!!r,margin:Number(r),observe:!0},s),C.createElement(na,{radius:y,adjustCamera:r}),C.createElement(zr,T.default({},t,{position:[0,M/2,0],onCentered:D}),e)),C.createElement("group",{position:[0,-v/2-M/2,0]},E&&C.createElement(Yn,T.default({scale:4*y,far:y,blur:2},P)),S&&C.createElement(Jn,T.default({temporal:!0,frames:100,alphaTest:.9,toneMapped:!0,scale:4*y},P),C.createElement(ea,{amount:null!==(m=P.amount)&&void 0!==m?m:8,radius:null!==(f=P.radius)&&void 0!==f?f:y,ambient:null!==(p=P.ambient)&&void 0!==p?p:.5,intensity:null!==(h=P.intensity)&&void 0!==h?h:1,position:[x.main[0]*y,x.main[1]*y,x.main[2]*y],size:4*y,bias:-z,mapSize:b}))),o&&C.createElement(Zn,R))},exports.Stars=Ta,exports.Stats=function({showPanel:e=0,className:t,parent:r}){const n=function(e,t=[],r){const[n,a]=C.useState();return C.useLayoutEffect((()=>{const t=e();return a(t),sr(r,t),()=>sr(r,null)}),t),n}((()=>new A.default),[]);return C.useEffect((()=>{if(n){const o=r&&r.current||document.body;n.showPanel(e),null==o||o.appendChild(n.dom),t&&n.dom.classList.add(...t.split(" ").filter((e=>e)));const i=a.addEffect((()=>n.begin())),s=a.addAfterEffect((()=>n.end()));return()=>{null==o||o.removeChild(n.dom),i(),s()}}}),[r,n,t,e]),null},exports.StatsGl=function({className:e,parent:t,...r}){const n=a.useThree((e=>e.gl)),o=C.useMemo((()=>{const e=new L.default({...r});return e.init(n),e}),[n]);return C.useEffect((()=>{if(o){const r=t&&t.current||document.body;null==r||r.appendChild(o.dom),e&&o.container.classList.add(...e.split(" ").filter((e=>e)));const n=a.addAfterEffect((()=>o.update()));return()=>{null==r||r.removeChild(o.dom),n()}}}),[t,o,e]),null},exports.Svg=Qe,exports.Tetrahedron=hn,exports.Text=ze,exports.Text3D=Se,exports.Torus=fn,exports.TorusKnot=pn,exports.TrackballControls=ht,exports.Trail=je,exports.TransformControls=yt,exports.Tube=mn,exports.View=Go,exports.Wireframe=function({geometry:e,...t}){return e?C.createElement(Za,T.default({geometry:e},t)):C.createElement(Ya,t)},exports.accumulativeContext=Qn,exports.calcPosFromAngles=ba,exports.calculateAspectRatio=or,exports.calculateScaleFactor=de,exports.getFirstItem=ar,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,a=this.matrixWorld;void 0!==n&&(null===r.boundingSphere&&r.computeBoundingSphere(),zo.copy(r.boundingSphere),zo.applyMatrix4(a),!1!==e.ray.intersectsSphere(zo)&&(vo.copy(a).invert(),go.copy(e.ray).applyMatrix4(vo),null!==r.boundingBox&&null===go.intersectBox(r.boundingBox,wo)||t.push({distance:wo.distanceTo(e.ray.origin),point:wo.clone(),object:this})))},exports.shaderMaterial=Pe,exports.useAnimations=function(e,t){const r=C.useRef(),[o]=C.useState((()=>t?t instanceof n.Object3D?{current:t}:t:r)),[i]=C.useState((()=>new n.AnimationMixer(void 0)));C.useLayoutEffect((()=>{t&&(o.current=t instanceof n.Object3D?t:t.current),i._root=o.current}));const s=C.useRef({}),l=C.useMemo((()=>{const t={};return e.forEach((e=>Object.defineProperty(t,e.name,{enumerable:!0,get(){if(o.current)return s.current[e.name]||(s.current[e.name]=i.clipAction(e,o.current))},configurable:!0}))),{ref:o,clips:e,actions:t,names:e.map((e=>e.name)),mixer:i}}),[e]);return a.useFrame(((e,t)=>i.update(t))),C.useEffect((()=>{const e=o.current;return()=>{s.current={},i.stopAllAction(),Object.values(l.actions).forEach((t=>{e&&i.uncacheAction(t,e)}))}}),[e]),l},exports.useAspect=function(e,t,r=1){const n=a.useThree((e=>e.viewport)),o=t*(n.aspect>e/t?n.width/e:n.height/t);return[e*(n.aspect>e/t?n.width/e:n.height/t)*r,o*r,1]},exports.useBVH=function(e,t){t={strategy:z.SAH,verbose:!1,setBoundingBox:!0,maxDepth:40,maxLeafTris:10,indirect:!1,...t},C.useEffect((()=>{if(e.current){e.current.raycast=z.acceleratedRaycast;const r=e.current.geometry;return r.computeBoundsTree=z.computeBoundsTree,r.disposeBoundsTree=z.disposeBoundsTree,r.computeBoundsTree(t),()=>{r.boundsTree&&r.disposeBoundsTree()}}}),[e,JSON.stringify(t)])},exports.useBounds=Bn,exports.useBoxProjectedEnv=function(e=new R.Vector3,t=new R.Vector3){const[r]=C.useState((()=>({position:new R.Vector3,size:new R.Vector3})));a.applyProps(r,{position:e,size:t});const n=C.useRef(null),o=C.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>",mr)}`,e.fragmentShader=`\n ${fr}\n ${e.fragmentShader.replace("#include <envmap_physical_pars_fragment>",R.ShaderChunk.envmap_physical_pars_fragment).replace("vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );",`vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n ${pr}\n `).replace("reflectVec = inverseTransformDirection( reflectVec, viewMatrix );",`reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n ${hr}\n `)}`}(e,r.position,r.size),customProgramCacheKey:()=>JSON.stringify(r.position.toArray())+JSON.stringify(r.size.toArray())})),[...r.position.toArray(),...r.size.toArray()]);return C.useLayoutEffect((()=>{n.current.needsUpdate=!0}),[r]),o},exports.useCamera=function(e,t){const r=a.useThree((e=>e.pointer)),[o]=C.useState((()=>{const o=new n.Raycaster;return t&&a.applyProps(o,t,{}),function(t,a){o.setFromCamera(r,e instanceof n.Camera?e:e.current);const i=this.constructor.prototype.raycast.bind(this);i&&i(o,a)}}));return o},exports.useContextBridge=function(...e){const t=C.useRef([]);return t.current=e.map((e=>C.useContext(e))),C.useMemo((()=>({children:r})=>e.reduceRight(((e,r,n)=>C.createElement(r.Provider,{value:t.current[n],children:e})),r)),[])},exports.useCubeCamera=ut,exports.useCubeTexture=Jt,exports.useCursor=function(e,t="pointer",r="auto",n=document.body){C.useEffect((()=>{if(e)return n.style.cursor=t,()=>{n.style.cursor=r}}),[e])},exports.useDepthBuffer=function({size:e=256,frames:t=1/0}={}){const r=a.useThree((e=>e.viewport.dpr)),{width:o,height:i}=a.useThree((e=>e.size)),s=e||o*r,l=e||i*r,c=C.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 d=st(s,l,c);return a.useFrame((e=>{(t===1/0||u<t)&&(e.gl.setRenderTarget(d),e.gl.render(e.scene,e.camera),e.gl.setRenderTarget(null),u++)})),d.depthTexture},exports.useDetectGPU=e=>p.suspend((()=>g.getGPUTier(e)),["useDetectGPU"]),exports.useEnvironment=jn,exports.useFBO=st,exports.useFBX=er,exports.useFaceControls=Oi,exports.useFaceLandmarker=Bi,exports.useFont=Me,exports.useGLTF=tt,exports.useGizmoContext=Pt,exports.useHelper=lr,exports.useIntersect=dr,exports.useKTX2=rr,exports.useKeyboardControls=function(e){const[t,r,n]=C.useContext(ne);return e?n(e):[t,r]},exports.useMask=function(e,t=!1){return{stencilWrite:!0,stencilRef:e,stencilFunc:t?R.NotEqualStencilFunc:R.EqualStencilFunc,stencilFail:R.KeepStencilOp,stencilZFail:R.KeepStencilOp,stencilZPass:R.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"]),a=n[0],o=C.useMemo((()=>Object.keys(n).length),[]),i=`${C.useMemo((()=>"string"==typeof e?e:"number"==typeof e?n[e]:null),[e])||a}${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[De(s,r),s,o]},exports.useMotion=bt,exports.useNormalTexture=function(e=0,t={},r){const{repeat:a=[1,1],anisotropy:o=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=C.useMemo((()=>Object.keys(s).length),[]),c=s[0],u=`https://rawcdn.githack.com/pmndrs/drei-assets/7a3104997e1576f83472829815b00880d88b32fb/normals/${s[e]||c}`,d=De(u,r);return C.useLayoutEffect((()=>{d&&(d.wrapS=d.wrapT=n.RepeatWrapping,d.repeat=new n.Vector2(a[0],a[1]),d.offset=new n.Vector2(i[0],i[1]),d.anisotropy=o)}),[d,o,a,i]),[d,u,l]},exports.usePerformanceMonitor=function({onIncline:e,onDecline:r,onChange:n,onFallback:a}){const o=t.useContext(bo),i=t.useRef({onIncline:e,onDecline:r,onChange:n,onFallback:a});t.useLayoutEffect((()=>{i.current.onIncline=e,i.current.onDecline=r,i.current.onChange=n,i.current.onFallback=a}),[e,r,n,a]),t.useLayoutEffect((()=>o.subscribe(i)),[o])},exports.useProgress=Z,exports.useScroll=J,exports.useSelect=function(){return C.useContext(ae)},exports.useSpriteAnimator=function(){return C.useContext(Ir)},exports.useSpriteLoader=ir,exports.useSurfaceSampler=We,exports.useTexture=De,exports.useTrail=Oe,exports.useTrailTexture=function(e={}){const{size:r,maxAge:n,radius:o,intensity:i,interpolate:s,smoothing:l,minForce:c,blend:u,ease:d}=e,m=t.useMemo((()=>new gr(e)),[r,n,o,i,s,l,c,u,d]);a.useFrame(((e,t)=>{m.update(t)}));const f=t.useCallback((e=>m.addTouch(e.uv)),[m]);return[m.texture,f]},exports.useVideoTexture=nr;
|