UNPKG

@meese-os/website

Version:

meeseOS, implemented in OS.js

3 lines 630 kB
/*! For license information please see three-js.c9b97f7981cf868f4573.bundle.js.LICENSE.txt */
"use strict";(self.webpackChunk_meese_os_website=self.webpackChunk_meese_os_website||[]).push([[971],{911:(e,t,i)=>{i.r(t),i.d(t,{ACESFilmicToneMapping:()=>te,AddEquation:()=>E,AddOperation:()=>J,AdditiveAnimationBlendMode:()=>Lt,AdditiveBlending:()=>y,AlphaFormat:()=>Ue,AlwaysDepth:()=>H,AlwaysStencilFunc:()=>ai,AmbientLight:()=>Ju,AmbientLightProbe:()=>pd,AnimationAction:()=>Bd,AnimationClip:()=>Mu,AnimationLoader:()=>Cu,AnimationMixer:()=>Gd,AnimationObjectGroup:()=>Fd,AnimationUtils:()=>lu,ArcCurve:()=>Uh,ArrayCamera:()=>sl,ArrowHelper:()=>Lp,Audio:()=>Td,AudioAnalyser:()=>Pd,AudioContext:()=>cd,AudioListener:()=>Ed,AudioLoader:()=>ud,AxesHelper:()=>Pp,BackSide:()=>f,BasicDepthPacking:()=>Ot,BasicShadowMap:()=>c,Bone:()=>Yl,BooleanKeyframeTrack:()=>mu,Box2:()=>Qd,Box3:()=>dr,Box3Helper:()=>Tp,BoxBufferGeometry:()=>Up,BoxGeometry:()=>ba,BoxHelper:()=>Ep,BufferAttribute:()=>zn,BufferGeometry:()=>ra,BufferGeometryLoader:()=>rd,ByteType:()=>be,Cache:()=>Su,Camera:()=>Ca,CameraHelper:()=>Mp,CanvasTexture:()=>Lh,CapsuleBufferGeometry:()=>Dp,CapsuleGeometry:()=>ec,CatmullRomCurve3:()=>zh,CineonToneMapping:()=>ee,CircleBufferGeometry:()=>Np,CircleGeometry:()=>tc,ClampToEdgeWrapping:()=>ce,Clock:()=>_d,Color:()=>Ln,ColorKeyframeTrack:()=>fu,ColorManagement:()=>Yi,CompressedArrayTexture:()=>Ch,CompressedTexture:()=>Rh,CompressedTextureLoader:()=>Lu,ConeBufferGeometry:()=>Op,ConeGeometry:()=>rc,CubeCamera:()=>Pa,CubeReflectionMapping:()=>ne,CubeRefractionMapping:()=>ae,CubeTexture:()=>Ia,CubeTextureLoader:()=>Iu,CubeUVReflectionMapping:()=>le,CubicBezierCurve:()=>Vh,CubicBezierCurve3:()=>Wh,CubicInterpolant:()=>cu,CullFaceBack:()=>o,CullFaceFront:()=>l,CullFaceFrontBack:()=>h,CullFaceNone:()=>s,Curve:()=>Ph,CurvePath:()=>Kh,CustomBlending:()=>b,CustomToneMapping:()=>ie,CylinderBufferGeometry:()=>Fp,CylinderGeometry:()=>ic,Cylindrical:()=>Jd,Data3DTexture:()=>ar,DataArrayTexture:()=>rr,DataTexture:()=>Zl,DataTextureLoader:()=>Uu,DataUtils:()=>On,DecrementStencilOp:()=>Yt,DecrementWrapStencilOp:()=>Jt,DefaultLoadingManager:()=>Eu,DepthFormat:()=>Fe,DepthStencilFormat:()=>Be,DepthTexture:()=>cl,DirectionalLight:()=>Zu,DirectionalLightHelper:()=>_p,DiscreteInterpolant:()=>du,DisplayP3ColorSpace:()=>Vt,DodecahedronBufferGeometry:()=>Bp,DodecahedronGeometry:()=>ac,DoubleSide:()=>g,DstAlphaFactor:()=>N,DstColorFactor:()=>F,DynamicCopyUsage:()=>pi,DynamicDrawUsage:()=>oi,DynamicReadUsage:()=>ci,EdgesGeometry:()=>cc,EllipseCurve:()=>Ih,EqualDepth:()=>W,EqualStencilFunc:()=>ei,EquirectangularReflectionMapping:()=>se,EquirectangularRefractionMapping:()=>oe,Euler:()=>Zr,EventDispatcher:()=>_i,ExtrudeBufferGeometry:()=>zp,ExtrudeGeometry:()=>Ic,FileLoader:()=>Ru,Float16BufferAttribute:()=>qn,Float32BufferAttribute:()=>Yn,Float64BufferAttribute:()=>Zn,FloatType:()=>Re,Fog:()=>vl,FogExp2:()=>gl,FramebufferTexture:()=>Ah,FrontSide:()=>m,Frustum:()=>Ga,GLBufferAttribute:()=>Xd,GLSL1:()=>fi,GLSL3:()=>gi,GreaterDepth:()=>j,GreaterEqualDepth:()=>X,GreaterEqualStencilFunc:()=>ni,GreaterStencilFunc:()=>ii,GridHelper:()=>pp,Group:()=>ol,HalfFloatType:()=>Ce,HemisphereLight:()=>Ou,HemisphereLightHelper:()=>dp,HemisphereLightProbe:()=>dd,IcosahedronBufferGeometry:()=>Gp,IcosahedronGeometry:()=>Dc,ImageBitmapLoader:()=>ld,ImageLoader:()=>Pu,ImageUtils:()=>Ji,IncrementStencilOp:()=>qt,IncrementWrapStencilOp:()=>Zt,InstancedBufferAttribute:()=>$l,InstancedBufferGeometry:()=>id,InstancedInterleavedBuffer:()=>Wd,InstancedMesh:()=>oh,Int16BufferAttribute:()=>Vn,Int32BufferAttribute:()=>Xn,Int8BufferAttribute:()=>Gn,IntType:()=>we,InterleavedBuffer:()=>xl,InterleavedBufferAttribute:()=>Ml,Interpolant:()=>hu,InterpolateDiscrete:()=>bt,InterpolateLinear:()=>Et,InterpolateSmooth:()=>Tt,InvertStencilOp:()=>Kt,KeepStencilOp:()=>Xt,KeyframeTrack:()=>pu,LOD:()=>Gl,LatheBufferGeometry:()=>Hp,LatheGeometry:()=>$h,Layers:()=>Jr,LessDepth:()=>k,LessEqualDepth:()=>V,LessEqualStencilFunc:()=>ti,LessStencilFunc:()=>$t,Light:()=>Nu,LightProbe:()=>$u,Line:()=>mh,Line3:()=>tp,LineBasicMaterial:()=>lh,LineCurve:()=>Xh,LineCurve3:()=>jh,LineDashedMaterial:()=>tu,LineLoop:()=>_h,LineSegments:()=>vh,LinearEncoding:()=>Dt,LinearFilter:()=>ve,LinearInterpolant:()=>uu,LinearMipMapLinearFilter:()=>Me,LinearMipMapNearestFilter:()=>xe,LinearMipmapLinearFilter:()=>ye,LinearMipmapNearestFilter:()=>_e,LinearSRGBColorSpace:()=>kt,LinearToneMapping:()=>Q,Loader:()=>Tu,LoaderUtils:()=>td,LoadingManager:()=>bu,LoopOnce:()=>yt,LoopPingPong:()=>St,LoopRepeat:()=>Mt,LuminanceAlphaFormat:()=>Oe,LuminanceFormat:()=>Ne,MOUSE:()=>n,Material:()=>Tn,MaterialLoader:()=>ed,MathUtils:()=>Ii,Matrix3:()=>Di,Matrix4:()=>zr,MaxEquation:()=>R,Mesh:()=>Ma,MeshBasicMaterial:()=>In,MeshDepthMaterial:()=>el,MeshDistanceMaterial:()=>tl,MeshLambertMaterial:()=>$c,MeshMatcapMaterial:()=>eu,MeshNormalMaterial:()=>Qc,MeshPhongMaterial:()=>Jc,MeshPhysicalMaterial:()=>Zc,MeshStandardMaterial:()=>Yc,MeshToonMaterial:()=>Kc,MinEquation:()=>A,MirroredRepeatWrapping:()=>ue,MixOperation:()=>Z,MultiplyBlending:()=>S,MultiplyOperation:()=>Y,NearestFilter:()=>de,NearestMipMapLinearFilter:()=>ge,NearestMipMapNearestFilter:()=>me,NearestMipmapLinearFilter:()=>fe,NearestMipmapNearestFilter:()=>pe,NeverDepth:()=>G,NeverStencilFunc:()=>Qt,NoBlending:()=>_,NoColorSpace:()=>Gt,NoToneMapping:()=>K,NormalAnimationBlendMode:()=>Ct,NormalBlending:()=>x,NotEqualDepth:()=>q,NotEqualStencilFunc:()=>ri,NumberKeyframeTrack:()=>gu,Object3D:()=>un,ObjectLoader:()=>nd,ObjectSpaceNormalMap:()=>zt,OctahedronBufferGeometry:()=>kp,OctahedronGeometry:()=>Nc,OneFactor:()=>L,OneMinusDstAlphaFactor:()=>O,OneMinusDstColorFactor:()=>B,OneMinusSrcAlphaFactor:()=>D,OneMinusSrcColorFactor:()=>I,OrthographicCamera:()=>es,PCFShadowMap:()=>u,PCFSoftShadowMap:()=>d,PMREMGenerator:()=>ss,Path:()=>Qh,PerspectiveCamera:()=>La,Plane:()=>Fa,PlaneBufferGeometry:()=>Vp,PlaneGeometry:()=>Va,PlaneHelper:()=>wp,PointLight:()=>qu,PointLightHelper:()=>lp,Points:()=>Eh,PointsMaterial:()=>xh,PolarGridHelper:()=>mp,PolyhedronBufferGeometry:()=>Wp,PolyhedronGeometry:()=>nc,PositionalAudio:()=>Ld,PropertyBinding:()=>Od,PropertyMixer:()=>Id,QuadraticBezierCurve:()=>qh,QuadraticBezierCurve3:()=>Yh,Quaternion:()=>lr,QuaternionKeyframeTrack:()=>_u,QuaternionLinearInterpolant:()=>vu,RED_GREEN_RGTC2_Format:()=>_t,RED_RGTC1_Format:()=>gt,REVISION:()=>r,RGBADepthPacking:()=>Ft,RGBAFormat:()=>De,RGBAIntegerFormat:()=>Ve,RGBA_ASTC_10x10_Format:()=>dt,RGBA_ASTC_10x5_Format:()=>ht,RGBA_ASTC_10x6_Format:()=>ct,RGBA_ASTC_10x8_Format:()=>ut,RGBA_ASTC_12x10_Format:()=>pt,RGBA_ASTC_12x12_Format:()=>mt,RGBA_ASTC_4x4_Format:()=>tt,RGBA_ASTC_5x4_Format:()=>it,RGBA_ASTC_5x5_Format:()=>rt,RGBA_ASTC_6x5_Format:()=>nt,RGBA_ASTC_6x6_Format:()=>at,RGBA_ASTC_8x5_Format:()=>st,RGBA_ASTC_8x6_Format:()=>ot,RGBA_ASTC_8x8_Format:()=>lt,RGBA_BPTC_Format:()=>ft,RGBA_ETC2_EAC_Format:()=>et,RGBA_PVRTC_2BPPV1_Format:()=>Ke,RGBA_PVRTC_4BPPV1_Format:()=>Je,RGBA_S3TC_DXT1_Format:()=>Xe,RGBA_S3TC_DXT3_Format:()=>je,RGBA_S3TC_DXT5_Format:()=>qe,RGB_ETC1_Format:()=>Qe,RGB_ETC2_Format:()=>$e,RGB_PVRTC_2BPPV1_Format:()=>Ze,RGB_PVRTC_4BPPV1_Format:()=>Ye,RGB_S3TC_DXT1_Format:()=>We,RGFormat:()=>He,RGIntegerFormat:()=>ke,RawShaderMaterial:()=>qc,Ray:()=>Br,Raycaster:()=>jd,RectAreaLight:()=>Ku,RedFormat:()=>ze,RedIntegerFormat:()=>Ge,ReinhardToneMapping:()=>$,RepeatWrapping:()=>he,ReplaceStencilOp:()=>jt,ReverseSubtractEquation:()=>w,RingBufferGeometry:()=>Xp,RingGeometry:()=>Oc,SIGNED_RED_GREEN_RGTC2_Format:()=>xt,SIGNED_RED_RGTC1_Format:()=>vt,SRGBColorSpace:()=>Ht,Scene:()=>_l,ShaderChunk:()=>Wa,ShaderLib:()=>ja,ShaderMaterial:()=>Ra,ShadowMaterial:()=>jc,Shape:()=>uc,ShapeBufferGeometry:()=>jp,ShapeGeometry:()=>Fc,ShapePath:()=>Ip,ShapeUtils:()=>Cc,ShortType:()=>Ee,Skeleton:()=>Ql,SkeletonHelper:()=>op,SkinnedMesh:()=>ql,Source:()=>Ki,Sphere:()=>Lr,SphereBufferGeometry:()=>qp,SphereGeometry:()=>Bc,Spherical:()=>Zd,SphericalHarmonics3:()=>Qu,SplineCurve:()=>Zh,SpotLight:()=>ku,SpotLightHelper:()=>rp,Sprite:()=>Ol,SpriteMaterial:()=>Sl,SrcAlphaFactor:()=>U,SrcAlphaSaturateFactor:()=>z,SrcColorFactor:()=>P,StaticCopyUsage:()=>di,StaticDrawUsage:()=>si,StaticReadUsage:()=>hi,StereoCamera:()=>vd,StreamCopyUsage:()=>mi,StreamDrawUsage:()=>li,StreamReadUsage:()=>ui,StringKeyframeTrack:()=>xu,SubtractEquation:()=>T,SubtractiveBlending:()=>M,TOUCH:()=>a,TangentSpaceNormalMap:()=>Bt,TetrahedronBufferGeometry:()=>Yp,TetrahedronGeometry:()=>zc,Texture:()=>er,TextureLoader:()=>Du,TorusBufferGeometry:()=>Zp,TorusGeometry:()=>Gc,TorusKnotBufferGeometry:()=>Jp,TorusKnotGeometry:()=>Hc,Triangle:()=>bn,TriangleFanDrawMode:()=>Ut,TriangleStripDrawMode:()=>It,TrianglesDrawMode:()=>Pt,TubeBufferGeometry:()=>Kp,TubeGeometry:()=>kc,TwoPassDoubleSide:()=>v,UVMapping:()=>re,Uint16BufferAttribute:()=>Wn,Uint32BufferAttribute:()=>jn,Uint8BufferAttribute:()=>Hn,Uint8ClampedBufferAttribute:()=>kn,Uniform:()=>Hd,UniformsGroup:()=>Vd,UniformsLib:()=>Xa,UniformsUtils:()=>Aa,UnsignedByteType:()=>Se,UnsignedInt248Type:()=>Ie,UnsignedIntType:()=>Ae,UnsignedShort4444Type:()=>Le,UnsignedShort5551Type:()=>Pe,UnsignedShortType:()=>Te,VSMShadowMap:()=>p,Vector2:()=>Ui,Vector3:()=>hr,Vector4:()=>tr,VectorKeyframeTrack:()=>yu,VideoTexture:()=>wh,WebGL1Renderer:()=>fl,WebGL3DRenderTarget:()=>sr,WebGLArrayRenderTarget:()=>nr,WebGLCubeRenderTarget:()=>Ua,WebGLMultipleRenderTargets:()=>or,WebGLRenderTarget:()=>ir,WebGLRenderer:()=>ml,WebGLUtils:()=>al,WireframeGeometry:()=>Vc,WrapAroundEnding:()=>Rt,ZeroCurvatureEnding:()=>wt,ZeroFactor:()=>C,ZeroSlopeEnding:()=>At,ZeroStencilOp:()=>Wt,_SRGBAFormat:()=>vi,sRGBEncoding:()=>Nt});const r="152",n={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},a={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},s=0,o=1,l=2,h=3,c=0,u=1,d=2,p=3,m=0,f=1,g=2,v=2,_=0,x=1,y=2,M=3,S=4,b=5,E=100,T=101,w=102,A=103,R=104,C=200,L=201,P=202,I=203,U=204,D=205,N=206,O=207,F=208,B=209,z=210,G=0,H=1,k=2,V=3,W=4,X=5,j=6,q=7,Y=0,Z=1,J=2,K=0,Q=1,$=2,ee=3,te=4,ie=5,re=300,ne=301,ae=302,se=303,oe=304,le=306,he=1e3,ce=1001,ue=1002,de=1003,pe=1004,me=1004,fe=1005,ge=1005,ve=1006,_e=1007,xe=1007,ye=1008,Me=1008,Se=1009,be=1010,Ee=1011,Te=1012,we=1013,Ae=1014,Re=1015,Ce=1016,Le=1017,Pe=1018,Ie=1020,Ue=1021,De=1023,Ne=1024,Oe=1025,Fe=1026,Be=1027,ze=1028,Ge=1029,He=1030,ke=1031,Ve=1033,We=33776,Xe=33777,je=33778,qe=33779,Ye=35840,Ze=35841,Je=35842,Ke=35843,Qe=36196,$e=37492,et=37496,tt=37808,it=37809,rt=37810,nt=37811,at=37812,st=37813,ot=37814,lt=37815,ht=37816,ct=37817,ut=37818,dt=37819,pt=37820,mt=37821,ft=36492,gt=36283,vt=36284,_t=36285,xt=36286,yt=2200,Mt=2201,St=2202,bt=2300,Et=2301,Tt=2302,wt=2400,At=2401,Rt=2402,Ct=2500,Lt=2501,Pt=0,It=1,Ut=2,Dt=3e3,Nt=3001,Ot=3200,Ft=3201,Bt=0,zt=1,Gt="",Ht="srgb",kt="srgb-linear",Vt="display-p3",Wt=0,Xt=7680,jt=7681,qt=7682,Yt=7683,Zt=34055,Jt=34056,Kt=5386,Qt=512,$t=513,ei=514,ti=515,ii=516,ri=517,ni=518,ai=519,si=35044,oi=35048,li=35040,hi=35045,ci=35049,ui=35041,di=35046,pi=35050,mi=35042,fi="100",gi="300 es",vi=1035;class _i{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});var i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){var i;return void 0!==this._listeners&&void 0!==(i=this._listeners)[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){var i;void 0!==this._listeners&&void 0!==(e=this._listeners[e])&&-1!==(i=e.indexOf(t))&&e.splice(i,1)}dispatchEvent(e){if(void 0!==this._listeners){var t=this._listeners[e.type];if(void 0!==t){e.target=this;var i=t.slice(0);for(let t=0,r=i.length;t<r;t++)i[t].call(this,e);e.target=null}}}}const xi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let yi=1234567;const Mi=Math.PI/180,Si=180/Math.PI;function bi(){var e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(xi[255&e]+xi[e>>8&255]+xi[e>>16&255]+xi[e>>24&255]+"-"+xi[255&t]+xi[t>>8&255]+"-"+xi[t>>16&15|64]+xi[t>>24&255]+"-"+xi[63&i|128]+xi[i>>8&255]+"-"+xi[i>>16&255]+xi[i>>24&255]+xi[255&r]+xi[r>>8&255]+xi[r>>16&255]+xi[r>>24&255]).toLowerCase()}function Ei(e,t,i){return Math.max(t,Math.min(i,e))}function Ti(e,t){return(e%t+t)%t}function wi(e,t,i){return(1-i)*e+i*t}function Ai(e){return!(e&e-1)&&0!==e}function Ri(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function Ci(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Li(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Pi(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Ii={DEG2RAD:Mi,RAD2DEG:Si,generateUUID:bi,clamp:Ei,euclideanModulo:Ti,mapLinear:function(e,t,i,r,n){return r+(e-t)*(n-r)/(i-t)},inverseLerp:function(e,t,i){return e!==t?(i-e)/(t-e):0},lerp:wi,damp:function(e,t,i,r){return wi(e,t,1-Math.exp(-i*r))},pingpong:function(e,t=1){return t-Math.abs(Ti(e,2*t)-t)},smoothstep:function(e,t,i){return e<=t?0:i<=e?1:(e=(e-t)/(i-t))*e*(3-2*e)},smootherstep:function(e,t,i){return e<=t?0:i<=e?1:(e=(e-t)/(i-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(yi=e),e=yi+=1831565813,e=Math.imul(e^e>>>15,1|e),(((e^=e+Math.imul(e^e>>>7,61|e))^e>>>14)>>>0)/4294967296},degToRad:function(e){return e*Mi},radToDeg:function(e){return e*Si},isPowerOfTwo:Ai,ceilPowerOfTwo:Ri,floorPowerOfTwo:Ci,setQuaternionFromProperEuler:function(e,t,i,r,n){var a=Math.cos,s=Math.sin,o=a(i/2),l=s(i/2),h=a((t+r)/2),c=s((t+r)/2),u=a((t-r)/2),d=s((t-r)/2),p=a((r-t)/2),m=s((r-t)/2);switch(n){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*m,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*m,o*h);break;case"ZYZ":e.set(l*m,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}},normalize:Pi,denormalize:Li};class Ui{constructor(e=0,t=0){Ui.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){var t=this.x,i=this.y;return e=e.elements,this.x=e[0]*t+e[3]*i+e[6],this.y=e[1]*t+e[4]*i+e[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:(e=this.dot(e)/t,Math.acos(Ei(e,-1,1)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x;return t*t+(e=this.y-e.y)*e}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){var i=Math.cos(t),r=(t=Math.sin(t),this.x-e.x),n=this.y-e.y;return this.x=r*i-n*t+e.x,this.y=r*t+n*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Di{constructor(){Di.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,i,r,n,a,s,o,l){var h=this.elements;return h[0]=e,h[1]=r,h[2]=s,h[3]=t,h[4]=n,h[5]=o,h[6]=i,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){var t=this.elements;return e=e.elements,t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){return e=e.elements,this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){e=e.elements,t=t.elements;var i=this.elements,r=e[0],n=e[3],a=e[6],s=e[1],o=e[4],l=e[7],h=e[2],c=e[5],u=(e=e[8],t[0]),d=t[3],p=t[6],m=t[1],f=t[4],g=t[7],v=t[2],_=t[5];return t=t[8],i[0]=r*u+n*m+a*v,i[3]=r*d+n*f+a*_,i[6]=r*p+n*g+a*t,i[1]=s*u+o*m+l*v,i[4]=s*d+o*f+l*_,i[7]=s*p+o*g+l*t,i[2]=h*u+c*m+e*v,i[5]=h*d+c*f+e*_,i[8]=h*p+c*g+e*t,this}multiplyScalar(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){var e,t=(e=this.elements)[0],i=e[1],r=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7];return t*a*(e=e[8])-t*s*l-i*n*e+i*s*o+r*n*l-r*a*o}invert(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*n,d=l*n-a*o,p=t*c+i*u+r*d;return 0==p?this.set(0,0,0,0,0,0,0,0,0):(e[0]=c*(c=1/p),e[1]=(r*l-h*i)*c,e[2]=(s*i-r*a)*c,e[3]=u*c,e[4]=(h*t-r*o)*c,e[5]=(r*n-s*t)*c,e[6]=d*c,e[7]=(i*o-l*t)*c,e[8]=(a*t-i*n)*c,this)}transpose(){var e=this.elements,t=e[1];return e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,n,a,s){var o=Math.cos(n);return n=Math.sin(n),this.set(i*o,i*n,-i*(o*a+n*s)+a+e,-r*n,r*o,-r*(-n*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(Ni.makeScale(e,t)),this}rotate(e){return this.premultiply(Ni.makeRotation(-e)),this}translate(e,t){return this.premultiply(Ni.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,-e,0,e,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){var t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const Ni=new Di;function Oi(e){for(let t=e.length-1;0<=t;--t)if(65535<=e[t])return 1}const Fi={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Bi(e,t){return new Fi[e](t)}function zi(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Gi={};function Hi(e){e in Gi||(Gi[e]=!0,console.warn(e))}function ki(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Vi(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const Wi=(new Di).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Xi=(new Di).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]),ji={[kt]:e=>e,[Ht]:e=>e.convertSRGBToLinear(),[Vt]:function(e){return e.convertSRGBToLinear().applyMatrix3(Xi)}},qi={[kt]:e=>e,[Ht]:e=>e.convertLinearToSRGB(),[Vt]:function(e){return e.applyMatrix3(Wi).convertLinearToSRGB()}},Yi={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return kt},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(!1===this.enabled||t===i||!t||!i)return e;var r=ji[t],n=qi[i];if(void 0===r||void 0===n)throw new Error(`Unsupported color space conversion, "${t}" to "${i}".`);return n(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let Zi;class Ji{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;var i;return 2048<(t=e instanceof HTMLCanvasElement?e:((Zi=void 0===Zi?zi("canvas"):Zi).width=e.width,Zi.height=e.height,i=Zi.getContext("2d"),e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),Zi)).width||2048<t.height?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){var t=zi("canvas"),i=(t.width=e.width,t.height=e.height,t.getContext("2d")),r=(i.drawImage(e,0,0,e.width,e.height),i.getImageData(0,0,e.width,e.height)),n=r.data;for(let e=0;e<n.length;e++)n[e]=255*ki(n[e]/255);return i.putImageData(r,0,0),t}if(e.data){var a=e.data.slice(0);for(let e=0;e<a.length;e++)a instanceof Uint8Array||a instanceof Uint8ClampedArray?a[e]=Math.floor(255*ki(a[e]/255)):a[e]=ki(a[e]);return{data:a,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Ki{constructor(e=null){this.isSource=!0,this.uuid=bi(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){var t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];var i={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,i=r.length;t<i;t++)r[t].isDataTexture?e.push(Qi(r[t].image)):e.push(Qi(r[t]))}else e=Qi(r);i.url=e}return t||(e.images[this.uuid]=i),i}}function Qi(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Ji.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let $i=0;class er extends _i{constructor(e=er.DEFAULT_IMAGE,t=er.DEFAULT_MAPPING,i=ce,r=ce,n=ve,a=ye,s=De,o=Se,l=er.DEFAULT_ANISOTROPY,h=Gt){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:$i++}),this.uuid=bi(),this.name="",this.source=new Ki(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=i,this.wrapT=r,this.magFilter=n,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new Ui(0,0),this.repeat=new Ui(1,1),this.center=new Ui(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Di,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,"string"==typeof h?this.colorSpace=h:(Hi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=h===Nt?Ht:Gt),this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){var t,i=void 0===e||"string"==typeof e;return i||void 0===e.textures[this.uuid]?(t={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment},0<Object.keys(this.userData).length&&(t.userData=this.userData),i||(e.textures[this.uuid]=t),t):e.textures[this.uuid]}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping===re){if(e.applyMatrix3(this.matrix),e.x<0||1<e.x)switch(this.wrapS){case he:e.x=e.x-Math.floor(e.x);break;case ce:e.x=e.x<0?0:1;break;case ue:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||1<e.y)switch(this.wrapT){case he:e.y=e.y-Math.floor(e.y);break;case ce:e.y=e.y<0?0:1;break;case ue:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}this.flipY&&(e.y=1-e.y)}return e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Hi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Ht?Nt:Dt}set encoding(e){Hi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Nt?Ht:Gt}}er.DEFAULT_IMAGE=null,er.DEFAULT_MAPPING=re,er.DEFAULT_ANISOTROPY=1;class tr{constructor(e=0,t=0,i=0,r=1){tr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){var t=this.x,i=this.y,r=this.z,n=this.w;return e=e.elements,this.x=e[0]*t+e[4]*i+e[8]*r+e[12]*n,this.y=e[1]*t+e[5]*i+e[9]*r+e[13]*n,this.z=e[2]*t+e[6]*i+e[10]*r+e[14]*n,this.w=e[3]*t+e[7]*i+e[11]*r+e[15]*n,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r,n;var a,s,o,l,h,c,u=(e=e.elements)[0],d=e[4],p=e[8],m=e[1],f=e[5],g=e[9],v=e[2],_=e[6];if(e=e[10],Math.abs(d-m)<.01&&Math.abs(p-v)<.01&&Math.abs(g-_)<.01)Math.abs(d+m)<.1&&Math.abs(p+v)<.1&&Math.abs(g+_)<.1&&Math.abs(u+f+e-3)<.1?this.set(1,0,0,0):(t=Math.PI,o=(e+1)/2,l=(d+m)/4,h=(p+v)/4,c=(g+_)/4,(s=(f+1)/2)<(a=(u+1)/2)&&o<a?n=a<.01?(i=0,r=.707106781):(i=Math.sqrt(a),r=l/i,h/i):o<s?n=s<.01?(i=.707106781,r=0,.707106781):(r=Math.sqrt(s),i=l/r,c/r):o<.01?(i=.707106781,r=.707106781,n=0):(n=Math.sqrt(o),i=h/n,r=c/n),this.set(i,r,n,t));else{let t=Math.sqrt((_-g)*(_-g)+(p-v)*(p-v)+(m-d)*(m-d));Math.abs(t)<.001&&(t=1),this.x=(_-g)/t,this.y=(p-v)/t,this.z=(m-d)/t,this.w=Math.acos((u+f+e-1)/2)}return this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ir extends _i{constructor(e=1,t=1,i={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new tr(0,0,e,t),this.scissorTest=!1,this.viewport=new tr(0,0,e,t),e={width:e,height:t,depth:1},void 0!==i.encoding&&(Hi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=i.encoding===Nt?Ht:Gt),this.texture=new er(e,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:ve,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(e,t,i=1){this.width===e&&this.height===t&&this.depth===i||(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;var t=Object.assign({},e.texture.image);return this.texture.source=new Ki(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class rr extends er{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=de,this.minFilter=de,this.wrapR=ce,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class nr extends ir{constructor(e=1,t=1,i=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=i,this.texture=new rr(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class ar extends er{constructor(e=null,t=1,i=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=de,this.minFilter=de,this.wrapR=ce,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class sr extends ir{constructor(e=1,t=1,i=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=i,this.texture=new ar(null,e,t,i),this.texture.isRenderTargetTexture=!0}}class or extends ir{constructor(e=1,t=1,i=1,r={}){super(e,t,r),this.isWebGLMultipleRenderTargets=!0;var n=this.texture;this.texture=[];for(let e=0;e<i;e++)this.texture[e]=n.clone(),this.texture[e].isRenderTargetTexture=!0}setSize(e,t,i=1){if(this.width!==e||this.height!==t||this.depth!==i){this.width=e,this.height=t,this.depth=i;for(let r=0,n=this.texture.length;r<n;r++)this.texture[r].image.width=e,this.texture[r].image.height=t,this.texture[r].image.depth=i;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone());for(let t=this.texture.length=0,i=e.texture.length;t<i;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class lr{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,n,a,s){let o=i[r+0],l=i[r+1],h=i[r+2],c=i[r+3];i=n[a+0],r=n[a+1];var u=n[a+2];if(n=n[a+3],0===s)e[t+0]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c;else if(1===s)e[t+0]=i,e[t+1]=r,e[t+2]=u,e[t+3]=n;else{if(c!==n||o!==i||l!==r||h!==u){let e=1-s;var d=0<=(a=o*i+l*r+h*u+c*n)?1:-1,p=1-a*a;p>Number.EPSILON&&(p=Math.sqrt(p),a=Math.atan2(p,a*d),e=Math.sin(e*a)/p,s=Math.sin(s*a)/p),o=o*e+i*(a=s*d),l=l*e+r*a,h=h*e+u*a,c=c*e+n*a,e===1-s&&(o*=p=1/Math.sqrt(o*o+l*l+h*h+c*c),l*=p,h*=p,c*=p)}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}}static multiplyQuaternionsFlat(e,t,i,r,n,a){var s=i[r],o=i[r+1],l=i[r+2],h=(i=i[r+3],r=n[a],n[a+1]),c=n[a+2];return n=n[a+3],e[t]=s*n+i*r+o*c-l*h,e[t+1]=o*n+i*h+l*r-s*c,e[t+2]=l*n+i*c+s*h-o*r,e[t+3]=i*n-s*r-o*h-l*c,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){var i=e._x,r=e._y,n=e._z,a=e._order,s=(e=Math.cos,Math.sin),o=e(i/2),l=e(r/2),h=e(n/2),c=s(i/2),u=s(r/2),d=s(n/2);switch(a){case"XYZ":this._x=c*l*h+o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h-c*u*d;break;case"YXZ":this._x=c*l*h+o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h+c*u*d;break;case"ZXY":this._x=c*l*h-o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h-c*u*d;break;case"ZYX":this._x=c*l*h-o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h+c*u*d;break;case"YZX":this._x=c*l*h+o*u*d,this._y=o*u*h+c*l*d,this._z=o*l*d-c*u*h,this._w=o*l*h-c*u*d;break;case"XZY":this._x=c*l*h-o*u*d,this._y=o*u*h-c*l*d,this._z=o*l*d+c*u*h,this._w=o*l*h+c*u*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){t/=2;var i=Math.sin(t);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(t),this._onChangeCallback(),this}setFromRotationMatrix(e){var t=(e=e.elements)[0],i=e[4],r=e[8],n=e[1],a=e[5],s=e[9],o=e[2],l=e[6],h=t+a+(e=e[10]);return 0<h?(h=.5/Math.sqrt(h+1),this._w=.25/h,this._x=(l-s)*h,this._y=(r-o)*h,this._z=(n-i)*h):a<t&&e<t?(h=2*Math.sqrt(1+t-a-e),this._w=(l-s)/h,this._x=.25*h,this._y=(i+n)/h,this._z=(r+o)/h):e<a?(h=2*Math.sqrt(1+a-t-e),this._w=(r-o)/h,this._x=(i+n)/h,this._y=.25*h,this._z=(s+l)/h):(h=2*Math.sqrt(1+e-t-a),this._w=(n-i)/h,this._x=(r+o)/h,this._y=(s+l)/h,this._z=.25*h),this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=i,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ei(this.dot(e),-1,1)))}rotateTowards(e,t){var i=this.angleTo(e);return 0!==i&&(t=Math.min(1,t/i),this.slerp(e,t)),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(this._x=this._x*(e=1/e),this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){var i=e._x,r=e._y,n=e._z,a=(e=e._w,t._x),s=t._y,o=t._z;return t=t._w,this._x=i*t+e*a+r*o-n*s,this._y=r*t+e*s+n*a-i*o,this._z=n*t+e*o+i*s-r*a,this._w=e*t-i*a-r*s-n*o,this._onChangeCallback(),this}slerp(e,t){if(0!==t){if(1===t)return this.copy(e);var i,r,n=this._x,a=this._y,s=this._z,o=this._w;let l=o*e._w+n*e._x+a*e._y+s*e._z;l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),1<=l?(this._w=o,this._x=n,this._y=a,this._z=s):((e=1-l*l)<=Number.EPSILON?(this._w=(i=1-t)*o+t*this._w,this._x=i*n+t*this._x,this._y=i*a+t*this._y,this._z=i*s+t*this._z,this.normalize()):(i=Math.sqrt(e),e=Math.atan2(i,l),r=Math.sin((1-t)*e)/i,t=Math.sin(t*e)/i,this._w=o*r+this._w*t,this._x=n*r+this._x*t,this._y=a*r+this._y*t,this._z=s*r+this._z*t),this._onChangeCallback())}return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){var e=Math.random(),t=Math.sqrt(1-e),i=(e=Math.sqrt(e),2*Math.PI*Math.random()),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),e*Math.sin(r),e*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class hr{constructor(e=0,t=0,i=0){hr.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ur.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ur.setFromAxisAngle(e,t))}applyMatrix3(e){var t=this.x,i=this.y,r=this.z;return e=e.elements,this.x=e[0]*t+e[3]*i+e[6]*r,this.y=e[1]*t+e[4]*i+e[7]*r,this.z=e[2]*t+e[5]*i+e[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){var t=this.x,i=this.y,r=this.z,n=1/((e=e.elements)[3]*t+e[7]*i+e[11]*r+e[15]);return this.x=(e[0]*t+e[4]*i+e[8]*r+e[12])*n,this.y=(e[1]*t+e[5]*i+e[9]*r+e[13])*n,this.z=(e[2]*t+e[6]*i+e[10]*r+e[14])*n,this}applyQuaternion(e){var t=this.x,i=this.y,r=this.z,n=e.x,a=e.y,s=e.z,o=(e=e.w)*t+a*r-s*i,l=e*i+s*t-n*r,h=e*r+n*i-a*t;return t=-n*t-a*i-s*r,this.x=o*e+t*-n+l*-s-h*-a,this.y=l*e+t*-a+h*-n-o*-s,this.z=h*e+t*-s+o*-a-l*-n,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){var t=this.x,i=this.y,r=this.z;return e=e.elements,this.x=e[0]*t+e[4]*i+e[8]*r,this.y=e[1]*t+e[5]*i+e[9]*r,this.z=e[2]*t+e[6]*i+e[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){var i=e.x,r=e.y,n=(e=e.z,t.x),a=t.y;return t=t.z,this.x=r*t-e*a,this.y=e*n-i*t,this.z=i*a-r*n,this}projectOnVector(e){var t=e.lengthSq();return 0===t?this.set(0,0,0):(t=e.dot(this)/t,this.copy(e).multiplyScalar(t))}projectOnPlane(e){return cr.copy(this).projectOnVector(e),this.sub(cr)}reflect(e){return this.sub(cr.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:(e=this.dot(e)/t,Math.acos(Ei(e,-1,1)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){var t=this.x-e.x,i=this.y-e.y;return t*t+i*i+(e=this.z-e.z)*e}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){var r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){return e=e.elements,this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length();return e=this.setFromMatrixColumn(e,2).length(),this.x=t,this.y=i,this.z=e,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const cr=new hr,ur=new lr;class dr{constructor(e=new hr(1/0,1/0,1/0),t=new hr(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(mr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,i=e.count;t<i;t++)this.expandByPoint(mr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){return t=mr.copy(t).multiplyScalar(.5),this.min.copy(e).sub(t),this.max.copy(e).add(t),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),fr.copy(e.boundingBox),fr.applyMatrix4(e.matrixWorld),this.union(fr);else{var i=e.geometry;if(void 0!==i)if(t&&void 0!==i.attributes&&void 0!==i.attributes.position){var r=i.attributes.position;for(let t=0,i=r.count;t<i;t++)mr.fromBufferAttribute(r,t).applyMatrix4(e.matrixWorld),this.expandByPoint(mr)}else null===i.boundingBox&&i.computeBoundingBox(),fr.copy(i.boundingBox),fr.applyMatrix4(e.matrixWorld),this.union(fr)}var n=e.children;for(let e=0,i=n.length;e<i;e++)this.expandByObject(n[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,mr),mr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return i=0<e.normal.x?(t=e.normal.x*this.min.x,e.normal.x*this.max.x):(t=e.normal.x*this.max.x,e.normal.x*this.min.x),0<e.normal.y?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),0<e.normal.z?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){return!this.isEmpty()&&(this.getCenter(Sr),br.subVectors(this.max,Sr),gr.subVectors(e.a,Sr),vr.subVectors(e.b,Sr),_r.subVectors(e.c,Sr),xr.subVectors(vr,gr),yr.subVectors(_r,vr),Mr.subVectors(gr,_r),!!wr([0,-xr.z,xr.y,0,-yr.z,yr.y,0,-Mr.z,Mr.y,xr.z,0,-xr.x,yr.z,0,-yr.x,Mr.z,0,-Mr.x,-xr.y,xr.x,0,-yr.y,yr.x,0,-Mr.y,Mr.x,0],gr,vr,_r,br))&&!!wr([1,0,0,0,1,0,0,0,1],gr,vr,_r,br)&&(Er.crossVectors(xr,yr),wr([Er.x,Er.y,Er.z],gr,vr,_r,br))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(mr).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(pr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pr)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const pr=[new hr,new hr,new hr,new hr,new hr,new hr,new hr,new hr],mr=new hr,fr=new dr,gr=new hr,vr=new hr,_r=new hr,xr=new hr,yr=new hr,Mr=new hr,Sr=new hr,br=new hr,Er=new hr,Tr=new hr;function wr(e,t,i,r,n){for(let h=0,c=e.length-3;h<=c;h+=3){Tr.fromArray(e,h);var a=n.x*Math.abs(Tr.x)+n.y*Math.abs(Tr.y)+n.z*Math.abs(Tr.z),s=t.dot(Tr),o=i.dot(Tr),l=r.dot(Tr);if(Math.max(-Math.max(s,o,l),Math.min(s,o,l))>a)return!1}return!0}const Ar=new dr,Rr=new hr,Cr=new hr;class Lr{constructor(e=new hr,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){var i=this.center;void 0!==t?i.copy(t):Ar.setFromPoints(e).getCenter(i);let r=0;for(let t=0,n=e.length;t<n;t++)r=Math.max(r,i.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){var t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){var i=this.center.distanceToSquared(e);return t.copy(e),i>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){var t;return this.isEmpty()?(this.center.copy(e),this.radius=0):(Rr.subVectors(e,this.center),(e=Rr.lengthSq())>this.radius*this.radius&&(t=.5*((e=Math.sqrt(e))-this.radius),this.center.addScaledVector(Rr,t/e),this.radius+=t)),this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Cr.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Rr.copy(e.center).add(Cr)),this.expandByPoint(Rr.copy(e.center).sub(Cr)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Pr=new hr,Ir=new hr,Ur=new hr,Dr=new hr,Nr=new hr,Or=new hr,Fr=new hr;class Br{constructor(e=new hr,t=new hr(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Pr)),this}closestPointToPoint(e,t){return t.subVectors(e,this.origin),(e=t.dot(this.direction))<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,e)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){var t=Pr.subVectors(e,this.origin).dot(this.direction);return(t<0?this.origin:(Pr.copy(this.origin).addScaledVector(this.direction,t),Pr)).distanceToSquared(e)}distanceSqToSegment(e,t,i,r){Ir.copy(e).add(t).multiplyScalar(.5),Ur.copy(t).sub(e).normalize(),Dr.copy(this.origin).sub(Ir),e=.5*e.distanceTo(t),t=-this.direction.dot(Ur);var n=Dr.dot(this.direction),a=-Dr.dot(Ur),s=Dr.lengthSq(),o=Math.abs(1-t*t);let l,h,c,u;return c=0<o?(l=t*a-n,h=t*n-a,u=e*o,0<=l?h>=-u?h<=u?(l*=o=1/o,h*=o,l*(l+t*h+2*n)+h*(t*l+h+2*a)+s):(h=e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s):(h=-e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s):h<=-u?(l=Math.max(0,-(-t*e+n)),h=0<l?-e:Math.min(Math.max(-e,-a),e),-l*l+h*(h+2*a)+s):h<=u?(l=0,(h=Math.min(Math.max(-e,-a),e))*(h+2*a)+s):(l=Math.max(0,-(t*e+n)),h=0<l?e:Math.min(Math.max(-e,-a),e),-l*l+h*(h+2*a)+s)):(h=0<t?-e:e,-(l=Math.max(0,-(t*h+n)))*l+h*(h+2*a)+s),i&&i.copy(this.origin).addScaledVector(this.direction,l),r&&r.copy(Ir).addScaledVector(Ur,h),c}intersectSphere(e,t){Pr.subVectors(e.center,this.origin);var i=Pr.dot(this.direction),r=Pr.dot(Pr)-i*i;return(e=e.radius*e.radius)<r||(r=i-(e=Math.sqrt(e-r)),(i+=e)<0)?null:r<0?this.at(i,t):this.at(r,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){var t=e.normal.dot(this.direction);return 0===t?0===e.distanceToPoint(this.origin)?0:null:0<=(e=-(this.origin.dot(e.normal)+e.constant)/t)?e:null}intersectPlane(e,t){return null===(e=this.distanceToPlane(e))?null:this.at(e,t)}intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,r,n,a,s,o;var l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return r=0<=l?(i=(e.min.x-u.x)*l,(e.max.x-u.x)*l):(i=(e.max.x-u.x)*l,(e.min.x-u.x)*l),a=0<=h?(n=(e.min.y-u.y)*h,(e.max.y-u.y)*h):(n=(e.max.y-u.y)*h,(e.min.y-u.y)*h),i>a||n>r||((n>i||isNaN(i))&&(i=n),(a<r||isNaN(r))&&(r=a),o=0<=c?(s=(e.min.z-u.z)*c,(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,(e.min.z-u.z)*c),i>o)||s>r||((s>i||i!=i)&&(i=s),(r=o<r||r!=r?o:r)<0)?null:this.at(0<=i?i:r,t)}intersectsBox(e){return null!==this.intersectBox(e,Pr)}intersectTriangle(e,t,i,r,n){Nr.subVectors(t,e),Or.subVectors(i,e),Fr.crossVectors(Nr,Or);let a,s=this.direction.dot(Fr);if(0<s){if(r)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}return Dr.subVectors(this.origin,e),(t=a*this.direction.dot(Or.crossVectors(Dr,Or)))<0||(i=a*this.direction.dot(Nr.cross(Dr)))<0||t+i>s||(r=-a*Dr.dot(Fr))<0?null:this.at(r/s,n)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class zr{constructor(){zr.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,i,r,n,a,s,o,l,h,c,u,d,p,m,f){var g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=n,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new zr).fromArray(this.elements)}copy(e){var t=this.elements;return e=e.elements,t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],this}copyPosition(e){var t=this.elements;return e=e.elements,t[12]=e[12],t[13]=e[13],t[14]=e[14],this}setFromMatrix3(e){return e=e.elements,this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){var t=this.elements,i=e.elements,r=1/Gr.setFromMatrixColumn(e,0).length(),n=1/Gr.setFromMatrixColumn(e,1).length();return e=1/Gr.setFromMatrixColumn(e,2).length(),t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*n,t[5]=i[5]*n,t[6]=i[6]*n,t[7]=0,t[8]=i[8]*e,t[9]=i[9]*e,t[10]=i[10]*e,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){var t,i,r,n,a=this.elements,s=e.x,o=e.y,l=e.z,h=Math.cos(s),c=(s=Math.sin(s),Math.cos(o)),u=(o=Math.sin(o),Math.cos(l));return l=Math.sin(l),"XYZ"===e.order?(i=h*u,r=h*l,n=s*u,t=s*l,a[0]=c*u,a[4]=-c*l,a[8]=o,a[1]=r+n*o,a[5]=i-t*o,a[9]=-s*c,a[2]=t-i*o,a[6]=n+r*o,a[10]=h*c):"YXZ"===e.order?(t=c*l,i=o*u,a[0]=(n=c*u)+(r=o*l)*s,a[4]=i*s-t,a[8]=h*o,a[1]=h*l,a[5]=h*u,a[9]=-s,a[2]=t*s-i,a[6]=r+n*s,a[10]=h*c):"ZXY"===e.order?(t=c*l,i=o*u,a[0]=(r=c*u)-(n=o*l)*s,a[4]=-h*l,a[8]=i+t*s,a[1]=t+i*s,a[5]=h*u,a[9]=n-r*s,a[2]=-h*o,a[6]=s,a[10]=h*c):"ZYX"===e.order?(t=h*u,i=h*l,n=s*u,r=s*l,a[0]=c*u,a[4]=n*o-i,a[8]=t*o+r,a[1]=c*l,a[5]=r*o+t,a[9]=i*o-n,a[2]=-o,a[6]=s*c,a[10]=h*c):"YZX"===e.order?(r=h*c,t=h*o,i=s*c,n=s*o,a[0]=c*u,a[4]=n-r*l,a[8]=i*l+t,a[1]=l,a[5]=h*u,a[9]=-s*u,a[2]=-o*u,a[6]=t*l+i,a[10]=r-n*l):"XZY"===e.order&&(t=h*c,i=h*o,r=s*c,n=s*o,a[0]=c*u,a[4]=-l,a[8]=o*u,a[1]=t*l+n,a[5]=h*u,a[9]=i*l-r,a[2]=r*l-i,a[6]=s*u,a[10]=n*l+t),a[3]=0,a[7]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,this}makeRotationFromQuaternion(e){return this.compose(kr,e,Vr)}lookAt(e,t,i){var r=this.elements;return jr.subVectors(e,t),0===jr.lengthSq()&&(jr.z=1),jr.normalize(),Wr.crossVectors(i,jr),0===Wr.lengthSq()&&(1===Math.abs(i.z)?jr.x+=1e-4:jr.z+=1e-4,jr.normalize(),Wr.crossVectors(i,jr)),Wr.normalize(),Xr.crossVectors(jr,Wr),r[0]=Wr.x,r[4]=Xr.x,r[8]=jr.x,r[1]=Wr.y,r[5]=Xr.y,r[9]=jr.y,r[2]=Wr.z,r[6]=Xr.z,r[10]=jr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){e=e.elements,t=t.elements;var i=this.elements,r=e[0],n=e[4],a=e[8],s=e[12],o=e[1],l=e[5],h=e[9],c=e[13],u=e[2],d=e[6],p=e[10],m=e[14],f=e[3],g=e[7],v=e[11],_=(e=e[15],t[0]),x=t[4],y=t[8],M=t[12],S=t[1],b=t[5],E=t[9],T=t[13],w=t[2],A=t[6],R=t[10],C=t[14],L=t[3],P=t[7],I=t[11];return t=t[15],i[0]=r*_+n*S+a*w+s*L,i[4]=r*x+n*b+a*A+s*P,i[8]=r*y+n*E+a*R+s*I,i[12]=r*M+n*T+a*C+s*t,i[1]=o*_+l*S+h*w+c*L,i[5]=o*x+l*b+h*A+c*P,i[9]=o*y+l*E+h*R+c*I,i[13]=o*M+l*T+h*C+c*t,i[2]=u*_+d*S+p*w+m*L,i[6]=u*x+d*b+p*A+m*P,i[10]=u*y+d*E+p*R+m*I,i[14]=u*M+d*T+p*C+m*t,i[3]=f*_+g*S+v*w+e*L,i[7]=f*x+g*b+v*A+e*P,i[11]=f*y+g*E+v*R+e*I,i[15]=f*M+g*T+v*C+e*t,this}multiplyScalar(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){var e=this.elements,t=e[0],i=e[4],r=e[8],n=e[12],a=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+n*o*c-r*l*c-n*s*u+i*l*u+r*s*d-i*o*d)+e[7]*(+t*o*d-t*l*u+n*a*u-r*a*d+r*l*h-n*o*h)+e[11]*(+t*l*c-t*s*d-n*a*c+i*a*d+n*s*h-i*l*h)+e[15]*(-r*s*h-t*o*c+t*s*u+r*a*c-i*a*u+i*o*h)}transpose(){var e=this.elements,t=e[1];return e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){var r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){var e=this.elements,t=e[0],i=e[1],r=e[2],n=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=c*f*l-m*u*l+m*o*d-s*f*d-c*o*g+s*u*g,_=p*u*l-h*f*l-p*o*d+a*f*d+h*o*g-a*u*g,x=h*m*l-p*c*l+p*s*d-a*m*d-h*s*g+a*c*g,y=p*c*o-h*m*o-p*s*u+a*m*u+h*s*f-a*c*f,M=t*v+i*_+r*x+n*y;return 0==M?this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0):(e[0]=v*(v=1/M),e[1]=(m*u*n-c*f*n-m*r*d+i*f*d+c*r*g-i*u*g)*v,e[2]=(s*f*n-m*o*n+m*r*l-i*f*l-s*r*g+i*o*g)*v,e[3]=(c*o*n-s*u*n-c*r*l+i*u*l+s*r*d-i*o*d)*v,e[4]=_*v,e[5]=(h*f*n-p*u*n+p*r*d-t*f*d-h*r*g+t*u*g)*v,e[6]=(p*o*n-a*f*n-p*r*l+t*f*l+a*r*g-t*o*g)*v,e[7]=(a*u*n-h*o*n+h*r*l-t*u*l-a*r*d+t*o*d)*v,e[8]=x*v,e[9]=(p*c*n-h*m*n-p*i*d+t*m*d+h*i*g-t*c*g)*v,e[10]=(a*m*n-p*s*n+p*i*l-t*m*l-a*i*g+t*s*g)*v,e[11]=(h*s*n-a*c*n-h*i*l+t*c*l+a*i*d-t*s*d)*v,e[12]=y*v,e[13]=(h*m*r-p*c*r+p*i*u-t*m*u-h*i*f+t*c*f)*v,e[14]=(p*s*r-a*m*r-p*i*o+t*m*o+a*i*f-t*s*f)*v,e[15]=(a*c*r-h*s*r+h*i*o-t*c*o-a*i*u+t*s*u)*v,this)}scale(e){var t=this.elements,i=e.x,r=e.y;return e=e.z,t[0]*=i,t[4]*=r,t[8]*=e,t[1]*=i,t[5]*=r,t[9]*=e,t[2]*=i,t[6]*=r,t[10]*=e,t[3]*=i,t[7]*=r,t[11]*=e,this}getMaxScaleOnAxis(){var e=(i=this.elements)[0]*i[0]+i[1]*i[1]+i[2]*i[2],t=i[4]*i[4]+i[5]*i[5]+i[6]*i[6],i=i[8]*i[8]+i[9]*i[9]+i[10]*i[10];return Math.sqrt(Math.max(e,t,i))}makeTranslation(e,t,i){return this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){var t=Math.cos(e);return e=Math.sin(e),this.set(1,0,0,0,0,t,-e,0,0,e,t,0,0,0,0,1),this}makeRotationY(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,0,e,0,0,1,0,0,-e,0,t,0,0,0,0,1),this}makeRotationZ(e){var t=Math.cos(e);return e=Math.sin(e),this.set(t,-e,0,0,e,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){var i=Math.cos(t),r=(t=Math.sin(t),1-i),n=e.x,a=e.y,s=(e=e.z,r*n),o=r*a;return this.set(s*n+i,s*a-t*e,s*e+t*a,0,s*a+t*e,o*a+i,o*e-t*n,0,s*e-t*a,o*e+t*n,r*e*e+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,n,a){return this.set(1,i,n,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){var r=this.elements,n=(s=t._x)*(c=s+s),a=s*(u=(l=t._y)+l),s=s*(d=(h=t._z)+h),o=l*u,l=l*d,h=h*d,c=(t=t._w)*c,u=t*u,d=(t*=d,i.x),p=i.y;return i=i.z,r[0]=(1-(o+h))*d,r[1]=(a+t)*d,r[2]=(s-u)*d,r[3]=0,r[4]=(a-t)*p,r[5]=(1-(n+h))*p,r[6]=(l+c)*p,r[7]=0,r[8]=(s+u)*i,r[9]=(l-c)*i,r[10]=(1-(n+o))*i,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){var r=this.elements;let n=Gr.set(r[0],r[1],r[2]).length();var a=Gr.set(r[4],r[5],r[6]).length(),s=Gr.set(r[8],r[9],r[10]).length(),o=(this.determinant()<0&&(n=-n),e.x=r[12],e.y=r[13],e.z=r[14],Hr.copy(this),e=1/n,r=1/a,1/s);return Hr.elements[0]*=e,Hr.elements[1]*=e,Hr.elements[2]*=e,Hr.elements[4]*=r,Hr.elements[5]*=r,Hr.elements[6]*=r,Hr.elements[8]*=o,Hr.elements[9]*=o,Hr.elements[10]*=o,t.setFromRotationMatrix(Hr),i.x=n,i.y=a,i.z=s,this}makePerspective(e,t,i,r,n,a){var s=this.elements,o=2*n/(i-r),l=(t+e)/(t-e);return i=(i+r)/(i-r),r=-(a+n)/(a-n),a=-2*a*n/(a-n),s[0]=2*n/(t-e),s[4]=0,s[8]=l,s[12]=0,s[1]=0,s[5]=o,s[9]=i,s[13]=0,s[2]=0,s[6]=0,s[10]=r,s[14]=a,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,i,r,n,a){var s=this.elements,o=1/(t-e),l=1/(i-r),h=1/(a-n);return t=(t+e)*o,e=(i+r)*l,i=(a+n)*h,s[0]=2*o,s[4]=0,s[8]=0,s[12]=-t,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-e,s[2]=0,s[6]=0,s[10]=-2*h,s[14]=-i,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){var t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){var i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}const Gr=new hr,Hr=new zr,kr=new hr(0,0,0),Vr=new hr(1,1,1),Wr=new hr,Xr=new hr,jr=new hr,qr=new zr,Yr=new lr;class Zr{constructor(e=0,t=0,i=0,r=Zr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){var r=(e=e.elements)[0],n=e[4],a=e[8],s=e[1],o=e[5],l=e[9],h=e[2],c=e[6],u=e[10];switch(t){case"XYZ":this._y=Math.asin(Ei(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,u),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(c,o),this._z=0);break;case"YXZ":this._x=Math.asin(-Ei(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,u),this._z=Math.atan2(s,o)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ei(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-n,o)):(this._y=0,this._z=Math.atan2(s,r));break;case"ZYX":this._y=Math.asin(-Ei(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(c,u),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-n,o));break;case"YZX":this._z=Math.asin(Ei(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,o),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,u));break;case"XZY":this._z=Math.asin(-Ei(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(c,o),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return qr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(qr,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Yr.setFromEuler(this),this.setFromQuaternion(Yr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Zr.DEFAULT_ORDER="XYZ";class Jr{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}isEnabled(e){return!!(this.mask&1<<e)}}let Kr=0;const Qr=new hr,$r=new lr,en=new zr,tn=new hr,rn=new hr,nn=new hr,an=new lr,sn=new hr(1,0,0),on=new hr(0,1,0),ln=new hr(0,0,1),hn={type:"added"},cn={type:"removed"};class un extends _i{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Kr++}),this.uuid=bi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=un.DEFAULT_UP.clone();var e=new hr;const t=new Zr,i=new lr;var r=new hr(1,1,1);t._onChange(function(){i.setFromEuler(t,!1)}),i._onChange(function(){t.setFromQuaternion(i,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new zr},normalMatrix:{value:new Di}}),this.matrix=new zr,this.matrixWorld=new zr,this.matrixAutoUpdate=un.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=un.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Jr,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return $r.setFromAxisAngle(e,t),this.quaternion.multiply($r),this}rotateOnWorldAxis(e,t){return $r.setFromAxisAngle(e,t),this.quaternion.premultiply($r),this}rotateX(e){return this.rotateOnAxis(sn,e)}rotateY(e){return this.rotateOnAxis(on,e)}rotateZ(e){return this.rotateOnAxis(ln,e)}translateOnAxis(e,t){return Qr.copy(e).applyQuaternion(this.quaternion),this.position.add(Qr.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(sn,e)}translateY(e){return this.translateOnAxis(on,e)}translateZ(e){return this.translateOnAxis(ln,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(en.copy(this.matrixWorld).invert())}lookAt(e,t,i){e.isVector3?tn.copy(e):tn.set(e,t,i),e=this.parent,this.updateWorldMatrix(!0,!1),rn.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?en.lookAt(rn,tn,this.up):en.lookAt(tn,rn,this.up),this.quaternion.setFromRotationMatrix(en),e&&(en.extractRotation(e.matrixWorld),$r.setFromRotationMatrix(en),this.quaternion.premultiply($r.invert()))}add(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.add(arguments[e]);else e===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",e):e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),(e.parent=this).children.push(e),e.dispatchEvent(hn)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e);return this}remove(e){if(1<arguments.length)for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);else{var t=this.children.indexOf(e);-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(cn))}return this}removeFromParent(){var e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){var e=this.children[t];e.parent=null,e.dispatchEvent(cn)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),en.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),en.multiply(e.parent.matrixWorld)),e.applyMatrix4(en),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let r=0,n=this.children.length;r<n;r++){var i=this.children[r].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t){let i=[];this[e]===t&&i.push(this);for(let n=0,a=this.children.length;n<a;n++){var r=this.children[n].getObjectsByProperty(e,t);0<r.length&&(i=i.concat(r))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(rn,e,nn),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(rn,an,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);var t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverse(e)}traverseVisible(e){if(!1!==this.visible){e(this);var t=this.children;for(let i=0,r=t.length;i<r;i++)t[i].traverseVisible(e)}}traverseAncestors(e){var t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e=!(this.matrixWorldNeedsUpdate=!1));var t=this.children;for(let r=0,n=t.length;r<n;r++){var i=t[r];!0!==i.matrixWorldAutoUpdate&&!0!==e||i.updateMatrixWorld(e)}}updateWorldMatrix(e,t){var i=this.parent;if(!0===e&&null!==i&&!0===i.matrixWorldAutoUpdate&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){var r=this.children;for(let e=0,t=r.length;e<t;e++){var n=r[e];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){var t,i,r,n,a,s,o=void 0===e||"string"==typeof e,l={},h=(o&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},l.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"}),{});function c(t,i){return void 0===t[i.uuid]&&(t[i.uuid]=i.toJSON(e)),i.uuid}if(h.uuid=this.uuid,h.type=this.type,""!==this.name&&(h.name=this.name),!0===this.castShadow&&(h.castShadow=!0),!0===this.receiveShadow&&(h.receiveShadow=!0),!1===this.visible&&(h.visible=!1),!1===this.frustumCulled&&(h.frustumCulled=!1),0!==this.renderOrder&&(h.renderOrder=this.renderOrder),0<Object.keys(this.userData).length&&(h.userData=this.userData),h.layers=this.layers.mask,h.matrix=this.matrix.toArray(),h.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(h.matrixAutoUpdate=!1),this.isInstancedMesh&&(h.type="InstancedMesh",h.count=this.count,h.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor)&&(h.instanceColor=this.instanceColor.toJSON()),this.isScene)this.background&&(this.background.isColor?h.background=this.background.toJSON():this.background.isTexture&&(h.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(h.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){h.geometry=c(e.geometries,this.geometry);var u=this.geometry.parameters;if(void 0!==u&&void 0!==u.shapes){var d=u.shapes;if(Array.isArray(d))for(let t=0,i=d.length;t<i;t++){var p=d[t];c(e.shapes,p)}else c(e.shapes,d)}}if(this.isSkinnedMesh&&(h.bindMode=this.bindMode,h.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton)&&(c(e.skeletons,this.skeleton),h.skeleton=this.skeleton.uuid),void 0!==this.material)if(Array.isArray(this.material)){var m=[];for(let t=0,i=this.material.length;t<i;t++)m.push(c(e.materials,this.material[t]));h.material=m}else h.material=c(e.materials,this.material);if(0<this.children.length){h.children=[];for(let t=0;t<this.children.length;t++)h.children.push(this.children[t].toJSON(e).object)}if(0<this.animations.length){h.animations=[];for(let t=0;t<this.animations.length;t++){var f=this.animations[t];h.animations.push(c(e.animations,f))}}return o&&(u=g(e.geometries),o=g(e.materials),t=g(e.textures),i=g(e.images),r=g(e.shapes),n=g(e.skeletons),a=g(e.animations),s=g(e.nodes),0<u.length&&(l.geometries=u),0<o.length&&(l.materials=o),0<t.length&&(l.textures=t),0<i.length&&(l.images=i),0<r.length&&(l.shapes=r),0<n.length&&(l.skeletons=n),0<a.length&&(l.animations=a),0<s.length)&&(l.nodes=s),l.object=h,l;function g(e){var t=[];for(const r in e){var i=e[r];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){var i=e.children[t];this.add(i.clone())}return this}}un.DEFAULT_UP=new hr(0,1,0),un.DEFAULT_MATRIX_AUTO_UPDATE=!0,un.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const dn=new hr,pn=new hr,mn=new hr,fn=new hr,gn=new hr,vn=new hr,_n=new hr,xn=new hr,yn=new hr,Mn=new hr;let Sn=!1;class bn{constructor(e=new hr,t=new hr,i=new hr){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,r){return r.subVectors(i,t),dn.subVectors(e,t),r.cross(dn),0<(i=r.lengthSq())?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,i,r,n){dn.subVectors(r,t),pn.subVectors(i,t),mn.subVectors(e,t),r=dn.dot(dn),i=dn.dot(pn),e=dn.dot(mn),t=pn.dot(pn);var a=pn.dot(mn),s=r*t-i*i;return 0==s?n.set(-2,-1,-1):n.set(1-(t=(t*e-i*a)*(n=1/s))-(s=(r*a-i*e)*n),s,t)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,fn),0<=fn.x&&0<=fn.y&&fn.x+fn.y<=1}static getUV(e,t,i,r,n,a,s,o){return!1===Sn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Sn=!0),this.getInterpolation(e,t,i,r,n,a,s,o)}static getInterpolation(e,t,i,r,n,a,s,o){return this.getBarycoord(e,t,i,r,fn),o.setScalar(0),o.addScaledVector(n,fn.x),o.addScaledVector(a,fn.y),o.addScaledVector(s,fn.z),o}static isFrontFacing(e,t,i,r){return dn.subVectors(i,t),pn.subVectors(e,t),dn.cross(pn).dot(r)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return dn.subVectors(this.c,this.b),pn.subVectors(this.a,this.b),.5*dn.cross(pn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,n){return!1===Sn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),Sn=!0),bn.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}getInterpolation(e,t,i,r,n){return bn.getInterpolation(e,this.a,this.b,this.c,t,i,r,n)}containsPoint(e){return bn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){var i=this.a,r=this.b,n=this.c;let a,s;gn.subVectors(r,i),vn.subVectors(n,i),xn.subVectors(e,i);var o=gn.dot(xn),l=vn.dot(xn);if(o<=0&&l<=0)return t.copy(i);yn.subVectors(e,r);var h=gn.dot(yn),c=vn.dot(yn);if(0<=h&&c<=h)return t.copy(r);var u=o*c-h*l;if(u<=0&&0<=o&&h<=0)return a=o/(o-h),t.copy(i).addScaledVector(gn,a);Mn.subVectors(e,n),e=gn.dot(Mn);var d=vn.dot(Mn);return 0<=d&&e<=d?t.copy(n):(o=e*l-o*d)<=0&&0<=l&&d<=0?(s=l/(l-d),t.copy(i).addScaledVector(vn,s)):(l=h*d-e*c)<=0&&0<=c-h&&0<=e-d?(_n.subVectors(n,r),s=(c-h)/(c-h+(e-d)),t.copy(r).addScaledVector(_n,s)):(a=o*(n=1/(l+o+u)),s=u*n,t.copy(i).addScaledVector(gn,a).addScaledVector(vn,s))}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let En=0;class Tn extends _i{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:En++}),this.uuid=bi(),this.name="",this.type="Material",this.blending=x,this.side=m,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=U,this.blendDst=D,this.blendEquation=E,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=V,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ai,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xt,this.stencilZFail=Xt,this.stencilZPass=Xt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){0<this._alphaTest!=0<e&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const r in e){var t,i=e[r];void 0===i?console.warn(`THREE.Material: parameter '${r}' has value of undefined.`):void 0===(t=this[r])?console.warn(`THREE.Material: '${r}' is not a property of THREE.${this.type}.`):t&&t.isColor?t.set(i):t&&t.isVector3&&i&&i.isVector3?t.copy(i):this[r]=i}}toJSON(e){var t=void 0===e||"string"==typeof e,i=(t&&(e={textures:{},images:{}}),{metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}});function r(e){var t=[];for(const r in e){var i=e[r];delete i.metadata,t.push(i)}return t}return i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine)&&(i.combine=this.combine),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==x&&(i.blending=this.blending),this.side!==m&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),0<this.alphaTest&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),1<this.wireframeLinewidth&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),0<Object.keys(this.userData).length&&(i.userData=this.userData),t&&(t=r(e.textures),e=r(e.images),0<t.length&&(i.textures=t),0<e.length)&&(i.images=e),i}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes;let i=null;if(null!==t){var r=t.length;i=new Array(r);for(let e=0;e!==r;++e)i[e]=t[e].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const wn={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},An={h:0,s:0,l:0},Rn={h:0,s:0,l:0};function Cn(e,t,i){return i<0&&(i+=1),1<i&&--i,i<1/6?e+6*(t-e)*i:i<.5?t:i<2/3?e+6*(t-e)*(2/3-i):e}class Ln{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===i?this.set(e):this.setRGB(e,t,i)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ht){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Yi.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=Yi.workingColorSpace){return this.r=e,this.g=t,this.b=i,Yi.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=Yi.workingColorSpace){return e=Ti(e,1),t=Ei(t,0,1),i=Ei(i,0,1),0===t?this.r=this.g=this.b=i:(this.r=Cn(t=2*i-(i=i<=.5?i*(1+t):i+t-i*t),i,e+1/3),this.g=Cn(t,i,e),this.b=Cn(t,i,e-1/3)),Yi.toWorkingColorSpace(this,r),this}setStyle(e,t=Ht){function i(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(a=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;var r=a[1],n=a[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(n))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(a=/^\#([A-Fa-f\d]+)$/.exec(e)){var a=(r=a[1]).length;if(3===a)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(6===a)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&0<e.length)return this.setColorName(e,t);return this}setColorName(e,t=Ht){var i=wn[e.toLowerCase()];return void 0!==i?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ki(e.r),this.g=ki(e.g),this.b=ki(e.b),this}copyLinearToSRGB(e){return this.r=Vi(e.r),this.g=Vi(e.g),this.b=Vi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ht){return Yi.fromWorkingColorSpace(Pn.copy(this),e),65536*Math.round(Ei(255*Pn.r,0,255))+256*Math.round(Ei(255*Pn.g,0,255))+Math.round(Ei(255*Pn.b,0,255))}getHexString(e=Ht){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Yi.workingColorSpace){Yi.fromWorkingColorSpace(Pn.copy(this),t);var i=Pn.r,r=Pn.g,n=Pn.b,a=(t=Math.max(i,r,n),Math.min(i,r,n));let s,o;var l=(a+t)/2;if(a===t)s=0,o=0;else{var h=t-a;switch(o=l<=.5?h/(t+a):h/(2-t-a),t){case i:s=(r-n)/h+(r<n?6:0);break;case r:s=(n-i)/h+2;break;case n:s=(i-r)/h+4}s/=6}return e.h=s,e.s=o,e.l=l,e}getRGB(e,t=Yi.workingColorSpace){return Yi.fromWorkingColorSpace(Pn.copy(this),t),e.r=Pn.r,e.g=Pn.g,e.b=Pn.b,e}getStyle(e=Ht){Yi.fromWorkingColorSpace(Pn.copy(this),e);var t=Pn.r,i=Pn.g,r=Pn.b;return e!==Ht?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(255*t)},${Math.round(255*i)},${Math.round(255*r)})`}offsetHSL(e,t,i){return this.getHSL(An),An.h+=e,An.s+=t,An.l+=i,this.setHSL(An.h,An.s,An.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(An),e.getHSL(Rn),e=wi(An.h,Rn.h,t);var i=wi(An.s,Rn.s,t);return t=wi(An.l,Rn.l,t),this.setHSL(e,i,t),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){var t=this.r,i=this.g,r=this.b;return e=e.elements,this.r=e[0]*t+e[3]*i+e[6]*r,this.g=e[1]*t+e[4]*i+e[7]*r,this.b=e[2]*t+e[5]*i+e[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Pn=new Ln;Ln.NAMES=wn;class In extends Tn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ln(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Un=function(){var e=new ArrayBuffer(4),t=new Float32Array(e),i=(e=new Uint32Array(e),new Uint32Array(512)),r=new Uint32Array(512);for(let e=0;e<256;++e){var n=e-127;n<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):n<-14?(i[e]=1024>>-n-14,i[256|e]=1024>>-n-14|32768,r[e]=-n-1,r[256|e]=-n-1):n<=15?(i[e]=15+n<<10,i[256|e]=15+n<<10|32768,r[e]=13,r[256|e]=13):n<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}var a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;!(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,a[e]=t|i}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=1199570944,s[32]=2147483648;for(let e=33;e<63;++e)s[e]=2147483648+(e-32<<23);s[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}();function Dn(e){65504<Math.abs(e)&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Ei(e,-65504,65504),Un.floatView[0]=e;var t=(e=Un.uint32View[0])>>23&511;return Un.baseTable[t]+((8388607&e)>>Un.shiftTable[t])}function Nn(e){var t=e>>10;return Un.uint32View[0]=Un.mantissaTable[Un.offsetTable[t]+(1023&e)]+Un.exponentTable[t],Un.floatView[0]}const On={toHalfFloat:Dn,fromHalfFloat:Nn},Fn=new hr,Bn=new Ui;class zn{constructor(e,t,i=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=i,this.usage=si,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let r=0,n=this.itemSize;r<n;r++)this.array[e+r]=t.array[i+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,i=this.count;t<i;t++)Bn.fromBufferAttribute(this,t),Bn.applyMatrix3(e),this.setXY(t,Bn.x,Bn.y);else if(3===this.itemSize)for(let t=0,i=this.count;t<i;t++)Fn.fromBufferAttribute(this,t),Fn.applyMatrix3(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}applyMatrix4(e){for(let t=0,i=this.count;t<i;t++)Fn.fromBufferAttribute(this,t),Fn.applyMatrix4(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)Fn.fromBufferAttribute(this,t),Fn.applyNormalMatrix(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)Fn.fromBufferAttribute(this,t),Fn.transformDirection(e),this.setXYZ(t,Fn.x,Fn.y,Fn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized?Li(t,this.array):t}setX(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized?Li(t,this.array):t}setY(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized?Li(t,this.array):t}setZ(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized?Li(t,this.array):t}setW(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array)),this.array[e+0]=t,this.array[e+1]=i,this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array),n=Pi(n,this.array)),this.array[e+0]=t,this.array[e+1]=i,this.array[e+2]=r,this.array[e+3]=n,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){var e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==si&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class Gn extends zn{constructor(e,t,i){super(new Int8Array(e),t,i)}}class Hn extends zn{constructor(e,t,i){super(new Uint8Array(e),t,i)}}class kn extends zn{constructor(e,t,i){super(new Uint8ClampedArray(e),t,i)}}class Vn extends zn{constructor(e,t,i){super(new Int16Array(e),t,i)}}class Wn extends zn{constructor(e,t,i){super(new Uint16Array(e),t,i)}}class Xn extends zn{constructor(e,t,i){super(new Int32Array(e),t,i)}}class jn extends zn{constructor(e,t,i){super(new Uint32Array(e),t,i)}}class qn extends zn{constructor(e,t,i){super(new Uint16Array(e),t,i),this.isFloat16BufferAttribute=!0}getX(e){let t=Nn(this.array[e*this.itemSize]);return this.normalized?Li(t,this.array):t}setX(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize]=Dn(t),this}getY(e){let t=Nn(this.array[e*this.itemSize+1]);return this.normalized?Li(t,this.array):t}setY(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+1]=Dn(t),this}getZ(e){let t=Nn(this.array[e*this.itemSize+2]);return this.normalized?Li(t,this.array):t}setZ(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+2]=Dn(t),this}getW(e){let t=Nn(this.array[e*this.itemSize+3]);return this.normalized?Li(t,this.array):t}setW(e,t){return this.normalized&&(t=Pi(t,this.array)),this.array[e*this.itemSize+3]=Dn(t),this}setXY(e,t,i){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(i),this}setXYZ(e,t,i,r){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(i),this.array[e+2]=Dn(r),this}setXYZW(e,t,i,r,n){return e*=this.itemSize,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array),n=Pi(n,this.array)),this.array[e+0]=Dn(t),this.array[e+1]=Dn(i),this.array[e+2]=Dn(r),this.array[e+3]=Dn(n),this}}class Yn extends zn{constructor(e,t,i){super(new Float32Array(e),t,i)}}class Zn extends zn{constructor(e,t,i){super(new Float64Array(e),t,i)}}let Jn=0;const Kn=new zr,Qn=new un,$n=new hr,ea=new dr,ta=new dr,ia=new hr;class ra extends _i{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Jn++}),this.uuid=bi(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Oi(e)?jn:Wn)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){var t,i=(void 0!==(void 0!==(t=this.attributes.position)&&(t.applyMatrix4(e),t.needsUpdate=!0),t=this.attributes.normal)&&(i=(new Di).getNormalMatrix(e),t.applyNormalMatrix(i),t.needsUpdate=!0),this.attributes.tangent);return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Kn.makeRotationFromQuaternion(e),this.applyMatrix4(Kn),this}rotateX(e){return Kn.makeRotationX(e),this.applyMatrix4(Kn),this}rotateY(e){return Kn.makeRotationY(e),this.applyMatrix4(Kn),this}rotateZ(e){return Kn.makeRotationZ(e),this.applyMatrix4(Kn),this}translate(e,t,i){return Kn.makeTranslation(e,t,i),this.applyMatrix4(Kn),this}scale(e,t,i){return Kn.makeScale(e,t,i),this.applyMatrix4(Kn),this}lookAt(e){return Qn.lookAt(e),Qn.updateMatrix(),this.applyMatrix4(Qn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($n).negate(),this.translate($n.x,$n.y,$n.z),this}setFromPoints(e){var t=[];for(let r=0,n=e.length;r<n;r++){var i=e[r];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new Yn(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new dr);var e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new hr(-1/0,-1/0,-1/0),new hr(1/0,1/0,1/0));else{if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,r=t.length;e<r;e++){var i=t[e];ea.setFromBufferAttribute(i),this.morphTargetsRelative?(ia.addVectors(this.boundingBox.min,ea.min),this.boundingBox.expandByPoint(ia),ia.addVectors(this.boundingBox.max,ea.max),this.boundingBox.expandByPoint(ia)):(this.boundingBox.expandByPoint(ea.min),this.boundingBox.expandByPoint(ea.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Lr);var e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new hr,1/0);else if(e){var i=this.boundingSphere.center;if(ea.setFromBufferAttribute(e),t)for(let e=0,i=t.length;e<i;e++){var r=t[e];ta.setFromBufferAttribute(r),this.morphTargetsRelative?(ia.addVectors(ea.min,ta.min),ea.expandByPoint(ia),ia.addVectors(ea.max,ta.max),ea.expandByPoint(ia)):(ea.expandByPoint(ta.min),ea.expandByPoint(ta.max))}ea.getCenter(i);let s=0;for(let t=0,r=e.count;t<r;t++)ia.fromBufferAttribute(e,t),s=Math.max(s,i.distanceToSquared(ia));if(t)for(let r=0,o=t.length;r<o;r++){var n=t[r],a=this.morphTargetsRelative;for(let t=0,r=n.count;t<r;t++)ia.fromBufferAttribute(n,t),a&&($n.fromBufferAttribute(e,t),ia.add($n)),s=Math.max(s,i.distanceToSquared(ia))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){var e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");else{var i=e.array;const d=t.position.array,p=t.normal.array,m=t.uv.array;var r,n,a,s,o=d.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new zn(new Float32Array(4*o),4));const f=this.getAttribute("tangent").array,g=[],v=[];for(let I=0;I<o;I++)g[I]=new hr,v[I]=new hr;const _=new hr,x=new hr,y=new hr,M=new Ui,S=new Ui,b=new Ui,E=new hr,T=new hr;let w=this.groups;for(let U=0,D=(w=0===w.length?[{start:0,count:i.length}]:w).length;U<D;++U){var l=w[U],h=l.start;for(let N=h,O=h+l.count;N<O;N+=3)r=i[N+0],n=i[N+1],a=i[N+2],_.fromArray(d,3*r),x.fromArray(d,3*n),y.fromArray(d,3*a),M.fromArray(m,2*r),S.fromArray(m,2*n),b.fromArray(m,2*a),x.sub(_),y.sub(_),S.sub(M),b.sub(M),s=1/(S.x*b.y-b.x*S.y),isFinite(s)&&(E.copy(x).multiplyScalar(b.y).addScaledVector(y,-S.y).multiplyScalar(s),T.copy(y).multiplyScalar(S.x).addScaledVector(x,-b.x).multiplyScalar(s),g[r].add(E),g[n].add(E),g[a].add(E),v[r].add(T),v[n].add(T),v[a].add(T))}const A=new hr,R=new hr,C=new hr,L=new hr;for(let F=0,B=w.length;F<B;++F){var c=w[F],u=c.start;for(let z=u,G=u+c.count;z<G;z+=3)P(i[z+0]),P(i[z+1]),P(i[z+2])}function P(e){C.fromArray(p,3*e),L.copy(C);var t=g[e];A.copy(t),A.sub(C.multiplyScalar(C.dot(t))).normalize(),R.crossVectors(L,t),t=(t=R.dot(v[e]))<0?-1:1,f[4*e]=A.x,f[4*e+1]=A.y,f[4*e+2]=A.z,f[4*e+3]=t}}}computeVertexNormals(){var e=this.index,t=this.getAttribute("position");if(void 0!==t){let p=this.getAttribute("normal");if(void 0===p)p=new zn(new Float32Array(3*t.count),3),this.setAttribute("normal",p);else for(let e=0,t=p.count;e<t;e++)p.setXYZ(e,0,0,0);var i=new hr,r=new hr,n=new hr,a=new hr,s=new hr,o=new hr,l=new hr,h=new hr;if(e)for(let m=0,f=e.count;m<f;m+=3){var c=e.getX(m+0),u=e.getX(m+1),d=e.getX(m+2);i.fromBufferAttribute(t,c),r.fromBufferAttribute(t,u),n.fromBufferAttribute(t,d),l.subVectors(n,r),h.subVectors(i,r),l.cross(h),a.fromBufferAttribute(p,c),s.fromBufferAttribute(p,u),o.fromBufferAttribute(p,d),a.add(l),s.add(l),o.add(l),p.setXYZ(c,a.x,a.y,a.z),p.setXYZ(u,s.x,s.y,s.z),p.setXYZ(d,o.x,o.y,o.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),r.fromBufferAttribute(t,e+1),n.fromBufferAttribute(t,e+2),l.subVectors(n,r),h.subVectors(i,r),l.cross(h),p.setXYZ(e+0,l.x,l.y,l.z),p.setXYZ(e+1,l.x,l.y,l.z),p.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),p.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){var e=this.attributes.normal;for(let t=0,i=e.count;t<i;t++)ia.fromBufferAttribute(e,t),ia.normalize(),e.setXYZ(t,ia.x,ia.y,ia.z)}toNonIndexed(){function e(e,t){var i=e.array,r=e.itemSize,n=e.normalized,a=new i.constructor(t.length*r);let s=0,o=0;for(let n=0,l=t.length;n<l;n++){s=e.isInterleavedBufferAttribute?t[n]*e.data.stride+e.offset:t[n]*r;for(let e=0;e<r;e++)a[o++]=i[s++]}return new zn(a,r,n)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;var t=new ra,i=this.index.array,r=this.attributes;for(const a in r){var n=e(r[a],i);t.setAttribute(a,n)}var a=this.morphAttributes;for(const r in a){var s=[],o=a[r];for(let t=0,r=o.length;t<r;t++){var l=e(o[t],i);s.push(l)}t.morphAttributes[r]=s}t.morphTargetsRelative=this.morphTargetsRelative;var h=this.groups;for(let e=0,i=h.length;e<i;e++){var c=h[e];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){var e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),0<Object.keys(this.userData).length&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(const i in t)void 0!==t[i]&&(e[i]=t[i])}else{e.data={attributes:{}};var i=this.index,r=(null!==i&&(e.data.index={type:i.array.constructor.name,array:Array.prototype.slice.call(i.array)}),this.attributes);for(const t in r){var n=r[t];e.data.attributes[t]=n.toJSON(e.data)}var a={};let t=!1;for(const i in this.morphAttributes){var s=this.morphAttributes[i],o=[];for(let t=0,i=s.length;t<i;t++){var l=s[t];o.push(l.toJSON(e.data))}0<o.length&&(a[i]=o,t=!0)}t&&(e.data.morphAttributes=a,e.data.morphTargetsRelative=this.morphTargetsRelative),0<(i=this.groups).length&&(e.data.groups=JSON.parse(JSON.stringify(i))),null!==(i=this.boundingSphere)&&(e.data.boundingSphere={center:i.center.toArray(),radius:i.radius})}return e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var t={},i=(this.name=e.name,e.index),r=(null!==i&&this.setIndex(i.clone(t)),e.attributes);for(const e in r){var n=r[e];this.setAttribute(e,n.clone(t))}var a=e.morphAttributes;for(const e in a){var s=[],o=a[e];for(let e=0,i=o.length;e<i;e++)s.push(o[e].clone(t));this.morphAttributes[e]=s}this.morphTargetsRelative=e.morphTargetsRelative;var l=e.groups;for(let e=0,t=l.length;e<t;e++){var h=l[e];this.addGroup(h.start,h.count,h.materialIndex)}return null!==(i=e.boundingBox)&&(this.boundingBox=i.clone()),null!==(i=e.boundingSphere)&&(this.boundingSphere=i.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const na=new zr,aa=new Br,sa=new Lr,oa=new hr,la=new hr,ha=new hr,ca=new hr,ua=new hr,da=new hr,pa=new Ui,ma=new Ui,fa=new Ui,ga=new hr,va=new hr,_a=new hr,xa=new hr,ya=new hr;class Ma extends un{constructor(e=new ra,t=new In){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(0<t.length){var i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){var r=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=e}}}}getVertexPosition(e,t){var i=this.geometry,r=i.attributes.position,n=i.morphAttributes.position,a=i.morphTargetsRelative,s=(t.fromBufferAttribute(r,e),this.morphTargetInfluences);if(n&&s){da.set(0,0,0);for(let i=0,r=n.length;i<r;i++){var o=s[i],l=n[i];0!==o&&(ua.fromBufferAttribute(l,e),a?da.addScaledVector(ua,o):da.addScaledVector(ua.sub(t),o))}t.add(da)}return t}raycast(e,t){var i=this.geometry,r=this.material,n=this.matrixWorld;if(void 0!==r){if(null===i.boundingSphere&&i.computeBoundingSphere(),sa.copy(i.boundingSphere),sa.applyMatrix4(n),aa.copy(e.ray).recast(e.near),!1===sa.containsPoint(aa.origin)){if(null===aa.intersectSphere(sa,oa))return;if(aa.origin.distanceToSquared(oa)>(e.far-e.near)**2)return}na.copy(n).invert(),aa.copy(e.ray).applyMatrix4(na),null!==i.boundingBox&&!1===aa.intersectsBox(i.boundingBox)||this._computeIntersections(e,t)}}_computeIntersections(e,t){let i;var r=this.geometry,n=this.material,a=r.index,s=r.attributes.position,o=r.attributes.uv,l=r.attributes.uv1,h=r.attributes.normal,c=r.groups,u=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,s=c.length;r<s;r++){var d=c[r],p=n[d.materialIndex];for(let r=Math.max(d.start,u.start),n=Math.min(a.count,Math.min(d.start+d.count,u.start+u.count));r<n;r+=3){var m=a.getX(r),f=a.getX(r+1),g=a.getX(r+2);(i=Sa(this,p,e,aa,o,l,h,m,f,g))&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=d.materialIndex,t.push(i))}}else for(let r=Math.max(0,u.start),s=Math.min(a.count,u.start+u.count);r<s;r+=3){var v=a.getX(r),_=a.getX(r+1),x=a.getX(r+2);(i=Sa(this,n,e,aa,o,l,h,v,_,x))&&(i.faceIndex=Math.floor(r/3),t.push(i))}else if(void 0!==s)if(Array.isArray(n))for(let r=0,a=c.length;r<a;r++){var y=c[r],M=n[y.materialIndex];for(let r=Math.max(y.start,u.start),n=Math.min(s.count,Math.min(y.start+y.count,u.start+u.count));r<n;r+=3)(i=Sa(this,M,e,aa,o,l,h,r,r+1,r+2))&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=y.materialIndex,t.push(i))}else for(let r=Math.max(0,u.start),a=Math.min(s.count,u.start+u.count);r<a;r+=3)(i=Sa(this,n,e,aa,o,l,h,r,r+1,r+2))&&(i.faceIndex=Math.floor(r/3),t.push(i))}}function Sa(e,t,i,r,n,a,s,o,l,h){return e.getVertexPosition(o,la),e.getVertexPosition(l,ha),e.getVertexPosition(h,ca),e=function(e,t,i,r,n,a,s,o){let l;return null===(l=t.side===f?r.intersectTriangle(s,a,n,!0,o):r.intersectTriangle(n,a,s,t.side===m,o))||(ya.copy(o),ya.applyMatrix4(e.matrixWorld),(r=i.ray.origin.distanceTo(ya))<i.near)||r>i.far?null:{distance:r,point:ya.clone(),object:e}}(e,t,i,r,la,ha,ca,xa),e&&(n&&(pa.fromBufferAttribute(n,o),ma.fromBufferAttribute(n,l),fa.fromBufferAttribute(n,h),e.uv=bn.getInterpolation(xa,la,ha,ca,pa,ma,fa,new Ui)),a&&(pa.fromBufferAttribute(a,o),ma.fromBufferAttribute(a,l),fa.fromBufferAttribute(a,h),e.uv1=bn.getInterpolation(xa,la,ha,ca,pa,ma,fa,new Ui),e.uv2=e.uv1),s&&(ga.fromBufferAttribute(s,o),va.fromBufferAttribute(s,l),_a.fromBufferAttribute(s,h),e.normal=bn.getInterpolation(xa,la,ha,ca,ga,va,_a,new hr),0<e.normal.dot(r.direction))&&e.normal.multiplyScalar(-1),t={a:o,b:l,c:h,normal:new hr,materialIndex:0},bn.getNormal(la,ha,ca,t.normal),e.face=t),e}class ba extends ra{constructor(e=1,t=1,i=1,r=1,n=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:n,depthSegments:a};const s=this,o=(r=Math.floor(r),n=Math.floor(n),a=Math.floor(a),[]),l=[],h=[],c=[];let u=0,d=0;function p(e,t,i,r,n,a,p,m,f,g,v){var _=a/f,x=p/g,y=a/2,M=p/2,S=m/2,b=f+1,E=g+1;let T=0,w=0;var A=new hr;for(let a=0;a<E;a++){var R=a*x-M;for(let s=0;s<b;s++){var C=s*_-y;A[e]=C*r,A[t]=R*n,A[i]=S,l.push(A.x,A.y,A.z),A[e]=0,A[t]=0,A[i]=0<m?1:-1,h.push(A.x,A.y,A.z),c.push(s/f),c.push(1-a/g),T+=1}}for(let e=0;e<g;e++)for(let t=0;t<f;t++){var L=u+t+b*e,P=u+t+b*(e+1),I=u+(t+1)+b*(e+1),U=u+(t+1)+b*e;o.push(L,P,U),o.push(P,I,U),w+=6}s.addGroup(d,w,v),d+=w,u+=T}p("z","y","x",-1,-1,i,t,e,a,n,0),p("z","y","x",1,-1,i,t,-e,a,n,1),p("x","z","y",1,1,e,i,t,r,a,2),p("x","z","y",1,-1,e,i,-t,r,a,3),p("x","y","z",1,-1,e,t,i,r,n,4),p("x","y","z",-1,-1,e,t,-i,r,n,5),this.setIndex(o),this.setAttribute("position",new Yn(l,3)),this.setAttribute("normal",new Yn(h,3)),this.setAttribute("uv",new Yn(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ba(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ea(e){var t={};for(const r in e){t[r]={};for(const n in e[r]){var i=e[r][n];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[r][n]=null):t[r][n]=i.clone():Array.isArray(i)?t[r][n]=i.slice():t[r][n]=i}}return t}function Ta(e){var t={};for(let r=0;r<e.length;r++){var i=Ea(e[r]);for(const e in i)t[e]=i[e]}return t}function wa(e){return null===e.getRenderTarget()?e.outputColorSpace:kt}const Aa={clone:Ea,merge:Ta};class Ra extends Tn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ea(e.uniforms),this.uniformsGroups=function(e){var t=[];for(let i=0;i<e.length;i++)t.push(e[i].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){var t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){var i=this.uniforms[r].value;i&&i.isTexture?t.uniforms[r]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[r]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[r]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[r]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[r]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[r]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[r]={type:"m4",value:i.toArray()}:t.uniforms[r]={value:i}}0<Object.keys(this.defines).length&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;var r={};for(const e in this.extensions)!0===this.extensions[e]&&(r[e]=!0);return 0<Object.keys(r).length&&(t.extensions=r),t}}class Ca extends un{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zr,this.projectionMatrix=new zr,this.projectionMatrixInverse=new zr}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class La extends Ca{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){e=.5*this.getFilmHeight()/e,this.fov=2*Si*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){var e=Math.tan(.5*Mi*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Si*Math.atan(Math.tan(.5*Mi*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,n,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){var e=this.near;let t=e*Math.tan(.5*Mi*this.fov)/this.zoom,i=2*t,r=this.aspect*i,n=-.5*r;var a,s=this.view,o=(null!==this.view&&this.view.enabled&&(o=s.fullWidth,a=s.fullHeight,n+=s.offsetX*r/o,t-=s.offsetY*i/a,r*=s.width/o,i*=s.height/a),this.filmOffset);0!==o&&(n+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(n,n+r,t,t-i,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){return(e=super.toJSON(e)).object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class Pa extends un{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i),(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,1,0),i.lookAt(-1,0,0),this.add(i),(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,0,-1),i.lookAt(0,1,0),this.add(i),(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,0,1),i.lookAt(0,-1,0),this.add(i),(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,1,0),i.lookAt(0,0,1),this.add(i),(i=new La(-90,1,e,t)).layers=this.layers,i.up.set(0,1,0),i.lookAt(0,0,-1),this.add(i)}update(e,t){null===this.parent&&this.updateMatrixWorld();var i=this.renderTarget,[r,n,a,s,o,l]=this.children,h=e.getRenderTarget(),c=e.toneMapping,u=e.xr.enabled,d=(e.toneMapping=K,e.xr.enabled=!1,i.texture.generateMipmaps);i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,n),e.setRenderTarget(i,2),e.render(t,a),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=d,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=u,i.texture.needsPMREMUpdate=!0}}class Ia extends er{constructor(e,t,i,r,n,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:ne,i,r,n,a,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class Ua extends ir{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0,e=[e={width:e,height:e,depth:1},e,e,e,e,e],void 0!==t.encoding&&(Hi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Nt?Ht:Gt),this.texture=new Ia(e,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:ve}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;var i={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new ba(5,5,5);return(i=new Ra({name:"CubemapFromEquirect",uniforms:Ea(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:f,blending:_})).uniforms.tEquirect.value=t,r=new Ma(r,i),i=t.minFilter,t.minFilter===ye&&(t.minFilter=ve),new Pa(1,10,this).update(e,r),t.minFilter=i,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,i,r){var n=e.getRenderTarget();for(let n=0;n<6;n++)e.setRenderTarget(this,n),e.clear(t,i,r);e.setRenderTarget(n)}}const Da=new hr,Na=new hr,Oa=new Di;class Fa{constructor(e=new hr(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){return i=Da.subVectors(i,t).cross(Na.subVectors(e,t)).normalize(),this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){var i=e.delta(Da),r=this.normal.dot(i);return 0===r?0===this.distanceToPoint(e.start)?t.copy(e.start):null:(r=-(e.start.dot(this.normal)+this.constant)/r)<0||1<r?null:t.copy(e.start).addScaledVector(i,r)}intersectsLine(e){var t=this.distanceToPoint(e.start);return e=this.distanceToPoint(e.end),t<0&&0<e||e<0&&0<t}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){return t=t||Oa.getNormalMatrix(e),e=this.coplanarPoint(Da).applyMatrix4(e),t=this.normal.applyMatrix3(t).normalize(),this.constant=-e.dot(t),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Ba=new Lr,za=new hr;class Ga{constructor(e=new Fa,t=new Fa,i=new Fa,r=new Fa,n=new Fa,a=new Fa){this.planes=[e,t,i,r,n,a]}set(e,t,i,r,n,a){var s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(r),s[4].copy(n),s[5].copy(a),this}copy(e){var t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){var t=this.planes,i=(e=e.elements)[0],r=e[1],n=e[2],a=e[3],s=e[4],o=e[5],l=e[6],h=e[7],c=e[8],u=e[9],d=e[10],p=e[11],m=e[12],f=e[13],g=e[14];return e=e[15],t[0].setComponents(a-i,h-s,p-c,e-m).normalize(),t[1].setComponents(a+i,h+s,p+c,e+m).normalize(),t[2].setComponents(a+r,h+o,p+u,e+f).normalize(),t[3].setComponents(a-r,h-o,p-u,e-f).normalize(),t[4].setComponents(a-n,h-l,p-d,e-g).normalize(),t[5].setComponents(a+n,h+l,p+d,e+g).normalize(),this}intersectsObject(e){var t;return(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),Ba.copy(e.boundingSphere)):(null===(t=e.geometry).boundingSphere&&t.computeBoundingSphere(),Ba.copy(t.boundingSphere))).applyMatrix4(e.matrixWorld),this.intersectsSphere(Ba)}intersectsSprite(e){return Ba.center.set(0,0,0),Ba.radius=.7071067811865476,Ba.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ba)}intersectsSphere(e){var t=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(i)<r)return!1;return!0}intersectsBox(e){var t=this.planes;for(let r=0;r<6;r++){var i=t[r];if(za.x=(0<i.normal.x?e.max:e.min).x,za.y=(0<i.normal.y?e.max:e.min).y,za.z=(0<i.normal.z?e.max:e.min).z,i.distanceToPoint(za)<0)return!1}return!0}containsPoint(e){var t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Ha(){let e=null,t=!1,i=null,r=null;function n(t,a){i(t,a),r=e.requestAnimationFrame(n)}return{start:function(){!0!==t&&null!==i&&(r=e.requestAnimationFrame(n),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function ka(e,t){const i=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);var i=r.get(t);i&&(e.deleteBuffer(i.buffer),r.delete(t))},update:function(t,n){var a,s,o,l,h;t.isGLBufferAttribute?(!(a=r.get(t))||a.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}):(t.isInterleavedBufferAttribute&&(t=t.data),void 0===(a=r.get(t))?r.set(t,function(t,r){var n=t.array,a=t.usage,s=e.createBuffer();let o;if(e.bindBuffer(r,s),e.bufferData(r,n,a),t.onUploadCallback(),n instanceof Float32Array)o=e.FLOAT;else if(n instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!i)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");o=e.HALF_FLOAT}else o=e.UNSIGNED_SHORT;else if(n instanceof Int16Array)o=e.SHORT;else if(n instanceof Uint32Array)o=e.UNSIGNED_INT;else if(n instanceof Int32Array)o=e.INT;else if(n instanceof Int8Array)o=e.BYTE;else{if(!(n instanceof Uint8Array||n instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+n);o=e.UNSIGNED_BYTE}return{buffer:s,type:o,bytesPerElement:n.BYTES_PER_ELEMENT,version:t.version}}(t,n)):a.version<t.version&&(s=a.buffer,l=(o=t).array,h=o.updateRange,e.bindBuffer(n,s),-1===h.count?e.bufferSubData(n,0,l):(i?e.bufferSubData(n,h.offset*l.BYTES_PER_ELEMENT,l,h.offset,h.count):e.bufferSubData(n,h.offset*l.BYTES_PER_ELEMENT,l.subarray(h.offset,h.offset+h.count)),h.count=-1),o.onUploadCallback(),a.version=t.version))}}}class Va extends ra{constructor(e=1,t=1,i=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:i,heightSegments:r};var n=e/2,a=t/2,s=Math.floor(i),o=Math.floor(r),l=s+1,h=o+1,c=e/s,u=t/o,d=[],p=[],m=[],f=[];for(let e=0;e<h;e++){var g=e*u-a;for(let t=0;t<l;t++){var v=t*c-n;p.push(v,-g,0),m.push(0,0,1),f.push(t/s),f.push(1-e/o)}}for(let e=0;e<o;e++)for(let t=0;t<s;t++){var _=t+l*e,x=t+l*(e+1),y=t+1+l*(e+1),M=t+1+l*e;d.push(_,x,M),d.push(x,y,M)}this.setIndex(d),this.setAttribute("position",new Yn(p,3)),this.setAttribute("normal",new Yn(m,3)),this.setAttribute("uv",new Yn(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Va(e.width,e.height,e.widthSegments,e.heightSegments)}}const Wa={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\tif ( diffuseColor.a < alphaTest ) discard;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660,  0.0556434,\n\t\t-1.5371385,  1.8760108, -0.2040259,\n\t\t-0.4985314,  0.0415560,  1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n    float x2 = x * x;\n    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_NORMALMAP_TANGENTSPACE\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal, vNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t  f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3(  1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108,  1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605,  1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},Xa={common:{diffuse:{value:new Ln(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Di},alphaMap:{value:null},alphaMapTransform:{value:new Di},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Di}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Di}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Di}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Di},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Di},normalScale:{value:new Ui(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Di},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Di}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Di}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Di}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Ln(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Ln(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Di}},sprite:{diffuse:{value:new Ln(16777215)},opacity:{value:1},center:{value:new Ui(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Di},alphaMap:{value:null},alphaTest:{value:0}}},ja={basic:{uniforms:Ta([Xa.common,Xa.specularmap,Xa.envmap,Xa.aomap,Xa.lightmap,Xa.fog]),vertexShader:Wa.meshbasic_vert,fragmentShader:Wa.meshbasic_frag},lambert:{uniforms:Ta([Xa.common,Xa.specularmap,Xa.envmap,Xa.aomap,Xa.lightmap,Xa.emissivemap,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,Xa.fog,Xa.lights,{emissive:{value:new Ln(0)}}]),vertexShader:Wa.meshlambert_vert,fragmentShader:Wa.meshlambert_frag},phong:{uniforms:Ta([Xa.common,Xa.specularmap,Xa.envmap,Xa.aomap,Xa.lightmap,Xa.emissivemap,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,Xa.fog,Xa.lights,{emissive:{value:new Ln(0)},specular:{value:new Ln(1118481)},shininess:{value:30}}]),vertexShader:Wa.meshphong_vert,fragmentShader:Wa.meshphong_frag},standard:{uniforms:Ta([Xa.common,Xa.envmap,Xa.aomap,Xa.lightmap,Xa.emissivemap,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,Xa.roughnessmap,Xa.metalnessmap,Xa.fog,Xa.lights,{emissive:{value:new Ln(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wa.meshphysical_vert,fragmentShader:Wa.meshphysical_frag},toon:{uniforms:Ta([Xa.common,Xa.aomap,Xa.lightmap,Xa.emissivemap,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,Xa.gradientmap,Xa.fog,Xa.lights,{emissive:{value:new Ln(0)}}]),vertexShader:Wa.meshtoon_vert,fragmentShader:Wa.meshtoon_frag},matcap:{uniforms:Ta([Xa.common,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,Xa.fog,{matcap:{value:null}}]),vertexShader:Wa.meshmatcap_vert,fragmentShader:Wa.meshmatcap_frag},points:{uniforms:Ta([Xa.points,Xa.fog]),vertexShader:Wa.points_vert,fragmentShader:Wa.points_frag},dashed:{uniforms:Ta([Xa.common,Xa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wa.linedashed_vert,fragmentShader:Wa.linedashed_frag},depth:{uniforms:Ta([Xa.common,Xa.displacementmap]),vertexShader:Wa.depth_vert,fragmentShader:Wa.depth_frag},normal:{uniforms:Ta([Xa.common,Xa.bumpmap,Xa.normalmap,Xa.displacementmap,{opacity:{value:1}}]),vertexShader:Wa.meshnormal_vert,fragmentShader:Wa.meshnormal_frag},sprite:{uniforms:Ta([Xa.sprite,Xa.fog]),vertexShader:Wa.sprite_vert,fragmentShader:Wa.sprite_frag},background:{uniforms:{uvTransform:{value:new Di},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Wa.background_vert,fragmentShader:Wa.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Wa.backgroundCube_vert,fragmentShader:Wa.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Wa.cube_vert,fragmentShader:Wa.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Wa.equirect_vert,fragmentShader:Wa.equirect_frag},distanceRGBA:{uniforms:Ta([Xa.common,Xa.displacementmap,{referencePosition:{value:new hr},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wa.distanceRGBA_vert,fragmentShader:Wa.distanceRGBA_frag},shadow:{uniforms:Ta([Xa.lights,Xa.fog,{color:{value:new Ln(0)},opacity:{value:1}}]),vertexShader:Wa.shadow_vert,fragmentShader:Wa.shadow_frag}},qa=(ja.physical={uniforms:Ta([ja.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Di},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Di},clearcoatNormalScale:{value:new Ui(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Di},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Di},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Di},sheen:{value:0},sheenColor:{value:new Ln(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Di},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Di},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Di},transmissionSamplerSize:{value:new Ui},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Di},attenuationDistance:{value:0},attenuationColor:{value:new Ln(0)},specularColor:{value:new Ln(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Di},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Di}}]),vertexShader:Wa.meshphysical_vert,fragmentShader:Wa.meshphysical_frag},{r:0,b:0,g:0});function Ya(e,t,i,r,n,a,s){const o=new Ln(0);let l,h,c=!0===a?0:1,u=null,d=0,p=null;function g(t,i){t.getRGB(qa,wa(e)),r.buffers.color.setClear(qa.r,qa.g,qa.b,i,s)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),c=t,g(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,g(o,c)},render:function(a,v){let _=!1,x=!0===v.isScene?v.background:null;switch(x&&x.isTexture&&(x=(0<v.backgroundBlurriness?i:t).get(x)),null===x?g(o,c):x&&x.isColor&&(g(x,1),_=!0),e.xr.getEnvironmentBlendMode()){case"opaque":_=!0;break;case"additive":r.buffers.color.setClear(0,0,0,1,s),_=!0;break;case"alpha-blend":r.buffers.color.setClear(0,0,0,0,s),_=!0}(e.autoClear||_)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),x&&(x.isCubeTexture||x.mapping===le)?(void 0===h&&((h=new Ma(new ba(1,1,1),new Ra({name:"BackgroundCubeMaterial",uniforms:Ea(ja.backgroundCube.uniforms),vertexShader:ja.backgroundCube.vertexShader,fragmentShader:ja.backgroundCube.fragmentShader,side:f,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(h)),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&!1===x.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.toneMapped=x.colorSpace!==Ht,u===x&&d===x.version&&p===e.toneMapping||(h.material.needsUpdate=!0,u=x,d=x.version,p=e.toneMapping),h.layers.enableAll(),a.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(void 0===l&&((l=new Ma(new Va(2,2),new Ra({name:"BackgroundMaterial",uniforms:Ea(ja.background.uniforms),vertexShader:ja.background.vertexShader,fragmentShader:ja.background.fragmentShader,side:m,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=x.colorSpace!==Ht,!0===x.matrixAutoUpdate&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),u===x&&d===x.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=x,d=x.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null))}}}function Za(e,t,i,r){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),s=r.isWebGL2||null!==a,o={},l=p(null);let h=l,c=!1;function u(t){if(r.isWebGL2)return e.bindVertexArray(t);a.bindVertexArrayOES(t)}function d(t){if(r.isWebGL2)return e.deleteVertexArray(t);a.deleteVertexArrayOES(t)}function p(e){var t=[],i=[],r=[];for(let e=0;e<n;e++)t[e]=0,i[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:i,attributeDivisors:r,object:e,attributes:{},index:null}}function m(){var e=h.newAttributes;for(let t=0,i=e.length;t<i;t++)e[t]=0}function f(e){g(e,0)}function g(i,n){var a=h.newAttributes,s=h.enabledAttributes,o=h.attributeDivisors;a[i]=1,0===s[i]&&(e.enableVertexAttribArray(i),s[i]=1),o[i]!==n&&((r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](i,n),o[i]=n)}function v(){var t=h.newAttributes,i=h.enabledAttributes;for(let r=0,n=i.length;r<n;r++)i[r]!==t[r]&&(e.disableVertexAttribArray(r),i[r]=0)}function _(t,i,n,a,s,o){!0!==r.isWebGL2||n!==e.INT&&n!==e.UNSIGNED_INT?e.vertexAttribPointer(t,i,n,a,s,o):e.vertexAttribIPointer(t,i,n,s,o)}function x(){y(),c=!0,h!==l&&u((h=l).object)}function y(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(n,l,d,x,y){let M=!1;if(s){var S=function(t,i,n){n=!0===n.wireframe;let s=o[t.id];void 0===s&&(s={},o[t.id]=s);let l=s[i.id];void 0===l&&(l={},s[i.id]=l);let h=l[n];return void 0===h&&(h=p(r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),l[n]=h),h}(x,d,l);if(h!==S&&u((h=S).object),M=function(e,t,i,r){var n=h.attributes,a=t.attributes;let s=0;var o=i.getAttributes();for(const t in o)if(0<=o[t].location){var l=n[t];let i=a[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t)&&e.instanceColor&&(i=e.instanceColor),void 0===l)return!0;if(l.attribute!==i)return!0;if(i&&l.data!==i.data)return!0;s++}return h.attributesNum!==s||h.index!==r}(n,x,d,y)){var b=n,E=(S=d,y),T={},w=x.attributes;let e=0;var A=S.getAttributes();for(const t in A)if(0<=A[t].location){let i=w[t];void 0===i&&("instanceMatrix"===t&&b.instanceMatrix&&(i=b.instanceMatrix),"instanceColor"===t)&&b.instanceColor&&(i=b.instanceColor);var R={};(R.attribute=i)&&i.data&&(R.data=i.data),T[t]=R,e++}h.attributes=T,h.attributesNum=e,h.index=E}}else S=!0===l.wireframe,h.geometry===x.id&&h.program===d.id&&h.wireframe===S||(h.geometry=x.id,h.program=d.id,h.wireframe=S,M=!0);null!==y&&i.update(y,e.ELEMENT_ARRAY_BUFFER),(M||c)&&(c=!1,function(n,a,s,o){if(!1!==r.isWebGL2||!n.isInstancedMesh&&!o.isInstancedBufferGeometry||null!==t.get("ANGLE_instanced_arrays")){m();var l=o.attributes,h=s.getAttributes(),c=a.defaultAttributeValues;for(const t in h){var u=h[t];if(0<=u.location){let r=l[t];if(void 0!==(r=void 0===r&&("instanceMatrix"===t&&n.instanceMatrix&&(r=n.instanceMatrix),"instanceColor"===t)&&n.instanceColor?n.instanceColor:r)){var d=r.normalized,p=r.itemSize,x=i.get(r);if(void 0!==x){var y=x.buffer,M=x.type,S=x.bytesPerElement;if(r.isInterleavedBufferAttribute){var b=r.data,E=b.stride,T=r.offset;if(b.isInstancedInterleavedBuffer){for(let e=0;e<u.locationSize;e++)g(u.location+e,b.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=b.meshPerAttribute*b.count)}else for(let e=0;e<u.locationSize;e++)f(u.location+e);e.bindBuffer(e.ARRAY_BUFFER,y);for(let e=0;e<u.locationSize;e++)_(u.location+e,p/u.locationSize,M,d,E*S,(T+p/u.locationSize*e)*S)}else{if(r.isInstancedBufferAttribute){for(let e=0;e<u.locationSize;e++)g(u.location+e,r.meshPerAttribute);!0!==n.isInstancedMesh&&void 0===o._maxInstanceCount&&(o._maxInstanceCount=r.meshPerAttribute*r.count)}else for(let e=0;e<u.locationSize;e++)f(u.location+e);e.bindBuffer(e.ARRAY_BUFFER,y);for(let e=0;e<u.locationSize;e++)_(u.location+e,p/u.locationSize,M,d,p*S,p/u.locationSize*e*S)}}}else if(void 0!==c){var w=c[t];if(void 0!==w)switch(w.length){case 2:e.vertexAttrib2fv(u.location,w);break;case 3:e.vertexAttrib3fv(u.location,w);break;case 4:e.vertexAttrib4fv(u.location,w);break;default:e.vertexAttrib1fv(u.location,w)}}}}v()}}(n,l,d,x),null!==y)&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,i.get(y).buffer)},reset:x,resetDefaultState:y,dispose:function(){x();for(const i in o){var e=o[i];for(const i in e){var t=e[i];for(const e in t)d(t[e].object),delete t[e];delete e[i]}delete o[i]}},releaseStatesOfGeometry:function(e){if(void 0!==o[e.id]){var t=o[e.id];for(const e in t){var i=t[e];for(const e in i)d(i[e].object),delete i[e];delete t[e]}delete o[e.id]}},releaseStatesOfProgram:function(e){for(const r in o){var t=o[r];if(void 0!==t[e.id]){var i=t[e.id];for(const e in i)d(i[e].object),delete i[e];delete t[e.id]}}},initAttributes:m,enableAttribute:f,disableUnusedAttributes:v}}function Ja(e,t,i,r){const n=r.isWebGL2;let a;this.setMode=function(e){a=e},this.render=function(t,r){e.drawArrays(a,t,r),i.update(r,a,1)},this.renderInstances=function(r,s,o){if(0!==o){let l,h;if(n)l=e,h="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),h="drawArraysInstancedANGLE",null===l)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[h](a,r,s,o),i.update(s,a,o)}}}function Ka(e,t,i){let r;function n(t){if("highp"===t){if(0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.HIGH_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision)return"highp";t="mediump"}return"mediump"===t&&0<e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision&&0<e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision?"mediump":"lowp"}var a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let s=void 0!==i.precision?i.precision:"highp";var o=((o=n(s))!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o),a||t.has("WEBGL_draw_buffers")),l=(i=!0===i.logarithmicDepthBuffer,e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS)),h=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),c=e.getParameter(e.MAX_TEXTURE_SIZE),u=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),d=e.getParameter(e.MAX_VERTEX_ATTRIBS),p=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),m=e.getParameter(e.MAX_VARYING_VECTORS),f=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),g=0<h,v=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:o,getMaxAnisotropy:function(){var i;return r=void 0===r?!0===t.has("EXT_texture_filter_anisotropic")?(i=t.get("EXT_texture_filter_anisotropic"),e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)):0:r},getMaxPrecision:n,precision:s,logarithmicDepthBuffer:i,maxTextures:l,maxVertexTextures:h,maxTextureSize:c,maxCubemapSize:u,maxAttributes:d,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:f,vertexTextures:g,floatFragmentTextures:v,floatVertexTextures:g&&v,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Qa(e){const t=this;let i=null,r=0,n=!1,a=!1;const s=new Fa,o=new Di,l={value:null,needsUpdate:!1};function h(e,i,r,n){var a=null!==e?e.length:0;let h=null;if(0!==a){if(h=l.value,!0!==n||null===h){n=r+4*a;var c=i.matrixWorldInverse;o.getNormalMatrix(c),(null===h||h.length<n)&&(h=new Float32Array(n));for(let t=0,i=r;t!==a;++t,i+=4)s.copy(e[t]).applyMatrix4(c,o),s.normal.toArray(h,i),h[i+3]=s.constant}l.value=h,l.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,h}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){var i=0!==e.length||t||0!==r||n;return n=t,r=e.length,i},this.beginShadows=function(){a=!0,h(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){i=h(e,t,0)},this.setState=function(s,o,c){var u=s.clippingPlanes,d=s.clipIntersection,p=s.clipShadows;if(s=e.get(s),!n||null===u||0===u.length||a&&!p)a?h(null):(l.value!==i&&(l.value=i,l.needsUpdate=0<r),t.numPlanes=r,t.numIntersection=0);else{var m=4*(p=a?0:r),f=s.clippingState||null;l.value=f,f=h(u,o,m,c);for(let e=0;e!==m;++e)f[e]=i[e];s.clippingState=f,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=p}}}function $a(e){let t=new WeakMap;function i(e,t){return t===se?e.mapping=ne:t===oe&&(e.mapping=ae),e}function r(e){var i=((e=e.target).removeEventListener("dispose",r),t.get(e));void 0!==i&&(t.delete(e),i.dispose())}return{get:function(n){if(n&&n.isTexture&&!1===n.isRenderTargetTexture){var a=n.mapping;if(a===se||a===oe)return t.has(n)?i(t.get(n).texture,n.mapping):(a=n.image)&&0<a.height?((a=new Ua(a.height/2)).fromEquirectangularTexture(e,n),t.set(n,a),n.addEventListener("dispose",r),i(a.texture,n.mapping)):null}return n},dispose:function(){t=new WeakMap}}}class es extends Ca{constructor(e=-1,t=1,i=1,r=-1,n=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=n,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,n,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=n,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let n=i-e,a=i+e,s=r+t,o=r-t;null!==this.view&&this.view.enabled&&(i=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom,n+=i*this.view.offsetX,a=n+i*this.view.width,s-=e*this.view.offsetY,o=s-e*this.view.height),this.projectionMatrix.makeOrthographic(n,a,s,o,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){return(e=super.toJSON(e)).object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const ts=[.125,.215,.35,.446,.526,.582],is=new es,rs=new Ln;let ns=null;t=1/(i=(1+Math.sqrt(5))/2);const as=[new hr(1,1,1),new hr(-1,1,1),new hr(1,1,-1),new hr(-1,1,-1),new hr(0,i,t),new hr(0,i,-t),new hr(t,0,i),new hr(-t,0,i),new hr(i,t,0),new hr(-i,t,0)];class ss{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){ns=this._renderer.getRenderTarget(),this._setSize(256);var n=this._allocateTargets();return n.depthBuffer=!0,this._sceneToCubeUV(e,i,r,n),0<t&&this._blur(n,0,0,t),this._applyPMREM(n),this._cleanup(n),n}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=cs(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=hs(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(ns),e.scissorTest=!1,ls(e,0,0,e.width,e.height)}_fromTexture(e,t){return e.mapping===ne||e.mapping===ae?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),ns=this._renderer.getRenderTarget(),t=t||this._allocateTargets(),this._textureToCubeUV(e,t),this._applyPMREM(t),this._cleanup(t),t}_allocateTargets(){var e,t,i=3*Math.max(this._cubeSize,112),r=4*this._cubeSize,n={magFilter:ve,minFilter:ve,generateMipmaps:!1,type:Ce,format:De,colorSpace:kt,depthBuffer:!1},a=os(i,r,n);return null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.width===i&&this._pingPongRenderTarget.height===r||(null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=os(i,r,n),n=this._lodMax,({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){var t=[],i=[],r=[];let n=e;var a=e-4+1+ts.length;for(let m=0;m<a;m++){var s=Math.pow(2,n);i.push(s);let a=1/s;m>e-4?a=ts[m-e+4-1]:0===m&&(a=0),r.push(a);var o=-(s=1/(s-2)),l=[o,o,s=1+s,o,s,s,o,o,s,s,o,s],h=new Float32Array(108),c=new Float32Array(72),u=new Float32Array(36);for(let e=0;e<6;e++){var d=e%3*2/3-1,p=2<e?0:-1;h.set([d,p,0,d+2/3,p,0,d+2/3,1+p,0,d,p,0,d+2/3,1+p,0,d,1+p,0],18*e),c.set(l,12*e),d=[e,e,e,e,e,e],u.set(d,6*e)}(o=new ra).setAttribute("position",new zn(h,3)),o.setAttribute("uv",new zn(c,2)),o.setAttribute("faceIndex",new zn(u,1)),t.push(o),4<n&&n--}return{lodPlanes:t,sizeLods:i,sigmas:r}}(n)),this._blurMaterial=(e=new Float32Array(20),t=new hr(0,1,0),i=new Ra({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/i,CUBEUV_TEXEL_HEIGHT:1/r,CUBEUV_MAX_MIP:n+".0"},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:t}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:_,depthTest:!1,depthWrite:!1}))),a}_compileMaterial(e){e=new Ma(this._lodPlanes[0],e),this._renderer.compile(e,is)}_sceneToCubeUV(e,t,i,r){var n=new La(90,1,t,i),a=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=(t=o.autoClear,i=o.toneMapping,o.getClearColor(rs),o.toneMapping=K,o.autoClear=!1,new In({name:"PMREM.Background",side:f,depthWrite:!1,depthTest:!1})),h=new Ma(new ba,l);let c=!1;var u=e.background;u?u.isColor&&(l.color.copy(u),e.background=null,c=!0):(l.color.copy(rs),c=!0);for(let t=0;t<6;t++){var d=t%3,p=(0==d?(n.up.set(0,a[t],0),n.lookAt(s[t],0,0)):1==d?(n.up.set(0,0,a[t]),n.lookAt(0,s[t],0)):(n.up.set(0,a[t],0),n.lookAt(0,0,s[t])),this._cubeSize);ls(r,d*p,2<t?p:0,p,p),o.setRenderTarget(r),c&&o.render(h,n),o.render(e,n)}h.geometry.dispose(),h.material.dispose(),o.toneMapping=i,o.autoClear=t,e.background=u}_textureToCubeUV(e,t){var i=this._renderer,r=((r=e.mapping===ne||e.mapping===ae)?(null===this._cubemapMaterial&&(this._cubemapMaterial=cs()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=hs()),r?this._cubemapMaterial:this._equirectMaterial),n=new Ma(this._lodPlanes[0],r);ls(t,0,0,3*(r.uniforms.envMap.value=e,r=this._cubeSize),2*r),i.setRenderTarget(t),i.render(n,is)}_applyPMREM(e){var t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){var r=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),n=as[(t-1)%as.length];this._blur(e,t-1,t,r,n)}t.autoClear=i}_blur(e,t,i,r,n){var a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,r,"latitudinal",n),this._halfBlur(a,e,i,i,r,"longitudinal",n)}_halfBlur(e,t,i,r,n,a,s){var o=this._renderer,l=this._blurMaterial,h=("latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!"),new Ma(this._lodPlanes[r],l)),c=(l=l.uniforms,this._sizeLods[i]-1),u=n/(c=isFinite(n)?Math.PI/(2*c):2*Math.PI/39),d=isFinite(n)?1+Math.floor(3*u):20,p=(20<d&&console.warn(`sigmaRadians, ${n}, is too large and will clip, as it requested ${d} samples when the maximum is set to 20`),[]);let m=0;for(let e=0;e<20;++e){const t=e/u;var f=Math.exp(-t*t/2);p.push(f),0===e?m+=f:e<d&&(m+=2*f)}for(let e=0;e<p.length;e++)p[e]=p[e]/m;l.envMap.value=e.texture,l.samples.value=d,l.weights.value=p,l.latitudinal.value="latitudinal"===a,s&&(l.poleAxis.value=s),n=this._lodMax,l.dTheta.value=c,l.mipInt.value=n-i,ls(t,3*(e=this._sizeLods[r])*(n-4<r?r-n+4:0),a=4*(this._cubeSize-e),3*e,2*e),o.setRenderTarget(t),o.render(h,is)}}function os(e,t,i){return(e=new ir(e,t,i)).texture.mapping=le,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function ls(e,t,i,r,n){e.viewport.set(t,i,r,n),e.scissor.set(t,i,r,n)}function hs(){return new Ra({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:_,depthTest:!1,depthWrite:!1})}function cs(){return new Ra({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:_,depthTest:!1,depthWrite:!1})}function us(e){let t=new WeakMap,i=null;function r(e){var i=((e=e.target).removeEventListener("dispose",r),t.get(e));void 0!==i&&(t.delete(e),i.dispose())}return{get:function(n){if(n&&n.isTexture){var a,s=(o=n.mapping)===se||o===oe,o=o===ne||o===ae;if(s||o)return n.isRenderTargetTexture&&!0===n.needsPMREMUpdate?(n.needsPMREMUpdate=!1,a=t.get(n),null===i&&(i=new ss(e)),a=s?i.fromEquirectangular(n,a):i.fromCubemap(n,a),t.set(n,a),a.texture):t.has(n)?t.get(n).texture:(a=n.image,s&&a&&0<a.height||o&&a&&function(e){let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(a)?(null===i&&(i=new ss(e)),o=s?i.fromEquirectangular(n):i.fromCubemap(n),t.set(n,o),n.addEventListener("dispose",r),o.texture):null)}return n},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function ds(e){const t={};function i(i){if(void 0!==t[i])return t[i];let r;switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return t[i]=r}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){var t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function ps(e,t,i,r){const n={},a=new WeakMap;function s(e){var o=e.target;null!==o.index&&t.remove(o.index);for(const e in o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete n[o.id],(e=a.get(o))&&(t.remove(e),a.delete(o)),r.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,i.memory.geometries--}return{get:function(e,t){return!0!==n[t.id]&&(t.addEventListener("dispose",s),n[t.id]=!0,i.memory.geometries++),t},update:function(i){var r=i.attributes;for(const i in r)t.update(r[i],e.ARRAY_BUFFER);var n=i.morphAttributes;for(const i in n){var a=n[i];for(let i=0,r=a.length;i<r;i++)t.update(a[i],e.ARRAY_BUFFER)}},getWireframeAttribute:function(e){var i,r=a.get(e);return(!r||null!==(i=e.index)&&r.version<i.version)&&function(e){var i=[],r=e.index,n=e.attributes.position;let s=0;if(null!==r){var o=r.array;s=r.version;for(let e=0,t=o.length;e<t;e+=3){var l=o[e+0],h=o[e+1],c=o[e+2];i.push(l,h,h,c,c,l)}}else{r=n.array,s=n.version;for(let e=0,t=r.length/3-1;e<t;e+=3){var u=e+0,d=e+1,p=e+2;i.push(u,d,d,p,p,u)}}(n=new(Oi(i)?jn:Wn)(i,1)).version=s,(r=a.get(e))&&t.remove(r),a.set(e,n)}(e),a.get(e)}}}function ms(e,t,i,r){const n=r.isWebGL2;let a,s,o;this.setMode=function(e){a=e},this.setIndex=function(e){s=e.type,o=e.bytesPerElement},this.render=function(t,r){e.drawElements(a,r,s,t*o),i.update(r,a,1)},this.renderInstances=function(r,l,h){if(0!==h){let c,u;if(n)c=e,u="drawElementsInstanced";else if(c=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](a,l,s,r*o,h),i.update(l,a,h)}}}function fs(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(i,r,n){switch(t.calls++,r){case e.TRIANGLES:t.triangles+=n*(i/3);break;case e.LINES:t.lines+=n*(i/2);break;case e.LINE_STRIP:t.lines+=n*(i-1);break;case e.LINE_LOOP:t.lines+=n*i;break;case e.POINTS:t.points+=n*i;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",r)}}}}function gs(e,t){return e[0]-t[0]}function vs(e,t){return Math.abs(t[1])-Math.abs(e[1])}function _s(e,t,i){const r={},n=new Float32Array(8),a=new WeakMap,s=new tr,o=[];for(let e=0;e<8;e++)o[e]=[e,0];return{update:function(l,h,c){var u=l.morphTargetInfluences;if(!0===t.isWebGL2){var d=void 0!==(l=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color)?l.length:0;let r=a.get(h);if(void 0===r||r.count!==d){void 0!==r&&r.texture.dispose();var p=void 0!==h.morphAttributes.position,m=void 0!==h.morphAttributes.normal,f=void 0!==h.morphAttributes.color,g=h.morphAttributes.position||[],v=h.morphAttributes.normal||[],_=h.morphAttributes.color||[];let e=1==f?3:1==m?2:1==p?1:0,i=h.attributes.position.count*e,n=1;i>t.maxTextureSize&&(n=Math.ceil(i/t.maxTextureSize),i=t.maxTextureSize);var x=new Float32Array(i*n*4*d);const o=new rr(x,i,n,d);o.type=Re,o.needsUpdate=!0;var y=4*e;for(let e=0;e<d;e++){var M=g[e],S=v[e],b=_[e],E=i*n*4*e;for(let e=0;e<M.count;e++){var T=e*y;1==p&&(s.fromBufferAttribute(M,e),x[E+T]=s.x,x[E+T+1]=s.y,x[E+T+2]=s.z,x[E+T+3]=0),1==m&&(s.fromBufferAttribute(S,e),x[E+T+4]=s.x,x[E+T+5]=s.y,x[E+T+6]=s.z,x[E+T+7]=0),1==f&&(s.fromBufferAttribute(b,e),x[E+T+8]=s.x,x[E+T+9]=s.y,x[E+T+10]=s.z,x[E+T+11]=4===b.itemSize?s.w:1)}}r={count:d,texture:o,size:new Ui(i,n)},a.set(h,r),h.addEventListener("dispose",function e(){o.dispose(),a.delete(h),h.removeEventListener("dispose",e)})}let n=0;for(let e=0;e<u.length;e++)n+=u[e];l=h.morphTargetsRelative?1:1-n,c.getUniforms().setValue(e,"morphTargetBaseInfluence",l),c.getUniforms().setValue(e,"morphTargetInfluences",u),c.getUniforms().setValue(e,"morphTargetsTexture",r.texture,i),c.getUniforms().setValue(e,"morphTargetsTextureSize",r.size)}else{var w=void 0===u?0:u.length;let t=r[h.id];if(void 0===t||t.length!==w){t=[];for(let e=0;e<w;e++)t[e]=[e,0];r[h.id]=t}for(let e=0;e<w;e++){var A=t[e];A[0]=e,A[1]=u[e]}t.sort(vs);for(let e=0;e<8;e++)e<w&&t[e][1]?(o[e][0]=t[e][0],o[e][1]=t[e][1]):(o[e][0]=Number.MAX_SAFE_INTEGER,o[e][1]=0);o.sort(gs);var R=h.morphAttributes.position,C=h.morphAttributes.normal;let i=0;for(let e=0;e<8;e++){var L=(P=o[e])[0],P=P[1];L!==Number.MAX_SAFE_INTEGER&&P?(R&&h.getAttribute("morphTarget"+e)!==R[L]&&h.setAttribute("morphTarget"+e,R[L]),C&&h.getAttribute("morphNormal"+e)!==C[L]&&h.setAttribute("morphNormal"+e,C[L]),n[e]=P,i+=P):(R&&!0===h.hasAttribute("morphTarget"+e)&&h.deleteAttribute("morphTarget"+e),C&&!0===h.hasAttribute("morphNormal"+e)&&h.deleteAttribute("morphNormal"+e),n[e]=0)}l=h.morphTargetsRelative?1:1-i,c.getUniforms().setValue(e,"morphTargetBaseInfluence",l),c.getUniforms().setValue(e,"morphTargetInfluences",n)}}}}function xs(e,t,i,r){let n=new WeakMap;function a(e){(e=e.target).removeEventListener("dispose",a),i.remove(e.instanceMatrix),null!==e.instanceColor&&i.remove(e.instanceColor)}return{update:function(s){var o=r.render.frame,l=s.geometry;return l=t.get(s,l),n.get(l)!==o&&(t.update(l),n.set(l,o)),s.isInstancedMesh&&(!1===s.hasEventListener("dispose",a)&&s.addEventListener("dispose",a),i.update(s.instanceMatrix,e.ARRAY_BUFFER),null!==s.instanceColor)&&i.update(s.instanceColor,e.ARRAY_BUFFER),l},dispose:function(){n=new WeakMap}}}const ys=new er,Ms=new rr,Ss=new ar,bs=new Ia,Es=[],Ts=[],ws=new Float32Array(16),As=new Float32Array(9),Rs=new Float32Array(4);function Cs(e,t,i){var r=e[0];if(r<=0||0<r)return e;var n=t*i;let a=Es[n];if(void 0===a&&(a=new Float32Array(n),Es[n]=a),0!==t){r.toArray(a,0);for(let r=1,n=0;r!==t;++r)n+=i,e[r].toArray(a,n)}return a}function Ls(e,t){if(e.length===t.length){for(let i=0,r=e.length;i<r;i++)if(e[i]!==t[i])return;return 1}}function Ps(e,t){for(let i=0,r=t.length;i<r;i++)e[i]=t[i]}function Is(e,t){let i=Ts[t];void 0===i&&(i=new Int32Array(t),Ts[t]=i);for(let r=0;r!==t;++r)i[r]=e.allocateTextureUnit();return i}function Us(e,t){var i=this.cache;i[0]!==t&&(e.uniform1f(this.addr,t),i[0]=t)}function Ds(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y):Ls(i,t)||(e.uniform2fv(this.addr,t),Ps(i,t))}function Ns(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z):void 0!==t.r?i[0]===t.r&&i[1]===t.g&&i[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),i[0]=t.r,i[1]=t.g,i[2]=t.b):Ls(i,t)||(e.uniform3fv(this.addr,t),Ps(i,t))}function Os(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w):Ls(i,t)||(e.uniform4fv(this.addr,t),Ps(i,t))}function Fs(e,t){var i=this.cache,r=t.elements;void 0===r?Ls(i,t)||(e.uniformMatrix2fv(this.addr,!1,t),Ps(i,t)):Ls(i,r)||(Rs.set(r),e.uniformMatrix2fv(this.addr,!1,Rs),Ps(i,r))}function Bs(e,t){var i=this.cache,r=t.elements;void 0===r?Ls(i,t)||(e.uniformMatrix3fv(this.addr,!1,t),Ps(i,t)):Ls(i,r)||(As.set(r),e.uniformMatrix3fv(this.addr,!1,As),Ps(i,r))}function zs(e,t){var i=this.cache,r=t.elements;void 0===r?Ls(i,t)||(e.uniformMatrix4fv(this.addr,!1,t),Ps(i,t)):Ls(i,r)||(ws.set(r),e.uniformMatrix4fv(this.addr,!1,ws),Ps(i,r))}function Gs(e,t){var i=this.cache;i[0]!==t&&(e.uniform1i(this.addr,t),i[0]=t)}function Hs(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y):Ls(i,t)||(e.uniform2iv(this.addr,t),Ps(i,t))}function ks(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z):Ls(i,t)||(e.uniform3iv(this.addr,t),Ps(i,t))}function Vs(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w):Ls(i,t)||(e.uniform4iv(this.addr,t),Ps(i,t))}function Ws(e,t){var i=this.cache;i[0]!==t&&(e.uniform1ui(this.addr,t),i[0]=t)}function Xs(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),i[0]=t.x,i[1]=t.y):Ls(i,t)||(e.uniform2uiv(this.addr,t),Ps(i,t))}function js(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),i[0]=t.x,i[1]=t.y,i[2]=t.z):Ls(i,t)||(e.uniform3uiv(this.addr,t),Ps(i,t))}function qs(e,t){var i=this.cache;void 0!==t.x?i[0]===t.x&&i[1]===t.y&&i[2]===t.z&&i[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),i[0]=t.x,i[1]=t.y,i[2]=t.z,i[3]=t.w):Ls(i,t)||(e.uniform4uiv(this.addr,t),Ps(i,t))}function Ys(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTexture2D(t||ys,n)}function Zs(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTexture3D(t||Ss,n)}function Js(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTextureCube(t||bs,n)}function Ks(e,t,i){var r=this.cache,n=i.allocateTextureUnit();r[0]!==n&&(e.uniform1i(this.addr,n),r[0]=n),i.setTexture2DArray(t||Ms,n)}function Qs(e,t){e.uniform1fv(this.addr,t)}function $s(e,t){t=Cs(t,this.size,2),e.uniform2fv(this.addr,t)}function eo(e,t){t=Cs(t,this.size,3),e.uniform3fv(this.addr,t)}function to(e,t){t=Cs(t,this.size,4),e.uniform4fv(this.addr,t)}function io(e,t){t=Cs(t,this.size,4),e.uniformMatrix2fv(this.addr,!1,t)}function ro(e,t){t=Cs(t,this.size,9),e.uniformMatrix3fv(this.addr,!1,t)}function no(e,t){t=Cs(t,this.size,16),e.uniformMatrix4fv(this.addr,!1,t)}function ao(e,t){e.uniform1iv(this.addr,t)}function so(e,t){e.uniform2iv(this.addr,t)}function oo(e,t){e.uniform3iv(this.addr,t)}function lo(e,t){e.uniform4iv(this.addr,t)}function ho(e,t){e.uniform1uiv(this.addr,t)}function co(e,t){e.uniform2uiv(this.addr,t)}function uo(e,t){e.uniform3uiv(this.addr,t)}function po(e,t){e.uniform4uiv(this.addr,t)}function mo(e,t,i){var r=this.cache,n=t.length,a=Is(i,n);Ls(r,a)||(e.uniform1iv(this.addr,a),Ps(r,a));for(let e=0;e!==n;++e)i.setTexture2D(t[e]||ys,a[e])}function fo(e,t,i){var r=this.cache,n=t.length,a=Is(i,n);Ls(r,a)||(e.uniform1iv(this.addr,a),Ps(r,a));for(let e=0;e!==n;++e)i.setTexture3D(t[e]||Ss,a[e])}function go(e,t,i){var r=this.cache,n=t.length,a=Is(i,n);Ls(r,a)||(e.uniform1iv(this.addr,a),Ps(r,a));for(let e=0;e!==n;++e)i.setTextureCube(t[e]||bs,a[e])}function vo(e,t,i){var r=this.cache,n=t.length,a=Is(i,n);Ls(r,a)||(e.uniform1iv(this.addr,a),Ps(r,a));for(let e=0;e!==n;++e)i.setTexture2DArray(t[e]||Ms,a[e])}class _o{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Us;case 35664:return Ds;case 35665:return Ns;case 35666:return Os;case 35674:return Fs;case 35675:return Bs;case 35676:return zs;case 5124:case 35670:return Gs;case 35667:case 35671:return Hs;case 35668:case 35672:return ks;case 35669:case 35673:return Vs;case 5125:return Ws;case 36294:return Xs;case 36295:return js;case 36296:return qs;case 35678:case 36198:case 36298:case 36306:case 35682:return Ys;case 35679:case 36299:case 36307:return Zs;case 35680:case 36300:case 36308:case 36293:return Js;case 36289:case 36303:case 36311:case 36292:return Ks}}(t.type)}}class xo{constructor(e,t,i){this.id=e,this.addr=i,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Qs;case 35664:return $s;case 35665:return eo;case 35666:return to;case 35674:return io;case 35675:return ro;case 35676:return no;case 5124:case 35670:return ao;case 35667:case 35671:return so;case 35668:case 35672:return oo;case 35669:case 35673:return lo;case 5125:return ho;case 36294:return co;case 36295:return uo;case 36296:return po;case 35678:case 36198:case 36298:case 36306:case 35682:return mo;case 35679:case 36299:case 36307:return fo;case 35680:case 36300:case 36308:case 36293:return go;case 36289:case 36303:case 36311:case 36292:return vo}}(t.type)}}class yo{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,i){var r=this.seq;for(let a=0,s=r.length;a!==s;++a){var n=r[a];n.setValue(e,t[n.id],i)}}}const Mo=/(\w+)(\])?(\[|\.)?/g;function So(e,t){e.seq.push(t),e.map[t.id]=t}class bo{constructor(e,t){this.seq=[],this.map={};var i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let d=0;d<i;++d){var r=e.getActiveUniform(t,d),n=(u=c=h=s=n=void 0,r),a=e.getUniformLocation(t,r.name),s=this,o=n.name,l=o.length;for(Mo.lastIndex=0;;){var h=Mo.exec(o),c=Mo.lastIndex;let e=h[1];var u="]"===h[2];if(u&&(e|=0),void 0===(h=h[3])||"["===h&&c+2===l){So(s,new(void 0===h?_o:xo)(e,n,a));break}{let t=s.map[e];void 0===t&&So(s,t=new yo(e)),s=t}}}}setValue(e,t,i,r){void 0!==(t=this.map[t])&&t.setValue(e,i,r)}setOptional(e,t,i){void 0!==(t=t[i])&&this.setValue(e,i,t)}static upload(e,t,i,r){for(let s=0,o=t.length;s!==o;++s){var n=t[s],a=i[n.id];!1!==a.needsUpdate&&n.setValue(e,a.value,r)}}static seqWithValue(e,t){var i=[];for(let n=0,a=e.length;n!==a;++n){var r=e[n];r.id in t&&i.push(r)}return i}}function Eo(e,t,i){return t=e.createShader(t),e.shaderSource(t,i),e.compileShader(t),t}let To=0;function wo(e,t,i){var r=e.getShaderParameter(t,e.COMPILE_STATUS),n=e.getShaderInfoLog(t).trim();return r&&""===n?"":(r=/ERROR: 0:(\d+)/.exec(n))?(r=parseInt(r[1]),i.toUpperCase()+"\n\n"+n+"\n\n"+function(e,t){var i=e.split("\n"),r=[],n=(e=Math.max(t-6,0),Math.min(t+6,i.length));for(let s=e;s<n;s++){var a=s+1;r.push(`${a===t?">":" "} ${a}: `+i[s])}return r.join("\n")}(e.getShaderSource(t),r)):n}function Ao(e,t){return t=function(e){switch(e){case kt:return["Linear","( value )"];case Ht:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t),"vec4 "+e+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Ro(e){return""!==e}function Co(e,t){var i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function Lo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const Po=/^[ \t]*#include +<([\w\d./]+)>/gm;function Io(e){return e.replace(Po,Uo)}function Uo(e,t){var i=Wa[t];if(void 0===i)throw new Error("Can not resolve #include <"+t+">");return Io(i)}const Do=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function No(e){return e.replace(Do,Oo)}function Oo(e,t,i,r){let n="";for(let e=parseInt(t);e<parseInt(i);e++)n+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return n}function Fo(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Bo(e,t,i,r){const n=e.getContext();var a,s=i.defines,o=i.vertexShader,l=i.fragmentShader,h=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===u?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===d?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===p&&(t="SHADOWMAP_TYPE_VSM"),t}(i),c=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case ne:case ae:t="ENVMAP_TYPE_CUBE";break;case le:t="ENVMAP_TYPE_CUBE_UV"}return t}(i),m=function(e){return e.envMap&&e.envMapMode===ae?"ENVMAP_MODE_REFRACTION":"ENVMAP_MODE_REFLECTION"}(i),f=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Y:t="ENVMAP_BLENDING_MULTIPLY";break;case Z:t="ENVMAP_BLENDING_MIX";break;case J:t="ENVMAP_BLENDING_ADD"}return t}(i),g=null===(g=(g=i).envMapCubeUVHeight)?null:(a=Math.log2(g)-2,g=1/g,{texelWidth:1/(3*Math.max(Math.pow(2,a),112)),texelHeight:g,maxMip:a}),v=i.isWebGL2?"":[(a=i).extensionDerivatives||a.envMapCubeUVHeight||a.bumpMap||a.normalMapTangentSpace||a.clearcoatNormalMap||a.flatShading||"physical"===a.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ro).join("\n");s=function(e){var t=[];for(const r in e){var i=e[r];!1!==i&&t.push("#define "+r+" "+i)}return t.join("\n")}(s);const _=n.createProgram();let x,y,M,S,b=i.glslVersion?"#version "+i.glslVersion+"\n":"";if(i.isRawShaderMaterial?(0<(x=[s].filter(Ro).join("\n")).length&&(x+="\n"),0<(y=[v,s].filter(Ro).join("\n")).length&&(y+="\n")):(x=[Fo(i),"#define SHADER_NAME "+i.shaderName,s,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",0<i.morphTargetsCount&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",0<i.morphTargetsCount&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",0<i.morphTargetsCount&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Ro).join("\n"),y=[v,Fo(i),"#define SHADER_NAME "+i.shaderName,s,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+c:"",i.envMap?"#define "+m:"",i.envMap?"#define "+f:"",g?"#define CUBEUV_TEXEL_WIDTH "+g.texelWidth:"",g?"#define CUBEUV_TEXEL_HEIGHT "+g.texelHeight:"",g?"#define CUBEUV_MAX_MIP "+g.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+h:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",i.toneMapping!==K?"#define TONE_MAPPING":"",i.toneMapping!==K?Wa.tonemapping_pars_fragment:"",i.toneMapping!==K?function(e,t){let i;switch(t){case Q:i="Linear";break;case $:i="Reinhard";break;case ee:i="OptimizedCineon";break;case te:i="ACESFilmic";break;case ie:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 toneMapping( vec3 color ) { return "+i+"ToneMapping( color ); }"}(0,i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",Wa.encodings_pars_fragment,Ao("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(Ro).join("\n")),o=Lo(Co(Io(o),i),i),l=Lo(Co(Io(l),i),i),o=No(o),l=No(l),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(b="#version 300 es\n",x=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,y=["#define varying in",i.glslVersion===gi?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===gi?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+y),v=b+x+o,s=b+y+l,c=Eo(n,n.VERTEX_SHADER,v),m=Eo(n,n.FRAGMENT_SHADER,s),n.attachShader(_,c),n.attachShader(_,m),void 0!==i.index0AttributeName?n.bindAttribLocation(_,0,i.index0AttributeName):!0===i.morphTargets&&n.bindAttribLocation(_,0,"position"),n.linkProgram(_),e.debug.checkShaderErrors){f=n.getProgramInfoLog(_).trim(),g=n.getShaderInfoLog(c).trim(),h=n.getShaderInfoLog(m).trim();let t=!0,i=!0;!1===n.getProgramParameter(_,n.LINK_STATUS)?(t=!1,"function"==typeof e.debug.onShaderError?e.debug.onShaderError(n,_,c,m):(o=wo(n,c,"vertex"),l=wo(n,m,"fragment"),console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(_,n.VALIDATE_STATUS)+"\n\nProgram Info Log: "+f+"\n"+o+"\n"+l))):""!==f?console.warn("THREE.WebGLProgram: Program Info Log:",f):""!==g&&""!==h||(i=!1),i&&(this.diagnostics={runnable:t,programLog:f,vertexShader:{log:g,prefix:x},fragmentShader:{log:h,prefix:y}})}return n.deleteShader(c),n.deleteShader(m),this.getUniforms=function(){return M=void 0===M?new bo(n,_):M},this.getAttributes=function(){return S=void 0===S?function(e,t){var i={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){var n=e.getActiveAttrib(t,s),a=n.name;let r=1;n.type===e.FLOAT_MAT2&&(r=2),n.type===e.FLOAT_MAT3&&(r=3),n.type===e.FLOAT_MAT4&&(r=4),i[a]={type:n.type,location:e.getAttribLocation(t,a),locationSize:r}}return i}(n,_):S},this.destroy=function(){r.releaseStatesOfProgram(this),n.deleteProgram(_),this.program=void 0},this.name=i.shaderName,this.id=To++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=c,this.fragmentShader=m,this}let zo=0;class Go{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){var t=e.vertexShader,i=e.fragmentShader;return t=this._getShaderStage(t),i=this._getShaderStage(i),!1===(e=this._getShaderCacheForMaterial(e)).has(t)&&(e.add(t),t.usedTimes++),!1===e.has(i)&&(e.add(i),i.usedTimes++),this}remove(e){for(const t of this.materialCache.get(e))t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){var t=this.materialCache;let i=t.get(e);return void 0===i&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){var t=this.shaderCache;let i=t.get(e);return void 0===i&&(i=new Ho(e),t.set(e,i)),i}}class Ho{constructor(e){this.id=zo++,this.code=e,this.usedTimes=0}}function ko(e,t,i,r,n,a,s){const o=new Jr,l=new Go,h=[],c=n.isWebGL2,u=n.logarithmicDepthBuffer,d=n.vertexTextures;let p=n.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function v(e){return 1===e?"uv1":2===e?"uv2":3===e?"uv3":"uv"}return{getParameters:function(a,o,h,_,y){var M=_.fog,S=y.geometry,b=(_=a.isMeshStandardMaterial?_.environment:null,(_=(a.isMeshStandardMaterial?i:t).get(a.envMap||_))&&_.mapping===le?_.image.height:null),E=m[a.type];null!==a.precision&&(p=n.getMaxPrecision(a.precision))!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead.");var T=void 0!==(T=S.morphAttributes.position||S.morphAttributes.normal||S.morphAttributes.color)?T.length:0;let w,A,R,C,L=0;void 0!==S.morphAttributes.position&&(L=1),void 0!==S.morphAttributes.normal&&(L=2),void 0!==S.morphAttributes.color&&(L=3),E?(w=(P=ja[E]).vertexShader,A=P.fragmentShader):(w=a.vertexShader,A=a.fragmentShader,l.update(a),R=l.getVertexShaderID(a),C=l.getFragmentShaderID(a));var P=e.getRenderTarget(),I=!0===y.isInstancedMesh,U=!!a.map,D=!!a.matcap,N=!!_,O=!!a.aoMap,F=!!a.lightMap,B=!!a.bumpMap,z=!!a.normalMap,G=!!a.displacementMap,H=!!a.emissiveMap,k=!!a.metalnessMap,V=!!a.roughnessMap,W=0<a.clearcoat,X=0<a.iridescence,j=0<a.sheen,q=0<a.transmission,Y=W&&!!a.clearcoatMap,Z=W&&!!a.clearcoatNormalMap,J=W&&!!a.clearcoatRoughnessMap,Q=X&&!!a.iridescenceMap,$=X&&!!a.iridescenceThicknessMap,ee=j&&!!a.sheenColorMap,te=j&&!!a.sheenRoughnessMap,ie=!!a.specularMap,re=!!a.specularColorMap,ne=!!a.specularIntensityMap,ae=q&&!!a.transmissionMap,se=q&&!!a.thicknessMap,oe=!!a.gradientMap,he=!!a.alphaMap,ce=0<a.alphaTest,ue=!!a.extensions,de=!!S.attributes.uv1,pe=!!S.attributes.uv2,me=!!S.attributes.uv3;return{isWebGL2:c,shaderID:E,shaderName:a.type,vertexShader:w,fragmentShader:A,defines:a.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:I,instancingColor:I&&null!==y.instanceColor,supportsVertexTextures:d,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:kt,map:U,matcap:D,envMap:N,envMapMode:N&&_.mapping,envMapCubeUVHeight:b,aoMap:O,lightMap:F,bumpMap:B,normalMap:z,displacementMap:d&&G,emissiveMap:H,normalMapObjectSpace:z&&a.normalMapType===zt,normalMapTangentSpace:z&&a.normalMapType===Bt,metalnessMap:k,roughnessMap:V,clearcoat:W,clearcoatMap:Y,clearcoatNormalMap:Z,clearcoatRoughnessMap:J,iridescence:X,iridescenceMap:Q,iridescenceThicknessMap:$,sheen:j,sheenColorMap:ee,sheenRoughnessMap:te,specularMap:ie,specularColorMap:re,specularIntensityMap:ne,transmission:q,transmissionMap:ae,thicknessMap:se,gradientMap:oe,opaque:!1===a.transparent&&a.blending===x,alphaMap:he,alphaTest:ce,combine:a.combine,mapUv:U&&v(a.map.channel),aoMapUv:O&&v(a.aoMap.channel),lightMapUv:F&&v(a.lightMap.channel),bumpMapUv:B&&v(a.bumpMap.channel),normalMapUv:z&&v(a.normalMap.channel),displacementMapUv:G&&v(a.displacementMap.channel),emissiveMapUv:H&&v(a.emissiveMap.channel),metalnessMapUv:k&&v(a.metalnessMap.channel),roughnessMapUv:V&&v(a.roughnessMap.channel),clearcoatMapUv:Y&&v(a.clearcoatMap.channel),clearcoatNormalMapUv:Z&&v(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:J&&v(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&v(a.iridescenceMap.channel),iridescenceThicknessMapUv:$&&v(a.iridescenceThicknessMap.channel),sheenColorMapUv:ee&&v(a.sheenColorMap.channel),sheenRoughnessMapUv:te&&v(a.sheenRoughnessMap.channel),specularMapUv:ie&&v(a.specularMap.channel),specularColorMapUv:re&&v(a.specularColorMap.channel),specularIntensityMapUv:ne&&v(a.specularIntensityMap.channel),transmissionMapUv:ae&&v(a.transmissionMap.channel),thicknessMapUv:se&&v(a.thicknessMap.channel),alphaMapUv:he&&v(a.alphaMap.channel),vertexTangents:z&&!!S.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,vertexUv1s:de,vertexUv2s:pe,vertexUv3s:me,pointsUvs:!0===y.isPoints&&!!S.attributes.uv&&(U||he),fog:!!M,useFog:!0===a.fog,fogExp2:M&&M.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===y.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:T,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&0<h.length,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:K,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===g,flipSided:a.side===f,useDepthPacking:0<=a.depthPacking,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ue&&!0===a.extensions.derivatives,extensionFragDepth:ue&&!0===a.extensions.fragDepth,extensionDrawBuffers:ue&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ue&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){var i,r,n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&((i=n).push((r=t).precision),i.push(r.outputColorSpace),i.push(r.envMapMode),i.push(r.envMapCubeUVHeight),i.push(r.mapUv),i.push(r.alphaMapUv),i.push(r.lightMapUv),i.push(r.aoMapUv),i.push(r.bumpMapUv),i.push(r.normalMapUv),i.push(r.displacementMapUv),i.push(r.emissiveMapUv),i.push(r.metalnessMapUv),i.push(r.roughnessMapUv),i.push(r.clearcoatMapUv),i.push(r.clearcoatNormalMapUv),i.push(r.clearcoatRoughnessMapUv),i.push(r.iridescenceMapUv),i.push(r.iridescenceThicknessMapUv),i.push(r.sheenColorMapUv),i.push(r.sheenRoughnessMapUv),i.push(r.specularMapUv),i.push(r.specularColorMapUv),i.push(r.specularIntensityMapUv),i.push(r.transmissionMapUv),i.push(r.thicknessMapUv),i.push(r.combine),i.push(r.fogExp2),i.push(r.sizeAttenuation),i.push(r.morphTargetsCount),i.push(r.morphAttributeCount),i.push(r.numDirLights),i.push(r.numPointLights),i.push(r.numSpotLights),i.push(r.numSpotLightMaps),i.push(r.numHemiLights),i.push(r.numRectAreaLights),i.push(r.numDirLightShadows),i.push(r.numPointLightShadows),i.push(r.numSpotLightShadows),i.push(r.numSpotLightShadowsWithMaps),i.push(r.shadowMapType),i.push(r.toneMapping),i.push(r.numClippingPlanes),i.push(r.numClipIntersection),i.push(r.depthPacking),i=n,r=t,o.disableAll(),r.isWebGL2&&o.enable(0),r.supportsVertexTextures&&o.enable(1),r.instancing&&o.enable(2),r.instancingColor&&o.enable(3),r.matcap&&o.enable(4),r.envMap&&o.enable(5),r.normalMapObjectSpace&&o.enable(6),r.normalMapTangentSpace&&o.enable(7),r.clearcoat&&o.enable(8),r.iridescence&&o.enable(9),r.alphaTest&&o.enable(10),r.vertexColors&&o.enable(11),r.vertexAlphas&&o.enable(12),r.vertexUv1s&&o.enable(13),r.vertexUv2s&&o.enable(14),r.vertexUv3s&&o.enable(15),r.vertexTangents&&o.enable(16),i.push(o.mask),o.disableAll(),r.fog&&o.enable(0),r.useFog&&o.enable(1),r.flatShading&&o.enable(2),r.logarithmicDepthBuffer&&o.enable(3),r.skinning&&o.enable(4),r.morphTargets&&o.enable(5),r.morphNormals&&o.enable(6),r.morphColors&&o.enable(7),r.premultipliedAlpha&&o.enable(8),r.shadowMapEnabled&&o.enable(9),r.useLegacyLights&&o.enable(10),r.doubleSided&&o.enable(11),r.flipSided&&o.enable(12),r.useDepthPacking&&o.enable(13),r.dithering&&o.enable(14),r.transmission&&o.enable(15),r.sheen&&o.enable(16),r.opaque&&o.enable(17),r.pointsUvs&&o.enable(18),i.push(o.mask),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){var t=m[e.type];return t?(t=ja[t],Aa.clone(t.uniforms)):e.uniforms},acquireProgram:function(t,i){let r;for(let e=0,t=h.length;e<t;e++){var n=h[e];if(n.cacheKey===i){++(r=n).usedTimes;break}}return void 0===r&&(r=new Bo(e,i,t,a),h.push(r)),r},releaseProgram:function(e){var t;0==--e.usedTimes&&(t=h.indexOf(e),h[t]=h[h.length-1],h.pop(),e.destroy())},releaseShaderCache:function(e){l.remove(e)},programs:h,dispose:function(){l.dispose()}}}function Vo(){let e=new WeakMap;return{get:function(t){let i=e.get(t);return void 0===i&&(i={},e.set(t,i)),i},remove:function(t){e.delete(t)},update:function(t,i,r){e.get(t)[i]=r},dispose:function(){e=new WeakMap}}}function Wo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Xo(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function jo(){const e=[];let t=0;const i=[],r=[],n=[];function a(i,r,n,a,s,o){let l=e[t];return void 0===l?(l={id:i.id,object:i,geometry:r,material:n,groupOrder:a,renderOrder:i.renderOrder,z:s,group:o},e[t]=l):(l.id=i.id,l.object=i,l.geometry=r,l.material=n,l.groupOrder=a,l.renderOrder=i.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:i,transmissive:r,transparent:n,init:function(){t=0,i.length=0,r.length=0,n.length=0},push:function(e,t,s,o,l,h){e=a(e,t,s,o,l,h),(0<s.transmission?r:!0===s.transparent?n:i).push(e)},unshift:function(e,t,s,o,l,h){e=a(e,t,s,o,l,h),(0<s.transmission?r:!0===s.transparent?n:i).unshift(e)},finish:function(){for(let r=t,n=e.length;r<n;r++){var i=e[r];if(null===i.id)break;i.id=null,i.object=null,i.geometry=null,i.material=null,i.group=null}},sort:function(e,t){1<i.length&&i.sort(e||Wo),1<r.length&&r.sort(t||Xo),1<n.length&&n.sort(t||Xo)}}}function qo(){let e=new WeakMap;return{get:function(t,i){var r=e.get(t);let n;return void 0===r?(n=new jo,e.set(t,[n])):i>=r.length?(n=new jo,r.push(n)):n=r[i],n},dispose:function(){e=new WeakMap}}}function Yo(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":i={direction:new hr,color:new Ln};break;case"SpotLight":i={position:new hr,direction:new hr,color:new Ln,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new hr,color:new Ln,distance:0,decay:0};break;case"HemisphereLight":i={direction:new hr,skyColor:new Ln,groundColor:new Ln};break;case"RectAreaLight":i={color:new Ln,position:new hr,halfWidth:new hr,halfHeight:new hr}}return e[t.id]=i}}}let Zo=0;function Jo(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Ko(e,t){const i=new Yo,r=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let i;switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ui};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ui,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i}}}(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)n.probe.push(new hr);const a=new hr,s=new zr,o=new zr;return{setup:function(a,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)n.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,m=0,f=0,g=0,v=0,_=0,x=0;a.sort(Jo);var y=!0===s?Math.PI:1;for(let e=0,t=a.length;e<t;e++){var M,S,b,E,T=a[e],w=T.color,A=T.intensity,R=T.distance,C=T.shadow&&T.shadow.map?T.shadow.map.texture:null;if(T.isAmbientLight)o+=w.r*A*y,l+=w.g*A*y,h+=w.b*A*y;else if(T.isLightProbe)for(let e=0;e<9;e++)n.probe[e].addScaledVector(T.sh.coefficients[e],A);else T.isDirectionalLight?((b=i.get(T)).color.copy(T.color).multiplyScalar(T.intensity*y),T.castShadow&&(M=T.shadow,(S=r.get(T)).shadowBias=M.bias,S.shadowNormalBias=M.normalBias,S.shadowRadius=M.radius,S.shadowMapSize=M.mapSize,n.directionalShadow[c]=S,n.directionalShadowMap[c]=C,n.directionalShadowMatrix[c]=T.shadow.matrix,f++),n.directional[c]=b,c++):T.isSpotLight?((M=i.get(T)).position.setFromMatrixPosition(T.matrixWorld),M.color.copy(w).multiplyScalar(A*y),M.distance=R,M.coneCos=Math.cos(T.angle),M.penumbraCos=Math.cos(T.angle*(1-T.penumbra)),M.decay=T.decay,n.spot[d]=M,S=T.shadow,T.map&&(n.spotLightMap[_]=T.map,_++,S.updateMatrices(T),T.castShadow)&&x++,n.spotLightMatrix[d]=S.matrix,T.castShadow&&((b=r.get(T)).shadowBias=S.bias,b.shadowNormalBias=S.normalBias,b.shadowRadius=S.radius,b.shadowMapSize=S.mapSize,n.spotShadow[d]=b,n.spotShadowMap[d]=C,v++),d++):T.isRectAreaLight?((R=i.get(T)).color.copy(w).multiplyScalar(A),R.halfWidth.set(.5*T.width,0,0),R.halfHeight.set(0,.5*T.height,0),n.rectArea[p]=R,p++):T.isPointLight?((w=i.get(T)).color.copy(T.color).multiplyScalar(T.intensity*y),w.distance=T.distance,w.decay=T.decay,T.castShadow&&(R=T.shadow,(E=r.get(T)).shadowBias=R.bias,E.shadowNormalBias=R.normalBias,E.shadowRadius=R.radius,E.shadowMapSize=R.mapSize,E.shadowCameraNear=R.camera.near,E.shadowCameraFar=R.camera.far,n.pointShadow[u]=E,n.pointShadowMap[u]=C,n.pointShadowMatrix[u]=T.shadow.matrix,g++),n.point[u]=w,u++):T.isHemisphereLight&&((R=i.get(T)).skyColor.copy(T.color).multiplyScalar(A*y),R.groundColor.copy(T.groundColor).multiplyScalar(A*y),n.hemi[m]=R,m++)}0<p&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(n.rectAreaLTC1=Xa.LTC_FLOAT_1,n.rectAreaLTC2=Xa.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(n.rectAreaLTC1=Xa.LTC_HALF_1,n.rectAreaLTC2=Xa.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),n.ambient[0]=o,n.ambient[1]=l,n.ambient[2]=h,(s=n.hash).directionalLength===c&&s.pointLength===u&&s.spotLength===d&&s.rectAreaLength===p&&s.hemiLength===m&&s.numDirectionalShadows===f&&s.numPointShadows===g&&s.numSpotShadows===v&&s.numSpotMaps===_||(n.directional.length=c,n.spot.length=d,n.rectArea.length=p,n.point.length=u,n.hemi.length=m,n.directionalShadow.length=f,n.directionalShadowMap.length=f,n.pointShadow.length=g,n.pointShadowMap.length=g,n.spotShadow.length=v,n.spotShadowMap.length=v,n.directionalShadowMatrix.length=f,n.pointShadowMatrix.length=g,n.spotLightMatrix.length=v+_-x,n.spotLightMap.length=_,n.numSpotLightShadowsWithMaps=x,s.directionalLength=c,s.pointLength=u,s.spotLength=d,s.rectAreaLength=p,s.hemiLength=m,s.numDirectionalShadows=f,s.numPointShadows=g,s.numSpotShadows=v,s.numSpotMaps=_,n.version=Zo++)},setupView:function(e,t){let i=0,r=0,l=0,h=0,c=0;var u=t.matrixWorldInverse;for(let t=0,g=e.length;t<g;t++){var d,p,m,f=e[t];f.isDirectionalLight?((d=n.directional[i]).direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),d.direction.sub(a),d.direction.transformDirection(u),i++):f.isSpotLight?((d=n.spot[l]).position.setFromMatrixPosition(f.matrixWorld),d.position.applyMatrix4(u),d.direction.setFromMatrixPosition(f.matrixWorld),a.setFromMatrixPosition(f.target.matrixWorld),d.direction.sub(a),d.direction.transformDirection(u),l++):f.isRectAreaLight?((p=n.rectArea[h]).position.setFromMatrixPosition(f.matrixWorld),p.position.applyMatrix4(u),o.identity(),s.copy(f.matrixWorld),s.premultiply(u),o.extractRotation(s),p.halfWidth.set(.5*f.width,0,0),p.halfHeight.set(0,.5*f.height,0),p.halfWidth.applyMatrix4(o),p.halfHeight.applyMatrix4(o),h++):f.isPointLight?((p=n.point[r]).position.setFromMatrixPosition(f.matrixWorld),p.position.applyMatrix4(u),r++):f.isHemisphereLight&&((m=n.hemi[c]).direction.setFromMatrixPosition(f.matrixWorld),m.direction.transformDirection(u),c++)}},state:n}}function Qo(e,t){const i=new Ko(e,t),r=[],n=[];return{init:function(){r.length=0,n.length=0},state:{lightsArray:r,shadowsArray:n,lights:i},setupLights:function(e){i.setup(r,e)},setupLightsView:function(e){i.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){n.push(e)}}}function $o(e,t){let i=new WeakMap;return{get:function(r,n=0){var a=i.get(r);let s;return void 0===a?(s=new Qo(e,t),i.set(r,[s])):n>=a.length?(s=new Qo(e,t),a.push(s)):s=a[n],s},dispose:function(){i=new WeakMap}}}class el extends Tn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ot,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class tl extends Tn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function il(e,t,i){let r=new Ga;const n=new Ui,a=new Ui,s=new tr,o=new el({depthPacking:Ft}),l=new tl,h={},c=i.maxTextureSize,d={[m]:f,[f]:m,[g]:g},v=new Ra({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ui},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),x=v.clone();x.defines.HORIZONTAL_PASS=1,(i=new ra).setAttribute("position",new zn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Ma(i,v),M=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=u;let S=this.type;function b(t,i,r,n){let a=null;if(void 0!==(t=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial))a=t;else if(a=!0===r.isPointLight?l:o,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&0<i.alphaTest||i.map&&0<i.alphaTest){t=a.uuid;var s=i.uuid;let e=h[t],r=(void 0===e&&(e={},h[t]=e),e[s]);void 0===r&&(r=a.clone(),e[s]=r),a=r}return a.visible=i.visible,a.wireframe=i.wireframe,a.side=n===p?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:d[i.side],a.alphaMap=i.alphaMap,a.alphaTest=i.alphaTest,a.map=i.map,a.clipShadows=i.clipShadows,a.clippingPlanes=i.clippingPlanes,a.clipIntersection=i.clipIntersection,a.displacementMap=i.displacementMap,a.displacementScale=i.displacementScale,a.displacementBias=i.displacementBias,a.wireframeLinewidth=i.wireframeLinewidth,a.linewidth=i.linewidth,!0===r.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=r),a}this.render=function(i,o,l){if(!1!==M.enabled&&(!1!==M.autoUpdate||!1!==M.needsUpdate)&&0!==i.length){var h=e.getRenderTarget(),u=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),m=e.state,f=(m.setBlending(_),m.buffers.color.setClear(1,1,1,1),m.buffers.depth.setTest(!0),m.setScissorTest(!1),S!==p&&this.type===p),g=S===p&&this.type!==p;for(let h=0,u=i.length;h<u;h++){var E=i[h],T=E.shadow;if(void 0===T)console.warn("THREE.WebGLShadowMap:",E,"has no shadow.");else if(!1!==T.autoUpdate||!1!==T.needsUpdate){n.copy(T.mapSize);var w,A,R=T.getFrameExtents(),C=(n.multiply(R),a.copy(T.mapSize),(n.x>c||n.y>c)&&(n.x>c&&(a.x=Math.floor(c/R.x),n.x=a.x*R.x,T.mapSize.x=a.x),n.y>c)&&(a.y=Math.floor(c/R.y),n.y=a.y*R.y,T.mapSize.y=a.y),null!==T.map&&1!=f&&1!=g||(R=this.type!==p?{minFilter:de,magFilter:de}:{},null!==T.map&&T.map.dispose(),T.map=new ir(n.x,n.y,R),T.map.texture.name=E.name+".shadowMap",T.camera.updateProjectionMatrix()),e.setRenderTarget(T.map),e.clear(),T.getViewportCount());for(let i=0;i<C;i++){var L=T.getViewport(i);s.set(a.x*L.x,a.y*L.y,a.x*L.z,a.y*L.w),m.viewport(s),T.updateMatrices(E,i),r=T.getFrustum(),function i(n,a,s,o,l){if(!1===n.visible)return;if(n.layers.test(a.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&l===p)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let a=0,h=t.length;a<h;a++){const h=t[a],c=r[h.materialIndex];if(c&&c.visible){const t=b(n,c,o,l);e.renderBufferDirect(s,null,i,t,n,h)}}}else if(r.visible){const t=b(n,r,o,l);e.renderBufferDirect(s,null,i,t,n,null)}}const h=n.children;for(let e=0,t=h.length;e<t;e++)i(h[e],a,s,o,l)}(o,l,T.camera,E,this.type)}!0!==T.isPointLightShadow&&this.type===p&&(R=void 0,R=T,w=l,A=t.update(y),v.defines.VSM_SAMPLES!==R.blurSamples&&(v.defines.VSM_SAMPLES=R.blurSamples,x.defines.VSM_SAMPLES=R.blurSamples,v.needsUpdate=!0,x.needsUpdate=!0),null===R.mapPass&&(R.mapPass=new ir(n.x,n.y)),v.uniforms.shadow_pass.value=R.map.texture,v.uniforms.resolution.value=R.mapSize,v.uniforms.radius.value=R.radius,e.setRenderTarget(R.mapPass),e.clear(),e.renderBufferDirect(w,null,A,v,y,null),x.uniforms.shadow_pass.value=R.mapPass.texture,x.uniforms.resolution.value=R.mapSize,x.uniforms.radius.value=R.radius,e.setRenderTarget(R.map),e.clear(),e.renderBufferDirect(w,null,A,x,y,null)),T.needsUpdate=!1}}S=this.type,M.needsUpdate=!1,e.setRenderTarget(h,u,d)}}}function rl(e,t,i){const r=i.isWebGL2,n=new function(){let t=!1;const i=new tr;let r=null;const n=new tr(0,0,0,0);return{setMask:function(i){r===i||t||(e.colorMask(i,i,i,i),r=i)},setLocked:function(e){t=e},setClear:function(t,r,a,s,o){!0===o&&(t*=s,r*=s,a*=s),i.set(t,r,a,s),!1===n.equals(i)&&(e.clearColor(t,r,a,s),n.copy(i))},reset:function(){t=!1,r=null,n.set(-1,0,0,0)}}},a=new function(){let t=!1,i=null,r=null,n=null;return{setTest:function(t){(t?ye:Me)(e.DEPTH_TEST)},setMask:function(r){i===r||t||(e.depthMask(r),i=r)},setFunc:function(t){if(r!==t){switch(t){case G:e.depthFunc(e.NEVER);break;case H:e.depthFunc(e.ALWAYS);break;case k:e.depthFunc(e.LESS);break;case V:e.depthFunc(e.LEQUAL);break;case W:e.depthFunc(e.EQUAL);break;case X:e.depthFunc(e.GEQUAL);break;case j:e.depthFunc(e.GREATER);break;case q:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}r=t}},setLocked:function(e){t=e},setClear:function(t){n!==t&&(e.clearDepth(t),n=t)},reset:function(){t=!1,i=null,r=null,n=null}}},h=new function(){let t=!1,i=null,r=null,n=null,a=null,s=null,o=null,l=null,h=null;return{setTest:function(i){t||(i?ye:Me)(e.STENCIL_TEST)},setMask:function(r){i===r||t||(e.stencilMask(r),i=r)},setFunc:function(t,i,s){r===t&&n===i&&a===s||(e.stencilFunc(t,i,s),r=t,n=i,a=s)},setOp:function(t,i,r){s===t&&o===i&&l===r||(e.stencilOp(t,i,r),s=t,o=i,l=r)},setLocked:function(e){t=e},setClear:function(t){h!==t&&(e.clearStencil(t),h=t)},reset:function(){t=!1,i=null,r=null,n=null,a=null,s=null,o=null,l=null,h=null}}},c=new WeakMap,u=new WeakMap;let d={},p={},m=new WeakMap,v=[],Y=null,Z=!1,J=null,K=null,Q=null,$=null,ee=null,te=null,ie=null,re=!1,ne=null,ae=null,se=null,oe=null,le=null;const he=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let ce=!1,ue=0;-1!==(me=e.getParameter(e.VERSION)).indexOf("WebGL")?(ue=parseFloat(/^WebGL (\d)/.exec(me)[1]),ce=1<=ue):-1!==me.indexOf("OpenGL ES")&&(ue=parseFloat(/^OpenGL ES (\d)/.exec(me)[1]),ce=2<=ue);let de=null,pe={};var me=e.getParameter(e.SCISSOR_BOX),fe=e.getParameter(e.VIEWPORT);const ge=(new tr).fromArray(me),ve=(new tr).fromArray(fe);function _e(t,i,n,a){var s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<n;o++)!r||t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY?e.texImage2D(i+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,s):e.texImage3D(i,0,e.RGBA,1,1,a,0,e.RGBA,e.UNSIGNED_BYTE,s);return o}const xe={};function ye(t){!0!==d[t]&&(e.enable(t),d[t]=!0)}function Me(t){!1!==d[t]&&(e.disable(t),d[t]=!1)}xe[e.TEXTURE_2D]=_e(e.TEXTURE_2D,e.TEXTURE_2D,1),xe[e.TEXTURE_CUBE_MAP]=_e(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(xe[e.TEXTURE_2D_ARRAY]=_e(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),xe[e.TEXTURE_3D]=_e(e.TEXTURE_3D,e.TEXTURE_3D,1,1)),n.setClear(0,0,0,1),a.setClear(1),h.setClear(0),ye(e.DEPTH_TEST),a.setFunc(V),Te(!1),we(o),ye(e.CULL_FACE),Ee(_);const Se={[E]:e.FUNC_ADD,[T]:e.FUNC_SUBTRACT,[w]:e.FUNC_REVERSE_SUBTRACT},be=(r?(Se[A]=e.MIN,Se[R]=e.MAX):null!==(me=t.get("EXT_blend_minmax"))&&(Se[A]=me.MIN_EXT,Se[R]=me.MAX_EXT),{[C]:e.ZERO,[L]:e.ONE,[P]:e.SRC_COLOR,[U]:e.SRC_ALPHA,[z]:e.SRC_ALPHA_SATURATE,[F]:e.DST_COLOR,[N]:e.DST_ALPHA,[I]:e.ONE_MINUS_SRC_COLOR,[D]:e.ONE_MINUS_SRC_ALPHA,[B]:e.ONE_MINUS_DST_COLOR,[O]:e.ONE_MINUS_DST_ALPHA});function Ee(t,i,r,n,a,s,o,l){if(t===_)!0===Z&&(Me(e.BLEND),Z=!1);else if(!1===Z&&(ye(e.BLEND),Z=!0),t!==b){if(t!==J||l!==re){if(K===E&&ee===E||(e.blendEquation(e.FUNC_ADD),K=E,ee=E),l)switch(t){case x:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case y:e.blendFunc(e.ONE,e.ONE);break;case M:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case S:e.blendFuncSeparate(e.ZERO,e.SRC_COLOR,e.ZERO,e.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case x:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case y:e.blendFunc(e.SRC_ALPHA,e.ONE);break;case M:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case S:e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}Q=null,$=null,te=null,ie=null,J=t,re=l}}else a=a||i,s=s||r,o=o||n,i===K&&a===ee||(e.blendEquationSeparate(Se[i],Se[a]),K=i,ee=a),r===Q&&n===$&&s===te&&o===ie||(e.blendFuncSeparate(be[r],be[n],be[s],be[o]),Q=r,$=n,te=s,ie=o),J=t,re=!1}function Te(t){ne!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),ne=t)}function we(t){t!==s?(ye(e.CULL_FACE),t!==ae&&(t===o?e.cullFace(e.BACK):t===l?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))):Me(e.CULL_FACE),ae=t}function Ae(t,i,r){t?(ye(e.POLYGON_OFFSET_FILL),oe===i&&le===r||(e.polygonOffset(i,r),oe=i,le=r)):Me(e.POLYGON_OFFSET_FILL)}return{buffers:{color:n,depth:a,stencil:h},enable:ye,disable:Me,bindFramebuffer:function(t,i){return p[t]!==i&&(e.bindFramebuffer(t,i),p[t]=i,r&&(t===e.DRAW_FRAMEBUFFER&&(p[e.FRAMEBUFFER]=i),t===e.FRAMEBUFFER)&&(p[e.DRAW_FRAMEBUFFER]=i),!0)},drawBuffers:function(r,n){let a=v,s=!1;if(r)if(void 0===(a=m.get(n))&&(a=[],m.set(n,a)),r.isWebGLMultipleRenderTargets){if(n=r.texture,a.length!==n.length||a[0]!==e.COLOR_ATTACHMENT0){for(let t=0,i=n.length;t<i;t++)a[t]=e.COLOR_ATTACHMENT0+t;a.length=n.length,s=!0}}else a[0]!==e.COLOR_ATTACHMENT0&&(a[0]=e.COLOR_ATTACHMENT0,s=!0);else a[0]!==e.BACK&&(a[0]=e.BACK,s=!0);s&&(i.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(t){return Y!==t&&(e.useProgram(t),Y=t,!0)},setBlending:Ee,setMaterial:function(t,i){(t.side===g?Me:ye)(e.CULL_FACE);let r=t.side===f;Te(r=i?!r:r),t.blending===x&&!1===t.transparent?Ee(_):Ee(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),n.setMask(t.colorWrite),i=t.stencilWrite,h.setTest(i),i&&(h.setMask(t.stencilWriteMask),h.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),h.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),Ae(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),(!0===t.alphaToCoverage?ye:Me)(e.SAMPLE_ALPHA_TO_COVERAGE)},setFlipSided:Te,setCullFace:we,setLineWidth:function(t){t!==se&&(ce&&e.lineWidth(t),se=t)},setPolygonOffset:Ae,setScissorTest:function(t){(t?ye:Me)(e.SCISSOR_TEST)},activeTexture:function(t){void 0===t&&(t=e.TEXTURE0+he-1),de!==t&&(e.activeTexture(t),de=t)},bindTexture:function(t,i,r){void 0===r&&(r=null===de?e.TEXTURE0+he-1:de);let n=pe[r];void 0===n&&(n={type:void 0,texture:void 0},pe[r]=n),n.type===t&&n.texture===i||(de!==r&&(e.activeTexture(r),de=r),e.bindTexture(t,i||xe[t]),n.type=t,n.texture=i)},unbindTexture:function(){var t=pe[de];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,i){let r=u.get(i);void 0===r&&(r=new WeakMap,u.set(i,r)),void 0===r.get(t)&&(i=e.getUniformBlockIndex(i,t.name),r.set(t,i))},uniformBlockBinding:function(t,i){var r=u.get(i).get(t);c.get(i)!==r&&(e.uniformBlockBinding(i,r,t.__bindingPointIndex),c.set(i,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===ge.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),ge.copy(t))},viewport:function(t){!1===ve.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),ve.copy(t))},reset:function(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),!0===r&&(e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),d={},de=null,pe={},p={},m=new WeakMap,v=[],Y=null,Z=!1,J=null,K=null,Q=null,$=null,ee=null,te=null,ie=null,re=!1,ne=null,ae=null,se=null,oe=null,le=null,ge.set(0,0,e.canvas.width,e.canvas.height),ve.set(0,0,e.canvas.width,e.canvas.height),n.reset(),a.reset(),h.reset()}}}function nl(e,t,i,r,n,a,s){const o=n.isWebGL2,l=n.maxTextures,h=n.maxCubemapSize,c=n.maxTextureSize,u=n.maxSamples,d=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap;let f;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function _(e,t){return v?new OffscreenCanvas(e,t):zi("canvas")}function x(e,t,i,r){let n=1;return(n=e.width>r||e.height>r?r/Math.max(e.width,e.height):n)<1||!0===t?"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?(t=(r=t?Ci:Math.floor)(n*e.width),r=r(n*e.height),void 0===f&&(f=_(t,r)),(i=i?_(t,r):f).width=t,i.height=r,i.getContext("2d").drawImage(e,0,0,t,r),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+t+"x"+r+")."),i):("data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e):e}function y(e){return Ai(e.width)&&Ai(e.height)}function M(e,t){return e.generateMipmaps&&t&&e.minFilter!==de&&e.minFilter!==ve}function S(t){e.generateMipmap(t)}function b(i,r,n,a,s=!1){if(!1===o)return r;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=r;return r===e.RED&&(n===e.FLOAT&&(l=e.R32F),n===e.HALF_FLOAT&&(l=e.R16F),n===e.UNSIGNED_BYTE)&&(l=e.R8),r===e.RG&&(n===e.FLOAT&&(l=e.RG32F),n===e.HALF_FLOAT&&(l=e.RG16F),n===e.UNSIGNED_BYTE)&&(l=e.RG8),(l=r===e.RGBA&&(n===e.FLOAT&&(l=e.RGBA32F),n===e.HALF_FLOAT&&(l=e.RGBA16F),n===e.UNSIGNED_BYTE&&(l=a===Ht&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),n===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),n===e.UNSIGNED_SHORT_5_5_5_1)?e.RGB5_A1:l)!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function E(e,t,i){return!0===M(e,i)||e.isFramebufferTexture&&e.minFilter!==de&&e.minFilter!==ve?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&0<e.mipmaps.length?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function T(t){return t===de||t===pe||t===fe?e.NEAREST:e.LINEAR}function w(e){var t,i,n,a;(e=e.target).removeEventListener("dispose",w),t=e,void 0!==(i=r.get(t)).__webglInit&&(n=t.source,(a=g.get(n))&&((i=a[i.__cacheKey]).usedTimes--,0===i.usedTimes&&R(t),0===Object.keys(a).length)&&g.delete(n),r.remove(t)),e.isVideoTexture&&m.delete(e)}function A(t){var i=((t=t.target).removeEventListener("dispose",A),t.texture),n=r.get(t),a=r.get(i);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(n.__webglFramebuffer),n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,n=i.length;t<n;t++){var o=r.get(i[t]);o.__webglTexture&&(e.deleteTexture(o.__webglTexture),s.memory.textures--),r.remove(i[t])}r.remove(i),r.remove(t)}function R(t){var i=r.get(t);e.deleteTexture(i.__webglTexture),t=t.source,delete g.get(t)[i.__cacheKey],s.memory.textures--}let C=0;function L(t,n){var a,o=r.get(t);if(t.isVideoTexture&&(a=t,l=s.render.frame,m.get(a)!==l)&&(m.set(a,l),a.update()),!1===t.isRenderTargetTexture&&0<t.version&&o.__version!==t.version){var l=t.image;if(null===l)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==l.complete)return void N(o,t,n);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.bindTexture(e.TEXTURE_2D,o.__webglTexture,e.TEXTURE0+n)}const P={[he]:e.REPEAT,[ce]:e.CLAMP_TO_EDGE,[ue]:e.MIRRORED_REPEAT},I={[de]:e.NEAREST,[pe]:e.NEAREST_MIPMAP_NEAREST,[fe]:e.NEAREST_MIPMAP_LINEAR,[ve]:e.LINEAR,[_e]:e.LINEAR_MIPMAP_NEAREST,[ye]:e.LINEAR_MIPMAP_LINEAR};function U(i,a,s){s?(e.texParameteri(i,e.TEXTURE_WRAP_S,P[a.wrapS]),e.texParameteri(i,e.TEXTURE_WRAP_T,P[a.wrapT]),i!==e.TEXTURE_3D&&i!==e.TEXTURE_2D_ARRAY||e.texParameteri(i,e.TEXTURE_WRAP_R,P[a.wrapR]),e.texParameteri(i,e.TEXTURE_MAG_FILTER,I[a.magFilter]),e.texParameteri(i,e.TEXTURE_MIN_FILTER,I[a.minFilter])):(e.texParameteri(i,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(i,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),i!==e.TEXTURE_3D&&i!==e.TEXTURE_2D_ARRAY||e.texParameteri(i,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),a.wrapS===ce&&a.wrapT===ce||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,e.TEXTURE_MAG_FILTER,T(a.magFilter)),e.texParameteri(i,e.TEXTURE_MIN_FILTER,T(a.minFilter)),a.minFilter!==de&&a.minFilter!==ve&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")&&(s=t.get("EXT_texture_filter_anisotropic"),a.magFilter===de||a.minFilter!==fe&&a.minFilter!==ye||a.type===Re&&!1===t.has("OES_texture_float_linear")||!1===o&&a.type===Ce&&!1===t.has("OES_texture_half_float_linear")||(1<a.anisotropy||r.get(a).__currentAnisotropy)&&(e.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,n.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy))}function D(t,i){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",w));var n=i.source;let a=g.get(n);void 0===a&&(a={},g.set(n,a)),(n=[]).push((o=i).wrapS),n.push(o.wrapT),n.push(o.wrapR||0),n.push(o.magFilter),n.push(o.minFilter),n.push(o.anisotropy),n.push(o.internalFormat),n.push(o.format),n.push(o.type),n.push(o.generateMipmaps),n.push(o.premultiplyAlpha),n.push(o.flipY),n.push(o.unpackAlignment),n.push(o.colorSpace);var o=n.join();return o!==t.__cacheKey&&(void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),a[o].usedTimes++,void 0!==(n=a[t.__cacheKey])&&(a[t.__cacheKey].usedTimes--,0===n.usedTimes)&&R(i),t.__cacheKey=o,t.__webglTexture=a[o].texture),r}function N(t,n,s){let l=e.TEXTURE_2D;(n.isDataArrayTexture||n.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),n.isData3DTexture&&(l=e.TEXTURE_3D);var h=D(t,n),u=n.source,d=(i.bindTexture(l,t.__webglTexture,e.TEXTURE0+s),r.get(u));if(u.version!==d.__version||!0===h){i.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,n.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,n.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),s=n,s=!o&&(s.wrapS!==ce||s.wrapT!==ce||s.minFilter!==de&&s.minFilter!==ve)&&!1===y(n.image),s=y(p=H(n,x(n.image,s,!1,c)))||o;var p,m=a.convert(n.format,n.colorSpace);let t,r=a.convert(n.type),_=b(n.internalFormat,m,r,n.colorSpace);U(l,n,s);var f=n.mipmaps,g=o&&!0!==n.isVideoTexture,v=(h=void 0===d.__version||!0===h,E(n,p,s));if(n.isDepthTexture)_=e.DEPTH_COMPONENT,o?_=n.type===Re?e.DEPTH_COMPONENT32F:n.type===Ae?e.DEPTH_COMPONENT24:n.type===Ie?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:n.type===Re&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===Fe&&_===e.DEPTH_COMPONENT&&n.type!==Te&&n.type!==Ae&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=Ae,r=a.convert(n.type)),n.format===Be&&_===e.DEPTH_COMPONENT&&(_=e.DEPTH_STENCIL,n.type!==Ie)&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=Ie,r=a.convert(n.type)),h&&(g?i.texStorage2D(e.TEXTURE_2D,1,_,p.width,p.height):i.texImage2D(e.TEXTURE_2D,0,_,p.width,p.height,0,m,r,null));else if(n.isDataTexture)if(0<f.length&&s){g&&h&&i.texStorage2D(e.TEXTURE_2D,v,_,f[0].width,f[0].height);for(let n=0,a=f.length;n<a;n++)t=f[n],g?i.texSubImage2D(e.TEXTURE_2D,n,0,0,t.width,t.height,m,r,t.data):i.texImage2D(e.TEXTURE_2D,n,_,t.width,t.height,0,m,r,t.data);n.generateMipmaps=!1}else g?(h&&i.texStorage2D(e.TEXTURE_2D,v,_,p.width,p.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,p.width,p.height,m,r,p.data)):i.texImage2D(e.TEXTURE_2D,0,_,p.width,p.height,0,m,r,p.data);else if(n.isCompressedTexture)if(n.isCompressedArrayTexture){g&&h&&i.texStorage3D(e.TEXTURE_2D_ARRAY,v,_,f[0].width,f[0].height,p.depth);for(let a=0,s=f.length;a<s;a++)t=f[a],n.format!==De?null!==m?g?i.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,t.width,t.height,p.depth,m,t.data,0,0):i.compressedTexImage3D(e.TEXTURE_2D_ARRAY,a,_,t.width,t.height,p.depth,0,t.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):g?i.texSubImage3D(e.TEXTURE_2D_ARRAY,a,0,0,0,t.width,t.height,p.depth,m,r,t.data):i.texImage3D(e.TEXTURE_2D_ARRAY,a,_,t.width,t.height,p.depth,0,m,r,t.data)}else{g&&h&&i.texStorage2D(e.TEXTURE_2D,v,_,f[0].width,f[0].height);for(let a=0,s=f.length;a<s;a++)t=f[a],n.format!==De?null!==m?g?i.compressedTexSubImage2D(e.TEXTURE_2D,a,0,0,t.width,t.height,m,t.data):i.compressedTexImage2D(e.TEXTURE_2D,a,_,t.width,t.height,0,t.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):g?i.texSubImage2D(e.TEXTURE_2D,a,0,0,t.width,t.height,m,r,t.data):i.texImage2D(e.TEXTURE_2D,a,_,t.width,t.height,0,m,r,t.data)}else if(n.isDataArrayTexture)g?(h&&i.texStorage3D(e.TEXTURE_2D_ARRAY,v,_,p.width,p.height,p.depth),i.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,r,p.data)):i.texImage3D(e.TEXTURE_2D_ARRAY,0,_,p.width,p.height,p.depth,0,m,r,p.data);else if(n.isData3DTexture)g?(h&&i.texStorage3D(e.TEXTURE_3D,v,_,p.width,p.height,p.depth),i.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,r,p.data)):i.texImage3D(e.TEXTURE_3D,0,_,p.width,p.height,p.depth,0,m,r,p.data);else if(n.isFramebufferTexture){if(h)if(g)i.texStorage2D(e.TEXTURE_2D,v,_,p.width,p.height);else{let t=p.width,n=p.height;for(let a=0;a<v;a++)i.texImage2D(e.TEXTURE_2D,a,_,t,n,0,m,r,null),t>>=1,n>>=1}}else if(0<f.length&&s){g&&h&&i.texStorage2D(e.TEXTURE_2D,v,_,f[0].width,f[0].height);for(let n=0,a=f.length;n<a;n++)t=f[n],g?i.texSubImage2D(e.TEXTURE_2D,n,0,0,m,r,t):i.texImage2D(e.TEXTURE_2D,n,_,m,r,t);n.generateMipmaps=!1}else g?(h&&i.texStorage2D(e.TEXTURE_2D,v,_,p.width,p.height),i.texSubImage2D(e.TEXTURE_2D,0,0,0,m,r,p)):i.texImage2D(e.TEXTURE_2D,0,_,m,r,p);M(n,s)&&S(l),d.__version=u.version,n.onUpdate&&n.onUpdate(n)}t.__version=n.version}function O(t,n,s,o,l){var h=a.convert(s.format,s.colorSpace),c=a.convert(s.type),u=b(s.internalFormat,h,c,s.colorSpace);r.get(n).__hasExternalTextures||(l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?i.texImage3D(l,0,u,n.width,n.height,n.depth,0,h,c,null):i.texImage2D(l,0,u,n.width,n.height,0,h,c,null)),i.bindFramebuffer(e.FRAMEBUFFER,t),G(n)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,r.get(s).__webglTexture,0,z(n)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,r.get(s).__webglTexture,0),i.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,i,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),i.depthBuffer&&!i.stencilBuffer){let a=e.DEPTH_COMPONENT16;r||G(i)?((n=i.depthTexture)&&n.isDepthTexture&&(n.type===Re?a=e.DEPTH_COMPONENT32F:n.type===Ae&&(a=e.DEPTH_COMPONENT24)),n=z(i),G(i)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,n,a,i.width,i.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,n,a,i.width,i.height)):e.renderbufferStorage(e.RENDERBUFFER,a,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(i.depthBuffer&&i.stencilBuffer){var n=z(i);r&&!1===G(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,n,e.DEPTH24_STENCIL8,i.width,i.height):G(i)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,n,e.DEPTH24_STENCIL8,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i.width,i.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{var s=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let t=0;t<s.length;t++){var o=s[t],l=a.convert(o.format,o.colorSpace),h=a.convert(o.type);l=b(o.internalFormat,l,h,o.colorSpace),h=z(i),r&&!1===G(i)?e.renderbufferStorageMultisample(e.RENDERBUFFER,h,l,i.width,i.height):G(i)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,h,l,i.width,i.height):e.renderbufferStorage(e.RENDERBUFFER,l,i.width,i.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function B(t){var n=r.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!n.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");var s=n.__webglFramebuffer,o=t;if(o&&o.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(i.bindFramebuffer(e.FRAMEBUFFER,s),!o.depthTexture||!o.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(o.depthTexture).__webglTexture&&o.depthTexture.image.width===o.width&&o.depthTexture.image.height===o.height||(o.depthTexture.image.width=o.width,o.depthTexture.image.height=o.height,o.depthTexture.needsUpdate=!0),L(o.depthTexture,0),s=r.get(o.depthTexture).__webglTexture;var l=z(o);if(o.depthTexture.format===Fe)G(o)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,s,0);else{if(o.depthTexture.format!==Be)throw new Error("Unknown depthTexture format");G(o)?d.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0,l):e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.TEXTURE_2D,s,0)}}else if(a){n.__webglDepthbuffer=[];for(let r=0;r<6;r++)i.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[r]),n.__webglDepthbuffer[r]=e.createRenderbuffer(),F(n.__webglDepthbuffer[r],t,!1)}else i.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer),n.__webglDepthbuffer=e.createRenderbuffer(),F(n.__webglDepthbuffer,t,!1);i.bindFramebuffer(e.FRAMEBUFFER,null)}function z(e){return Math.min(u,e.samples)}function G(e){var i=r.get(e);return o&&0<e.samples&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function H(e,i){var r=e.colorSpace,n=e.format,a=e.type;return!0!==e.isCompressedTexture&&e.format!==vi&&r!==kt&&r!==Gt&&(r===Ht?!1===o?!0===t.has("EXT_sRGB")&&n===De?(e.format=vi,e.minFilter=ve,e.generateMipmaps=!1):i=Ji.sRGBToLinear(i):n===De&&a===Se||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",r)),i}this.allocateTextureUnit=function(){var e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=L,this.setTexture2DArray=function(t,n){var a=r.get(t);0<t.version&&a.__version!==t.version?N(a,t,n):i.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+n)},this.setTexture3D=function(t,n){var a=r.get(t);0<t.version&&a.__version!==t.version?N(a,t,n):i.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+n)},this.setTextureCube=function(t,n){var s=r.get(t);if(0<t.version&&s.__version!==t.version){var l=s,c=t;if(t=n,6===c.image.length){var u=D(l,c),d=c.source,p=(i.bindTexture(e.TEXTURE_CUBE_MAP,l.__webglTexture,e.TEXTURE0+t),r.get(d));if(d.version!==p.__version||!0===u){i.activeTexture(e.TEXTURE0+t),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,c.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,c.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,c.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);var m=c.isCompressedTexture||c.image[0].isCompressedTexture,f=c.image[0]&&c.image[0].isDataTexture,g=[];for(let e=0;e<6;e++)g[e]=m||f?f?c.image[e].image:c.image[e]:x(c.image[e],!1,!0,h),g[e]=H(c,g[e]);var v=y(t=g[0])||o,_=a.convert(c.format,c.colorSpace),T=a.convert(c.type),w=b(c.internalFormat,_,T,c.colorSpace),A=o&&!0!==c.isVideoTexture;u=void 0===p.__version||!0===u;let r,n=E(c,t,v);if(U(e.TEXTURE_CUBE_MAP,c,v),m){A&&u&&i.texStorage2D(e.TEXTURE_CUBE_MAP,n,w,t.width,t.height);for(let t=0;t<6;t++){r=g[t].mipmaps;for(let n=0;n<r.length;n++){var R=r[n];c.format!==De?null!==_?A?i.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,R.width,R.height,_,R.data):i.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,w,R.width,R.height,0,R.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):A?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,0,0,R.width,R.height,_,T,R.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n,w,R.width,R.height,0,_,T,R.data)}}}else{r=c.mipmaps,A&&u&&(0<r.length&&n++,i.texStorage2D(e.TEXTURE_CUBE_MAP,n,w,g[0].width,g[0].height));for(let t=0;t<6;t++)if(f){A?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g[t].width,g[t].height,_,T,g[t].data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,w,g[t].width,g[t].height,0,_,T,g[t].data);for(let n=0;n<r.length;n++){var C=r[n].image[t].image;A?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,C.width,C.height,_,T,C.data):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,w,C.width,C.height,0,_,T,C.data)}}else{A?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,_,T,g[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,w,_,T,g[t]);for(let n=0;n<r.length;n++){var L=r[n];A?i.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,0,0,_,T,L.image[t]):i.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,n+1,w,_,T,L.image[t])}}}M(c,v)&&S(e.TEXTURE_CUBE_MAP),p.__version=d.version,c.onUpdate&&c.onUpdate(c)}l.__version=c.version}}else i.bindTexture(e.TEXTURE_CUBE_MAP,s.__webglTexture,e.TEXTURE0+n)},this.rebindTextures=function(t,i,n){var a=r.get(t);void 0!==i&&O(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D),void 0!==n&&B(t)},this.setupRenderTarget=function(t){const l=t.texture;var h=r.get(t),c=r.get(l),u=(t.addEventListener("dispose",A),!0!==t.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=e.createTexture()),c.__version=l.version,s.memory.textures++),!0===t.isWebGLCubeRenderTarget),d=!0===t.isWebGLMultipleRenderTargets,p=y(t)||o;if(u){h.__webglFramebuffer=[];for(let t=0;t<6;t++)h.__webglFramebuffer[t]=e.createFramebuffer()}else{if(h.__webglFramebuffer=e.createFramebuffer(),d)if(n.drawBuffers){var m=t.texture;for(let t=0,i=m.length;t<i;t++){var f=r.get(m[t]);void 0===f.__webglTexture&&(f.__webglTexture=e.createTexture(),s.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(o&&0<t.samples&&!1===G(t)){var g=d?l:[l];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],i.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let i=0;i<g.length;i++){const r=g[i];h.__webglColorRenderbuffer[i]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,h.__webglColorRenderbuffer[i]);var v=a.convert(r.format,r.colorSpace),_=a.convert(r.type);v=b(r.internalFormat,v,_,r.colorSpace,!0===t.isXRRenderTarget),_=z(t),e.renderbufferStorageMultisample(e.RENDERBUFFER,_,v,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+i,e.RENDERBUFFER,h.__webglColorRenderbuffer[i])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(h.__webglDepthRenderbuffer=e.createRenderbuffer(),F(h.__webglDepthRenderbuffer,t,!0)),i.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){i.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),U(e.TEXTURE_CUBE_MAP,l,p);for(let i=0;i<6;i++)O(h.__webglFramebuffer[i],t,l,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+i);M(l,p)&&S(e.TEXTURE_CUBE_MAP)}else if(d){var x=t.texture;for(let n=0,a=x.length;n<a;n++){var E=x[n],T=r.get(E);i.bindTexture(e.TEXTURE_2D,T.__webglTexture),U(e.TEXTURE_2D,E,p),O(h.__webglFramebuffer,t,E,e.COLOR_ATTACHMENT0+n,e.TEXTURE_2D),M(E,p)&&S(e.TEXTURE_2D)}}else{let r=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(o?r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),i.bindTexture(r,c.__webglTexture),U(r,l,p),O(h.__webglFramebuffer,t,l,e.COLOR_ATTACHMENT0,r),M(l,p)&&S(r)}i.unbindTexture(),t.depthBuffer&&B(t)},this.updateRenderTargetMipmap=function(t){var n=y(t)||o,a=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let o=0,h=a.length;o<h;o++){var s,l=a[o];M(l,n)&&(s=t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:e.TEXTURE_2D,l=r.get(l).__webglTexture,i.bindTexture(s,l),S(s),i.unbindTexture())}},this.updateMultisampleRenderTarget=function(t){if(o&&0<t.samples&&!1===G(t)){var n=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height;let o=e.COLOR_BUFFER_BIT;var l=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=r.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t<n.length;t++)i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),i.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);i.bindFramebuffer(e.READ_FRAMEBUFFER,c.__webglMultisampledFramebuffer),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let i=0;i<n.length;i++){l.push(e.COLOR_ATTACHMENT0+i),t.depthBuffer&&l.push(h);var d=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;!1===d&&(t.depthBuffer&&(o|=e.DEPTH_BUFFER_BIT),t.stencilBuffer)&&(o|=e.STENCIL_BUFFER_BIT),u&&e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,c.__webglColorRenderbuffer[i]),!0===d&&(e.invalidateFramebuffer(e.READ_FRAMEBUFFER,[h]),e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[h])),u&&(d=r.get(n[i]).__webglTexture,e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,d,0)),e.blitFramebuffer(0,0,a,s,0,0,a,s,o,e.NEAREST),p&&e.invalidateFramebuffer(e.READ_FRAMEBUFFER,l)}if(i.bindFramebuffer(e.READ_FRAMEBUFFER,null),i.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),u)for(let t=0;t<n.length;t++){i.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,c.__webglColorRenderbuffer[t]);var m=r.get(n[t]).__webglTexture;i.bindFramebuffer(e.FRAMEBUFFER,c.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,m,0)}i.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=B,this.setupFrameBufferTexture=O,this.useMultisampledRTT=G}function al(e,t,i){const r=i.isWebGL2;return{convert:function(i,n=Gt){let a;if(i===Se)return e.UNSIGNED_BYTE;if(i===Le)return e.UNSIGNED_SHORT_4_4_4_4;if(i===Pe)return e.UNSIGNED_SHORT_5_5_5_1;if(i===be)return e.BYTE;if(i===Ee)return e.SHORT;if(i===Te)return e.UNSIGNED_SHORT;if(i===we)return e.INT;if(i===Ae)return e.UNSIGNED_INT;if(i===Re)return e.FLOAT;if(i===Ce)return r?e.HALF_FLOAT:null!==(a=t.get("OES_texture_half_float"))?a.HALF_FLOAT_OES:null;if(i===Ue)return e.ALPHA;if(i===De)return e.RGBA;if(i===Ne)return e.LUMINANCE;if(i===Oe)return e.LUMINANCE_ALPHA;if(i===Fe)return e.DEPTH_COMPONENT;if(i===Be)return e.DEPTH_STENCIL;if(i===vi)return null!==(a=t.get("EXT_sRGB"))?a.SRGB_ALPHA_EXT:null;if(i===ze)return e.RED;if(i===Ge)return e.RED_INTEGER;if(i===He)return e.RG;if(i===ke)return e.RG_INTEGER;if(i===Ve)return e.RGBA_INTEGER;if(i===We||i===Xe||i===je||i===qe)if(n===Ht){if(null===(a=t.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(i===We)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Xe)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===je)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===qe)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(a=t.get("WEBGL_compressed_texture_s3tc")))return null;if(i===We)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Xe)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===je)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===qe)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(i===Ye||i===Ze||i===Je||i===Ke){if(null===(a=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(i===Ye)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Ze)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Je)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Ke)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(i===Qe)return null!==(a=t.get("WEBGL_compressed_texture_etc1"))?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(i===$e||i===et){if(null===(a=t.get("WEBGL_compressed_texture_etc")))return null;if(i===$e)return n===Ht?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(i===et)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(i===tt||i===it||i===rt||i===nt||i===at||i===st||i===ot||i===lt||i===ht||i===ct||i===ut||i===dt||i===pt||i===mt){if(null===(a=t.get("WEBGL_compressed_texture_astc")))return null;if(i===tt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===it)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===rt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===nt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===at)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===st)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===ot)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===lt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ht)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ct)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ut)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===dt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===pt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===mt)return n===Ht?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(i===ft){if(null===(a=t.get("EXT_texture_compression_bptc")))return null;if(i===ft)return n===Ht?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(i===gt||i===vt||i===_t||i===xt){if(null===(a=t.get("EXT_texture_compression_rgtc")))return null;if(i===ft)return a.COMPRESSED_RED_RGTC1_EXT;if(i===vt)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===_t)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===xt)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return i===Ie?r?e.UNSIGNED_INT_24_8:null!==(a=t.get("WEBGL_depth_texture"))?a.UNSIGNED_INT_24_8_WEBGL:null:void 0!==e[i]?e[i]:null}}}class sl extends La{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class ol extends un{constructor(){super(),this.isGroup=!0,this.type="Group"}}const ll={type:"move"};class hl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ol,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new ol,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new hr,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new hr),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ol,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new hr,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new hr),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){var t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,i){let r=null,n=null,a=null;var s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){a=!0;for(const r of e.hand.values()){var h=t.getJointPose(r,i),c=this._getHandJoint(l,r);null!==h&&(c.matrix.fromArray(h.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,c.jointRadius=h.radius),c.visible=null!==h}var u=l.joints["index-finger-tip"],d=l.joints["thumb-tip"];u=u.position.distanceTo(d.position),l.inputState.pinching&&.025<u?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&u<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(n=t.getPose(e.gripSpace,i))&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1);null!==s&&null!==(r=null===(r=t.getPose(e.targetRaySpace,i))&&null!==n?n:r)&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(ll))}return null!==s&&(s.visible=null!==r),null!==o&&(o.visible=null!==n),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){var i;return void 0===e.joints[t.jointName]&&((i=new ol).matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)),e.joints[t.jointName]}}class cl extends er{constructor(e,t,i,r,n,a,s,o,l,h){if((h=void 0!==h?h:Fe)!==Fe&&h!==Be)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super(null,r,n,a,s,o,h,i=void 0===(i=void 0===i&&h===Fe?Ae:i)&&h===Be?Ie:i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:de,this.minFilter=void 0!==o?o:de,this.flipY=!1,this.generateMipmaps=!1}}class ul extends _i{constructor(e,t){super();const i=this;let r=null,n=1,a=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null;const m=t.getContextAttributes();let f=null,g=null;const v=[],_=[],x=new Set,y=new Map,M=new La,S=(M.layers.enable(1),M.viewport=new tr,new La),b=(S.layers.enable(2),S.viewport=new tr,[M,S]),E=new sl;E.layers.enable(1),E.layers.enable(2);let T=null,w=null;function A(e){var t=_.indexOf(e.inputSource);-1!==t&&void 0!==(t=v[t])&&(t.update(e.inputSource,e.frame,l||a),t.dispatchEvent({type:e.type,data:e.inputSource}))}function R(){r.removeEventListener("select",A),r.removeEventListener("selectstart",A),r.removeEventListener("selectend",A),r.removeEventListener("squeeze",A),r.removeEventListener("squeezestart",A),r.removeEventListener("squeezeend",A),r.removeEventListener("end",R),r.removeEventListener("inputsourceschange",C);for(let e=0;e<v.length;e++){var t=_[e];null!==t&&(_[e]=null,v[e].disconnect(t))}T=null,w=null,e.setRenderTarget(f),d=null,u=null,c=null,r=null,g=null,D.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function C(e){for(let r=0;r<e.removed.length;r++){var t=e.removed[r],i=_.indexOf(t);0<=i&&(_[i]=null,v[i].disconnect(t))}for(let t=0;t<e.added.length;t++){var r=e.added[t];let i=_.indexOf(r);if(-1===i){for(let e=0;e<v.length;e++){if(e>=_.length){_.push(r),i=e;break}if(null===_[e]){_[e]=r,i=e;break}}if(-1===i)break}var n=v[i];n&&n.connect(r)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new hl,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new hl,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new hl,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){n=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(h){if(null!==(r=h)){if(f=e.getRenderTarget(),r.addEventListener("select",A),r.addEventListener("selectstart",A),r.addEventListener("selectend",A),r.addEventListener("squeeze",A),r.addEventListener("squeezestart",A),r.addEventListener("squeezeend",A),r.addEventListener("end",R),r.addEventListener("inputsourceschange",C),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2)h={antialias:void 0!==r.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:n},d=new XRWebGLLayer(r,t,h),r.updateRenderState({baseLayer:d}),g=new ir(d.framebufferWidth,d.framebufferHeight,{format:De,type:Se,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil});else{let i=null,a=null,s=null;m.depth&&(s=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,i=m.stencil?Be:Fe,a=m.stencil?Ie:Ae),h={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:n},c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(h),r.updateRenderState({layers:[u]}),g=new ir(u.textureWidth,u.textureHeight,{format:De,type:Se,depthTexture:new cl(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await r.requestReferenceSpace(s),D.setContext(r),D.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode};const L=new hr,P=new hr;function I(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null!==r){E.near=S.near=M.near=e.near,E.far=S.far=M.far=e.far,T===E.near&&w===E.far||(r.updateRenderState({depthNear:E.near,depthFar:E.far}),T=E.near,w=E.far);var t,i,n,a,s,o,l,h,c=e.parent,u=E.cameras;I(E,c);for(let e=0;e<u.length;e++)I(u[e],c);2===u.length?(t=E,i=M,d=S,L.setFromMatrixPosition(i.matrixWorld),P.setFromMatrixPosition(d.matrixWorld),m=L.distanceTo(P),n=i.projectionMatrix.elements,d=d.projectionMatrix.elements,a=n[14]/(n[10]-1),s=n[14]/(n[10]+1),o=(n[9]+1)/n[5],l=(n[9]-1)/n[5],p=a*(n=(n[8]-1)/n[0]),h=a*(d=(d[8]+1)/d[0]),n=(d=m/(d-n))*-n,i.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(n),t.translateZ(d),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert(),i=a+d,a=s+d,t.projectionMatrix.makePerspective(p-n,m-n+h,o*s/a*i,l*s/a*i,i,a),t.projectionMatrixInverse.copy(t.projectionMatrix).invert()):E.projectionMatrix.copy(M.projectionMatrix);var d=e,p=E,m=c,f=(null===m?d.matrix.copy(p.matrixWorld):(d.matrix.copy(m.matrixWorld),d.matrix.invert(),d.matrix.multiply(p.matrixWorld)),d.matrix.decompose(d.position,d.quaternion,d.scale),d.updateMatrixWorld(!0),d.children);for(let e=0,t=f.length;e<t;e++)f[e].updateMatrixWorld(!0);d.projectionMatrix.copy(p.projectionMatrix),d.projectionMatrixInverse.copy(p.projectionMatrixInverse),d.isPerspectiveCamera&&(d.fov=2*Si*Math.atan(1/d.projectionMatrix.elements[5]),d.zoom=1)}},this.getCamera=function(){return E},this.getFoveation=function(){if(null!==u||null!==d)return o},this.setFoveation=function(e){o=e,null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.getPlanes=function(){return x};let U=null;const D=new Ha;D.setAnimationLoop(function(t,r){if(h=r.getViewerPose(l||a),p=r,null!==h){var n=h.views;null!==d&&(e.setRenderTargetFramebuffer(g,d.framebuffer),e.setRenderTarget(g));let t=!1;n.length!==E.cameras.length&&(E.cameras.length=0,t=!0);for(let i=0;i<n.length;i++){var s,o=n[i];let r=null,a=(null!==d?r=d.getViewport(o):(r=(s=c.getViewSubImage(u,o)).viewport,0===i&&(e.setRenderTargetTextures(g,s.colorTexture,u.ignoreDepthValues?void 0:s.depthStencilTexture),e.setRenderTarget(g))),b[i]);void 0===a&&((a=new La).layers.enable(i),a.viewport=new tr,b[i]=a),a.matrix.fromArray(o.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.projectionMatrix.fromArray(o.projectionMatrix),a.projectionMatrixInverse.copy(a.projectionMatrix).invert(),a.viewport.set(r.x,r.y,r.width,r.height),0===i&&(E.matrix.copy(a.matrix),E.matrix.decompose(E.position,E.quaternion,E.scale)),!0===t&&E.cameras.push(a)}}for(let e=0;e<v.length;e++){var m=_[e],f=v[e];null!==m&&void 0!==f&&f.update(m,r,l||a)}if(U&&U(t,r),r.detectedPlanes){i.dispatchEvent({type:"planesdetected",data:r.detectedPlanes});let e=null;for(const t of x)r.detectedPlanes.has(t)||(e=null===e?[]:e).push(t);if(null!==e)for(const t of e)x.delete(t),y.delete(t),i.dispatchEvent({type:"planeremoved",data:t});for(const e of r.detectedPlanes){var M;x.has(e)?(M=y.get(e),e.lastChangedTime>M&&(y.set(e,e.lastChangedTime),i.dispatchEvent({type:"planechanged",data:e}))):(x.add(e),y.set(e,r.lastChangedTime),i.dispatchEvent({type:"planeadded",data:e}))}}p=null}),this.setAnimationLoop=function(e){U=e},this.dispose=function(){}}}function dl(e,t){function i(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function r(r,n){r.opacity.value=n.opacity,n.color&&r.diffuse.value.copy(n.color),n.emissive&&r.emissive.value.copy(n.emissive).multiplyScalar(n.emissiveIntensity),n.map&&(r.map.value=n.map,i(n.map,r.mapTransform)),n.alphaMap&&(r.alphaMap.value=n.alphaMap,i(n.alphaMap,r.alphaMapTransform)),n.bumpMap&&(r.bumpMap.value=n.bumpMap,i(n.bumpMap,r.bumpMapTransform),r.bumpScale.value=n.bumpScale,n.side===f)&&(r.bumpScale.value*=-1),n.normalMap&&(r.normalMap.value=n.normalMap,i(n.normalMap,r.normalMapTransform),r.normalScale.value.copy(n.normalScale),n.side===f)&&r.normalScale.value.negate(),n.displacementMap&&(r.displacementMap.value=n.displacementMap,i(n.displacementMap,r.displacementMapTransform),r.displacementScale.value=n.displacementScale,r.displacementBias.value=n.displacementBias),n.emissiveMap&&(r.emissiveMap.value=n.emissiveMap,i(n.emissiveMap,r.emissiveMapTransform)),n.specularMap&&(r.specularMap.value=n.specularMap,i(n.specularMap,r.specularMapTransform)),0<n.alphaTest&&(r.alphaTest.value=n.alphaTest);var a=t.get(n).envMap;a&&(r.envMap.value=a,r.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,r.reflectivity.value=n.reflectivity,r.ior.value=n.ior,r.refractionRatio.value=n.refractionRatio),n.lightMap&&(r.lightMap.value=n.lightMap,a=!0===e.useLegacyLights?Math.PI:1,r.lightMapIntensity.value=n.lightMapIntensity*a,i(n.lightMap,r.lightMapTransform)),n.aoMap&&(r.aoMap.value=n.aoMap,r.aoMapIntensity.value=n.aoMapIntensity,i(n.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(t,i){i.color.getRGB(t.fogColor.value,wa(e)),i.isFog?(t.fogNear.value=i.near,t.fogFar.value=i.far):i.isFogExp2&&(t.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,n,a,s,o){var l,h,c,u,d,p;n.isMeshBasicMaterial||n.isMeshLambertMaterial?r(e,n):n.isMeshToonMaterial?(r(e,n),d=e,(p=n).gradientMap&&(d.gradientMap.value=p.gradientMap)):n.isMeshPhongMaterial?(r(e,n),d=n,(p=e).specular.value.copy(d.specular),p.shininess.value=Math.max(d.shininess,1e-4)):n.isMeshStandardMaterial?(r(e,n),c=n,(u=e).metalness.value=c.metalness,c.metalnessMap&&(u.metalnessMap.value=c.metalnessMap,i(c.metalnessMap,u.metalnessMapTransform)),u.roughness.value=c.roughness,c.roughnessMap&&(u.roughnessMap.value=c.roughnessMap,i(c.roughnessMap,u.roughnessMapTransform)),t.get(c).envMap&&(u.envMapIntensity.value=c.envMapIntensity),n.isMeshPhysicalMaterial&&(u=n,c=o,(o=e).ior.value=u.ior,0<u.sheen&&(o.sheenColor.value.copy(u.sheenColor).multiplyScalar(u.sheen),o.sheenRoughness.value=u.sheenRoughness,u.sheenColorMap&&(o.sheenColorMap.value=u.sheenColorMap,i(u.sheenColorMap,o.sheenColorMapTransform)),u.sheenRoughnessMap)&&(o.sheenRoughnessMap.value=u.sheenRoughnessMap,i(u.sheenRoughnessMap,o.sheenRoughnessMapTransform)),0<u.clearcoat&&(o.clearcoat.value=u.clearcoat,o.clearcoatRoughness.value=u.clearcoatRoughness,u.clearcoatMap&&(o.clearcoatMap.value=u.clearcoatMap,i(u.clearcoatMap,o.clearcoatMapTransform)),u.clearcoatRoughnessMap&&(o.clearcoatRoughnessMap.value=u.clearcoatRoughnessMap,i(u.clearcoatRoughnessMap,o.clearcoatRoughnessMapTransform)),u.clearcoatNormalMap)&&(o.clearcoatNormalMap.value=u.clearcoatNormalMap,i(u.clearcoatNormalMap,o.clearcoatNormalMapTransform),o.clearcoatNormalScale.value.copy(u.clearcoatNormalScale),u.side===f)&&o.clearcoatNormalScale.value.negate(),0<u.iridescence&&(o.iridescence.value=u.iridescence,o.iridescenceIOR.value=u.iridescenceIOR,o.iridescenceThicknessMinimum.value=u.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum.value=u.iridescenceThicknessRange[1],u.iridescenceMap&&(o.iridescenceMap.value=u.iridescenceMap,i(u.iridescenceMap,o.iridescenceMapTransform)),u.iridescenceThicknessMap)&&(o.iridescenceThicknessMap.value=u.iridescenceThicknessMap,i(u.iridescenceThicknessMap,o.iridescenceThicknessMapTransform)),0<u.transmission&&(o.transmission.value=u.transmission,o.transmissionSamplerMap.value=c.texture,o.transmissionSamplerSize.value.set(c.width,c.height),u.transmissionMap&&(o.transmissionMap.value=u.transmissionMap,i(u.transmissionMap,o.transmissionMapTransform)),o.thickness.value=u.thickness,u.thicknessMap&&(o.thicknessMap.value=u.thicknessMap,i(u.thicknessMap,o.thicknessMapTransform)),o.attenuationDistance.value=u.attenuationDistance,o.attenuationColor.value.copy(u.attenuationColor)),o.specularIntensity.value=u.specularIntensity,o.specularColor.value.copy(u.specularColor),u.specularColorMap&&(o.specularColorMap.value=u.specularColorMap,i(u.specularColorMap,o.specularColorMapTransform)),u.specularIntensityMap)&&(o.specularIntensityMap.value=u.specularIntensityMap,i(u.specularIntensityMap,o.specularIntensityMapTransform))):n.isMeshMatcapMaterial?(r(e,n),c=e,(u=n).matcap&&(c.matcap.value=u.matcap)):n.isMeshDepthMaterial?r(e,n):n.isMeshDistanceMaterial?(r(e,n),o=e,h=n,h=t.get(h).light,o.referencePosition.value.setFromMatrixPosition(h.matrixWorld),o.nearDistance.value=h.shadow.camera.near,o.farDistance.value=h.shadow.camera.far):n.isMeshNormalMaterial?r(e,n):n.isLineBasicMaterial?(o=n,(h=e).diffuse.value.copy(o.color),h.opacity.value=o.opacity,o.map&&(h.map.value=o.map,i(o.map,h.mapTransform)),n.isLineDashedMaterial&&(o=n,(l=e).dashSize.value=o.dashSize,l.totalSize.value=o.dashSize+o.gapSize,l.scale.value=o.scale)):n.isPointsMaterial?(l=n,o=a,a=s,(s=e).diffuse.value.copy(l.color),s.opacity.value=l.opacity,s.size.value=l.size*o,s.scale.value=.5*a,l.map&&(s.map.value=l.map,i(l.map,s.uvTransform)),l.alphaMap&&(s.alphaMap.value=l.alphaMap),0<l.alphaTest&&(s.alphaTest.value=l.alphaTest)):n.isSpriteMaterial?(o=n,(a=e).diffuse.value.copy(o.color),a.opacity.value=o.opacity,a.rotation.value=o.rotation,o.map&&(a.map.value=o.map,i(o.map,a.mapTransform)),o.alphaMap&&(a.alphaMap.value=o.alphaMap),0<o.alphaTest&&(a.alphaTest.value=o.alphaTest)):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function pl(e,t,i,r){let n={},a={},s=[];const o=i.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e){var t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function h(t){var i=((t=t.target).removeEventListener("dispose",h),s.indexOf(t.__bindingPointIndex));s.splice(i,1),e.deleteBuffer(n[t.id]),delete n[t.id],delete a[t.id]}return{bind:function(e,t){t=t.program,r.uniformBlockBinding(e,t)},update:function(i,c){var u;if(void 0===(u=n[i.id])){{var d=(x=i).uniforms;let e=0,t=0;for(let i=0,r=d.length;i<r;i++){var p,m=d[i],f={boundary:0,storage:0},g=Array.isArray(m.value)?m.value:[m.value];for(let e=0,t=g.length;e<t;e++){var v=l(g[e]);f.boundary+=v.boundary,f.storage+=v.storage}m.__data=new Float32Array(f.storage/Float32Array.BYTES_PER_ELEMENT),m.__offset=e,0<i&&(p=16-(t=e%16),0!==t)&&p-f.boundary<0&&(e+=16-t,m.__offset=e),e+=f.storage}0<(t=e%16)&&(e+=16-t),x.__size=e,x.__cache={}}x=i,y=function(){for(let e=0;e<o;e++)if(-1===s.indexOf(e))return s.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}(),x.__bindingPointIndex=y,M=e.createBuffer(),_=x.__size,x=x.usage,e.bindBuffer(e.UNIFORM_BUFFER,M),e.bufferData(e.UNIFORM_BUFFER,_,x),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,y,M),u=M,n[i.id]=u,i.addEventListener("dispose",h)}var _=c.program,x=(r.updateUBOMapping(i,_),t.render.frame);if(a[i.id]!==x){var y=i,M=n[y.id],S=y.uniforms,b=y.__cache;e.bindBuffer(e.UNIFORM_BUFFER,M);for(let t=0,i=S.length;t<i;t++){var E=S[t];if(!0===function(e,t,i){if(e=e.value,void 0===i[t]){if("number"==typeof e)i[t]=e;else{var r=Array.isArray(e)?e:[e],n=[];for(let e=0;e<r.length;e++)n.push(r[e].clone());i[t]=n}return!0}if("number"==typeof e){if(i[t]!==e)return i[t]=e,!0}else{var a=Array.isArray(i[t])?i[t]:[i[t]],s=Array.isArray(e)?e:[e];for(let e=0;e<a.length;e++){var o=a[e];if(!1===o.equals(s[e]))return o.copy(s[e]),!0}}return!1}(E,t,b)){var T=E.__offset,w=Array.isArray(E.value)?E.value:[E.value];let t=0;for(let i=0;i<w.length;i++){var A=w[i],R=l(A);"number"==typeof A?(E.__data[0]=A,e.bufferSubData(e.UNIFORM_BUFFER,T+t,E.__data)):A.isMatrix3?(E.__data[0]=A.elements[0],E.__data[1]=A.elements[1],E.__data[2]=A.elements[2],E.__data[3]=A.elements[0],E.__data[4]=A.elements[3],E.__data[5]=A.elements[4],E.__data[6]=A.elements[5],E.__data[7]=A.elements[0],E.__data[8]=A.elements[6],E.__data[9]=A.elements[7],E.__data[10]=A.elements[8],E.__data[11]=A.elements[0]):(A.toArray(E.__data,t),t+=R.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,T,E.__data)}}e.bindBuffer(e.UNIFORM_BUFFER,null),a[i.id]=x}},dispose:function(){for(const t in n)e.deleteBuffer(n[t]);s=[],n={},a={}}}}class ml{constructor(e={}){const{canvas:t=(d=zi("canvas"),d.style.display="block",d),context:i=null,depth:n=!0,stencil:a=!0,alpha:s=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:h=!1,powerPreference:c="default",failIfMajorPerformanceCaveat:u=!1}=e;var d;this.isWebGLRenderer=!0;let p,v=(p=null!==i?i.getContextAttributes().alpha:s,null),_=null;const x=[],y=[],M=(this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Ht,this.useLegacyLights=!0,this.toneMapping=K,this.toneMappingExposure=1,this);let S=!1,b=0,E=0,T=null,w=-1,A=null;const R=new tr,C=new tr;let L=null,P=t.width,I=t.height,U=1,D=null,N=null;const O=new tr(0,0,P,I),F=new tr(0,0,P,I);let B=!1;const z=new Ga;let G=!1,H=!1,k=null;const V=new zr,W=new hr,X={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function j(){return null===T?U:1}let q,Y,Z,J,Q,$,ee,te,ie,re,ne,ae,se,oe,le,he,ce,ue,de,pe,me,fe,ge,ve,_e=i;function xe(e,i){for(let n=0;n<e.length;n++){var r=e[n];if(null!==(r=t.getContext(r,i)))return r}return null}try{var Me={alpha:!0,depth:n,stencil:a,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:h,powerPreference:c,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine","three.js r"+r),t.addEventListener("webglcontextlost",we,!1),t.addEventListener("webglcontextrestored",Ae,!1),t.addEventListener("webglcontextcreationerror",Le,!1),null===_e){var be=["webgl2","webgl","experimental-webgl"];if(!0===M.isWebGL1Renderer&&be.shift(),null===(_e=xe(be,Me)))throw xe(be)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===_e.getShaderPrecisionFormat&&(_e.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Ee(){q=new ds(_e),Y=new Ka(_e,q,e),q.init(Y),fe=new al(_e,q,Y),Z=new rl(_e,q,Y),J=new fs(_e),Q=new Vo,$=new nl(_e,q,Z,Q,Y,fe,J),ee=new $a(M),te=new us(M),ie=new ka(_e,Y),ge=new Za(_e,q,ie,Y),re=new ps(_e,ie,J,ge),ne=new xs(_e,re,ie,J),de=new _s(_e,Y,$),he=new Qa(Q),ae=new ko(M,ee,te,q,Y,ge,he),se=new dl(M,Q),oe=new qo,le=new $o(q,Y),ue=new Ya(M,ee,te,Z,ne,p,l),ce=new il(M,ne,Y),ve=new pl(_e,J,Y,Z),pe=new Ja(_e,q,J,Y),me=new ms(_e,q,J,Y),J.programs=ae.programs,M.capabilities=Y,M.extensions=q,M.properties=Q,M.renderLists=oe,M.shadowMap=ce,M.state=Z,M.info=J}Ee();const Te=new ul(M,_e);function we(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),S=!0}function Ae(){console.log("THREE.WebGLRenderer: Context Restored."),S=!1;var e=J.autoReset,t=ce.enabled,i=ce.autoUpdate,r=ce.needsUpdate,n=ce.type;Ee(),J.autoReset=e,ce.enabled=t,ce.autoUpdate=i,ce.needsUpdate=r,ce.type=n}function Le(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Pe(e){var t=((e=e.target).removeEventListener("dispose",Pe),e),i=Q.get(t).programs;void 0!==i&&(i.forEach(function(e){ae.releaseProgram(e)}),t.isShaderMaterial)&&ae.releaseShaderCache(t),Q.remove(e)}this.xr=Te,this.getContext=function(){return _e},this.getContextAttributes=function(){return _e.getContextAttributes()},this.forceContextLoss=function(){var e=q.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){var e=q.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return U},this.setPixelRatio=function(e){void 0!==e&&(U=e,this.setSize(P,I,!1))},this.getSize=function(e){return e.set(P,I)},this.setSize=function(e,i,r=!0){Te.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(P=e,I=i,t.width=Math.floor(e*U),t.height=Math.floor(i*U),!0===r&&(t.style.width=e+"px",t.style.height=i+"px"),this.setViewport(0,0,e,i))},this.getDrawingBufferSize=function(e){return e.set(P*U,I*U).floor()},this.setDrawingBufferSize=function(e,i,r){P=e,I=i,U=r,t.width=Math.floor(e*r),t.height=Math.floor(i*r),this.setViewport(0,0,e,i)},this.getCurrentViewport=function(e){return e.copy(R)},this.getViewport=function(e){return e.copy(O)},this.setViewport=function(e,t,i,r){e.isVector4?O.set(e.x,e.y,e.z,e.w):O.set(e,t,i,r),Z.viewport(R.copy(O).multiplyScalar(U).floor())},this.getScissor=function(e){return e.copy(F)},this.setScissor=function(e,t,i,r){e.isVector4?F.set(e.x,e.y,e.z,e.w):F.set(e,t,i,r),Z.scissor(C.copy(F).multiplyScalar(U).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(e){Z.setScissorTest(B=e)},this.setOpaqueSort=function(e){D=e},this.setTransparentSort=function(e){N=e},this.getClearColor=function(e){return e.copy(ue.getClearColor())},this.setClearColor=function(){ue.setClearColor.apply(ue,arguments)},this.getClearAlpha=function(){return ue.getClearAlpha()},this.setClearAlpha=function(){ue.setClearAlpha.apply(ue,arguments)},this.clear=function(e=!0,t=!0,i=!0){let r=0;e&&(r|=_e.COLOR_BUFFER_BIT),t&&(r|=_e.DEPTH_BUFFER_BIT),i&&(r|=_e.STENCIL_BUFFER_BIT),_e.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",we,!1),t.removeEventListener("webglcontextrestored",Ae,!1),t.removeEventListener("webglcontextcreationerror",Le,!1),oe.dispose(),le.dispose(),Q.dispose(),ee.dispose(),te.dispose(),ne.dispose(),ge.dispose(),ve.dispose(),ae.dispose(),Te.dispose(),Te.removeEventListener("sessionstart",Ue),Te.removeEventListener("sessionend",Ne),k&&(k.dispose(),k=null),Oe.stop()},this.renderBufferDirect=function(e,t,i,r,n,a){null===t&&(t=X);var s=n.isMesh&&n.matrixWorld.determinant()<0;e=function(e,t,i,r,n){!0!==t.isScene&&(t=X),$.resetTextureUnits();var a=t.fog,s=r.isMeshStandardMaterial?t.environment:null,o=null===T?M.outputColorSpace:!0===T.isXRRenderTarget?T.texture.colorSpace:kt,l=(s=(r.isMeshStandardMaterial?te:ee).get(r.envMap||s),!0===r.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize),h=!!r.normalMap&&!!i.attributes.tangent,c=!!i.morphAttributes.position,u=!!i.morphAttributes.normal,d=!!i.morphAttributes.color,p=r.toneMapped?M.toneMapping:K,m=void 0!==(m=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color)?m.length:0,f=Q.get(r),g=_.state.lights;!0!==G||!0!==H&&e===A||(E=e===A&&r.id===w,he.setState(r,e,E));let v=!1;r.version===f.__version?(f.needsLights&&f.lightsStateVersion!==g.state.version||f.outputColorSpace!==o||n.isInstancedMesh&&!1===f.instancing||!n.isInstancedMesh&&!0===f.instancing||n.isSkinnedMesh&&!1===f.skinning||!n.isSkinnedMesh&&!0===f.skinning||f.envMap!==s||!0===r.fog&&f.fog!==a||void 0!==f.numClippingPlanes&&(f.numClippingPlanes!==he.numPlanes||f.numIntersection!==he.numIntersection)||f.vertexAlphas!==l||f.vertexTangents!==h||f.morphTargets!==c||f.morphNormals!==u||f.morphColors!==d||f.toneMapping!==p||!0===Y.isWebGL2&&f.morphTargetsCount!==m)&&(v=!0):(v=!0,f.__version=r.version);let x=f.currentProgram;!0===v&&(x=Ge(r,t,n));let y=!1,S=!1,b=!1;var E=x.getUniforms();if(g=f.uniforms,Z.useProgram(x.program)&&(y=!0,S=!0,b=!0),r.id!==w&&(w=r.id,S=!0),(y||A!==e)&&(E.setValue(_e,"projectionMatrix",e.projectionMatrix),Y.logarithmicDepthBuffer&&E.setValue(_e,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),A!==e&&(A=e,S=!0,b=!0),(r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap)&&void 0!==(o=E.map.cameraPosition)&&o.setValue(_e,W.setFromMatrixPosition(e.matrixWorld)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&E.setValue(_e,"isOrthographic",!0===e.isOrthographicCamera),r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||n.isSkinnedMesh)&&E.setValue(_e,"viewMatrix",e.matrixWorldInverse),n.isSkinnedMesh&&(E.setOptional(_e,n,"bindMatrix"),E.setOptional(_e,n,"bindMatrixInverse"),l=n.skeleton)&&(Y.floatVertexTextures?(null===l.boneTexture&&l.computeBoneTexture(),E.setValue(_e,"boneTexture",l.boneTexture,$),E.setValue(_e,"boneTextureSize",l.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.")),(void 0!==(h=i.morphAttributes).position||void 0!==h.normal||void 0!==h.color&&!0===Y.isWebGL2)&&de.update(n,i,x),!S&&f.receiveShadow===n.receiveShadow||(f.receiveShadow=n.receiveShadow,E.setValue(_e,"receiveShadow",n.receiveShadow)),r.isMeshGouraudMaterial&&null!==r.envMap&&(g.envMap.value=s,g.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1),S&&(E.setValue(_e,"toneMappingExposure",M.toneMappingExposure),f.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(g,b),a&&!0===r.fog&&se.refreshFogUniforms(g,a),se.refreshMaterialUniforms(g,r,U,I,k),bo.upload(_e,f.uniformsList,g,$)),r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(bo.upload(_e,f.uniformsList,g,$),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&E.setValue(_e,"center",n.center),E.setValue(_e,"modelViewMatrix",n.modelViewMatrix),E.setValue(_e,"normalMatrix",n.normalMatrix),E.setValue(_e,"modelMatrix",n.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){var R,C=r.uniformsGroups;for(let e=0,t=C.length;e<t;e++)Y.isWebGL2?(R=C[e],ve.update(R,x),ve.bind(R,x)):console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return x}(e,t,i,r,n),Z.setMaterial(r,s);let o=i.index,l=1;!0===r.wireframe&&(o=re.getWireframeAttribute(i),l=2),t=i.drawRange,s=i.attributes.position;let h=t.start*l,c=(t.start+t.count)*l;if(null!==a&&(h=Math.max(h,a.start*l),c=Math.min(c,(a.start+a.count)*l)),null!==o?(h=Math.max(h,0),c=Math.min(c,o.count)):null!=s&&(h=Math.max(h,0),c=Math.min(c,s.count)),!((t=c-h)<0||t==1/0)){ge.setup(n,r,e,i,o);let l=pe;if(null!==o&&(a=ie.get(o),(l=me).setIndex(a)),n.isMesh)!0===r.wireframe?(Z.setLineWidth(r.wireframeLinewidth*j()),l.setMode(_e.LINES)):l.setMode(_e.TRIANGLES);else if(n.isLine){let e=r.linewidth;void 0===e&&(e=1),Z.setLineWidth(e*j()),n.isLineSegments?l.setMode(_e.LINES):n.isLineLoop?l.setMode(_e.LINE_LOOP):l.setMode(_e.LINE_STRIP)}else n.isPoints?l.setMode(_e.POINTS):n.isSprite&&l.setMode(_e.TRIANGLES);n.isInstancedMesh?l.renderInstances(h,t,n.count):i.isInstancedBufferGeometry?(s=void 0!==i._maxInstanceCount?i._maxInstanceCount:1/0,e=Math.min(i.instanceCount,s),l.renderInstances(h,t,e)):l.render(h,t)}},this.compile=function(e,t){function i(e,t,i){!0===e.transparent&&e.side===g&&!1===e.forceSinglePass?(e.side=f,e.needsUpdate=!0,Ge(e,t,i),e.side=m,e.needsUpdate=!0,Ge(e,t,i),e.side=g):Ge(e,t,i)}(_=le.get(e)).init(),y.push(_),e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(_.pushLight(e),e.castShadow)&&_.pushShadow(e)}),_.setupLights(M.useLegacyLights),e.traverse(function(t){var r=t.material;if(r)if(Array.isArray(r))for(let n=0;n<r.length;n++)i(r[n],e,t);else i(r,e,t)}),y.pop(),_=null};let Ie=null;function Ue(){Oe.stop()}function Ne(){Oe.start()}const Oe=new Ha;function Fe(e,t,i,r){var n=e.opaque,a=e.transmissive;if(e=e.transparent,_.setupLightsView(i),!0===G&&he.setGlobalState(M.clippingPlanes,i),0<a.length){var s=n,l=a,h=t,c=i,u=(null===k&&(u=Y.isWebGL2,k=new ir(1024,1024,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Ce:Se,minFilter:ye,samples:u&&!0===o?4:0})),M.getRenderTarget()),d=(M.setRenderTarget(k),M.clear(),M.toneMapping);M.toneMapping=K,Be(s,h,c),$.updateMultisampleRenderTarget(k),$.updateRenderTargetMipmap(k);let e=!1;for(let t=0,i=l.length;t<i;t++){var p,m=(y=l[t]).object,v=y.geometry,x=y.material,y=y.group;x.side===g&&m.layers.test(c.layers)&&(p=x.side,x.side=f,x.needsUpdate=!0,ze(m,h,c,v,x,y),x.side=p,x.needsUpdate=!0,e=!0)}!0===e&&($.updateMultisampleRenderTarget(k),$.updateRenderTargetMipmap(k)),M.setRenderTarget(u),M.toneMapping=d}r&&Z.viewport(R.copy(r)),0<n.length&&Be(n,t,i),0<a.length&&Be(a,t,i),0<e.length&&Be(e,t,i),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Be(e,t,i){var r=!0===t.isScene?t.overrideMaterial:null;for(let l=0,h=e.length;l<h;l++){var n=(o=e[l]).object,a=o.geometry,s=null===r?o.material:r,o=o.group;n.layers.test(i.layers)&&ze(n,t,i,a,s,o)}}function ze(e,t,i,r,n,a){e.onBeforeRender(M,t,i,r,n,a),e.modelViewMatrix.multiplyMatrices(i.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),n.onBeforeRender(M,t,i,r,e,a),!0===n.transparent&&n.side===g&&!1===n.forceSinglePass?(n.side=f,n.needsUpdate=!0,M.renderBufferDirect(i,t,r,n,e,a),n.side=m,n.needsUpdate=!0,M.renderBufferDirect(i,t,r,n,e,a),n.side=g):M.renderBufferDirect(i,t,r,n,e,a),e.onAfterRender(M,t,i,r,n,a)}function Ge(e,t,i){!0!==t.isScene&&(t=X);var r=Q.get(e),n=_.state.lights,a=_.state.shadowsArray,s=n.state.version,o=(a=ae.getParameters(e,n.state,a,t,i),ae.getProgramCacheKey(a));let l=r.programs,h=(r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?te:ee).get(e.envMap||r.environment),void 0===l&&(e.addEventListener("dispose",Pe),l=new Map,r.programs=l),l.get(o));if(void 0!==h){if(r.currentProgram===h&&r.lightsStateVersion===s)return He(e,a),h}else a.uniforms=ae.getUniforms(e),e.onBuild(i,a,M),e.onBeforeCompile(a,M),h=ae.acquireProgram(a,o),l.set(o,h),r.uniforms=a.uniforms;return t=r.uniforms,(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(t.clippingPlanes=he.uniform),He(e,a),r.needsLights=(i=e).isMeshLambertMaterial||i.isMeshToonMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isShadowMaterial||i.isShaderMaterial&&!0===i.lights,r.lightsStateVersion=s,r.needsLights&&(t.ambientLightColor.value=n.state.ambient,t.lightProbe.value=n.state.probe,t.directionalLights.value=n.state.directional,t.directionalLightShadows.value=n.state.directionalShadow,t.spotLights.value=n.state.spot,t.spotLightShadows.value=n.state.spotShadow,t.rectAreaLights.value=n.state.rectArea,t.ltc_1.value=n.state.rectAreaLTC1,t.ltc_2.value=n.state.rectAreaLTC2,t.pointLights.value=n.state.point,t.pointLightShadows.value=n.state.pointShadow,t.hemisphereLights.value=n.state.hemi,t.directionalShadowMap.value=n.state.directionalShadowMap,t.directionalShadowMatrix.value=n.state.directionalShadowMatrix,t.spotShadowMap.value=n.state.spotShadowMap,t.spotLightMatrix.value=n.state.spotLightMatrix,t.spotLightMap.value=n.state.spotLightMap,t.pointShadowMap.value=n.state.pointShadowMap,t.pointShadowMatrix.value=n.state.pointShadowMatrix),o=h.getUniforms(),a=bo.seqWithValue(o.seq,t),r.currentProgram=h,r.uniformsList=a,h}function He(e,t){(e=Q.get(e)).outputColorSpace=t.outputColorSpace,e.instancing=t.instancing,e.skinning=t.skinning,e.morphTargets=t.morphTargets,e.morphNormals=t.morphNormals,e.morphColors=t.morphColors,e.morphTargetsCount=t.morphTargetsCount,e.numClippingPlanes=t.numClippingPlanes,e.numIntersection=t.numClipIntersection,e.vertexAlphas=t.vertexAlphas,e.vertexTangents=t.vertexTangents,e.toneMapping=t.toneMapping}Oe.setAnimationLoop(function(e){Ie&&Ie(e)}),"undefined"!=typeof self&&Oe.setContext(self),this.setAnimationLoop=function(e){Ie=e,Te.setAnimationLoop(e),null===e?Oe.stop():Oe.start()},Te.addEventListener("sessionstart",Ue),Te.addEventListener("sessionend",Ne),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else if(!0!==S){!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Te.enabled&&!0===Te.isPresenting&&(!0===Te.cameraAutoUpdate&&Te.updateCamera(t),t=Te.getCamera()),!0===e.isScene&&e.onBeforeRender(M,e,t,T),(_=le.get(e,y.length)).init(),y.push(_),V.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),z.setFromProjectionMatrix(V),H=this.localClippingEnabled,G=he.init(this.clippingPlanes,H),(v=oe.get(e,x.length)).init(),x.push(v),function e(t,i,r,n){if(!1===t.visible)return;if(t.layers.test(i.layers))if(t.isGroup)r=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(i);else if(t.isLight)_.pushLight(t),t.castShadow&&_.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||z.intersectsSprite(t)){n&&W.setFromMatrixPosition(t.matrixWorld).applyMatrix4(V);const e=ne.update(t),i=t.material;i.visible&&v.push(t,e,i,r,W.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(!t.frustumCulled||z.intersectsObject(t))){t.isSkinnedMesh&&t.skeleton.frame!==J.render.frame&&(t.skeleton.update(),t.skeleton.frame=J.render.frame);const e=ne.update(t),i=t.material;if(n&&(null===e.boundingSphere&&e.computeBoundingSphere(),W.copy(e.boundingSphere.center).applyMatrix4(t.matrixWorld).applyMatrix4(V)),Array.isArray(i)){const n=e.groups;for(let a=0,s=n.length;a<s;a++){const s=n[a],o=i[s.materialIndex];o&&o.visible&&v.push(t,e,o,r,W.z,s)}}else i.visible&&v.push(t,e,i,r,W.z,null)}const a=t.children;for(let t=0,s=a.length;t<s;t++)e(a[t],i,r,n)}(e,t,0,M.sortObjects),v.finish(),!0===M.sortObjects&&v.sort(D,N),!0===G&&he.beginShadows();var i=_.state.shadowsArray;if(ce.render(i,e,t),!0===G&&he.endShadows(),!0===this.info.autoReset&&this.info.reset(),ue.render(v,e),_.setupLights(M.useLegacyLights),t.isArrayCamera){var r=t.cameras;for(let t=0,i=r.length;t<i;t++){var n=r[t];Fe(v,e,n,n.viewport)}}else Fe(v,e,t);null!==T&&($.updateMultisampleRenderTarget(T),$.updateRenderTargetMipmap(T)),!0===e.isScene&&e.onAfterRender(M,e,t),ge.resetDefaultState(),w=-1,A=null,y.pop(),_=0<y.length?y[y.length-1]:null,x.pop(),v=0<x.length?x[x.length-1]:null}},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return E},this.getRenderTarget=function(){return T},this.setRenderTargetTextures=function(e,t,i){Q.get(e.texture).__webglTexture=t,Q.get(e.depthTexture).__webglTexture=i,(t=Q.get(e)).__hasExternalTextures=!0,t.__hasExternalTextures&&(t.__autoAllocateDepthBuffer=void 0===i,t.__autoAllocateDepthBuffer||!0===q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),t.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){(e=Q.get(e)).__webglFramebuffer=t,e.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,i=0){T=e,b=t,E=i;let r=!0,n=null,a=!1,s=!1;L=e?(void 0!==(o=Q.get(e)).__useDefaultFramebuffer?(Z.bindFramebuffer(_e.FRAMEBUFFER,null),r=!1):void 0===o.__webglFramebuffer?$.setupRenderTarget(e):o.__hasExternalTextures&&$.rebindTextures(e,Q.get(e.texture).__webglTexture,Q.get(e.depthTexture).__webglTexture),((o=e.texture).isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0),o=Q.get(e).__webglFramebuffer,e.isWebGLCubeRenderTarget?(n=o[t],a=!0):n=Y.isWebGL2&&0<e.samples&&!1===$.useMultisampledRTT(e)?Q.get(e).__webglMultisampledFramebuffer:o,R.copy(e.viewport),C.copy(e.scissor),e.scissorTest):(R.copy(O).multiplyScalar(U).floor(),C.copy(F).multiplyScalar(U).floor(),B);var o=Z.bindFramebuffer(_e.FRAMEBUFFER,n);o&&Y.drawBuffers&&r&&Z.drawBuffers(e,n),Z.viewport(R),Z.scissor(C),Z.setScissorTest(L),a?(o=Q.get(e.texture),_e.framebufferTexture2D(_e.FRAMEBUFFER,_e.COLOR_ATTACHMENT0,_e.TEXTURE_CUBE_MAP_POSITIVE_X+t,o.__webglTexture,i)):s&&(o=Q.get(e.texture),e=t||0,_e.framebufferTextureLayer(_e.FRAMEBUFFER,_e.COLOR_ATTACHMENT0,o.__webglTexture,i||0,e)),w=-1},this.readRenderTargetPixels=function(e,t,i,r,n,a,s){if(e&&e.isWebGLRenderTarget){let u=Q.get(e).__webglFramebuffer;if(u=e.isWebGLCubeRenderTarget&&void 0!==s?u[s]:u){Z.bindFramebuffer(_e.FRAMEBUFFER,u);try{var o,l=e.texture,h=l.format,c=l.type;h!==De&&fe.convert(h)!==_e.getParameter(_e.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):(o=c===Ce&&(q.has("EXT_color_buffer_half_float")||Y.isWebGL2&&q.has("EXT_color_buffer_float")),c===Se||fe.convert(c)===_e.getParameter(_e.IMPLEMENTATION_COLOR_READ_TYPE)||c===Re&&(Y.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float"))||o?0<=t&&t<=e.width-r&&0<=i&&i<=e.height-n&&_e.readPixels(t,i,r,n,fe.convert(h),fe.convert(c),a):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."))}finally{const e=null!==T?Q.get(T).__webglFramebuffer:null;Z.bindFramebuffer(_e.FRAMEBUFFER,e)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t,i=0){var r=Math.pow(2,-i),n=Math.floor(t.image.width*r);r=Math.floor(t.image.height*r),$.setTexture2D(t,0),_e.copyTexSubImage2D(_e.TEXTURE_2D,i,0,0,e.x,e.y,n,r),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,i,r=0){var n=t.image.width,a=t.image.height,s=fe.convert(i.format),o=fe.convert(i.type);$.setTexture2D(i,0),_e.pixelStorei(_e.UNPACK_FLIP_Y_WEBGL,i.flipY),_e.pixelStorei(_e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),_e.pixelStorei(_e.UNPACK_ALIGNMENT,i.unpackAlignment),t.isDataTexture?_e.texSubImage2D(_e.TEXTURE_2D,r,e.x,e.y,n,a,s,o,t.image.data):t.isCompressedTexture?_e.compressedTexSubImage2D(_e.TEXTURE_2D,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):_e.texSubImage2D(_e.TEXTURE_2D,r,e.x,e.y,s,o,t.image),0===r&&i.generateMipmaps&&_e.generateMipmap(_e.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,r,n=0){if(M.isWebGL1Renderer)console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var a=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=fe.convert(r.format),h=fe.convert(r.type);let g;if(r.isData3DTexture)$.setTexture3D(r,0),g=_e.TEXTURE_3D;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");$.setTexture2DArray(r,0),g=_e.TEXTURE_2D_ARRAY}_e.pixelStorei(_e.UNPACK_FLIP_Y_WEBGL,r.flipY),_e.pixelStorei(_e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),_e.pixelStorei(_e.UNPACK_ALIGNMENT,r.unpackAlignment);var c=_e.getParameter(_e.UNPACK_ROW_LENGTH),u=_e.getParameter(_e.UNPACK_IMAGE_HEIGHT),d=_e.getParameter(_e.UNPACK_SKIP_PIXELS),p=_e.getParameter(_e.UNPACK_SKIP_ROWS),m=_e.getParameter(_e.UNPACK_SKIP_IMAGES),f=i.isCompressedTexture?i.mipmaps[0]:i.image;_e.pixelStorei(_e.UNPACK_ROW_LENGTH,f.width),_e.pixelStorei(_e.UNPACK_IMAGE_HEIGHT,f.height),_e.pixelStorei(_e.UNPACK_SKIP_PIXELS,e.min.x),_e.pixelStorei(_e.UNPACK_SKIP_ROWS,e.min.y),_e.pixelStorei(_e.UNPACK_SKIP_IMAGES,e.min.z),i.isDataTexture||i.isData3DTexture?_e.texSubImage3D(g,n,t.x,t.y,t.z,a,s,o,l,h,f.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_e.compressedTexSubImage3D(g,n,t.x,t.y,t.z,a,s,o,l,f.data)):_e.texSubImage3D(g,n,t.x,t.y,t.z,a,s,o,l,h,f),_e.pixelStorei(_e.UNPACK_ROW_LENGTH,c),_e.pixelStorei(_e.UNPACK_IMAGE_HEIGHT,u),_e.pixelStorei(_e.UNPACK_SKIP_PIXELS,d),_e.pixelStorei(_e.UNPACK_SKIP_ROWS,p),_e.pixelStorei(_e.UNPACK_SKIP_IMAGES,m),0===n&&r.generateMipmaps&&_e.generateMipmap(g),Z.unbindTexture()}},this.initTexture=function(e){e.isCubeTexture?$.setTextureCube(e,0):e.isData3DTexture?$.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?$.setTexture2DArray(e,0):$.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){b=0,E=0,T=null,Z.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Ht?Nt:Dt}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Nt?Ht:kt}}class fl extends ml{}fl.prototype.isWebGL1Renderer=!0;class gl{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Ln(e),this.density=t}clone(){return new gl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class vl{constructor(e,t=1,i=1e3){this.isFog=!0,this.name="",this.color=new Ln(e),this.near=t,this.far=i}clone(){return new vl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class _l extends un{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){return e=super.toJSON(e),null!==this.fog&&(e.object.fog=this.fog.toJSON()),0<this.backgroundBlurriness&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e}get autoUpdate(){return console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("THREE.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}}class xl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=si,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=bi()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,n=this.stride;r<n;r++)this.array[e+r]=t.array[i+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=bi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer),e=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),(e=new this.constructor(e,this.stride)).setUsage(this.usage),e}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=bi()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const yl=new hr;class Ml{constructor(e,t,i,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=i,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,i=this.data.count;t<i;t++)yl.fromBufferAttribute(this,t),yl.applyMatrix4(e),this.setXYZ(t,yl.x,yl.y,yl.z);return this}applyNormalMatrix(e){for(let t=0,i=this.count;t<i;t++)yl.fromBufferAttribute(this,t),yl.applyNormalMatrix(e),this.setXYZ(t,yl.x,yl.y,yl.z);return this}transformDirection(e){for(let t=0,i=this.count;t<i;t++)yl.fromBufferAttribute(this,t),yl.transformDirection(e),this.setXYZ(t,yl.x,yl.y,yl.z);return this}setX(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Pi(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized?Li(t,this.array):t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized?Li(t,this.array):t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized?Li(t,this.array):t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized?Li(t,this.array):t}setXY(e,t,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this}setXYZ(e,t,i,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this}setXYZW(e,t,i,r,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pi(t,this.array),i=Pi(i,this.array),r=Pi(r,this.array),n=Pi(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=i,this.data.array[e+2]=r,this.data.array[e+3]=n,this}clone(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Ml(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized);console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");var t=[];for(let e=0;e<this.count;e++){var i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return new zn(new this.array.constructor(t),this.itemSize,this.normalized)}toJSON(e){if(void 0!==e)return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized};console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");var t=[];for(let e=0;e<this.count;e++){var i=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[i+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}}class Sl extends Tn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ln(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let bl;const El=new hr,Tl=new hr,wl=new hr,Al=new Ui,Rl=new Ui,Cl=new zr,Ll=new hr,Pl=new hr,Il=new hr,Ul=new Ui,Dl=new Ui,Nl=new Ui;class Ol extends un{constructor(e){var t;super(),this.isSprite=!0,this.type="Sprite",void 0===bl&&(bl=new ra,t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new xl(t,5),bl.setIndex([0,1,2,0,2,3]),bl.setAttribute("position",new Ml(t,3,0,!1)),bl.setAttribute("uv",new Ml(t,2,3,!1))),this.geometry=bl,this.material=void 0!==e?e:new Sl,this.center=new Ui(.5,.5)}raycast(e,t){let i,r;null===e.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Tl.setFromMatrixScale(this.matrixWorld),Cl.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),wl.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Tl.multiplyScalar(-wl.z),0!==(n=this.material.rotation)&&(r=Math.cos(n),i=Math.sin(n));var n=this.center,a=(Fl(Ll.set(-.5,-.5,0),wl,n,Tl,i,r),Fl(Pl.set(.5,-.5,0),wl,n,Tl,i,r),Fl(Il.set(.5,.5,0),wl,n,Tl,i,r),Ul.set(0,0),Dl.set(1,0),Nl.set(1,1),e.ray.intersectTriangle(Ll,Pl,Il,!1,El));null===a&&(Fl(Pl.set(-.5,.5,0),wl,n,Tl,i,r),Dl.set(0,1),null===(a=e.ray.intersectTriangle(Ll,Il,Pl,!1,El)))||(n=e.ray.origin.distanceTo(El))<e.near||n>e.far||t.push({distance:n,point:El.clone(),uv:bn.getInterpolation(El,Ll,Pl,Il,Ul,Dl,Nl,new Ui),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Fl(e,t,i,r,n,a){Al.subVectors(e,i).addScalar(.5).multiply(r),void 0!==n?(Rl.x=a*Al.x-n*Al.y,Rl.y=n*Al.x+a*Al.y):Rl.copy(Al),e.copy(t),e.x+=Rl.x,e.y+=Rl.y,e.applyMatrix4(Cl)}const Bl=new hr,zl=new hr;class Gl extends un{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);var t=e.levels;for(let e=0,r=t.length;e<r;e++){var i=t[e];this.addLevel(i.object.clone(),i.distance,i.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,i=0){t=Math.abs(t);var r=this.levels;let n;for(n=0;n<r.length&&!(t<r[n].distance);n++);return r.splice(n,0,{distance:t,hysteresis:i,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){var t=this.levels;if(0<t.length){let i,r;for(i=1,r=t.length;i<r;i++){let r=t[i].distance;if(t[i].object.visible&&(r-=r*t[i].hysteresis),e<r)break}return t[i-1].object}return null}raycast(e,t){var i;0<this.levels.length&&(Bl.setFromMatrixPosition(this.matrixWorld),i=e.ray.origin.distanceTo(Bl),this.getObjectForDistance(i).raycast(e,t))}update(e){var t=this.levels;if(1<t.length){Bl.setFromMatrixPosition(e.matrixWorld),zl.setFromMatrixPosition(this.matrixWorld);var i=Bl.distanceTo(zl)/e.zoom;let r,n;for(t[0].object.visible=!0,r=1,n=t.length;r<n;r++){let e=t[r].distance;if(t[r].object.visible&&(e-=e*t[r].hysteresis),!(i>=e))break;t[r-1].object.visible=!1,t[r].object.visible=!0}for(this._currentLevel=r-1;r<n;r++)t[r].object.visible=!1}}toJSON(e){var t=super.toJSON(e),i=(!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[],this.levels);for(let e=0,n=i.length;e<n;e++){var r=i[e];t.object.levels.push({object:r.object.uuid,distance:r.distance,hysteresis:r.hysteresis})}return t}}const Hl=new hr,kl=new tr,Vl=new tr,Wl=new hr,Xl=new zr,jl=new hr;class ql extends Ma{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new zr,this.bindMatrixInverse=new zr,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){var e=this.geometry,t=(null===this.boundingBox&&(this.boundingBox=new dr),this.boundingBox.makeEmpty(),e.getAttribute("position"));for(let e=0;e<t.count;e++)jl.fromBufferAttribute(t,e),this.applyBoneTransform(e,jl),this.boundingBox.expandByPoint(jl)}computeBoundingSphere(){var e=this.geometry,t=(null===this.boundingSphere&&(this.boundingSphere=new Lr),this.boundingSphere.makeEmpty(),e.getAttribute("position"));for(let e=0;e<t.count;e++)jl.fromBufferAttribute(t,e),this.applyBoneTransform(e,jl),this.boundingSphere.expandByPoint(jl)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){var e=new tr,t=this.geometry.attributes.skinWeight;for(let r=0,n=t.count;r<n;r++){e.fromBufferAttribute(t,r);var i=1/e.manhattanLength();i!=1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(r,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){var i=this.skeleton,r=this.geometry;kl.fromBufferAttribute(r.attributes.skinIndex,e),Vl.fromBufferAttribute(r.attributes.skinWeight,e),Hl.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){var n,a=Vl.getComponent(e);0!==a&&(n=kl.getComponent(e),Xl.multiplyMatrices(i.bones[n].matrixWorld,i.boneInverses[n]),t.addScaledVector(Wl.copy(Hl).applyMatrix4(Xl),a))}return t.applyMatrix4(this.bindMatrixInverse)}boneTransform(e,t){return console.warn("THREE.SkinnedMesh: .boneTransform() was renamed to .applyBoneTransform() in r151."),this.applyBoneTransform(e,t)}}class Yl extends un{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Zl extends er{constructor(e=null,t=1,i=1,r,n,a,s,o,l=de,h=de,c,u){super(null,a,s,o,l,h,r,n,c,u),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Jl=new zr,Kl=new zr;class Ql{constructor(e=[],t=[]){this.uuid=bi(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){var e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new zr)}}calculateInverses(){for(let t=this.boneInverses.length=0,i=this.bones.length;t<i;t++){var e=new zr;this.bones[t]&&e.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(e)}}pose(){for(let t=0,i=this.bones.length;t<i;t++){var e=this.bones[t];e&&e.matrixWorld.copy(this.boneInverses[t]).invert()}for(let e=0,i=this.bones.length;e<i;e++){var t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){var e=this.bones,t=this.boneInverses,i=this.boneMatrices,r=this.boneTexture;for(let r=0,a=e.length;r<a;r++){var n=e[r]?e[r].matrixWorld:Kl;Jl.multiplyMatrices(n,t[r]),Jl.toArray(i,16*r)}null!==r&&(r.needsUpdate=!0)}clone(){return new Ql(this.bones,this.boneInverses)}computeBoneTexture(){var e=Ri(Math.sqrt(4*this.bones.length)),t=(e=Math.max(e,4),new Float32Array(e*e*4)),i=(t.set(this.boneMatrices),new Zl(t,e,e,De,Re));return i.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=i,this.boneTextureSize=e,this}getBoneByName(e){for(let i=0,r=this.bones.length;i<r;i++){var t=this.bones[i];if(t.name===e)return t}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let r=0,n=e.bones.length;r<n;r++){var i=e.bones[r];let n=t[i];void 0===n&&(console.warn("THREE.Skeleton: No bone found with UUID:",i),n=new Yl),this.bones.push(n),this.boneInverses.push((new zr).fromArray(e.boneInverses[r]))}return this.init(),this}toJSON(){var e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]},t=(e.uuid=this.uuid,this.bones),i=this.boneInverses;for(let n=0,a=t.length;n<a;n++){var r=t[n];e.bones.push(r.uuid),r=i[n],e.boneInverses.push(r.toArray())}return e}}class $l extends zn{constructor(e,t,i,r=1){super(e,t,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){var e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const eh=new zr,th=new zr,ih=[],rh=new dr,nh=new zr,ah=new Ma,sh=new Lr;class oh extends Ma{constructor(e,t,i){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new $l(new Float32Array(16*i),16),this.instanceColor=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let e=0;e<i;e++)this.setMatrixAt(e,nh)}computeBoundingBox(){var e=this.geometry,t=this.count;null===this.boundingBox&&(this.boundingBox=new dr),null===e.boundingBox&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,eh),rh.copy(e.boundingBox).applyMatrix4(eh),this.boundingBox.union(rh)}computeBoundingSphere(){var e=this.geometry,t=this.count;null===this.boundingSphere&&(this.boundingSphere=new Lr),null===e.boundingSphere&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<t;i++)this.getMatrixAt(i,eh),sh.copy(e.boundingSphere).applyMatrix4(eh),this.boundingSphere.union(sh)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){var i=this.matrixWorld,r=this.count;if(ah.geometry=this.geometry,ah.material=this.material,void 0!==ah.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),sh.copy(this.boundingSphere),sh.applyMatrix4(i),!1!==e.ray.intersectsSphere(sh)))for(let a=0;a<r;a++){this.getMatrixAt(a,eh),th.multiplyMatrices(i,eh),ah.matrixWorld=th,ah.raycast(e,ih);for(let e=0,i=ih.length;e<i;e++){var n=ih[e];n.instanceId=a,n.object=this,t.push(n)}ih.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new $l(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class lh extends Tn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ln(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const hh=new hr,ch=new hr,uh=new zr,dh=new Br,ph=new Lr;class mh extends un{constructor(e=new ra,t=new lh){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){var e=this.geometry;if(null===e.index){var t=e.attributes.position,i=[0];for(let e=1,r=t.count;e<r;e++)hh.fromBufferAttribute(t,e-1),ch.fromBufferAttribute(t,e),i[e]=i[e-1],i[e]+=hh.distanceTo(ch);e.setAttribute("lineDistance",new Yn(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){var i=this.geometry,r=this.matrixWorld,n=e.params.Line.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),ph.copy(i.boundingSphere),ph.applyMatrix4(r),ph.radius+=n,!1!==e.ray.intersectsSphere(ph)){uh.copy(r).invert(),dh.copy(e.ray).applyMatrix4(uh);var s,o=(r=n/((this.scale.x+this.scale.y+this.scale.z)/3))*r,l=new hr,h=new hr,c=new hr,u=new hr,d=this.isLineSegments?2:1,p=i.index,m=i.attributes.position;if(null!==p)for(let i=Math.max(0,a.start),r=Math.min(p.count,a.start+a.count)-1;i<r;i+=d){var f=p.getX(i),g=p.getX(i+1);o<(l.fromBufferAttribute(m,f),h.fromBufferAttribute(m,g),f=dh.distanceSqToSegment(l,h,u,c))||(u.applyMatrix4(this.matrixWorld),(g=e.ray.origin.distanceTo(u))<e.near)||g>e.far||t.push({distance:g,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}else for(let i=Math.max(0,a.start),r=Math.min(m.count,a.start+a.count)-1;i<r;i+=d)l.fromBufferAttribute(m,i),h.fromBufferAttribute(m,i+1),o<dh.distanceSqToSegment(l,h,u,c)||(u.applyMatrix4(this.matrixWorld),(s=e.ray.origin.distanceTo(u))<e.near)||s>e.far||t.push({distance:s,point:c.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}updateMorphTargets(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(0<t.length){var i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){var r=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=e}}}}}const fh=new hr,gh=new hr;class vh extends mh{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){var e=this.geometry;if(null===e.index){var t=e.attributes.position,i=[];for(let e=0,r=t.count;e<r;e+=2)fh.fromBufferAttribute(t,e),gh.fromBufferAttribute(t,e+1),i[e]=0===e?0:i[e-1],i[e+1]=i[e]+fh.distanceTo(gh);e.setAttribute("lineDistance",new Yn(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class _h extends mh{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class xh extends Tn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Ln(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const yh=new zr,Mh=new Br,Sh=new Lr,bh=new hr;class Eh extends un{constructor(e=new ra,t=new xh){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){var i=this.geometry,r=this.matrixWorld,n=e.params.Points.threshold,a=i.drawRange;if(null===i.boundingSphere&&i.computeBoundingSphere(),Sh.copy(i.boundingSphere),Sh.applyMatrix4(r),Sh.radius+=n,!1!==e.ray.intersectsSphere(Sh)){yh.copy(r).invert(),Mh.copy(e.ray).applyMatrix4(yh);var s=(n/=(this.scale.x+this.scale.y+this.scale.z)/3)*n,o=i.index,l=i.attributes.position;if(null!==o)for(let i=Math.max(0,a.start),n=Math.min(o.count,a.start+a.count);i<n;i++){var h=o.getX(i);bh.fromBufferAttribute(l,h),Th(bh,h,s,r,e,t,this)}else for(let i=Math.max(0,a.start),n=Math.min(l.count,a.start+a.count);i<n;i++)bh.fromBufferAttribute(l,i),Th(bh,i,s,r,e,t,this)}}updateMorphTargets(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(0<t.length){var i=e[t[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=i.length;e<t;e++){var r=i[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[r]=e}}}}}function Th(e,t,i,r,n,a,s){var o=Mh.distanceSqToPoint(e);o<i&&(i=new hr,Mh.closestPointToPoint(e,i),i.applyMatrix4(r),(e=n.ray.origin.distanceTo(i))<n.near||e>n.far||a.push({distance:e,distanceToRay:Math.sqrt(o),point:i,index:t,face:null,object:s}))}class wh extends er{constructor(e,t,i,r,n,a,s,o,l){super(e,t,i,r,n,a,s,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:ve,this.magFilter=void 0!==n?n:ve,this.generateMipmaps=!1;const h=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(function t(){h.needsUpdate=!0,e.requestVideoFrameCallback(t)})}clone(){return new this.constructor(this.image).copy(this)}update(){var e=this.image;0=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Ah extends er{constructor(e,t,i){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=i,this.magFilter=de,this.minFilter=de,this.generateMipmaps=!1,this.needsUpdate=!0}}class Rh extends er{constructor(e,t,i,r,n,a,s,o,l,h,c,u){super(null,a,s,o,l,h,r,n,c,u),this.isCompressedTexture=!0,this.image={width:t,height:i},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ch extends Rh{constructor(e,t,i,r,n,a){super(e,t,i,n,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ce}}class Lh extends er{constructor(e,t,i,r,n,a,s,o,l){super(e,t,i,r,n,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ph{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){return e=this.getUtoTmapping(e),this.getPoint(e,t)}getPoints(e=5){var t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){var t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){var e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t=[];let i,r=this.getPoint(0),n=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),n+=i.distanceTo(r),t.push(n),r=i;return this.cacheArcLengths=t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){var i=this.getLengths();let r=0;var n=i.length;let a,s,o=(a=t||e*i[n-1],0),l=n-1;for(;o<=l;)if((s=i[r=Math.floor(o+(l-o)/2)]-a)<0)o=r+1;else{if(!(0<s)){l=r;break}l=r-1}return i[r=l]===a?r/(n-1):(r+(e=(a-(t=i[r]))/((e=i[r+1])-t)))/(n-1)}getTangent(e,t){let i=e-1e-4,r=e+1e-4;i<0&&(i=0),1<r&&(r=1),e=this.getPoint(i);var n=this.getPoint(r);return(t=t||new(e.isVector2?Ui:hr)).copy(n).sub(e).normalize(),t}getTangentAt(e,t){return e=this.getUtoTmapping(e),this.getTangent(e,t)}computeFrenetFrames(e,t){var i=new hr,r=[],n=[],a=[],s=new hr,o=new zr;for(let t=0;t<=e;t++){var l=t/e;r[t]=this.getTangentAt(l,new hr)}n[0]=new hr,a[0]=new hr;let h=Number.MAX_VALUE;var c,u=Math.abs(r[0].x),d=Math.abs(r[0].y),p=Math.abs(r[0].z);u<=h&&(h=u,i.set(1,0,0)),d<=h&&(h=d,i.set(0,1,0)),p<=h&&i.set(0,0,1),s.crossVectors(r[0],i).normalize(),n[0].crossVectors(r[0],s),a[0].crossVectors(r[0],n[0]);for(let t=1;t<=e;t++)n[t]=n[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(r[t-1],r[t]),s.length()>Number.EPSILON&&(s.normalize(),c=Math.acos(Ei(r[t-1].dot(r[t]),-1,1)),n[t].applyMatrix4(o.makeRotationAxis(s,c))),a[t].crossVectors(r[t],n[t]);if(!0===t){let t=Math.acos(Ei(n[0].dot(n[e]),-1,1));t/=e,0<r[0].dot(s.crossVectors(n[0],n[e]))&&(t=-t);for(let i=1;i<=e;i++)n[i].applyMatrix4(o.makeRotationAxis(r[i],t*i)),a[i].crossVectors(r[i],n[i])}return{tangents:r,normals:n,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Ih extends Ph{constructor(e=0,t=0,i=1,r=1,n=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=r,this.aStartAngle=n,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){t=t||new Ui;var i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;for(var n=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;var a,s;r<Number.EPSILON&&(r=n?0:i),!0!==this.aClockwise||n||(r===i?r=-i:r-=i),n=this.aStartAngle+e*r;let o=this.aX+this.xRadius*Math.cos(n),l=this.aY+this.yRadius*Math.sin(n);return 0!==this.aRotation&&(e=Math.cos(this.aRotation),n=Math.sin(this.aRotation),o=(a=o-this.aX)*e-(s=l-this.aY)*n+this.aX,l=a*n+s*e+this.aY),t.set(o,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){var e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class Uh extends Ih{constructor(e,t,i,r,n,a){super(e,t,i,i,r,n,a),this.isArcCurve=!0,this.type="ArcCurve"}}function Dh(){let e=0,t=0,i=0,r=0;function n(n,a,s,o){e=n,t=s,i=-3*n+3*a-2*s-o,r=2*n-2*a+s+o}return{initCatmullRom:function(e,t,i,r,a){n(t,i,a*(i-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,i,r,a,s,o){e=(t-e)/a-(i-e)/(a+s)+(i-t)/s,a=(i-t)/s-(r-t)/(s+o)+(r-i)/o,n(t,i,e*=s,a*=s)},calc:function(n){var a=n*n;return e+t*n+i*a+r*(a*n)}}}const Nh=new hr,Oh=new Dh,Fh=new Dh,Bh=new Dh;class zh extends Ph{constructor(e=[],t=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=i,this.tension=r}getPoint(e,t=new hr){var i=this.points,r=i.length;e=(r-(this.closed?0:1))*e;let n,a,s=Math.floor(e),o=e-s;this.closed?s+=0<s?0:(Math.floor(Math.abs(s)/r)+1)*r:0===o&&s===r-1&&(s=r-2,o=1),n=this.closed||0<s?i[(s-1)%r]:(Nh.subVectors(i[0],i[1]).add(i[0]),Nh),e=i[s%r];var l=i[(s+1)%r];if(a=this.closed||s+2<r?i[(s+2)%r]:(Nh.subVectors(i[r-1],i[r-2]).add(i[r-1]),Nh),"centripetal"===this.curveType||"chordal"===this.curveType){i="chordal"===this.curveType?.5:.25;let t=Math.pow(n.distanceToSquared(e),i),r=Math.pow(e.distanceToSquared(l),i),s=Math.pow(l.distanceToSquared(a),i);r<1e-4&&(r=1),t<1e-4&&(t=r),s<1e-4&&(s=r),Oh.initNonuniformCatmullRom(n.x,e.x,l.x,a.x,t,r,s),Fh.initNonuniformCatmullRom(n.y,e.y,l.y,a.y,t,r,s),Bh.initNonuniformCatmullRom(n.z,e.z,l.z,a.z,t,r,s)}else"catmullrom"===this.curveType&&(Oh.initCatmullRom(n.x,e.x,l.x,a.x,this.tension),Fh.initCatmullRom(n.y,e.y,l.y,a.y,this.tension),Bh.initCatmullRom(n.z,e.z,l.z,a.z,this.tension));return t.set(Oh.calc(o),Fh.calc(o),Bh.calc(o)),t}copy(e){super.copy(e),this.points=[];for(let i=0,r=e.points.length;i<r;i++){var t=e.points[i];this.points.push(t.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){var e=super.toJSON();e.points=[];for(let i=0,r=this.points.length;i<r;i++){var t=this.points[i];e.points.push(t.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let i=0,r=e.points.length;i<r;i++){var t=e.points[i];this.points.push((new hr).fromArray(t))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Gh(e,t,i,r,n){var a=e*e;return(2*i-2*r+(t=.5*(r-t))+(n=.5*(n-i)))*(e*a)+(-3*i+3*r-2*t-n)*a+t*e+i}function Hh(e,t,i,r){return(n=1-(n=e))*n*t+2*(1-e)*e*i+e*e*r;var n}function kh(e,t,i,r,n){return(a=1-(a=e))*a*a*t+3*(a=1-e)*a*e*i+3*(1-e)*e*e*r+e*e*e*n;var a}class Vh extends Ph{constructor(e=new Ui,t=new Ui,i=new Ui,r=new Ui){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new Ui){var i=this.v0,r=this.v1,n=this.v2,a=this.v3;return t.set(kh(e,i.x,r.x,n.x,a.x),kh(e,i.y,r.y,n.y,a.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){var e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Wh extends Ph{constructor(e=new hr,t=new hr,i=new hr,r=new hr){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=i,this.v3=r}getPoint(e,t=new hr){var i=this.v0,r=this.v1,n=this.v2,a=this.v3;return t.set(kh(e,i.x,r.x,n.x,a.x),kh(e,i.y,r.y,n.y,a.y),kh(e,i.z,r.z,n.z,a.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){var e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Xh extends Ph{constructor(e=new Ui,t=new Ui){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ui){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ui){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class jh extends Ph{constructor(e=new hr,t=new hr){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new hr){return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new hr){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class qh extends Ph{constructor(e=new Ui,t=new Ui,i=new Ui){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new Ui){var i=this.v0,r=this.v1,n=this.v2;return t.set(Hh(e,i.x,r.x,n.x),Hh(e,i.y,r.y,n.y)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Yh extends Ph{constructor(e=new hr,t=new hr,i=new hr){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=i}getPoint(e,t=new hr){var i=this.v0,r=this.v1,n=this.v2;return t.set(Hh(e,i.x,r.x,n.x),Hh(e,i.y,r.y,n.y),Hh(e,i.z,r.z,n.z)),t}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){var e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Zh extends Ph{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ui){e=((s=this.points).length-1)*e;var i=Math.floor(e),r=(e-=i,s[0===i?i:i-1]),n=s[i],a=s[i>s.length-2?s.length-1:i+1],s=s[i>s.length-3?s.length-1:i+2];return t.set(Gh(e,r.x,n.x,a.x,s.x),Gh(e,r.y,n.y,a.y,s.y)),t}copy(e){super.copy(e),this.points=[];for(let i=0,r=e.points.length;i<r;i++){var t=e.points[i];this.points.push(t.clone())}return this}toJSON(){var e=super.toJSON();e.points=[];for(let i=0,r=this.points.length;i<r;i++){var t=this.points[i];e.points.push(t.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let i=0,r=e.points.length;i<r;i++){var t=e.points[i];this.points.push((new Ui).fromArray(t))}return this}}var Jh=Object.freeze({__proto__:null,ArcCurve:Uh,CatmullRomCurve3:zh,CubicBezierCurve:Vh,CubicBezierCurve3:Wh,EllipseCurve:Ih,LineCurve:Xh,LineCurve3:jh,QuadraticBezierCurve:qh,QuadraticBezierCurve3:Yh,SplineCurve:Zh});class Kh extends Ph{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){var e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Xh(t,e))}getPoint(e,t){var i,r,n,a=e*this.getLength(),s=this.getCurveLengths();let o=0;for(;o<s.length;){if(s[o]>=a)return i=s[o]-a,n=(r=this.curves[o]).getLength(),r.getPointAt(0===n?0:1-i/n,t);o++}return null}getLength(){var e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;var e=[];let t=0;for(let i=0,r=this.curves.length;i<r;i++)t+=this.curves[i].getLength(),e.push(t);return this.cacheLengths=e}getSpacedPoints(e=40){var t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){var t=[];let i;for(let o=0,l=this.curves;o<l.length;o++){var r=l[o],n=r.isEllipseCurve?2*e:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?e*r.points.length:e,a=r.getPoints(n);for(let e=0;e<a.length;e++){var s=a[e];i&&i.equals(s)||(t.push(s),i=s)}}return this.autoClose&&1<t.length&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let i=0,r=e.curves.length;i<r;i++){var t=e.curves[i];this.curves.push(t.clone())}return this.autoClose=e.autoClose,this}toJSON(){var e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let i=0,r=this.curves.length;i<r;i++){var t=this.curves[i];e.curves.push(t.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let i=0,r=e.curves.length;i<r;i++){var t=e.curves[i];this.curves.push((new Jh[t.type]).fromJSON(t))}return this}}class Qh extends Kh{constructor(e){super(),this.type="Path",this.currentPoint=new Ui,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,i=e.length;t<i;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){var i=new Xh(this.currentPoint.clone(),new Ui(e,t));return this.curves.push(i),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,i,r){return e=new qh(this.currentPoint.clone(),new Ui(e,t),new Ui(i,r)),this.curves.push(e),this.currentPoint.set(i,r),this}bezierCurveTo(e,t,i,r,n,a){return e=new Vh(this.currentPoint.clone(),new Ui(e,t),new Ui(i,r),new Ui(n,a)),this.curves.push(e),this.currentPoint.set(n,a),this}splineThru(e){var t=[this.currentPoint.clone()].concat(e);return t=new Zh(t),this.curves.push(t),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,i,r,n,a){var s=this.currentPoint.x,o=this.currentPoint.y;return this.absarc(e+s,t+o,i,r,n,a),this}absarc(e,t,i,r,n,a){return this.absellipse(e,t,i,i,r,n,a),this}ellipse(e,t,i,r,n,a,s,o){var l=this.currentPoint.x,h=this.currentPoint.y;return this.absellipse(e+l,t+h,i,r,n,a,s,o),this}absellipse(e,t,i,r,n,a,s,o){return e=new Ih(e,t,i,r,n,a,s,o),0<this.curves.length&&((t=e.getPoint(0)).equals(this.currentPoint)||this.lineTo(t.x,t.y)),this.curves.push(e),i=e.getPoint(1),this.currentPoint.copy(i),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){var e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class $h extends ra{constructor(e=[new Ui(0,-.5),new Ui(.5,0),new Ui(0,.5)],t=12,i=0,r=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:i,phiLength:r},t=Math.floor(t),r=Ei(r,0,2*Math.PI);var n=[],a=[],s=[],o=[],l=[],h=1/t,c=new hr,u=new Ui,d=new hr,p=new hr,m=new hr;let f=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=+g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(m.x,m.y,m.z);break;default:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=+g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let n=0;n<=t;n++){var v=i+n*h*r,_=Math.sin(v),x=Math.cos(v);for(let i=0;i<=e.length-1;i++){c.x=e[i].x*_,c.y=e[i].y,c.z=e[i].x*x,a.push(c.x,c.y,c.z),u.x=n/t,u.y=i/(e.length-1),s.push(u.x,u.y);var y=o[3*i+0]*_,M=o[3*i+1],S=o[3*i+0]*x;l.push(y,M,S)}}for(let i=0;i<t;i++)for(let t=0;t<e.length-1;t++){var b=t+i*e.length,E=b+e.length,T=b+e.length+1,w=b+1;n.push(b,E,w),n.push(T,w,E)}this.setIndex(n),this.setAttribute("position",new Yn(a,3)),this.setAttribute("uv",new Yn(s,2)),this.setAttribute("normal",new Yn(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new $h(e.points,e.segments,e.phiStart,e.phiLength)}}class ec extends $h{constructor(e=1,t=1,i=4,r=8){var n=new Qh;n.absarc(0,-t/2,e,1.5*Math.PI,0),n.absarc(0,t/2,e,0,.5*Math.PI),super(n.getPoints(i),r),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:i,radialSegments:r}}static fromJSON(e){return new ec(e.radius,e.length,e.capSegments,e.radialSegments)}}class tc extends ra{constructor(e=1,t=32,i=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:i,thetaLength:r},t=Math.max(3,t);var n=[],a=[],s=[],o=[],l=new hr,h=new Ui;a.push(0,0,0),s.push(0,0,1),o.push(.5,.5);for(let n=0,u=3;n<=t;n++,u+=3){var c=i+n/t*r;l.x=e*Math.cos(c),l.y=e*Math.sin(c),a.push(l.x,l.y,l.z),s.push(0,0,1),h.x=(a[u]/e+1)/2,h.y=(a[u+1]/e+1)/2,o.push(h.x,h.y)}for(let e=1;e<=t;e++)n.push(e,e+1,0);this.setIndex(n),this.setAttribute("position",new Yn(a,3)),this.setAttribute("normal",new Yn(s,3)),this.setAttribute("uv",new Yn(o,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new tc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class ic extends ra{constructor(e=1,t=1,i=1,r=32,n=1,a=!1,s=0,o=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:i,radialSegments:r,heightSegments:n,openEnded:a,thetaStart:s,thetaLength:o};const l=this,h=(r=Math.floor(r),n=Math.floor(n),[]),c=[],u=[],d=[];let p=0;const m=[],f=i/2;let g=0;{var v=new hr,_=new hr;let a=0;var x=(t-e)/i;for(let a=0;a<=n;a++){var y=[],M=a/n,S=M*(t-e)+e;for(let e=0;e<=r;e++){var b=e/r,E=b*o+s,T=Math.sin(E);E=Math.cos(E),_.x=S*T,_.y=-M*i+f,_.z=S*E,c.push(_.x,_.y,_.z),v.set(T,x,E).normalize(),u.push(v.x,v.y,v.z),d.push(b,1-M),y.push(p++)}m.push(y)}for(let e=0;e<r;e++)for(let t=0;t<n;t++){var w=m[t][e],A=m[t+1][e],R=m[t+1][e+1],C=m[t][e+1];h.push(w,A,C),h.push(A,R,C),a+=6}l.addGroup(g,a,0),g+=a}function L(i){var n=p,a=new Ui,m=new hr;let v=0;var _=!0===i?e:t,x=!0===i?1:-1;for(let e=1;e<=r;e++)c.push(0,f*x,0),u.push(0,x,0),d.push(.5,.5),p++;var y=p;for(let e=0;e<=r;e++){var M=e/r*o+s,S=Math.cos(M);M=Math.sin(M),m.x=_*M,m.y=f*x,m.z=_*S,c.push(m.x,m.y,m.z),u.push(0,x,0),a.x=.5*S+.5,a.y=.5*M*x+.5,d.push(a.x,a.y),p++}for(let e=0;e<r;e++){var b=n+e,E=y+e;!0===i?h.push(E,E+1,b):h.push(E+1,E,b),v+=3}l.addGroup(g,v,!0===i?1:2),g+=v}!1===a&&(0<e&&L(!0),0<t)&&L(!1),this.setIndex(h),this.setAttribute("position",new Yn(c,3)),this.setAttribute("normal",new Yn(u,3)),this.setAttribute("uv",new Yn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ic(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rc extends ic{constructor(e=1,t=1,i=32,r=1,n=!1,a=0,s=2*Math.PI){super(0,e,t,i,r,n,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:i,heightSegments:r,openEnded:n,thetaStart:a,thetaLength:s}}static fromJSON(e){return new rc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class nc extends ra{constructor(e=[],t=[],i=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:i,detail:r};const n=[],a=[];var s=r,o=new hr,l=new hr,h=new hr;for(let e=0;e<t.length;e+=3){B(t[e+0],o),B(t[e+1],l),B(t[e+2],h),c=void 0,u=void 0,m=void 0,f=void 0,g=void 0,v=void 0,_=void 0;var c=o,u=l,d=h,p=s+1,m=[];for(let e=0;e<=p;e++){m[e]=[];var f=c.clone().lerp(d,e/p),g=u.clone().lerp(d,e/p),v=p-e;for(let t=0;t<=v;t++)m[e][t]=0===t&&e===p?f:f.clone().lerp(g,t/v)}for(let e=0;e<p;e++)for(let t=0;t<2*(p-e)-1;t++){var _=Math.floor(t/2);t%2==0?(F(m[e][_+1]),F(m[e+1][_]),F(m[e][_])):(F(m[e][_+1]),F(m[e+1][_+1]),F(m[e+1][_]))}}var x=i,y=new hr;for(let e=0;e<n.length;e+=3)y.x=n[e+0],y.y=n[e+1],y.z=n[e+2],y.normalize().multiplyScalar(x),n[e+0]=y.x,n[e+1]=y.y,n[e+2]=y.z;var M=new hr;for(let e=0;e<n.length;e+=3){M.x=n[e+0],M.y=n[e+1],M.z=n[e+2];var S=G(M)/2/Math.PI+.5,b=function(e){return Math.atan2(-e.y,Math.sqrt(e.x*e.x+e.z*e.z))}(M)/Math.PI+.5;a.push(S,1-b)}var E=new hr,T=new hr,w=new hr,A=new hr,R=new Ui,C=new Ui,L=new Ui;for(let e=0,t=0;e<n.length;e+=9,t+=6){E.set(n[e+0],n[e+1],n[e+2]),T.set(n[e+3],n[e+4],n[e+5]),w.set(n[e+6],n[e+7],n[e+8]),R.set(a[t+0],a[t+1]),C.set(a[t+2],a[t+3]),L.set(a[t+4],a[t+5]),A.copy(E).add(T).add(w).divideScalar(3);var P=G(A);z(R,t+0,E,P),z(C,t+2,T,P),z(L,t+4,w,P)}for(let e=0;e<a.length;e+=6){var I=a[e+0],U=a[e+2],D=a[e+4],N=Math.max(I,U,D),O=Math.min(I,U,D);.9<N&&O<.1&&(I<.2&&(a[e+0]+=1),U<.2&&(a[e+2]+=1),D<.2)&&(a[e+4]+=1)}function F(e){n.push(e.x,e.y,e.z)}function B(t,i){t*=3,i.x=e[0+t],i.y=e[1+t],i.z=e[2+t]}function z(e,t,i,r){r<0&&1===e.x&&(a[t]=e.x-1),0===i.x&&0===i.z&&(a[t]=r/2/Math.PI+.5)}function G(e){return Math.atan2(e.z,-e.x)}this.setAttribute("position",new Yn(n,3)),this.setAttribute("normal",new Yn(n.slice(),3)),this.setAttribute("uv",new Yn(a,2)),0===r?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new nc(e.vertices,e.indices,e.radius,e.details)}}class ac extends nc{constructor(e=1,t=0){var i=(1+Math.sqrt(5))/2,r=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-i,0,-r,i,0,r,-i,0,r,i,-r,-i,0,-r,i,0,r,-i,0,r,i,0,-i,0,-r,i,0,-r,-i,0,r,i,0,r],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ac(e.radius,e.detail)}}const sc=new hr,oc=new hr,lc=new hr,hc=new bn;class cc extends ra{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){var i,r,n=Math.pow(10,4),a=Math.cos(Mi*t),s=e.getIndex(),o=e.getAttribute("position"),l=(s||o).count,h=[0,0,0],c=["a","b","c"],u=new Array(3),d={},p=[];for(let e=0;e<l;e+=3){s?(h[0]=s.getX(e),h[1]=s.getX(e+1),h[2]=s.getX(e+2)):(h[0]=e,h[1]=e+1,h[2]=e+2);var{a:m,b:f,c:g}=hc;if(m.fromBufferAttribute(o,h[0]),f.fromBufferAttribute(o,h[1]),g.fromBufferAttribute(o,h[2]),hc.getNormal(lc),u[0]=`${Math.round(m.x*n)},${Math.round(m.y*n)},`+Math.round(m.z*n),u[1]=`${Math.round(f.x*n)},${Math.round(f.y*n)},`+Math.round(f.z*n),u[2]=`${Math.round(g.x*n)},${Math.round(g.y*n)},`+Math.round(g.z*n),u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){var v=(e+1)%3,_=u[e],x=u[v],y=hc[c[e]],M=hc[c[v]],S=_+"_"+x;(x=x+"_"+_)in d&&d[x]?(lc.dot(d[x].normal)<=a&&(p.push(y.x,y.y,y.z),p.push(M.x,M.y,M.z)),d[x]=null):S in d||(d[S]={index0:h[e],index1:h[v],normal:lc.clone()})}}for(const e in d)d[e]&&(({index0:i,index1:r}=d[e]),sc.fromBufferAttribute(o,i),oc.fromBufferAttribute(o,r),p.push(sc.x,sc.y,sc.z),p.push(oc.x,oc.y,oc.z));this.setAttribute("position",new Yn(p,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class uc extends Qh{constructor(e){super(e),this.uuid=bi(),this.type="Shape",this.holes=[]}getPointsHoles(e){var t=[];for(let i=0,r=this.holes.length;i<r;i++)t[i]=this.holes[i].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let i=0,r=e.holes.length;i<r;i++){var t=e.holes[i];this.holes.push(t.clone())}return this}toJSON(){var e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let i=0,r=this.holes.length;i<r;i++){var t=this.holes[i];e.holes.push(t.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let i=0,r=e.holes.length;i<r;i++){var t=e.holes[i];this.holes.push((new Qh).fromJSON(t))}return this}}const dc=function(e,t,i=2){var r=t&&t.length,n=r?t[0]*i:e.length;let a=pc(e,0,n,i,!0);var s=[];if(a&&a.next!==a.prev){let o,l,h,c,u,d,p;if(r&&(a=function(e,t,i,r){var n=[];let a,s,o,l,h;for(a=0,s=t.length;a<s;a++)o=t[a]*r,l=a<s-1?t[a+1]*r:e.length,(h=pc(e,o,l,r,!1))===h.next&&(h.steiner=!0),n.push(function(e){let t=e,i=e;for(;(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next,t!==e;);return i}(h));for(n.sort(gc),a=0;a<n.length;a++)i=function(e,t){var i=function(e,t){let i,r=t,n=-1/0;var a=e.x,s=e.y;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var o=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(o<=a&&o>n&&(n=o,i=r.x<r.next.x?r:r.next,o===a))return i}}while(r=r.next,r!==t);if(!i)return null;var l=i,h=i.x,c=i.y;let u,d=1/0;for(r=i;a>=r.x&&r.x>=h&&a!==r.x&&_c(s<c?a:n,s,h,c,s<c?n:a,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(a-r.x),Ec(r,e))&&(u<d||u===d&&(r.x>i.x||r.x===i.x&&function(e,t){return xc(e.prev,e,t.prev)<0&&xc(t.next,e,e.next)<0}(i,r)))&&(i=r,d=u),r=r.next,r!==l;);return i}(e,t);return i?(mc(t=Tc(i,e),t.next),mc(i,i.next)):t}(n[a],i);return i}(e,t,a,i)),e.length>80*i){o=h=e[0],l=c=e[1];for(let t=i;t<n;t+=i)u=e[t],d=e[t+1],u<o&&(o=u),d<l&&(l=d),u>h&&(h=u),d>c&&(c=d);p=0!==(p=Math.max(h-o,c-l))?32767/p:0}fc(a,s,i,o,l,p,0)}return s};function pc(e,t,i,r,n){let a,s;if(n===0<function(e,t,i,r){let n=0;for(let a=t,s=i-r;a<i;a+=r)n+=(e[s]-e[a])*(e[a+1]+e[s+1]),s=a;return n}(e,t,i,r))for(a=t;a<i;a+=r)s=wc(a,e[a],e[a+1],s);else for(a=i-r;a>=t;a-=r)s=wc(a,e[a],e[a+1],s);return s&&yc(s,s.next)&&(Ac(s),s=s.next),s}function mc(e,t){if(!e)return e;t=t||e;let i,r=e;do{if(i=!1,r.steiner||!yc(r,r.next)&&0!==xc(r.prev,r,r.next))r=r.next;else{if(Ac(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function fc(e,t,i,r,n,a,s){if(e){if(!s&&a){var o=e,l=r,h=n,c=a;let t=o;for(;0===t.z&&(t.z=vc(t.x,t.y,l,h,c)),t.prevZ=t.prev,t.nextZ=t.next,(t=t.next)!==o;);t.prevZ.nextZ=null,t.prevZ=null;{var u=t;let e,i,r,n,a,s,o,l,h=1;do{for(i=u,u=null,a=null,s=0;i;){for(s++,r=i,o=0,e=0;e<h&&(o++,r=r.nextZ);e++);for(l=h;0<o||0<l&&r;)0!==o&&(0===l||!r||i.z<=r.z)?(i=(n=i).nextZ,o--):(r=(n=r).nextZ,l--),a?a.nextZ=n:u=n,n.prevZ=a,a=n;i=r}}while(a.nextZ=null,h*=2,1<s)}}let d,p,m=e;for(;e.prev!==e.next;)if(d=e.prev,p=e.next,a?function(e,t,i,r){var n=e.prev,a=e,s=e.next;if(0<=xc(n,a,s))return;var o=n.x,l=a.x,h=s.x,c=n.y,u=a.y,d=s.y,p=o<l?o<h?o:h:l<h?l:h,m=c<u?c<d?c:d:u<d?u:d,f=l<o?h<o?o:h:h<l?l:h,g=u<c?d<c?c:d:d<u?u:d,v=vc(p,m,t,i,r),_=vc(f,g,t,i,r);let x=e.prevZ,y=e.nextZ;for(;x&&x.z>=v&&y&&y.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==n&&x!==s&&_c(o,c,l,u,h,d,x.x,x.y)&&0<=xc(x.prev,x,x.next))return;if(x=x.prevZ,y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==n&&y!==s&&_c(o,c,l,u,h,d,y.x,y.y)&&0<=xc(y.prev,y,y.next))return;y=y.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==n&&x!==s&&_c(o,c,l,u,h,d,x.x,x.y)&&0<=xc(x.prev,x,x.next))return;x=x.prevZ}for(;y&&y.z<=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==n&&y!==s&&_c(o,c,l,u,h,d,y.x,y.y)&&0<=xc(y.prev,y,y.next))return;y=y.nextZ}return 1}(e,r,n,a):function(e){var t=e.prev,i=e;if(0<=xc(t,i,e=e.next))return;var r=t.x,n=i.x,a=e.x,s=t.y,o=i.y,l=e.y,h=r<n?r<a?r:a:n<a?n:a,c=s<o?s<l?s:l:o<l?o:l,u=n<r?a<r?r:a:a<n?n:a,d=o<s?l<s?s:l:l<o?o:l;let p=e.next;for(;p!==t;){if(p.x>=h&&p.x<=u&&p.y>=c&&p.y<=d&&_c(r,s,n,o,a,l,p.x,p.y)&&0<=xc(p.prev,p,p.next))return;p=p.next}return 1}(e))t.push(d.i/i|0),t.push(e.i/i|0),t.push(p.i/i|0),Ac(e),e=p.next,m=p.next;else if((e=p)===m){s?1===s?fc(e=function(e,t,i){let r=e;do{var n=r.prev,a=r.next.next;!yc(n,a)&&Mc(n,r,r.next,a)&&Ec(n,a)&&Ec(a,n)&&(t.push(n.i/i|0),t.push(r.i/i|0),t.push(a.i/i|0),Ac(r),Ac(r.next),r=e=a),r=r.next}while(r!==e);return mc(r)}(mc(e),t,i),t,i,r,n,a,2):2===s&&function(e,t,i,r,n,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){var o;if(s.i!==e.i&&function(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&Mc(i,i.next,e,t))return 1}while(i=i.next,i!==e)}(e,t)&&(Ec(e,t)&&Ec(t,e)&&function(e,t){let i=e,r=!1;for(var n=(e.x+t.x)/2,a=(e.y+t.y)/2;i.y>a!=i.next.y>a&&i.next.y!==i.y&&n<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next,i!==e;);return r}(e,t)&&(xc(e.prev,e,t.prev)||xc(e,t.prev,t))||yc(e,t)&&0<xc(e.prev,e,e.next)&&0<xc(t.prev,t,t.next))}(s,e))return o=Tc(s,e),s=mc(s,s.next),o=mc(o,o.next),fc(s,t,i,r,n,a,0),fc(o,t,i,r,n,a,0);e=e.next}}while(s=s.next,s!==e)}(e,t,i,r,n,a):fc(mc(e),t,i,r,n,a,1);break}}}function gc(e,t){return e.x-t.x}function vc(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function _c(e,t,i,r,n,a,s,o){return(e-s)*(a-o)<=(n-s)*(t-o)&&(i-s)*(t-o)<=(e-s)*(r-o)&&(n-s)*(r-o)<=(i-s)*(a-o)}function xc(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function yc(e,t){return e.x===t.x&&e.y===t.y}function Mc(e,t,i,r){var n=bc(xc(e,t,i)),a=bc(xc(e,t,r)),s=bc(xc(i,r,e)),o=bc(xc(i,r,t));return n!==a&&s!==o||0===n&&Sc(e,i,t)||0===a&&Sc(e,r,t)||0===s&&Sc(i,e,r)||!(0!==o||!Sc(i,t,r))}function Sc(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function bc(e){return 0<e?1:e<0?-1:0}function Ec(e,t){return xc(e.prev,e,e.next)<0?0<=xc(e,t,e.next)&&0<=xc(e,e.prev,t):xc(e,t,e.prev)<0||xc(e,e.next,t)<0}function Tc(e,t){var i=new Rc(e.i,e.x,e.y),r=new Rc(t.i,t.x,t.y),n=e.next,a=t.prev;return(e.next=t).prev=e,(i.next=n).prev=i,(r.next=i).prev=r,(a.next=r).prev=a,r}function wc(e,t,i,r){return e=new Rc(e,t,i),r?(e.next=r.next,(e.prev=r).next.prev=e,r.next=e):(e.prev=e).next=e,e}function Ac(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Rc(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Cc{static area(e){var t=e.length;let i=0;for(let r=t-1,n=0;n<t;r=n++)i+=e[r].x*e[n].y-e[n].x*e[r].y;return.5*i}static isClockWise(e){return Cc.area(e)<0}static triangulateShape(e,t){var i=[],r=[],n=[];Lc(e),Pc(i,e);let a=e.length;t.forEach(Lc);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,Pc(i,t[e]);var s=dc(i,r);for(let e=0;e<s.length;e+=3)n.push(s.slice(e,e+3));return n}}function Lc(e){var t=e.length;2<t&&e[t-1].equals(e[0])&&e.pop()}function Pc(e,t){for(let i=0;i<t.length;i++)e.push(t[i].x),e.push(t[i].y)}class Ic extends ra{constructor(e=new uc([new Ui(.5,.5),new Ui(-.5,.5),new Ui(-.5,-.5),new Ui(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const i=this,r=[],n=[];for(let a=0,s=e.length;a<s;a++)!function(e){const a=[],s=void 0!==t.curveSegments?t.curveSegments:12,o=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let h=void 0===t.bevelEnabled||t.bevelEnabled,c=void 0!==t.bevelThickness?t.bevelThickness:.2,u=void 0!==t.bevelSize?t.bevelSize:c-.1,d=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const m=t.extrudePath,f=void 0!==t.UVGenerator?t.UVGenerator:Uc;let g,v,_,x,y,M=!1;m&&(g=m.getSpacedPoints(o),M=!0,h=!1,v=m.computeFrenetFrames(o,!1),_=new hr,x=new hr,y=new hr),h||(p=0,c=0,u=0,d=0);let S=(e=e.extractPoints(s)).shape;const b=e.holes;if(!Cc.isClockWise(S)){S=S.reverse();for(let e=0,t=b.length;e<t;e++){var E=b[e];Cc.isClockWise(E)&&(b[e]=E.reverse())}}const T=Cc.triangulateShape(S,b),w=S;for(let e=0,t=b.length;e<t;e++){var A=b[e];S=S.concat(A)}function R(e,t,i){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,i)}const C=S.length,L=T.length;function P(e,t,i){let r,n,a;var s=e.x-t.x,o=e.y-t.y,l=i.x-e.x,h=i.y-e.y,c=s*s+o*o;if(Math.abs(s*h-o*l)>Number.EPSILON){var u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=t.x-o/u;if(t=t.y+s/u,r=p+s*(u=((i.x-h/d-p)*h-(i.y+l/d-t)*l)/(s*h-o*l))-e.x,n=t+o*u-e.y,(i=r*r+n*n)<=2)return new Ui(r,n);a=Math.sqrt(i/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),a=e?(r=-o,n=s,Math.sqrt(c)):(r=s,n=o,Math.sqrt(c/2))}return new Ui(r/a,n/a)}var I=[];for(let e=0,t=w.length,i=t-1,r=e+1;e<t;e++,i++,r++)i===t&&(i=0),r===t&&(r=0),I[e]=P(w[e],w[i],w[r]);var U=[];let D,N=I.concat();for(let e=0,t=b.length;e<t;e++){var O=b[e];D=[];for(let e=0,t=O.length,i=t-1,r=e+1;e<t;e++,i++,r++)i===t&&(i=0),r===t&&(r=0),D[e]=P(O[e],O[i],O[r]);U.push(D),N=N.concat(D)}for(let e=0;e<p;e++){var F=e/p,B=c*Math.cos(F*Math.PI/2);const t=u*Math.sin(F*Math.PI/2)+d;for(let e=0,i=w.length;e<i;e++){var z=R(w[e],I[e],t);K(z.x,z.y,-B)}for(let e=0,i=b.length;e<i;e++){var G=b[e];D=U[e];for(let e=0,i=G.length;e<i;e++){var H=R(G[e],D[e],t);K(H.x,H.y,-B)}}}const k=u+d;for(let e=0;e<C;e++){var V=h?R(S[e],N[e],k):S[e];M?(x.copy(v.normals[0]).multiplyScalar(V.x),_.copy(v.binormals[0]).multiplyScalar(V.y),y.copy(g[0]).add(x).add(_),K(y.x,y.y,y.z)):K(V.x,V.y,0)}for(let e=1;e<=o;e++)for(let t=0;t<C;t++){var W=h?R(S[t],N[t],k):S[t];M?(x.copy(v.normals[e]).multiplyScalar(W.x),_.copy(v.binormals[e]).multiplyScalar(W.y),y.copy(g[e]).add(x).add(_),K(y.x,y.y,y.z)):K(W.x,W.y,l/o*e)}for(let e=p-1;0<=e;e--){var X=e/p,j=c*Math.cos(X*Math.PI/2);const t=u*Math.sin(X*Math.PI/2)+d;for(let e=0,i=w.length;e<i;e++){var q=R(w[e],I[e],t);K(q.x,q.y,l+j)}for(let e=0,i=b.length;e<i;e++){var Y=b[e];D=U[e];for(let e=0,i=Y.length;e<i;e++){var Z=R(Y[e],D[e],t);M?K(Z.x,Z.y+g[o-1].y,g[o-1].x+j):K(Z.x,Z.y,l+j)}}}function J(e,t){let n=e.length;for(;0<=--n;){var a=n;let m=n-1;m<0&&(m=e.length-1);for(let e=0,n=o+2*p;e<n;e++){var s=C*e,l=C*(e+1),h=(c=h=void 0,t+a+s),c=t+m+s,u=t+m+l,d=t+a+l;$(h),$(c),$(d),$(c),$(u),$(d),h=r.length/3,ee((c=f.generateSideWallUV(i,r,h-6,h-3,h-2,h-1))[0]),ee(c[1]),ee(c[3]),ee(c[1]),ee(c[2]),ee(c[3])}}}function K(e,t,i){a.push(e),a.push(t),a.push(i)}function Q(e,t,n){$(e),$(t),$(n),e=r.length/3,ee((t=f.generateTopUV(i,r,e-3,e-2,e-1))[0]),ee(t[1]),ee(t[2])}function $(e){r.push(a[3*e+0]),r.push(a[3*e+1]),r.push(a[3*e+2])}function ee(e){n.push(e.x),n.push(e.y)}(function(){var e=r.length/3;if(h){let e=0*C;for(let i=0;i<L;i++){var t=T[i];Q(t[2]+e,t[1]+e,t[0]+e)}e=C*(o+2*p);for(let t=0;t<L;t++){var n=T[t];Q(n[0]+e,n[1]+e,n[2]+e)}}else{for(let e=0;e<L;e++){var a=T[e];Q(a[2],a[1],a[0])}for(let e=0;e<L;e++){var s=T[e];Q(s[0]+C*o,s[1]+C*o,s[2]+C*o)}}i.addGroup(e,r.length/3-e,0)})(),function(){var e=r.length/3;let t=0;J(w,t),t+=w.length;for(let e=0,i=b.length;e<i;e++){var n=b[e];J(n,t),t+=n.length}i.addGroup(e,r.length/3-e,1)}()}(e[a]);this.setAttribute("position",new Yn(r,3)),this.setAttribute("uv",new Yn(n,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){var e=super.toJSON(),t=i=this.parameters.shapes,i=this.parameters.options,r=e;if(r.shapes=[],Array.isArray(t))for(let e=0,i=t.length;e<i;e++){var n=t[e];r.shapes.push(n.uuid)}else r.shapes.push(t.uuid);return r.options=Object.assign({},i),void 0!==i.extrudePath&&(r.options.extrudePath=i.extrudePath.toJSON()),r}static fromJSON(e,t){var i=[];for(let n=0,a=e.shapes.length;n<a;n++){var r=t[e.shapes[n]];i.push(r)}var n=e.options.extrudePath;return void 0!==n&&(e.options.extrudePath=(new Jh[n.type]).fromJSON(n)),new Ic(i,e.options)}}const Uc={generateTopUV:function(e,t,i,r,n){var a=t[3*i],s=(i=t[3*i+1],t[3*r]),o=(r=t[3*r+1],t[3*n]);return t=t[3*n+1],[new Ui(a,i),new Ui(s,r),new Ui(o,t)]},generateSideWallUV:function(e,t,i,r,n,a){var s=t[3*i],o=t[3*i+1],l=(i=t[3*i+2],t[3*r]),h=t[3*r+1],c=(r=t[3*r+2],t[3*n]),u=t[3*n+1],d=(n=t[3*n+2],t[3*a]),p=t[3*a+1];return t=t[3*a+2],Math.abs(o-h)<Math.abs(s-l)?[new Ui(s,1-i),new Ui(l,1-r),new Ui(c,1-n),new Ui(d,1-t)]:[new Ui(o,1-i),new Ui(h,1-r),new Ui(u,1-n),new Ui(p,1-t)]}};class Dc extends nc{constructor(e=1,t=0){var i=(1+Math.sqrt(5))/2;super([-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Dc(e.radius,e.detail)}}class Nc extends nc{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Nc(e.radius,e.detail)}}class Oc extends ra{constructor(e=.5,t=1,i=32,r=1,n=0,a=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:i,phiSegments:r,thetaStart:n,thetaLength:a},i=Math.max(3,i);var s=[],o=[],l=[],h=[];let c=e;var u=(t-e)/(r=Math.max(1,r)),d=new hr,p=new Ui;for(let e=0;e<=r;e++){for(let e=0;e<=i;e++){var m=n+e/i*a;d.x=c*Math.cos(m),d.y=c*Math.sin(m),o.push(d.x,d.y,d.z),l.push(0,0,1),p.x=(d.x/t+1)/2,p.y=(d.y/t+1)/2,h.push(p.x,p.y)}c+=u}for(let e=0;e<r;e++){var f=e*(i+1);for(let e=0;e<i;e++){var g=e+f,v=g+i+1,_=g+i+2,x=g+1;s.push(g,v,x),s.push(v,_,x)}}this.setIndex(s),this.setAttribute("position",new Yn(o,3)),this.setAttribute("normal",new Yn(l,3)),this.setAttribute("uv",new Yn(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Oc(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class Fc extends ra{constructor(e=new uc([new Ui(0,.5),new Ui(-.5,-.5),new Ui(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const i=[],r=[],n=[],a=[];let s=0,o=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(s,o,t),s+=o,o=0;function l(e){var s=r.length/3;let l=(e=e.extractPoints(t)).shape;var h=e.holes;!1===Cc.isClockWise(l)&&(l=l.reverse());for(let e=0,t=h.length;e<t;e++){var c=h[e];!0===Cc.isClockWise(c)&&(h[e]=c.reverse())}var u=Cc.triangulateShape(l,h);for(let e=0,t=h.length;e<t;e++){var d=h[e];l=l.concat(d)}for(let e=0,t=l.length;e<t;e++){var p=l[e];r.push(p.x,p.y,0),n.push(0,0,1),a.push(p.x,p.y)}for(let e=0,t=u.length;e<t;e++){var m=(g=u[e])[0]+s,f=g[1]+s,g=g[2]+s;i.push(m,f,g),o+=3}}this.setIndex(i),this.setAttribute("position",new Yn(r,3)),this.setAttribute("normal",new Yn(n,3)),this.setAttribute("uv",new Yn(a,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){var e=super.toJSON(),t=this.parameters.shapes,i=e;if(i.shapes=[],Array.isArray(t))for(let e=0,n=t.length;e<n;e++){var r=t[e];i.shapes.push(r.uuid)}else i.shapes.push(t.uuid);return i}static fromJSON(e,t){var i=[];for(let n=0,a=e.shapes.length;n<a;n++){var r=t[e.shapes[n]];i.push(r)}return new Fc(i,e.curveSegments)}}class Bc extends ra{constructor(e=1,t=32,i=16,r=0,n=2*Math.PI,a=0,s=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:i,phiStart:r,phiLength:n,thetaStart:a,thetaLength:s},t=Math.max(3,Math.floor(t)),i=Math.max(2,Math.floor(i));var o=Math.min(a+s,Math.PI);let l=0;var h=[],c=new hr,u=new hr,d=[],p=[],m=[],f=[];for(let d=0;d<=i;d++){var g=[],v=d/i;let x=0;0===d&&0===a?x=.5/t:d===i&&o===Math.PI&&(x=-.5/t);for(let i=0;i<=t;i++){var _=i/t;c.x=-e*Math.cos(r+_*n)*Math.sin(a+v*s),c.y=e*Math.cos(a+v*s),c.z=e*Math.sin(r+_*n)*Math.sin(a+v*s),p.push(c.x,c.y,c.z),u.copy(c).normalize(),m.push(u.x,u.y,u.z),f.push(_+x,1-v),g.push(l++)}h.push(g)}for(let e=0;e<i;e++)for(let r=0;r<t;r++){var x=h[e][r+1],y=h[e][r],M=h[e+1][r],S=h[e+1][r+1];(0!==e||0<a)&&d.push(x,y,S),(e!==i-1||o<Math.PI)&&d.push(y,M,S)}this.setIndex(d),this.setAttribute("position",new Yn(p,3)),this.setAttribute("normal",new Yn(m,3)),this.setAttribute("uv",new Yn(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bc(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class zc extends nc{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new zc(e.radius,e.detail)}}class Gc extends ra{constructor(e=1,t=.4,i=12,r=48,n=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:i,tubularSegments:r,arc:n},i=Math.floor(i),r=Math.floor(r);var a=[],s=[],o=[],l=[],h=new hr,c=new hr,u=new hr;for(let a=0;a<=i;a++)for(let m=0;m<=r;m++){var d=m/r*n,p=a/i*Math.PI*2;c.x=(e+t*Math.cos(p))*Math.cos(d),c.y=(e+t*Math.cos(p))*Math.sin(d),c.z=t*Math.sin(p),s.push(c.x,c.y,c.z),h.x=e*Math.cos(d),h.y=e*Math.sin(d),u.subVectors(c,h).normalize(),o.push(u.x,u.y,u.z),l.push(m/r),l.push(a/i)}for(let e=1;e<=i;e++)for(let t=1;t<=r;t++){var m=(r+1)*e+t-1,f=(r+1)*(e-1)+t-1,g=(r+1)*(e-1)+t,v=(r+1)*e+t;a.push(m,f,v),a.push(f,g,v)}this.setIndex(a),this.setAttribute("position",new Yn(s,3)),this.setAttribute("normal",new Yn(o,3)),this.setAttribute("uv",new Yn(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Gc(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class Hc extends ra{constructor(e=1,t=.4,i=64,r=8,n=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:i,radialSegments:r,p:n,q:a},i=Math.floor(i),r=Math.floor(r);var s=[],o=[],l=[],h=[],c=new hr,u=new hr,d=new hr,p=new hr,m=new hr,f=new hr,g=new hr;for(let s=0;s<=i;++s){var v=s/i*n*Math.PI*2;E(v,n,a,e,d),E(.01+v,n,a,e,p),f.subVectors(p,d),g.addVectors(p,d),m.crossVectors(f,g),g.crossVectors(m,f),m.normalize(),g.normalize();for(let e=0;e<=r;++e){var _=e/r*Math.PI*2,x=-t*Math.cos(_);_=t*Math.sin(_),c.x=d.x+(x*g.x+_*m.x),c.y=d.y+(x*g.y+_*m.y),c.z=d.z+(x*g.z+_*m.z),o.push(c.x,c.y,c.z),u.subVectors(c,d).normalize(),l.push(u.x,u.y,u.z),h.push(s/i),h.push(e/r)}}for(let e=1;e<=i;e++)for(let t=1;t<=r;t++){var y=(r+1)*(e-1)+(t-1),M=(r+1)*e+(t-1),S=(r+1)*e+t,b=(r+1)*(e-1)+t;s.push(y,M,b),s.push(M,S,b)}function E(e,t,i,r,n){var a=Math.cos(e),s=Math.sin(e);i=i/t*e,t=Math.cos(i),n.x=r*(2+t)*.5*a,n.y=r*(2+t)*s*.5,n.z=r*Math.sin(i)*.5}this.setIndex(s),this.setAttribute("position",new Yn(o,3)),this.setAttribute("normal",new Yn(l,3)),this.setAttribute("uv",new Yn(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hc(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class kc extends ra{constructor(e=new Yh(new hr(-1,-1,0),new hr(-1,1,0),new hr(1,1,0)),t=64,i=1,r=8,n=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:i,radialSegments:r,closed:n};const a=e.computeFrenetFrames(t,n),s=(this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals,new hr),o=new hr,l=new Ui;let h=new hr;const c=[],u=[],d=[],p=[];for(let e=0;e<t;e++)_(e);_(!1===n?t:0);for(let e=0;e<=t;e++)for(let i=0;i<=r;i++)l.x=e/t,l.y=i/r,d.push(l.x,l.y);for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){var m=(r+1)*(e-1)+(t-1),f=(r+1)*e+(t-1),g=(r+1)*e+t,v=(r+1)*(e-1)+t;p.push(m,f,v),p.push(f,g,v)}function _(n){h=e.getPointAt(n/t,h);var l=a.normals[n],d=a.binormals[n];for(let e=0;e<=r;e++){var p=e/r*Math.PI*2,m=Math.sin(p);p=-Math.cos(p),o.x=p*l.x+m*d.x,o.y=p*l.y+m*d.y,o.z=p*l.z+m*d.z,o.normalize(),u.push(o.x,o.y,o.z),s.x=h.x+i*o.x,s.y=h.y+i*o.y,s.z=h.z+i*o.z,c.push(s.x,s.y,s.z)}}this.setIndex(p),this.setAttribute("position",new Yn(c,3)),this.setAttribute("normal",new Yn(u,3)),this.setAttribute("uv",new Yn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){var e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new kc((new Jh[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class Vc extends ra{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){var t=[],i=new Set,r=new hr,n=new hr;if(null!==e.index){var a=e.attributes.position,s=e.index;let u=e.groups;for(let e=0,d=(u=0===u.length?[{start:0,count:s.count,materialIndex:0}]:u).length;e<d;++e){var o=u[e],l=o.start;for(let e=l,u=l+o.count;e<u;e+=3)for(let o=0;o<3;o++){var h=s.getX(e+o),c=s.getX(e+(o+1)%3);r.fromBufferAttribute(a,h),n.fromBufferAttribute(a,c),!0===Wc(r,n,i)&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}}else{var u=e.attributes.position;for(let e=0,a=u.count/3;e<a;e++)for(let a=0;a<3;a++){var d=3*e+a,p=3*e+(a+1)%3;r.fromBufferAttribute(u,d),n.fromBufferAttribute(u,p),!0===Wc(r,n,i)&&(t.push(r.x,r.y,r.z),t.push(n.x,n.y,n.z))}}this.setAttribute("position",new Yn(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function Wc(e,t,i){var r=`${e.x},${e.y},${e.z}-${t.x},${t.y},`+t.z;return t=`${t.x},${t.y},${t.z}-${e.x},${e.y},`+e.z,!0!==i.has(r)&&!0!==i.has(t)&&(i.add(r),i.add(t),!0)}var Xc=Object.freeze({__proto__:null,BoxGeometry:ba,CapsuleGeometry:ec,CircleGeometry:tc,ConeGeometry:rc,CylinderGeometry:ic,DodecahedronGeometry:ac,EdgesGeometry:cc,ExtrudeGeometry:Ic,IcosahedronGeometry:Dc,LatheGeometry:$h,OctahedronGeometry:Nc,PlaneGeometry:Va,PolyhedronGeometry:nc,RingGeometry:Oc,ShapeGeometry:Fc,SphereGeometry:Bc,TetrahedronGeometry:zc,TorusGeometry:Gc,TorusKnotGeometry:Hc,TubeGeometry:kc,WireframeGeometry:Vc});class jc extends Tn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Ln(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class qc extends Ra{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Yc extends Tn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ln(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ln(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Zc extends Yc{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ui(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ei(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ln(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ln(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ln(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){0<this._sheen!=0<e&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){0<this._clearcoat!=0<e&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){0<this._iridescence!=0<e&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){0<this._transmission!=0<e&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Jc extends Tn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Ln(16777215),this.specular=new Ln(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ln(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Kc extends Tn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Ln(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ln(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Qc extends Tn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class $c extends Tn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ln(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ln(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class eu extends Tn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Ln(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Bt,this.normalScale=new Ui(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class tu extends lh{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function iu(e,t,i){return nu(e)?new e.constructor(e.subarray(t,void 0!==i?i:e.length)):e.slice(t,i)}function ru(e,t,i){return!e||!i&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function nu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function au(e){var t=e.length,i=new Array(t);for(let e=0;e!==t;++e)i[e]=e;return i.sort(function(t,i){return e[t]-e[i]}),i}function su(e,t,i){var r=e.length,n=new e.constructor(r);for(let s=0,o=0;o!==r;++s){var a=i[s]*t;for(let i=0;i!==t;++i)n[o++]=e[a+i]}return n}function ou(e,t,i,r){let n=1,a=e[0];for(;void 0!==a&&void 0===a[r];)a=e[n++];if(void 0!==a){let s=a[r];if(void 0!==s)if(Array.isArray(s))for(;void 0!==(s=a[r])&&(t.push(a.time),i.push.apply(i,s)),void 0!==(a=e[n++]););else if(void 0!==s.toArray)for(;void 0!==(s=a[r])&&(t.push(a.time),s.toArray(i,i.length)),void 0!==(a=e[n++]););else for(;void 0!==(s=a[r])&&(t.push(a.time),i.push(s)),void 0!==(a=e[n++]););}}const lu={arraySlice:iu,convertArray:ru,isTypedArray:nu,getKeyframeOrder:au,sortedArray:su,flattenJSON:ou,subclip:function(e,t,i,r,n=30){var a=e.clone(),s=(a.name=t,[]);for(let e=0;e<a.tracks.length;++e){var o=a.tracks[e],l=o.getValueSize(),h=[],c=[];for(let e=0;e<o.times.length;++e){var u=o.times[e]*n;if(!(u<i||r<=u)){h.push(o.times[e]);for(let t=0;t<l;++t)c.push(o.values[e*l+t])}}0!==h.length&&(o.times=ru(h,o.times.constructor),o.values=ru(c,o.values.constructor),s.push(o))}a.tracks=s;let d=1/0;for(let e=0;e<a.tracks.length;++e)d>a.tracks[e].times[0]&&(d=a.tracks[e].times[0]);for(let e=0;e<a.tracks.length;++e)a.tracks[e].shift(-1*d);return a.resetDuration(),a},makeClipAdditive:function(e,t=0,i=e,r=30){var n=i.tracks.length,a=t/(r=r<=0?30:r);for(let t=0;t<n;++t){const r=i.tracks[t],n=r.ValueTypeName;if("bool"!==n&&"string"!==n){var s=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===n});if(void 0!==s){let e=0;var o=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(e=o/3);let t=0;var l,h,c,u=s.getValueSize(),d=(s.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(t=u/3),r.times.length-1);let i;i=a<=r.times[0]?(h=o-(l=e),iu(r.values,l,h)):a>=r.times[d]?(h=(l=d*o+e)+o-e,iu(r.values,l,h)):(c=o-(o=e),(d=r.createInterpolant()).evaluate(a),iu(d.resultBuffer,o,c)),"quaternion"===n&&(new lr).fromArray(i).normalize().conjugate().toArray(i);var p=s.times.length;for(let e=0;e<p;++e){var m=e*u+t;if("quaternion"===n)lr.multiplyQuaternionsFlat(s.values,m,i,0,s.values,m);else{var f=u-2*t;for(let e=0;e<f;++e)s.values[m+e]-=i[e]}}}}}return e.blendMode=Lt,e}};class hu{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==r?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){var t=this.parameterPositions;let i=this._cachedIndex,r=t[i],n=t[i-1];e:{t:{let h;i:{r:if(!(e<r)){for(var a=i+2;;){if(void 0===r){if(e<n)break r;return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(n=r,e<(r=t[++i]))break t}h=t.length;break i}if(e>=n)break e;var s=t[1];e<s&&(i=2,n=s);for(var o=i-2;;){if(void 0===n)return this._cachedIndex=0,this.copySampleValue_(0);if(i===o)break;if(r=n,e>=(n=t[--i-1]))break t}h=i,i=0}for(;i<h;){var l=i+h>>>1;e<t[l]?h=l:i=1+l}if(r=t[i],void 0===(n=t[i-1]))return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===r)return i=t.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,n,r)}return this.interpolate_(i,n,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){var t=this.resultBuffer,i=this.sampleValues,r=this.valueSize,n=e*r;for(let e=0;e!==r;++e)t[e]=i[n+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class cu extends hu{constructor(e,t,i,r){super(e,t,i,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:wt,endingEnd:wt}}intervalChanged_(e,t,i){var r=this.parameterPositions;let n=e-2,a=e+1,s=r[n],o=r[a];if(void 0===s)switch(this.getSettings_().endingStart){case At:n=e,s=2*t-i;break;case Rt:n=r.length-2,s=t+r[n]-r[n+1];break;default:n=e,s=i}if(void 0===o)switch(this.getSettings_().endingEnd){case At:a=e,o=2*i-t;break;case Rt:a=1,o=i+r[1]-r[0];break;default:a=e-1,o=t}var l=.5*(i-t),h=this.valueSize;this._weightPrev=l/(t-s),this._weightNext=l/(o-i),this._offsetPrev=n*h,this._offsetNext=a*h}interpolate_(e,t,i,r){var n=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=this._offsetPrev,c=this._offsetNext,u=(e=this._weightPrev,this._weightNext),d=-e*(t=(r=(i=(i-t)/(r-t))*i)*i)+2*e*r-e*i,p=(1+e)*t+(-1.5-2*e)*r+(-.5+e)*i+1,m=(-1-u)*t+(1.5+u)*r+.5*i,f=u*t-u*r;for(let e=0;e!==s;++e)n[e]=d*a[h+e]+p*a[l+e]+m*a[o+e]+f*a[c+e];return n}}class uu extends hu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){var n=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=e*s,l=o-s,h=(i-t)/(r-t),c=1-h;for(let e=0;e!==s;++e)n[e]=a[l+e]*c+a[o+e]*h;return n}}class du extends hu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class pu{constructor(e,t,i,r){if(void 0===e)throw new Error("THREE.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=ru(t,this.TimeBufferType),this.values=ru(i,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){var t=e.constructor;let i;return t.toJSON!==this.toJSON?i=t.toJSON(e):(i={name:e.name,times:ru(e.times,Array),values:ru(e.values,Array)},(t=e.getInterpolation())!==e.DefaultInterpolation&&(i.interpolation=t)),i.type=e.ValueTypeName,i}InterpolantFactoryMethodDiscrete(e){return new du(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new uu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new cu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case bt:t=this.InterpolantFactoryMethodDiscrete;break;case Et:t=this.InterpolantFactoryMethodLinear;break;case Tt:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){var i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(i);this.setInterpolation(this.DefaultInterpolation)}console.warn("THREE.KeyframeTrack:",i)}else this.createInterpolant=t;return this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return bt;case this.InterpolantFactoryMethodLinear:return Et;case this.InterpolantFactoryMethodSmooth:return Tt}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){var t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]+=e}return this}scale(e){if(1!==e){var t=this.times;for(let i=0,r=t.length;i!==r;++i)t[i]*=e}return this}trim(e,t){var i,r=this.times,n=r.length;let a=0,s=n-1;for(;a!==n&&r[a]<e;)++a;for(;-1!==s&&r[s]>t;)--s;return++s,0===a&&s===n||(a>=s&&(s=Math.max(s,1),a=s-1),i=this.getValueSize(),this.times=iu(r,a,s),this.values=iu(this.values,a*i,s*i)),this}validate(){let e=!0;var t=this.getValueSize(),i=(t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1),this.times),r=this.values,n=i.length;0===n&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==n;t++){var s=i[t];if("number"==typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,s,a),e=!1;break}a=s}if(void 0!==r&&nu(r))for(let t=0,i=r.length;t!==i;++t){var o=r[t];if(isNaN(o)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,o),e=!1;break}}return e}optimize(){var e=iu(this.times),t=iu(this.values),i=this.getValueSize(),r=this.getInterpolation()===Tt,n=e.length-1;let a=1;for(let p=1;p<n;++p){let n=!1;var s=e[p];if(s!==e[p+1]&&(1!==p||s!==e[0]))if(r)n=!0;else{var o=p*i,l=o-i,h=o+i;for(let e=0;e!==i;++e){var c=t[o+e];if(c!==t[l+e]||c!==t[h+e]){n=!0;break}}}if(n){if(p!==a){e[a]=e[p];var u=p*i,d=a*i;for(let e=0;e!==i;++e)t[d+e]=t[u+e]}++a}}if(0<n){e[a]=e[n];for(let e=n*i,r=a*i,s=0;s!==i;++s)t[r+s]=t[e+s];++a}return a!==e.length?(this.times=iu(e,0,a),this.values=iu(t,0,a*i)):(this.times=e,this.values=t),this}clone(){var e=iu(this.times,0),t=iu(this.values,0);return(e=new this.constructor(this.name,e,t)).createInterpolant=this.createInterpolant,e}}pu.prototype.TimeBufferType=Float32Array,pu.prototype.ValueBufferType=Float32Array,pu.prototype.DefaultInterpolation=Et;class mu extends pu{}mu.prototype.ValueTypeName="bool",mu.prototype.ValueBufferType=Array,mu.prototype.DefaultInterpolation=bt,mu.prototype.InterpolantFactoryMethodLinear=void 0,mu.prototype.InterpolantFactoryMethodSmooth=void 0;class fu extends pu{}fu.prototype.ValueTypeName="color";class gu extends pu{}gu.prototype.ValueTypeName="number";class vu extends hu{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){var n=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(i-t)/(r-t);let l=e*s;for(var h=l+s;l!==h;l+=4)lr.slerpFlat(n,0,a,l-s,a,l,o);return n}}class _u extends pu{InterpolantFactoryMethodLinear(e){return new vu(this.times,this.values,this.getValueSize(),e)}}_u.prototype.ValueTypeName="quaternion",_u.prototype.DefaultInterpolation=Et,_u.prototype.InterpolantFactoryMethodSmooth=void 0;class xu extends pu{}xu.prototype.ValueTypeName="string",xu.prototype.ValueBufferType=Array,xu.prototype.DefaultInterpolation=bt,xu.prototype.InterpolantFactoryMethodLinear=void 0,xu.prototype.InterpolantFactoryMethodSmooth=void 0;class yu extends pu{}class Mu{constructor(e,t=-1,i,r=Ct){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=bi(),this.duration<0&&this.resetDuration()}static parse(e){var t=[],i=e.tracks,r=1/(e.fps||1);for(let e=0,n=i.length;e!==n;++e)t.push(function(e){if(void 0===e.type)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");var t,i,r=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return gu;case"vector":case"vector2":case"vector3":case"vector4":return yu;case"color":return fu;case"quaternion":return _u;case"bool":case"boolean":return mu;case"string":return xu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);return void 0===e.times&&(ou(e.keys,t=[],i=[],"value"),e.times=t,e.values=i),void 0!==r.parse?r.parse(e):new r(e.name,e.times,e.values,e.interpolation)}(i[e]).scale(r));var n=new this(e.name,e.duration,t,e.blendMode);return n.uuid=e.uuid,n}static toJSON(e){var t=[],i=e.tracks;e={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,r=i.length;e!==r;++e)t.push(pu.toJSON(i[e]));return e}static CreateFromMorphTargetSequence(e,t,i,r){var n=t.length,a=[];for(let e=0;e<n;e++){let o=[],l=[];o.push((e+n-1)%n,e,(e+1)%n),l.push(0,1,0);var s=au(o);o=su(o,1,s),l=su(l,1,s),r||0!==o[0]||(o.push(n),l.push(l[0])),a.push(new gu(".morphTargetInfluences["+t[e].name+"]",o,l).scale(1/i))}return new this(e,-1,a)}static findByName(e,t){let i=e;Array.isArray(e)||(i=e.geometry&&e.geometry.animations||e.animations);for(let e=0;e<i.length;e++)if(i[e].name===t)return i[e];return null}static CreateClipsFromMorphTargetSequences(e,t,i){var r={},n=/^([\w-]*?)([\d]+)$/;for(let t=0,i=e.length;t<i;t++){var a=e[t],s=a.name.match(n);if(s&&1<s.length){let e=r[s=s[1]];e||(r[s]=e=[]),e.push(a)}}var o=[];for(const e in r)o.push(this.CreateFromMorphTargetSequence(e,r[e],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;function i(e,t,i,r,n){var a;0!==i.length&&(ou(i,i=[],a=[],r),0!==i.length)&&n.push(new e(t,i,a))}var r=[],n=e.name||"default",a=e.fps||30,s=e.blendMode;let o=e.length||-1;var l=e.hierarchy||[];for(let e=0;e<l.length;e++){var h=l[e].keys;if(h&&0!==h.length)if(h[0].morphTargets){var c={};let e;for(e=0;e<h.length;e++)if(h[e].morphTargets)for(let t=0;t<h[e].morphTargets.length;t++)c[h[e].morphTargets[t]]=-1;for(const t in c){var u=[],d=[];for(let i=0;i!==h[e].morphTargets.length;++i){var p=h[e];u.push(p.time),d.push(p.morphTarget===t?1:0)}r.push(new gu(".morphTargetInfluence["+t+"]",u,d))}o=c.length*a}else{var m=".bones["+t[e].name+"]";i(yu,m+".position",h,"pos",r),i(_u,m+".quaternion",h,"rot",r),i(yu,m+".scale",h,"scl",r)}}return 0===r.length?null:new this(n,o,r,s)}resetDuration(){let e=0;for(let i=0,r=this.tracks.length;i!==r;++i){var t=this.tracks[i];e=Math.max(e,t.times[t.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){var e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}const Su={enabled:!(yu.prototype.ValueTypeName="vector"),files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class bu{constructor(e,t,i){const r=this;let n,a=!1,s=0,o=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i,this.itemStart=function(e){o++,!1===a&&void 0!==r.onStart&&r.onStart(e,s,o),a=!0},this.itemEnd=function(e){s++,void 0!==r.onProgress&&r.onProgress(e,s,o),s===o&&(a=!1,void 0!==r.onLoad)&&r.onLoad()},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return n?n(e):e},this.setURLModifier=function(e){return n=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){return-1!==(e=l.indexOf(e))&&l.splice(e,2),this},this.getHandler=function(e){for(let r=0,n=l.length;r<n;r+=2){var t=l[r],i=l[r+1];if(t.global&&(t.lastIndex=0),t.test(e))return i}return null}}}const Eu=new bu;class Tu{constructor(e){this.manager=void 0!==e?e:Eu,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const i=this;return new Promise(function(r,n){i.load(e,r,t,n)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const wu={};class Au extends Error{constructor(e,t){super(e),this.response=t}}class Ru extends Tu{constructor(e){super(e)}load(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const n=Su.get(e);if(void 0!==n)return this.manager.itemStart(e),setTimeout(()=>{t&&t(n),this.manager.itemEnd(e)},0),n;if(void 0!==wu[e])wu[e].push({onLoad:t,onProgress:i,onError:r});else{wu[e]=[],wu[e].push({onLoad:t,onProgress:i,onError:r}),i=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});const n=this.mimeType,a=this.responseType;fetch(i).then(t=>{if(200!==t.status&&0!==t.status)throw new Au(`fetch for "${t.url}" responded with ${t.status}: `+t.statusText,t);{if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const i=wu[e],r=t.body.getReader(),n=(t=t.headers.get("Content-Length")||t.headers.get("X-File-Size"))?parseInt(t):0,a=0!==n;let s=0;return t=new ReadableStream({start(e){!function t(){r.read().then(({done:r,value:o})=>{if(r)e.close();else{s+=o.byteLength;const r=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:n});for(let e=0,t=i.length;e<t;e++){const t=i[e];t.onProgress&&t.onProgress(r)}e.enqueue(o),t()}})}()}}),new Response(t)}}).then(e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>(new DOMParser).parseFromString(e,n));case"json":return e.json();default:if(void 0===n)return e.text();{var t=(t=/charset="?([^;"\s]*)"?/i.exec(n))&&t[1]?t[1].toLowerCase():void 0;const i=new TextDecoder(t);return e.arrayBuffer().then(e=>i.decode(e))}}}).then(t=>{Su.add(e,t);var i=wu[e];delete wu[e];for(let e=0,n=i.length;e<n;e++){var r=i[e];r.onLoad&&r.onLoad(t)}}).catch(t=>{var i=wu[e];if(void 0===i)throw this.manager.itemError(e),t;delete wu[e];for(let e=0,n=i.length;e<n;e++){var r=i[e];r.onError&&r.onError(t)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Cu extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this;var a=new Ru(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(i){try{t(n.parse(JSON.parse(i)))}catch(i){r?r(i):console.error(i),n.manager.itemError(e)}},i,r)}parse(e){var t=[];for(let r=0;r<e.length;r++){var i=Mu.parse(e[r]);t.push(i)}return t}}class Lu extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this,a=[],s=new Rh,o=new Ru(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(n.withCredentials);let l=0;if(Array.isArray(e))for(let h=0,c=e.length;h<c;++h)!function(h){o.load(e[h],function(e){e=n.parse(e,!0),a[h]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(l+=1)&&(1===e.mipmapCount&&(s.minFilter=ve),s.image=a,s.format=e.format,s.needsUpdate=!0,t)&&t(s)},i,r)}(h);else o.load(e,function(e){var i=n.parse(e,!0);if(i.isCubemap){var r=i.mipmaps.length/i.mipmapCount;for(let e=0;e<r;e++){a[e]={mipmaps:[]};for(let t=0;t<i.mipmapCount;t++)a[e].mipmaps.push(i.mipmaps[e*i.mipmapCount+t]),a[e].format=i.format,a[e].width=i.width,a[e].height=i.height}s.image=a}else s.image.width=i.width,s.image.height=i.height,s.mipmaps=i.mipmaps;1===i.mipmapCount&&(s.minFilter=ve),s.format=i.format,s.needsUpdate=!0,t&&t(s)},i,r);return s}}class Pu extends Tu{constructor(e){super(e)}load(e,t,i,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Su.get(e);if(void 0!==a)return n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0),a;const s=zi("img");function o(){h(),Su.add(e,this),t&&t(this),n.manager.itemEnd(e)}function l(t){h(),r&&r(t),n.manager.itemError(e),n.manager.itemEnd(e)}function h(){s.removeEventListener("load",o,!1),s.removeEventListener("error",l,!1)}return s.addEventListener("load",o,!1),s.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(s.crossOrigin=this.crossOrigin),n.manager.itemStart(e),s.src=e,s}}class Iu extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=new Ia,a=new Pu(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let s=0;for(let i=0;i<e.length;++i)!function(i){a.load(e[i],function(e){n.images[i]=e,6===++s&&(n.needsUpdate=!0,t)&&t(n)},void 0,r)}(i);return n}}class Uu extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this,a=new Zl;var s=new Ru(this.manager);return s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setPath(this.path),s.setWithCredentials(n.withCredentials),s.load(e,function(e){(e=n.parse(e))&&(void 0!==e.image?a.image=e.image:void 0!==e.data&&(a.image.width=e.width,a.image.height=e.height,a.image.data=e.data),a.wrapS=void 0!==e.wrapS?e.wrapS:ce,a.wrapT=void 0!==e.wrapT?e.wrapT:ce,a.magFilter=void 0!==e.magFilter?e.magFilter:ve,a.minFilter=void 0!==e.minFilter?e.minFilter:ve,a.anisotropy=void 0!==e.anisotropy?e.anisotropy:1,void 0!==e.colorSpace?a.colorSpace=e.colorSpace:void 0!==e.encoding&&(a.encoding=e.encoding),void 0!==e.flipY&&(a.flipY=e.flipY),void 0!==e.format&&(a.format=e.format),void 0!==e.type&&(a.type=e.type),void 0!==e.mipmaps&&(a.mipmaps=e.mipmaps,a.minFilter=ye),1===e.mipmapCount&&(a.minFilter=ve),void 0!==e.generateMipmaps&&(a.generateMipmaps=e.generateMipmaps),a.needsUpdate=!0,t)&&t(a,e)},i,r),a}}class Du extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=new er;var a=new Pu(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(e){n.image=e,n.needsUpdate=!0,void 0!==t&&t(n)},i,r),n}}class Nu extends un{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Ln(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){return(e=super.toJSON(e)).object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}class Ou extends Nu{constructor(e,t,i){super(e,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(un.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Ln(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Fu=new zr,Bu=new hr,zu=new hr;class Gu{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ui(512,512),this.map=null,this.mapPass=null,this.matrix=new zr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ga,this._frameExtents=new Ui(1,1),this._viewportCount=1,this._viewports=[new tr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){var t=this.camera,i=this.matrix;Bu.setFromMatrixPosition(e.matrixWorld),t.position.copy(Bu),zu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(zu),t.updateMatrixWorld(),Fu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Fu),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(Fu)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Hu extends Gu{constructor(){super(new La(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){var t=this.camera,i=2*Si*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,n=e.distance||t.far;i===t.fov&&r===t.aspect&&n===t.far||(t.fov=i,t.aspect=r,t.far=n,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class ku extends Nu{constructor(e,t,i=0,r=Math.PI/3,n=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(un.DEFAULT_UP),this.updateMatrix(),this.target=new un,this.distance=i,this.angle=r,this.penumbra=n,this.decay=a,this.map=null,this.shadow=new Hu}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Vu=new zr,Wu=new hr,Xu=new hr;class ju extends Gu{constructor(){super(new La(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ui(4,2),this._viewportCount=6,this._viewports=[new tr(2,1,1,1),new tr(0,1,1,1),new tr(3,1,1,1),new tr(1,1,1,1),new tr(3,0,1,1),new tr(1,0,1,1)],this._cubeDirections=[new hr(1,0,0),new hr(-1,0,0),new hr(0,0,1),new hr(0,0,-1),new hr(0,1,0),new hr(0,-1,0)],this._cubeUps=[new hr(0,1,0),new hr(0,1,0),new hr(0,1,0),new hr(0,1,0),new hr(0,0,1),new hr(0,0,-1)]}updateMatrices(e,t=0){var i=this.camera,r=this.matrix,n=e.distance||i.far;n!==i.far&&(i.far=n,i.updateProjectionMatrix()),Wu.setFromMatrixPosition(e.matrixWorld),i.position.copy(Wu),Xu.copy(i.position),Xu.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(Xu),i.updateMatrixWorld(),r.makeTranslation(-Wu.x,-Wu.y,-Wu.z),Vu.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Vu)}}class qu extends Nu{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new ju}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Yu extends Gu{constructor(){super(new es(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Zu extends Nu{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(un.DEFAULT_UP),this.updateMatrix(),this.target=new un,this.shadow=new Yu}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Ju extends Nu{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Ku extends Nu{constructor(e,t,i=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=i,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){return(e=super.toJSON(e)).object.width=this.width,e.object.height=this.height,e}}class Qu{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new hr)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){var i=e.x,r=e.y,n=(e=e.z,this.coefficients);return t.copy(n[0]).multiplyScalar(.282095),t.addScaledVector(n[1],.488603*r),t.addScaledVector(n[2],.488603*e),t.addScaledVector(n[3],.488603*i),t.addScaledVector(n[4],i*r*1.092548),t.addScaledVector(n[5],r*e*1.092548),t.addScaledVector(n[6],.315392*(3*e*e-1)),t.addScaledVector(n[7],i*e*1.092548),t.addScaledVector(n[8],.546274*(i*i-r*r)),t}getIrradianceAt(e,t){var i=e.x,r=e.y,n=(e=e.z,this.coefficients);return t.copy(n[0]).multiplyScalar(.886227),t.addScaledVector(n[1],1.023328*r),t.addScaledVector(n[2],1.023328*e),t.addScaledVector(n[3],1.023328*i),t.addScaledVector(n[4],.858086*i*r),t.addScaledVector(n[5],.858086*r*e),t.addScaledVector(n[6],.743125*e*e-.247708),t.addScaledVector(n[7],.858086*i*e),t.addScaledVector(n[8],.429043*(i*i-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let i=0;i<9;i++)this.coefficients[i].addScaledVector(e.coefficients[i],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let i=0;i<9;i++)this.coefficients[i].lerp(e.coefficients[i],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){var i=this.coefficients;for(let r=0;r<9;r++)i[r].fromArray(e,t+3*r);return this}toArray(e=[],t=0){var i=this.coefficients;for(let r=0;r<9;r++)i[r].toArray(e,t+3*r);return e}static getBasisAt(e,t){var i=e.x,r=e.y;e=e.z,t[0]=.282095,t[1]=.488603*r,t[2]=.488603*e,t[3]=.488603*i,t[4]=1.092548*i*r,t[5]=1.092548*r*e,t[6]=.315392*(3*e*e-1),t[7]=1.092548*i*e,t[8]=.546274*(i*i-r*r)}}class $u extends Nu{constructor(e=new Qu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){return(e=super.toJSON(e)).object.sh=this.sh.toArray(),e}}class ed extends Tu{constructor(e){super(e),this.textures={}}load(e,t,i,r){const n=this;var a=new Ru(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(i){try{t(n.parse(JSON.parse(i)))}catch(i){r?r(i):console.error(i),n.manager.itemError(e)}},i,r)}parse(e){const t=this.textures;function i(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}var r=ed.createMaterialFromType(e.type);if(void 0!==e.uuid&&(r.uuid=e.uuid),void 0!==e.name&&(r.name=e.name),void 0!==e.color&&void 0!==r.color&&r.color.setHex(e.color),void 0!==e.roughness&&(r.roughness=e.roughness),void 0!==e.metalness&&(r.metalness=e.metalness),void 0!==e.sheen&&(r.sheen=e.sheen),void 0!==e.sheenColor&&(r.sheenColor=(new Ln).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(r.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==r.emissive&&r.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==r.specular&&r.specular.setHex(e.specular),void 0!==e.specularIntensity&&(r.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==r.specularColor&&r.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(r.shininess=e.shininess),void 0!==e.clearcoat&&(r.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(r.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(r.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(r.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(r.transmission=e.transmission),void 0!==e.thickness&&(r.thickness=e.thickness),void 0!==e.attenuationDistance&&(r.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==r.attenuationColor&&r.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(r.fog=e.fog),void 0!==e.flatShading&&(r.flatShading=e.flatShading),void 0!==e.blending&&(r.blending=e.blending),void 0!==e.combine&&(r.combine=e.combine),void 0!==e.side&&(r.side=e.side),void 0!==e.shadowSide&&(r.shadowSide=e.shadowSide),void 0!==e.opacity&&(r.opacity=e.opacity),void 0!==e.transparent&&(r.transparent=e.transparent),void 0!==e.alphaTest&&(r.alphaTest=e.alphaTest),void 0!==e.depthTest&&(r.depthTest=e.depthTest),void 0!==e.depthWrite&&(r.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(r.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(r.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(r.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(r.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(r.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(r.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(r.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(r.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(r.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(r.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(r.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(r.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(r.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(r.rotation=e.rotation),1!==e.linewidth&&(r.linewidth=e.linewidth),void 0!==e.dashSize&&(r.dashSize=e.dashSize),void 0!==e.gapSize&&(r.gapSize=e.gapSize),void 0!==e.scale&&(r.scale=e.scale),void 0!==e.polygonOffset&&(r.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(r.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(r.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(r.dithering=e.dithering),void 0!==e.alphaToCoverage&&(r.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(r.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(r.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.toneMapped&&(r.toneMapped=e.toneMapped),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?r.vertexColors=0<e.vertexColors:r.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){var n=e.uniforms[t];switch(r.uniforms[t]={},n.type){case"t":r.uniforms[t].value=i(n.value);break;case"c":r.uniforms[t].value=(new Ln).setHex(n.value);break;case"v2":r.uniforms[t].value=(new Ui).fromArray(n.value);break;case"v3":r.uniforms[t].value=(new hr).fromArray(n.value);break;case"v4":r.uniforms[t].value=(new tr).fromArray(n.value);break;case"m3":r.uniforms[t].value=(new Di).fromArray(n.value);break;case"m4":r.uniforms[t].value=(new zr).fromArray(n.value);break;default:r.uniforms[t].value=n.value}}if(void 0!==e.defines&&(r.defines=e.defines),void 0!==e.vertexShader&&(r.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(r.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(r.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)r.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(r.lights=e.lights),void 0!==e.clipping&&(r.clipping=e.clipping),void 0!==e.size&&(r.size=e.size),void 0!==e.sizeAttenuation&&(r.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(r.map=i(e.map)),void 0!==e.matcap&&(r.matcap=i(e.matcap)),void 0!==e.alphaMap&&(r.alphaMap=i(e.alphaMap)),void 0!==e.bumpMap&&(r.bumpMap=i(e.bumpMap)),void 0!==e.bumpScale&&(r.bumpScale=e.bumpScale),void 0!==e.normalMap&&(r.normalMap=i(e.normalMap)),void 0!==e.normalMapType&&(r.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),r.normalScale=(new Ui).fromArray(t)}return void 0!==e.displacementMap&&(r.displacementMap=i(e.displacementMap)),void 0!==e.displacementScale&&(r.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(r.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(r.roughnessMap=i(e.roughnessMap)),void 0!==e.metalnessMap&&(r.metalnessMap=i(e.metalnessMap)),void 0!==e.emissiveMap&&(r.emissiveMap=i(e.emissiveMap)),void 0!==e.emissiveIntensity&&(r.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(r.specularMap=i(e.specularMap)),void 0!==e.specularIntensityMap&&(r.specularIntensityMap=i(e.specularIntensityMap)),void 0!==e.specularColorMap&&(r.specularColorMap=i(e.specularColorMap)),void 0!==e.envMap&&(r.envMap=i(e.envMap)),void 0!==e.envMapIntensity&&(r.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(r.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(r.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(r.lightMap=i(e.lightMap)),void 0!==e.lightMapIntensity&&(r.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(r.aoMap=i(e.aoMap)),void 0!==e.aoMapIntensity&&(r.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(r.gradientMap=i(e.gradientMap)),void 0!==e.clearcoatMap&&(r.clearcoatMap=i(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=i(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(r.clearcoatNormalMap=i(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(r.clearcoatNormalScale=(new Ui).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(r.iridescenceMap=i(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(r.iridescenceThicknessMap=i(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(r.transmissionMap=i(e.transmissionMap)),void 0!==e.thicknessMap&&(r.thicknessMap=i(e.thicknessMap)),void 0!==e.sheenColorMap&&(r.sheenColorMap=i(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(r.sheenRoughnessMap=i(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:jc,SpriteMaterial:Sl,RawShaderMaterial:qc,ShaderMaterial:Ra,PointsMaterial:xh,MeshPhysicalMaterial:Zc,MeshStandardMaterial:Yc,MeshPhongMaterial:Jc,MeshToonMaterial:Kc,MeshNormalMaterial:Qc,MeshLambertMaterial:$c,MeshDepthMaterial:el,MeshDistanceMaterial:tl,MeshBasicMaterial:In,MeshMatcapMaterial:eu,LineDashedMaterial:tu,LineBasicMaterial:lh,Material:Tn}[e]}}class td{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let i=0,r=e.length;i<r;i++)t+=String.fromCharCode(e[i]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){var t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class id extends ra{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){var e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class rd extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this;var a=new Ru(n.manager);a.setPath(n.path),a.setRequestHeader(n.requestHeader),a.setWithCredentials(n.withCredentials),a.load(e,function(i){try{t(n.parse(JSON.parse(i)))}catch(i){r?r(i):console.error(i),n.manager.itemError(e)}},i,r)}parse(e){const t={},i={};function r(e,r){var n;return void 0!==t[r]?t[r]:(n=function(e,t){return void 0!==i[t]?i[t]:(e=(e=e.arrayBuffers)[t],e=new Uint32Array(e).buffer,i[t]=e)}(e,(e=e.interleavedBuffers[r]).buffer),n=Bi(e.type,n),(n=new xl(n,e.stride)).uuid=e.uuid,t[r]=n)}var n=new(e.isInstancedBufferGeometry?id:ra),a=(void 0!==(m=e.data.index)&&(m=Bi(m.type,m.array),n.setIndex(new zn(m,1))),e.data.attributes);for(const t in a){var s,o=a[t];let i;i=o.isInterleavedBufferAttribute?(s=r(e.data,o.data),new Ml(s,o.itemSize,o.offset,o.normalized)):(s=Bi(o.type,o.array),new(o.isInstancedBufferAttribute?$l:zn)(s,o.itemSize,o.normalized)),void 0!==o.name&&(i.name=o.name),void 0!==o.usage&&i.setUsage(o.usage),void 0!==o.updateRange&&(i.updateRange.offset=o.updateRange.offset,i.updateRange.count=o.updateRange.count),n.setAttribute(t,i)}var l=e.data.morphAttributes;if(l)for(const t in l){var h=l[t],c=[];for(let t=0,i=h.length;t<i;t++){var u,d=h[t];let i;i=d.isInterleavedBufferAttribute?(u=r(e.data,d.data),new Ml(u,d.itemSize,d.offset,d.normalized)):(u=Bi(d.type,d.array),new zn(u,d.itemSize,d.normalized)),void 0!==d.name&&(i.name=d.name),c.push(i)}n.morphAttributes[t]=c}e.data.morphTargetsRelative&&(n.morphTargetsRelative=!0);var p,m,f=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==f)for(let e=0,t=f.length;e!==t;++e){var g=f[e];n.addGroup(g.start,g.count,g.materialIndex)}return void 0!==(m=e.data.boundingSphere)&&(p=new hr,void 0!==m.center&&p.fromArray(m.center),n.boundingSphere=new Lr(p,m.radius)),e.name&&(n.name=e.name),e.userData&&(n.userData=e.userData),n}}class nd extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this;var a=""===this.path?td.extractUrlBase(e):this.path;(this.resourcePath=this.resourcePath||a,a=new Ru(this.manager)).setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(i){let a=null;try{a=JSON.parse(i)}catch(i){return void 0!==r&&r(i),void console.error("THREE:ObjectLoader: Can't parse "+e+".",i.message)}void 0===(i=a.metadata)||void 0===i.type||"geometry"===i.type.toLowerCase()?(void 0!==r&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e)):n.parse(a,t)},i,r)}async loadAsync(e,t){var i=""===this.path?td.extractUrlBase(e):this.path;if((this.resourcePath=this.resourcePath||i,i=new Ru(this.manager)).setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i=await i.loadAsync(e,t),void 0===(i=(t=JSON.parse(i)).metadata)||void 0===i.type||"geometry"===i.type.toLowerCase())throw new Error("THREE.ObjectLoader: Can't load "+e);return this.parseAsync(t)}parse(e,t){var i=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),n=(r=this.parseGeometries(e.geometries,r),this.parseImages(e.images,function(){void 0!==t&&t(o)})),a=this.parseTextures(e.textures,n),s=this.parseMaterials(e.materials,a);const o=this.parseObject(e.object,r,s,a,i);if(r=this.parseSkeletons(e.skeletons,o),this.bindSkeletons(o,r),void 0!==t){let e=!1;for(const t in n)if(n[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(o)}return o}async parseAsync(e){var t=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),r=(i=this.parseGeometries(e.geometries,i),await this.parseImagesAsync(e.images)),n=(r=this.parseTextures(e.textures,r),this.parseMaterials(e.materials,r));return i=this.parseObject(e.object,i,n,r,t),n=this.parseSkeletons(e.skeletons,i),this.bindSkeletons(i,n),i}parseShapes(e){var t={};if(void 0!==e)for(let r=0,n=e.length;r<n;r++){var i=(new uc).fromJSON(e[r]);t[i.uuid]=i}return t}parseSkeletons(e,t){var i={};const r={};if(t.traverse(function(e){e.isBone&&(r[e.uuid]=e)}),void 0!==e)for(let t=0,a=e.length;t<a;t++){var n=(new Ql).fromJSON(e[t],r);i[n.uuid]=n}return i}parseGeometries(e,t){var i={};if(void 0!==e){var r=new rd;for(let a=0,s=e.length;a<s;a++){let s;var n=e[a];switch(n.type){case"BufferGeometry":case"InstancedBufferGeometry":s=r.parse(n);break;default:n.type in Xc?s=Xc[n.type].fromJSON(n,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${n.type}"`)}s.uuid=n.uuid,void 0!==n.name&&(s.name=n.name),void 0!==n.userData&&(s.userData=n.userData),i[n.uuid]=s}}return i}parseMaterials(e,t){var i={},r={};if(void 0!==e){var n=new ed;n.setTextures(t);for(let t=0,s=e.length;t<s;t++){var a=e[t];void 0===i[a.uuid]&&(i[a.uuid]=n.parse(a)),r[a.uuid]=i[a.uuid]}}return r}parseAnimations(e){var t={};if(void 0!==e)for(let r=0;r<e.length;r++){var i=e[r];t[(i=Mu.parse(i)).uuid]=i}return t}parseImages(e,t){const i=this;var r={};let n;function a(e){var t,r;return"string"==typeof e?(t=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t=e)?t:i.resourcePath+t,r=t,i.manager.itemStart(r),n.load(r,function(){i.manager.itemEnd(r)},void 0,function(){i.manager.itemError(r),i.manager.itemEnd(r)})):e.data?{data:Bi(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&0<e.length){t=new bu(t),(n=new Pu(t)).setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){var s=e[t],o=s.url;if(Array.isArray(o)){var l=[];for(let e=0,t=o.length;e<t;e++){var h=a(o[e]);null!==h&&(h instanceof HTMLImageElement?l.push(h):l.push(new Zl(h.data,h.width,h.height)))}r[s.uuid]=new Ki(l)}else{var c=a(s.url);r[s.uuid]=new Ki(c)}}}return r}async parseImagesAsync(e){const t=this;var i={};let r;async function n(e){var i;return"string"==typeof e?(i=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i=e)?i:t.resourcePath+i,r.loadAsync(i)):e.data?{data:Bi(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&0<e.length){(r=new Pu(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,r=e.length;t<r;t++){var a=e[t],s=a.url;if(Array.isArray(s)){var o=[];for(let e=0,t=s.length;e<t;e++){var l=await n(s[e]);null!==l&&(l instanceof HTMLImageElement?o.push(l):o.push(new Zl(l.data,l.width,l.height)))}i[a.uuid]=new Ki(o)}else{var h=await n(a.url);i[a.uuid]=new Ki(h)}}}return i}parseTextures(e,t){function i(e,t){return"number"==typeof e?e:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}var r={};if(void 0!==e)for(let o=0,l=e.length;o<l;o++){var n=e[o],a=(void 0===n.image&&console.warn('THREE.ObjectLoader: No "image" specified for',n.uuid),void 0===t[n.image]&&console.warn("THREE.ObjectLoader: Undefined image",n.image),t[n.image]),s=a.data;let l;Array.isArray(s)?(l=new Ia,6===s.length&&(l.needsUpdate=!0)):(l=new(s&&s.data?Zl:er),s&&(l.needsUpdate=!0)),l.source=a,l.uuid=n.uuid,void 0!==n.name&&(l.name=n.name),void 0!==n.mapping&&(l.mapping=i(n.mapping,ad)),void 0!==n.channel&&(l.channel=n.channel),void 0!==n.offset&&l.offset.fromArray(n.offset),void 0!==n.repeat&&l.repeat.fromArray(n.repeat),void 0!==n.center&&l.center.fromArray(n.center),void 0!==n.rotation&&(l.rotation=n.rotation),void 0!==n.wrap&&(l.wrapS=i(n.wrap[0],sd),l.wrapT=i(n.wrap[1],sd)),void 0!==n.format&&(l.format=n.format),void 0!==n.internalFormat&&(l.internalFormat=n.internalFormat),void 0!==n.type&&(l.type=n.type),void 0!==n.colorSpace&&(l.colorSpace=n.colorSpace),void 0!==n.encoding&&(l.encoding=n.encoding),void 0!==n.minFilter&&(l.minFilter=i(n.minFilter,od)),void 0!==n.magFilter&&(l.magFilter=i(n.magFilter,od)),void 0!==n.anisotropy&&(l.anisotropy=n.anisotropy),void 0!==n.flipY&&(l.flipY=n.flipY),void 0!==n.generateMipmaps&&(l.generateMipmaps=n.generateMipmaps),void 0!==n.premultiplyAlpha&&(l.premultiplyAlpha=n.premultiplyAlpha),void 0!==n.unpackAlignment&&(l.unpackAlignment=n.unpackAlignment),void 0!==n.userData&&(l.userData=n.userData),r[n.uuid]=l}return r}parseObject(e,t,i,r,n){let a,s,o;function l(e){return void 0===t[e]&&console.warn("THREE.ObjectLoader: Undefined geometry",e),t[e]}function h(e){if(void 0!==e){if(Array.isArray(e)){var t=[];for(let n=0,a=e.length;n<a;n++){var r=e[n];void 0===i[r]&&console.warn("THREE.ObjectLoader: Undefined material",r),t.push(i[r])}return t}return void 0===i[e]&&console.warn("THREE.ObjectLoader: Undefined material",e),i[e]}}function c(e){return void 0===r[e]&&console.warn("THREE.ObjectLoader: Undefined texture",e),r[e]}switch(e.type){case"Scene":a=new _l,void 0!==e.background&&(Number.isInteger(e.background)?a.background=new Ln(e.background):a.background=c(e.background)),void 0!==e.environment&&(a.environment=c(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?a.fog=new vl(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(a.fog=new gl(e.fog.color,e.fog.density))),void 0!==e.backgroundBlurriness&&(a.backgroundBlurriness=e.backgroundBlurriness),void 0!==e.backgroundIntensity&&(a.backgroundIntensity=e.backgroundIntensity);break;case"PerspectiveCamera":a=new La(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(a.focus=e.focus),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.filmGauge&&(a.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(a.filmOffset=e.filmOffset),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new es(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(a.zoom=e.zoom),void 0!==e.view&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Ju(e.color,e.intensity);break;case"DirectionalLight":a=new Zu(e.color,e.intensity);break;case"PointLight":a=new qu(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Ku(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new ku(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":a=new Ou(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=(new $u).fromJSON(e);break;case"SkinnedMesh":s=l(e.geometry),o=h(e.material),a=new ql(s,o),void 0!==e.bindMode&&(a.bindMode=e.bindMode),void 0!==e.bindMatrix&&a.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(a.skeleton=e.skeleton);break;case"Mesh":s=l(e.geometry),o=h(e.material),a=new Ma(s,o);break;case"InstancedMesh":s=l(e.geometry),o=h(e.material);var u=e.count,d=e.instanceMatrix,p=e.instanceColor;(a=new oh(s,o,u)).instanceMatrix=new $l(new Float32Array(d.array),16),void 0!==p&&(a.instanceColor=new $l(new Float32Array(p.array),p.itemSize));break;case"LOD":a=new Gl;break;case"Line":a=new mh(l(e.geometry),h(e.material));break;case"LineLoop":a=new _h(l(e.geometry),h(e.material));break;case"LineSegments":a=new vh(l(e.geometry),h(e.material));break;case"PointCloud":case"Points":a=new Eh(l(e.geometry),h(e.material));break;case"Sprite":a=new Ol(h(e.material));break;case"Group":a=new ol;break;case"Bone":a=new Yl;break;default:a=new un}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera)&&(a.shadow.camera=this.parseObject(e.shadow.camera)),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children){var m=e.children;for(let e=0;e<m.length;e++)a.add(this.parseObject(m[e],t,i,r,n))}if(void 0!==e.animations){var f=e.animations;for(let e=0;e<f.length;e++){var g=f[e];a.animations.push(n[g])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(a.autoUpdate=e.autoUpdate);var v=e.levels;for(let e=0;e<v.length;e++){var _=v[e],x=a.getObjectByProperty("uuid",_.object);void 0!==x&&a.addLevel(x,_.distance,_.hysteresis)}}return a}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse(function(e){var i;!0===e.isSkinnedMesh&&void 0!==e.skeleton&&(void 0===(i=t[e.skeleton])?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(i,e.bindMatrix))})}}const ad={UVMapping:re,CubeReflectionMapping:ne,CubeRefractionMapping:ae,EquirectangularReflectionMapping:se,EquirectangularRefractionMapping:oe,CubeUVReflectionMapping:le},sd={RepeatWrapping:he,ClampToEdgeWrapping:ce,MirroredRepeatWrapping:ue},od={NearestFilter:de,NearestMipmapNearestFilter:pe,NearestMipmapLinearFilter:fe,LinearFilter:ve,LinearMipmapNearestFilter:_e,LinearMipmapLinearFilter:ye};class ld extends Tu{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const n=this,a=Su.get(e);if(void 0!==a)return n.manager.itemStart(e),setTimeout(function(){t&&t(a),n.manager.itemEnd(e)},0),a;var s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,fetch(e,s).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(n.options,{colorSpaceConversion:"none"}))}).then(function(i){Su.add(e,i),t&&t(i),n.manager.itemEnd(e)}).catch(function(t){r&&r(t),n.manager.itemError(e),n.manager.itemEnd(e)}),n.manager.itemStart(e)}}let hd;class cd{static getContext(){return hd=void 0===hd?new(window.AudioContext||window.webkitAudioContext):hd}static setContext(e){hd=e}}class ud extends Tu{constructor(e){super(e)}load(e,t,i,r){const n=this;var a=new Ru(this.manager);function s(t){r?r(t):console.error(t),n.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{var i=e.slice(0);cd.getContext().decodeAudioData(i,function(e){t(e)},s)}catch(e){s(e)}},i,r)}}class dd extends $u{constructor(e,t,i=1){super(void 0,i),this.isHemisphereLightProbe=!0,i=(new Ln).set(e),e=(new Ln).set(t),t=new hr(i.r,i.g,i.b),i=new hr(e.r,e.g,e.b);var r=(e=Math.sqrt(Math.PI))*Math.sqrt(.75);this.sh.coefficients[0].copy(t).add(i).multiplyScalar(e),this.sh.coefficients[1].copy(t).sub(i).multiplyScalar(r)}}class pd extends $u{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0,t=(new Ln).set(e),this.sh.coefficients[0].set(t.r,t.g,t.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const md=new zr,fd=new zr,gd=new zr;class vd{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new La,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new La,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){var t,i,r,n,a=this._cache;a.focus===e.focus&&a.fov===e.fov&&a.aspect===e.aspect*this.aspect&&a.near===e.near&&a.far===e.far&&a.zoom===e.zoom&&a.eyeSep===this.eyeSep||(a.focus=e.focus,a.fov=e.fov,a.aspect=e.aspect*this.aspect,a.near=e.near,a.far=e.far,a.zoom=e.zoom,a.eyeSep=this.eyeSep,gd.copy(e.projectionMatrix),t=(r=a.eyeSep/2)*a.near/a.focus,i=a.near*Math.tan(Mi*a.fov*.5)/a.zoom,fd.elements[12]=-r,md.elements[12]=r,r=-i*a.aspect+t,n=i*a.aspect+t,gd.elements[0]=2*a.near/(n-r),gd.elements[8]=(n+r)/(n-r),this.cameraL.projectionMatrix.copy(gd),r=-i*a.aspect-t,n=i*a.aspect-t,gd.elements[0]=2*a.near/(n-r),gd.elements[8]=(n+r)/(n-r),this.cameraR.projectionMatrix.copy(gd)),this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fd),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(md)}}class _d{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=xd(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;var t;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(e=((t=xd())-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e),e)}}function xd(){return("undefined"==typeof performance?Date:performance).now()}const yd=new hr,Md=new lr,Sd=new hr,bd=new hr;class Ed extends un{constructor(){super(),this.type="AudioListener",this.context=cd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new _d}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return(null!==this.filter?(this.gain.disconnect(this.filter),this.filter):this.gain).disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e),e=this.context.listener;var t,i=this.up;this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(yd,Md,Sd),bd.set(0,0,-1).applyQuaternion(Md),e.positionX?(t=this.context.currentTime+this.timeDelta,e.positionX.linearRampToValueAtTime(yd.x,t),e.positionY.linearRampToValueAtTime(yd.y,t),e.positionZ.linearRampToValueAtTime(yd.z,t),e.forwardX.linearRampToValueAtTime(bd.x,t),e.forwardY.linearRampToValueAtTime(bd.y,t),e.forwardZ.linearRampToValueAtTime(bd.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)):(e.setPosition(yd.x,yd.y,yd.z),e.setOrientation(bd.x,bd.y,bd.z,i.x,i.y,i.z))}}class Td extends un{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else{if(!1!==this.hasPlaybackControl)return this._startedAt=this.context.currentTime+e,(e=this.context.createBufferSource()).buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect();console.warn("THREE.Audio: this Audio has no playback control.")}}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e=e||[],!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("THREE.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("THREE.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const wd=new hr,Ad=new lr,Rd=new hr,Cd=new hr;class Ld extends Td{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,i){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=i,this}updateMatrixWorld(e){var t;super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying||(this.matrixWorld.decompose(wd,Ad,Rd),Cd.set(0,0,1).applyQuaternion(Ad),(e=this.panner).positionX?(t=this.context.currentTime+this.listener.timeDelta,e.positionX.linearRampToValueAtTime(wd.x,t),e.positionY.linearRampToValueAtTime(wd.y,t),e.positionZ.linearRampToValueAtTime(wd.z,t),e.orientationX.linearRampToValueAtTime(Cd.x,t),e.orientationY.linearRampToValueAtTime(Cd.y,t),e.orientationZ.linearRampToValueAtTime(Cd.z,t)):(e.setPosition(wd.x,wd.y,wd.z),e.setOrientation(Cd.x,Cd.y,Cd.z)))}}class Pd{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;var t=this.getFrequencyData();for(let i=0;i<t.length;i++)e+=t[i];return e/t.length}}class Id{constructor(e,t,i){let r,n,a;switch(this.binding=e,this.valueSize=i,t){case"quaternion":r=this._slerp,n=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*i),this._workIndex=5;break;case"string":case"bool":r=this._select,n=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(5*i);break;default:r=this._lerp,n=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*i)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=n,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){var i=this.buffer,r=this.valueSize,n=e*r+r;let a=this.cumulativeWeight;if(0===a){for(let e=0;e!==r;++e)i[n+e]=i[e];a=t}else e=t/(a+=t),this._mixBufferRegion(i,n,0,e,r);this.cumulativeWeight=a}accumulateAdditive(e){var t=this.buffer,i=this.valueSize,r=i*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,i),this.cumulativeWeightAdditive+=e}apply(e){var t,i=this.valueSize,r=this.buffer,n=e*i+i,a=(e=this.cumulativeWeight,this.cumulativeWeightAdditive),s=this.binding;this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,e<1&&(t=i*this._origIndex,this._mixBufferRegion(r,n,t,1-e,i)),0<a&&this._mixBufferRegionAdditive(r,n,this._addIndex*i,1,i);for(let e=i,t=i+i;e!==t;++e)if(r[e]!==r[e+i]){s.setValue(r,n);break}}saveOriginalState(){var e=this.binding,t=this.buffer,i=this.valueSize,r=i*this._origIndex;e.getValue(t,r);for(let e=i,n=r;e!==n;++e)t[e]=t[r+e%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){var e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let i=e;i<t;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){var e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[t+i]=this.buffer[e+i]}_select(e,t,i,r,n){if(.5<=r)for(let r=0;r!==n;++r)e[t+r]=e[i+r]}_slerp(e,t,i,r){lr.slerpFlat(e,t,e,t,e,i,r)}_slerpAdditive(e,t,i,r,n){n=this._workIndex*n,lr.multiplyQuaternionsFlat(e,n,e,t,e,i),lr.slerpFlat(e,t,e,t,e,n,r)}_lerp(e,t,i,r,n){var a=1-r;for(let o=0;o!==n;++o){var s=t+o;e[s]=e[s]*a+e[i+o]*r}}_lerpAdditive(e,t,i,r,n){for(let s=0;s!==n;++s){var a=t+s;e[a]=e[a]+e[i+s]*r}}}i="\\[\\]\\.:\\/";const Ud=new RegExp("["+i+"]","g");t="[^"+i+"]",i="[^"+i.replace("\\.","")+"]";const Dd=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",t)+/(WCOD+)?/.source.replace("WCOD",i)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",t)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",t)+"$"),Nd=["material","materials","bones","map"];class Od{constructor(e,t,i){this.path=t,this.parsedPath=i||Od.parseTrackName(t),this.node=Od.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return new(e&&e.isAnimationObjectGroup?Od.Composite:Od)(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Ud,"")}static parseTrackName(e){if(null===(i=Dd.exec(e)))throw new Error("PropertyBinding: Cannot parse trackName: "+e);var t,i,r=(i={nodeName:i[2],objectName:i[3],objectIndex:i[4],propertyName:i[5],propertyIndex:i[6]}).nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r&&(t=i.nodeName.substring(r+1),-1!==Nd.indexOf(t))&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=t),null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){var i=e.skeleton.getBoneByName(t);if(void 0!==i)return i}if(e.children){const r=function(e){for(let n=0;n<e.length;n++){var i=e[n];if(i.name===t||i.uuid===t)return i;if(i=r(i.children))return i}return null};if(i=r(e.children))return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){var i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)e[t++]=i[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){var i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){var i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){var i=this.resolvedProperty;for(let r=0,n=i.length;r!==n;++r)i[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;var t=this.parsedPath,i=t.objectName,r=t.propertyName;let n=t.propertyIndex;if(e||(e=Od.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(i){let r=t.objectIndex;switch(i){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===r){r=t;break}break;case"map":if("map"in e)e=e.map;else{if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map}break;default:if(void 0===e[i])return void console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[i]}if(void 0!==r){if(void 0===e[r])return void console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[r]}}var a=e[r];if(void 0===a)t=t.nodeName,console.error("THREE.PropertyBinding: Trying to update property for track: "+t+"."+r+" but it wasn't found.",e);else{let t=this.Versioning.None,i=(void 0!==(this.targetObject=e).needsUpdate?t=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(t=this.Versioning.MatrixWorldNeedsUpdate),this.BindingType.Direct);if(void 0!==n){if("morphTargetInfluences"===r){if(!e.geometry)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[n]&&(n=e.morphTargetDictionary[n])}i=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=n}else void 0!==a.fromArray&&void 0!==a.toArray?(i=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(i=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[i],this.setValue=this.SetterByBindingTypeAndVersioning[i][t]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.")}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Od.Composite=class{constructor(e,t,i){i=i||Od.parseTrackName(t),this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();var i=this._targetGroup.nCachedObjects_;void 0!==(i=this._bindings[i])&&i.getValue(e,t)}setValue(e,t){var i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,n=i.length;r!==n;++r)i[r].setValue(e,t)}bind(){var e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){var e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}},Od.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Od.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Od.prototype.GetterByBindingType=[Od.prototype._getValue_direct,Od.prototype._getValue_array,Od.prototype._getValue_arrayElement,Od.prototype._getValue_toArray],Od.prototype.SetterByBindingTypeAndVersioning=[[Od.prototype._setValue_direct,Od.prototype._setValue_direct_setNeedsUpdate,Od.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Od.prototype._setValue_array,Od.prototype._setValue_array_setNeedsUpdate,Od.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Od.prototype._setValue_arrayElement,Od.prototype._setValue_arrayElement_setNeedsUpdate,Od.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Od.prototype._setValue_fromArray,Od.prototype._setValue_fromArray_setNeedsUpdate,Od.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class Fd{constructor(){this.isAnimationObjectGroup=!0,this.uuid=bi(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;var e={};this._indicesByUUID=e;for(let t=0,i=arguments.length;t!==i;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){var e=this._objects,t=this._indicesByUUID,i=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length;let s,o=e.length,l=this.nCachedObjects_;for(let f=0,g=arguments.length;f!==g;++f){var h=arguments[f],c=h.uuid;let g=t[c];if(void 0===g){g=o++,t[c]=g,e.push(h);for(let e=0,t=a;e!==t;++e)n[e].push(new Od(h,i[e],r[e]))}else if(g<l){s=e[g];var u=--l,d=e[u];e[t[d.uuid]=g]=d,e[t[c]=u]=h;for(let e=0,t=a;e!==t;++e){var p=n[e],m=p[u];let t=p[g];p[g]=m,void 0===t&&(t=new Od(h,i[e],r[e])),p[u]=t}}else e[g]!==s&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){var e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_;for(let p=0,m=arguments.length;p!==m;++p){var a=arguments[p],s=a.uuid,o=t[s];if(void 0!==o&&o>=n){var l=n++,h=e[l];e[t[h.uuid]=o]=h,e[t[s]=l]=a;for(let e=0,t=r;e!==t;++e){var c=i[e],u=c[l],d=c[o];c[o]=u,c[l]=d}}}this.nCachedObjects_=n}uncache(){var e=this._objects,t=this._indicesByUUID,i=this._bindings,r=i.length;let n=this.nCachedObjects_,a=e.length;for(let g=0,v=arguments.length;g!==v;++g){var s=t[l=arguments[g].uuid];if(void 0!==s)if(delete t[l],s<n){var o=--n,l=e[o],h=--a,c=e[h];e[t[l.uuid]=s]=l,e[t[c.uuid]=o]=c,e.pop();for(let e=0,t=r;e!==t;++e){var u=i[e],d=u[o],p=u[h];u[s]=d,u[o]=p,u.pop()}}else{var m=--a;l=e[m],0<m&&(t[l.uuid]=s),e[s]=l,e.pop();for(let e=0,t=r;e!==t;++e){var f=i[e];f[s]=f[m],f.pop()}}}this.nCachedObjects_=n}subscribe_(e,t){var i=this._bindingsIndicesByPath,r=i[e],n=this._bindings;if(void 0!==r)return n[r];var a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);r=n.length,i[e]=r,a.push(e),s.push(t),n.push(c);for(let i=h,r=o.length;i!==r;++i){var u=o[i];c[i]=new Od(u,e,t)}return c}unsubscribe_(e){var t,i,r,n,a,s=this._bindingsIndicesByPath,o=s[e];void 0!==o&&(t=this._paths,i=this._parsedPaths,a=(r=this._bindings)[n=r.length-1],r[s[e[n]]=o]=a,r.pop(),i[o]=i[n],i.pop(),t[o]=t[n],t.pop())}}class Bd{constructor(e,t,i=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=i,this.blendMode=r;var n=t.tracks,a=n.length,s=new Array(a),o={endingStart:wt,endingEnd:wt};for(let e=0;e!==a;++e){var l=n[e].createInterpolant(null);(s[e]=l).settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Mt,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,i){var r,n;return e.fadeOut(t),this.fadeIn(t),i&&(n=(i=this._clip.duration)/(r=e._clip.duration),e.warp(1,r/i,t),this.warp(n,1,t)),this}crossFadeTo(e,t,i){return e.crossFadeFrom(this,t,i)}stopFading(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,i){var r=(s=this._mixer).time,n=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);var s=a.parameterPositions,o=a.sampleValues;return s[0]=r,s[1]=r+i,o[0]=e/n,o[1]=t/n,this}stopWarping(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,i,r){if(this.enabled){var n=this._startTime,a=(null!==n&&(t=(n=(e-n)*i)<0||0===i?0:(this._startTime=null,i*n)),t*=this._updateTimeScale(e),this._updateTime(t)),s=this._updateWeight(e);if(0<s){var o=this._interpolants,l=this._propertyBindings;if(this.blendMode===Lt)for(let e=0,t=o.length;e!==t;++e)o[e].evaluate(a),l[e].accumulateAdditive(s);else for(let e=0,t=o.length;e!==t;++e)o[e].evaluate(a),l[e].accumulate(r,s)}}else this._updateWeight(e)}_updateWeight(e){let t=0;var i,r;return this.enabled&&(t=this.weight,null!==(i=this._weightInterpolant))&&(t*=r=i.evaluate(e)[0],e>i.parameterPositions[1])&&(this.stopFading(),0===r)&&(this.enabled=!1),this._effectiveWeight=t}_updateTimeScale(e){let t=0;var i;return this.paused||(t=this.timeScale,null!==(i=this._timeScaleInterpolant)&&(t*=i.evaluate(e)[0],e>i.parameterPositions[1])&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)),this._effectiveTimeScale=t}_updateTime(e){var t=this._clip.duration,i=this.loop;let r=this.time+e,n=this._loopCount;var a,s=i===St;if(0===e)return-1===n||!s||1&~n?r:t-r;if(i===yt){-1===n&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else if(-1===n&&(0<=e?(n=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),r>=t||r<0?(r-=t*(i=Math.floor(r/t)),n+=Math.abs(i),(a=this.repetitions-n)<=0?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=0<e?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<e?1:-1})):(1==a?this._setEndings(a=e<0,!a,s):this._setEndings(!1,!1,s),this._loopCount=n,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i}))):this.time=r,s&&!(1&~n))return t-r;return r}_setEndings(e,t,i){var r=this._interpolantSettings;i?(r.endingStart=At,r.endingEnd=At):(r.endingStart=e?this.zeroSlopeAtStart?At:wt:Rt,r.endingEnd=t?this.zeroSlopeAtEnd?At:wt:Rt)}_scheduleFading(e,t,i){var r=(a=this._mixer).time;let n=this._weightInterpolant;null===n&&(n=a._lendControlInterpolant(),this._weightInterpolant=n);var a=n.parameterPositions,s=n.sampleValues;return a[0]=r,s[0]=t,a[1]=r+e,s[1]=i,this}}const zd=new Float32Array(1);class Gd extends _i{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){var i=e._localRoot||this._root,r=e._clip.tracks,n=r.length,a=e._propertyBindings,s=e._interpolants,o=i.uuid;let l=(e=this._bindingsByRootAndName)[o];void 0===l&&(l={},e[o]=l);for(let e=0;e!==n;++e){var h=r[e],c=h.name;let n=l[c];if(void 0!==n)++n.referenceCount;else{if(void 0!==(n=a[e])){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,o,c));continue}var u=t&&t._propertyBindings[e].binding.parsedPath;++(n=new Id(Od.create(i,c,u),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(n,o,c)}a[e]=n,s[e].resultBuffer=n.buffer}}_activateAction(e){if(!this._isActiveAction(e)){null===e._cacheIndex&&(t=(e._localRoot||this._root).uuid,i=e._clip.uuid,r=this._actionsByClip[i],this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,i,t));var t,i,r,n=e._propertyBindings;for(let e=0,t=n.length;e!==t;++e){var a=n[e];0==a.useCount++&&(this._lendBinding(a),a.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){var t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){var i=t[e];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){return null!==(e=e._cacheIndex)&&e<this._nActiveActions}_addInactiveAction(e,t,i){var r=this._actions,n=this._actionsByClip;let a=n[t];void 0===a?(a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,n[t]=a):(n=a.knownActions,e._byClipCacheIndex=n.length,n.push(e)),e._cacheIndex=r.length,r.push(e),a.actionByRoot[i]=e}_removeInactiveAction(e){var t,i=(t=this._actions)[t.length-1],r=e._cacheIndex,n=(t[i._cacheIndex=r]=i,t.pop(),e._cacheIndex=null,r=e._clip.uuid,(t=(i=this._actionsByClip)[r]).knownActions),a=n[n.length-1],s=e._byClipCacheIndex;n[a._byClipCacheIndex=s]=a,n.pop(),e._byClipCacheIndex=null,delete t.actionByRoot[(e._localRoot||this._root).uuid],0===n.length&&delete i[r],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){var t=e._propertyBindings;for(let e=0,r=t.length;e!==r;++e){var i=t[e];0==--i.referenceCount&&this._removeInactiveBinding(i)}}_lendAction(e){var t=this._actions,i=e._cacheIndex,r=this._nActiveActions++,n=t[r];t[e._cacheIndex=r]=e,t[n._cacheIndex=i]=n}_takeBackAction(e){var t=this._actions,i=e._cacheIndex,r=--this._nActiveActions,n=t[r];t[e._cacheIndex=r]=e,t[n._cacheIndex=i]=n}_addInactiveBinding(e,t,i){var r=this._bindingsByRootAndName,n=this._bindings;let a=r[t];void 0===a&&(a={},r[t]=a),(a[i]=e)._cacheIndex=n.length,n.push(e)}_removeInactiveBinding(e){var t=this._bindings,i=(r=e.binding).rootNode.uuid,r=r.path,n=this._bindingsByRootAndName,a=n[i],s=t[t.length-1];e=e._cacheIndex,t[s._cacheIndex=e]=s,t.pop(),delete a[r],0===Object.keys(a).length&&delete n[i]}_lendBinding(e){var t=this._bindings,i=e._cacheIndex,r=this._nActiveBindings++,n=t[r];t[e._cacheIndex=r]=e,t[n._cacheIndex=i]=n}_takeBackBinding(e){var t=this._bindings,i=e._cacheIndex,r=--this._nActiveBindings,n=t[r];t[e._cacheIndex=r]=e,t[n._cacheIndex=i]=n}_lendControlInterpolant(){var e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let i=e[t];return void 0===i&&(e[(i=new uu(new Float32Array(2),new Float32Array(2),1,zd)).__cacheIndex=t]=i),i}_takeBackControlInterpolant(e){var t=this._controlInterpolants,i=e.__cacheIndex,r=--this._nActiveControlInterpolants,n=t[r];t[e.__cacheIndex=r]=e,t[n.__cacheIndex=i]=n}clipAction(e,t,i){var r=t||this._root,n=r.uuid;let a="string"==typeof e?Mu.findByName(r,e):e;r=null!==a?a.uuid:e,e=this._actionsByClip[r];let s=null;if(void 0===i&&(i=null!==a?a.blendMode:Ct),void 0!==e){var o=e.actionByRoot[n];if(void 0!==o&&o.blendMode===i)return o;s=e.knownActions[0],null===a&&(a=s._clip)}return null===a?null:(o=new Bd(this,a,t,i),this._bindAction(o,s),this._addInactiveAction(o,r,n),o)}existingAction(e,t){var i=(t=t||this._root).uuid;return t=(t="string"==typeof e?Mu.findByName(t,e):e)?t.uuid:e,void 0!==(e=this._actionsByClip[t])&&e.actionByRoot[i]||null}stopAllAction(){var e=this._actions;for(let t=this._nActiveActions-1;0<=t;--t)e[t].stop();return this}update(e){e*=this.timeScale;var t=this._actions,i=this._nActiveActions,r=this.time+=e,n=Math.sign(e),a=this._accuIndex^=1;for(let s=0;s!==i;++s)t[s]._update(r,e,n,a);var s=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)s[e].apply(a);return this}setTime(e){for(let e=this.time=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){var t=this._actions,i=(e=e.uuid,this._actionsByClip),r=i[e];if(void 0!==r){var n=r.knownActions;for(let e=0,i=n.length;e!==i;++e){var a=n[e],s=(this._deactivateAction(a),a._cacheIndex),o=t[t.length-1];a._cacheIndex=null,a._byClipCacheIndex=null,t[o._cacheIndex=s]=o,t.pop(),this._removeInactiveBindingsForAction(a)}delete i[e]}}uncacheRoot(e){var t=e.uuid,i=this._actionsByClip;for(const e in i){var r=i[e].actionByRoot[t];void 0!==r&&(this._deactivateAction(r),this._removeInactiveAction(r))}var n=this._bindingsByRootAndName[t];if(void 0!==n)for(const e in n){var a=n[e];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){null!==(e=this.existingAction(e,t))&&(this._deactivateAction(e),this._removeInactiveAction(e))}}class Hd{constructor(e){this.value=e}clone(){return new Hd(void 0===this.value.clone?this.value:this.value.clone())}}let kd=0;class Vd extends _i{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:kd++}),this.name="",this.usage=si,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){return-1!==(e=this.uniforms.indexOf(e))&&this.uniforms.splice(e,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;var t=e.uniforms;for(let e=this.uniforms.length=0,i=t.length;e<i;e++)this.uniforms.push(t[e].clone());return this}clone(){return(new this.constructor).copy(this)}}class Wd extends xl{constructor(e,t,i=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){return(e=super.clone(e)).meshPerAttribute=this.meshPerAttribute,e}toJSON(e){return(e=super.toJSON(e)).isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}class Xd{constructor(e,t,i,r,n){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=i,this.elementSize=r,this.count=n,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class jd{constructor(e,t,i=0,r=1/0){this.ray=new Br(e,t),this.near=i,this.far=r,this.camera=null,this.layers=new Jr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,i=[]){return Yd(e,this,i,t),i.sort(qd),i}intersectObjects(e,t=!0,i=[]){for(let r=0,n=e.length;r<n;r++)Yd(e[r],this,i,t);return i.sort(qd),i}}function qd(e,t){return e.distance-t.distance}function Yd(e,t,i,r){if(e.layers.test(t.layers)&&e.raycast(t,i),!0===r){var n=e.children;for(let e=0,r=n.length;e<r;e++)Yd(n[e],t,i,!0)}}class Zd{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Ei(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}class Jd{constructor(e=1,t=0,i=0){return this.radius=e,this.theta=t,this.y=i,this}set(e,t,i){return this.radius=e,this.theta=t,this.y=i,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+i*i),this.theta=Math.atan2(e,i),this.y=t,this}clone(){return(new this.constructor).copy(this)}}const Kd=new Ui;class Qd{constructor(e=new Ui(1/0,1/0),t=new Ui(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){return t=Kd.copy(t).multiplyScalar(.5),this.min.copy(e).sub(t),this.max.copy(e).add(t),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Kd).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const $d=new hr,ep=new hr;class tp{constructor(e=new hr,t=new hr){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$d.subVectors(e,this.start),ep.subVectors(this.end,this.start),e=ep.dot(ep);let i=ep.dot($d)/e;return t?Ei(i,0,1):i}closestPointToPoint(e,t,i){return e=this.closestPointToPointParameter(e,t),this.delta(i).multiplyScalar(e).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const ip=new hr;class rp extends un{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper",e=new ra;var i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){var r=e/32*Math.PI*2,n=t/32*Math.PI*2;i.push(Math.cos(r),Math.sin(r),1,Math.cos(n),Math.sin(n),1)}e.setAttribute("position",new Yn(i,3)),t=new lh({fog:!1,toneMapped:!1}),this.cone=new vh(e,t),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);var e=this.light.distance||1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ip.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ip),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const np=new hr,ap=new zr,sp=new zr;class op extends vh{constructor(e){var t=function e(t){const i=[];!0===t.isBone&&i.push(t);for(let r=0;r<t.children.length;r++)i.push.apply(i,e(t.children[r]));return i}(e),i=new ra,r=[],n=[],a=new Ln(0,0,1),s=new Ln(0,1,0);for(let e=0;e<t.length;e++){var o=t[e];o.parent&&o.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),n.push(a.r,a.g,a.b),n.push(s.r,s.g,s.b))}i.setAttribute("position",new Yn(r,3)),i.setAttribute("color",new Yn(n,3)),super(i,new lh({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){var t=this.bones,i=this.geometry,r=i.getAttribute("position");sp.copy(this.root.matrixWorld).invert();for(let e=0,i=0;e<t.length;e++){var n=t[e];n.parent&&n.parent.isBone&&(ap.multiplyMatrices(sp,n.matrixWorld),np.setFromMatrixPosition(ap),r.setXYZ(i,np.x,np.y,np.z),ap.multiplyMatrices(sp,n.parent.matrixWorld),np.setFromMatrixPosition(ap),r.setXYZ(i+1,np.x,np.y,np.z),i+=2)}i.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}}class lp extends Ma{constructor(e,t,i){super(new Bc(t,4,2),new In({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=i,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const hp=new hr,cp=new Ln,up=new Ln;class dp extends un{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="HemisphereLightHelper",(e=new Nc(t)).rotateY(.5*Math.PI),this.material=new In({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0),i=e.getAttribute("position"),t=new Float32Array(3*i.count),e.setAttribute("color",new zn(t,3)),this.add(new Ma(e,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){var e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var t=e.geometry.getAttribute("color");cp.copy(this.light.color),up.copy(this.light.groundColor);for(let e=0,r=t.count;e<r;e++){var i=e<r/2?cp:up;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(hp.setFromMatrixPosition(this.light.matrixWorld).negate())}}class pp extends vh{constructor(e=10,t=10,i=4473924,r=8947848){i=new Ln(i),r=new Ln(r);var n=t/2,a=e/t,s=e/2,o=[],l=[];for(let e=0,c=0,u=-s;e<=t;e++,u+=a){o.push(-s,0,u,s,0,u),o.push(u,0,-s,u,0,s);var h=e===n?i:r;h.toArray(l,c),c+=3,h.toArray(l,c),c+=3,h.toArray(l,c),c+=3,h.toArray(l,c),c+=3}var c=((e=new ra).setAttribute("position",new Yn(o,3)),e.setAttribute("color",new Yn(l,3)),new lh({vertexColors:!0,toneMapped:!1}));super(e,c),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class mp extends vh{constructor(e=10,t=16,i=8,r=64,n=4473924,a=8947848){n=new Ln(n),a=new Ln(a);var s=[],o=[];if(1<t)for(let i=0;i<t;i++){var l=i/t*(2*Math.PI),h=Math.sin(l)*e;l=Math.cos(l)*e,s.push(0,0,0),s.push(h,0,l),h=1&i?n:a,o.push(h.r,h.g,h.b),o.push(h.r,h.g,h.b)}for(let t=0;t<i;t++){var c=1&t?n:a,u=e-e/i*t;for(let e=0;e<r;e++){var d=e/r*(2*Math.PI),p=Math.sin(d)*u,m=Math.cos(d)*u;s.push(p,0,m),o.push(c.r,c.g,c.b),d=(e+1)/r*(2*Math.PI),p=Math.sin(d)*u,m=Math.cos(d)*u,s.push(p,0,m),o.push(c.r,c.g,c.b)}}var f=new ra,g=(f.setAttribute("position",new Yn(s,3)),f.setAttribute("color",new Yn(o,3)),new lh({vertexColors:!0,toneMapped:!1}));super(f,g),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const fp=new hr,gp=new hr,vp=new hr;class _p extends un{constructor(e,t,i){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,this.type="DirectionalLightHelper",void 0===t&&(t=1);let r=new ra;r.setAttribute("position",new Yn([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3)),e=new lh({fog:!1,toneMapped:!1}),this.lightPlane=new mh(r,e),this.add(this.lightPlane),(r=new ra).setAttribute("position",new Yn([0,0,0,0,0,1],3)),this.targetLine=new mh(r,e),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),fp.setFromMatrixPosition(this.light.matrixWorld),gp.setFromMatrixPosition(this.light.target.matrixWorld),vp.subVectors(gp,fp),this.lightPlane.lookAt(gp),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(gp),this.targetLine.scale.z=vp.length()}}const xp=new hr,yp=new Ca;class Mp extends vh{constructor(e){var t=new ra,i=new lh({color:16777215,vertexColors:!0,toneMapped:!1});const r=[],n=[],a={};function s(e,t){o(e),o(t)}function o(e){r.push(0,0,0),n.push(0,0,0),void 0===a[e]&&(a[e]=[]),a[e].push(r.length/3-1)}s("n1","n2"),s("n2","n4"),s("n4","n3"),s("n3","n1"),s("f1","f2"),s("f2","f4"),s("f4","f3"),s("f3","f1"),s("n1","f1"),s("n2","f2"),s("n3","f3"),s("n4","f4"),s("p","n1"),s("p","n2"),s("p","n3"),s("p","n4"),s("u1","u2"),s("u2","u3"),s("u3","u1"),s("c","t"),s("p","c"),s("cn1","cn2"),s("cn3","cn4"),s("cf1","cf2"),s("cf3","cf4"),t.setAttribute("position",new Yn(r,3)),t.setAttribute("color",new Yn(n,3)),super(t,i),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update(),t=new Ln(16755200),i=new Ln(16711680),e=new Ln(43775);var l=new Ln(16777215),h=new Ln(3355443);this.setColors(t,i,e,l,h)}setColors(e,t,i,r,n){var a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,i.r,i.g,i.b),a.setXYZ(33,i.r,i.g,i.b),a.setXYZ(34,i.r,i.g,i.b),a.setXYZ(35,i.r,i.g,i.b),a.setXYZ(36,i.r,i.g,i.b),a.setXYZ(37,i.r,i.g,i.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,n.r,n.g,n.b),a.setXYZ(41,n.r,n.g,n.b),a.setXYZ(42,n.r,n.g,n.b),a.setXYZ(43,n.r,n.g,n.b),a.setXYZ(44,n.r,n.g,n.b),a.setXYZ(45,n.r,n.g,n.b),a.setXYZ(46,n.r,n.g,n.b),a.setXYZ(47,n.r,n.g,n.b),a.setXYZ(48,n.r,n.g,n.b),a.setXYZ(49,n.r,n.g,n.b),a.needsUpdate=!0}update(){var e=this.geometry,t=this.pointMap;yp.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Sp("c",t,e,yp,0,0,-1),Sp("t",t,e,yp,0,0,1),Sp("n1",t,e,yp,-1,-1,-1),Sp("n2",t,e,yp,1,-1,-1),Sp("n3",t,e,yp,-1,1,-1),Sp("n4",t,e,yp,1,1,-1),Sp("f1",t,e,yp,-1,-1,1),Sp("f2",t,e,yp,1,-1,1),Sp("f3",t,e,yp,-1,1,1),Sp("f4",t,e,yp,1,1,1),Sp("u1",t,e,yp,.7,1.1,-1),Sp("u2",t,e,yp,-.7,1.1,-1),Sp("u3",t,e,yp,0,2,-1),Sp("cf1",t,e,yp,-1,0,1),Sp("cf2",t,e,yp,1,0,1),Sp("cf3",t,e,yp,0,-1,1),Sp("cf4",t,e,yp,0,1,1),Sp("cn1",t,e,yp,-1,0,-1),Sp("cn2",t,e,yp,1,0,-1),Sp("cn3",t,e,yp,0,-1,-1),Sp("cn4",t,e,yp,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Sp(e,t,i,r,n,a,s){xp.set(n,a,s).unproject(r);var o=t[e];if(void 0!==o){var l=i.getAttribute("position");for(let e=0,t=o.length;e<t;e++)l.setXYZ(o[e],xp.x,xp.y,xp.z)}}const bp=new dr;class Ep extends vh{constructor(e,t=16776960){var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),n=new ra;n.setIndex(new zn(i,1)),n.setAttribute("position",new zn(r,3)),super(n,new lh({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){var t,i,r;void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&bp.setFromObject(this.object),bp.isEmpty()||(e=bp.min,t=bp.max,(r=(i=this.geometry.attributes.position).array)[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere())}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Tp extends vh{constructor(e,t=16776960){var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new ra;r.setIndex(new zn(i,1)),r.setAttribute("position",new Yn([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(r,new lh({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class wp extends mh{constructor(e,t=1,i=16776960){var r;((r=new ra).setAttribute("position",new Yn([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere(),super(r,new lh({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t,r=new ra).setAttribute("position",new Yn([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Ma(r,new In({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const Ap=new hr;let Rp,Cp;class Lp extends un{constructor(e=new hr(0,0,1),t=new hr(0,0,0),i=1,r=16776960,n=.2*i,a=.2*n){super(),this.type="ArrowHelper",void 0===Rp&&((Rp=new ra).setAttribute("position",new Yn([0,0,0,0,1,0],3)),(Cp=new ic(0,.5,1,5,1)).translate(0,-.5,0)),this.position.copy(t),this.line=new mh(Rp,new lh({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ma(Cp,new In({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(i,n,a)}setDirection(e){.99999<e.y?this.quaternion.set(0,0,0,1):e.y<-.99999?this.quaternion.set(1,0,0,0):(Ap.set(e.z,0,-e.x).normalize(),e=Math.acos(e.y),this.quaternion.setFromAxisAngle(Ap,e))}setLength(e,t=.2*e,i=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(i,t,i),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Pp extends vh{constructor(e=1){e=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e];var t=new ra;t.setAttribute("position",new Yn(e,3)),t.setAttribute("color",new Yn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,e=new lh({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,i){var r=new Ln,n=this.geometry.attributes.color.array;return r.set(e),r.toArray(n,0),r.toArray(n,3),r.set(t),r.toArray(n,6),r.toArray(n,9),r.set(i),r.toArray(n,12),r.toArray(n,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Ip{constructor(){this.type="ShapePath",this.color=new Ln,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Qh,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){return this.currentPath.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,a){return this.currentPath.bezierCurveTo(e,t,i,r,n,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){var t=Cc.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,n,a;var s=[];if(1===i.length)n=i[0],(a=new uc).curves=n.curves,s.push(a);else{var o,l,h=!t(i[0].getPoints()),c=(h=e?!h:h,[]),u=[];let _=[],x=0;u[x]=void 0,_[x]=[];for(let a=0,s=i.length;a<s;a++)r=t(o=(n=i[a]).getPoints()),(e?!r:r)?(!h&&u[x]&&x++,u[x]={s:new uc,p:o},u[x].s.curves=n.curves,h&&x++,_[x]=[]):_[x].push({h:n,p:o[0]});if(!u[0]){var d=i,p=[];for(let e=0,t=d.length;e<t;e++){var m=d[e],f=new uc;f.curves=m.curves,p.push(f)}return p}if(1<u.length){let e=!1,t=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let i=0,r=u.length;i<r;i++){var g=_[i];for(let r=0;r<g.length;r++){var v=g[r];let n=!0;for(let r=0;r<u.length;r++)!function(e,t){var i=t.length;let r=!1;for(let a=i-1,s=0;s<i;a=s++){let i=t[a],o=t[s],l=o.x-i.x,h=o.y-i.y;if(Math.abs(h)>Number.EPSILON){if(h<0&&(i=t[s],l=-l,o=t[a],h=-h),!(e.y<i.y||e.y>o.y))if(e.y===i.y){if(e.x===i.x)return 1}else{var n=h*(e.x-i.x)-l*(e.y-i.y);if(0==n)return 1;n<0||(r=!r)}}else if(e.y===i.y&&(o.x<=e.x&&e.x<=i.x||i.x<=e.x&&e.x<=o.x))return 1}return r}(v.p,u[r].p)||(i!==r&&t++,n?(n=!1,c[r].push(v)):e=!0);n&&c[i].push(v)}}0<t&&!1===e&&(_=c)}for(let e=0,t=u.length;e<t;e++){a=u[e].s,s.push(a);for(let t=0,i=(l=_[e]).length;t<i;t++)a.holes.push(l[t].h)}}return s}}class Up extends ba{constructor(e,t,i,r,n,a){console.warn("THREE.BoxBufferGeometry has been renamed to THREE.BoxGeometry."),super(e,t,i,r,n,a)}}class Dp extends ec{constructor(e,t,i,r){console.warn("THREE.CapsuleBufferGeometry has been renamed to THREE.CapsuleGeometry."),super(e,t,i,r)}}class Np extends tc{constructor(e,t,i,r){console.warn("THREE.CircleBufferGeometry has been renamed to THREE.CircleGeometry."),super(e,t,i,r)}}class Op extends rc{constructor(e,t,i,r,n,a,s){console.warn("THREE.ConeBufferGeometry has been renamed to THREE.ConeGeometry."),super(e,t,i,r,n,a,s)}}class Fp extends ic{constructor(e,t,i,r,n,a,s,o){console.warn("THREE.CylinderBufferGeometry has been renamed to THREE.CylinderGeometry."),super(e,t,i,r,n,a,s,o)}}class Bp extends ac{constructor(e,t){console.warn("THREE.DodecahedronBufferGeometry has been renamed to THREE.DodecahedronGeometry."),super(e,t)}}class zp extends Ic{constructor(e,t){console.warn("THREE.ExtrudeBufferGeometry has been renamed to THREE.ExtrudeGeometry."),super(e,t)}}class Gp extends Dc{constructor(e,t){console.warn("THREE.IcosahedronBufferGeometry has been renamed to THREE.IcosahedronGeometry."),super(e,t)}}class Hp extends $h{constructor(e,t,i,r){console.warn("THREE.LatheBufferGeometry has been renamed to THREE.LatheGeometry."),super(e,t,i,r)}}class kp extends Nc{constructor(e,t){console.warn("THREE.OctahedronBufferGeometry has been renamed to THREE.OctahedronGeometry."),super(e,t)}}class Vp extends Va{constructor(e,t,i,r){console.warn("THREE.PlaneBufferGeometry has been renamed to THREE.PlaneGeometry."),super(e,t,i,r)}}class Wp extends nc{constructor(e,t,i,r){console.warn("THREE.PolyhedronBufferGeometry has been renamed to THREE.PolyhedronGeometry."),super(e,t,i,r)}}class Xp extends Oc{constructor(e,t,i,r,n,a){console.warn("THREE.RingBufferGeometry has been renamed to THREE.RingGeometry."),super(e,t,i,r,n,a)}}class jp extends Fc{constructor(e,t){console.warn("THREE.ShapeBufferGeometry has been renamed to THREE.ShapeGeometry."),super(e,t)}}class qp extends Bc{constructor(e,t,i,r,n,a,s){console.warn("THREE.SphereBufferGeometry has been renamed to THREE.SphereGeometry."),super(e,t,i,r,n,a,s)}}class Yp extends zc{constructor(e,t){console.warn("THREE.TetrahedronBufferGeometry has been renamed to THREE.TetrahedronGeometry."),super(e,t)}}class Zp extends Gc{constructor(e,t,i,r,n){console.warn("THREE.TorusBufferGeometry has been renamed to THREE.TorusGeometry."),super(e,t,i,r,n)}}class Jp extends Hc{constructor(e,t,i,r,n,a){console.warn("THREE.TorusKnotBufferGeometry has been renamed to THREE.TorusKnotGeometry."),super(e,t,i,r,n,a)}}class Kp extends kc{constructor(e,t,i,r,n){console.warn("THREE.TubeBufferGeometry has been renamed to THREE.TubeGeometry."),super(e,t,i,r,n)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:r}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=r)}}]);
//# sourceMappingURL=three-js.c9b97f7981cf868f4573.bundle.js.map