@dcl-regenesislabs/web-editor 0.3.19 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor.js +474 -434
- package/package.json +1 -1
- package/three/worker.js +14 -14
package/three/worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(()=>{var LM=Object.defineProperty;var NM=(s,t)=>{for(var e in t)LM(s,e,{get:t[e],enumerable:!0})};var Vl={};NM(Vl,{ACESFilmicToneMapping:()=>Yp,AddEquation:()=>sr,AddOperation:()=>Gp,AdditiveAnimationBlendMode:()=>_f,AdditiveBlending:()=>cf,AgXToneMapping:()=>Kp,AlphaFormat:()=>mf,AlwaysCompare:()=>um,AlwaysDepth:()=>Jc,AlwaysStencilFunc:()=>ih,AmbientLight:()=>zc,AnimationAction:()=>Kc,AnimationClip:()=>ni,AnimationLoader:()=>Mh,AnimationMixer:()=>Xo,AnimationObjectGroup:()=>Ph,AnimationUtils:()=>vh,ArcCurve:()=>lc,ArrayCamera:()=>qc,ArrowHelper:()=>tf,AttachedBindMode:()=>nh,Audio:()=>Yc,AudioAnalyser:()=>Ih,AudioContext:()=>Wo,AudioListener:()=>Rh,AudioLoader:()=>wh,AxesHelper:()=>ef,BackSide:()=>qe,BasicDepthPacking:()=>em,BasicShadowMap:()=>q_,BatchedMesh:()=>ic,Bone:()=>Cr,BooleanKeyframeTrack:()=>zi,Box2:()=>Vh,Box3:()=>ne,Box3Helper:()=>jh,BoxGeometry:()=>Ui,BoxHelper:()=>Jh,BufferAttribute:()=>kt,BufferGeometry:()=>Vt,BufferGeometryLoader:()=>Xc,ByteType:()=>hf,Cache:()=>di,Camera:()=>hs,CameraHelper:()=>Zh,CanvasTexture:()=>Eo,CapsuleGeometry:()=>sc,CatmullRomCurve3:()=>uc,CineonToneMapping:()=>qp,CircleGeometry:()=>oc,ClampToEdgeWrapping:()=>en,Clock:()=>bs,Color:()=>yt,ColorKeyframeTrack:()=>Ho,ColorManagement:()=>ie,CompressedArrayTexture:()=>xh,CompressedCubeTexture:()=>_h,CompressedTexture:()=>gi,CompressedTextureLoader:()=>Sh,ConeGeometry:()=>Co,ConstantAlphaFactor:()=>kp,ConstantColorFactor:()=>Bp,Controls:()=>rf,CubeCamera:()=>Za,CubeReflectionMapping:()=>Wi,CubeRefractionMapping:()=>ur,CubeTexture:()=>Rr,CubeTextureLoader:()=>bh,CubeUVReflectionMapping:()=>Ts,CubicBezierCurve:()=>Io,CubicBezierCurve3:()=>hc,CubicInterpolant:()=>Uc,CullFaceBack:()=>of,CullFaceFront:()=>Sp,CullFaceFrontBack:()=>X_,CullFaceNone:()=>Mp,Curve:()=>In,CurvePath:()=>dc,CustomBlending:()=>Tp,CustomToneMapping:()=>$p,CylinderGeometry:()=>Ro,Cylindrical:()=>kh,Data3DTexture:()=>ls,DataArrayTexture:()=>cs,DataTexture:()=>zn,DataTextureLoader:()=>Th,DataUtils:()=>oh,DecrementStencilOp:()=>i0,DecrementWrapStencilOp:()=>s0,DefaultLoadingManager:()=>_m,DepthFormat:()=>rs,DepthStencilFormat:()=>Rs,DepthTexture:()=>wo,DetachedBindMode:()=>Jp,DirectionalLight:()=>lr,DirectionalLightHelper:()=>Kh,DiscreteInterpolant:()=>Fc,DodecahedronGeometry:()=>ac,DoubleSide:()=>Ve,DstAlphaFactor:()=>Np,DstColorFactor:()=>Up,DynamicCopyUsage:()=>v0,DynamicDrawUsage:()=>p0,DynamicReadUsage:()=>x0,EdgesGeometry:()=>cc,EllipseCurve:()=>gs,EqualCompare:()=>om,EqualDepth:()=>Qc,EqualStencilFunc:()=>l0,EquirectangularReflectionMapping:()=>Yo,EquirectangularRefractionMapping:()=>$o,Euler:()=>Rn,EventDispatcher:()=>kn,ExternalTexture:()=>Ao,ExtrudeGeometry:()=>xc,FileLoader:()=>Mn,Float16BufferAttribute:()=>fh,Float32BufferAttribute:()=>Lt,FloatType:()=>xn,Fog:()=>Qa,FogExp2:()=>ja,FramebufferTexture:()=>gh,FrontSide:()=>rn,Frustum:()=>or,FrustumArray:()=>nc,GLBufferAttribute:()=>Fh,GLSL1:()=>S0,GLSL3:()=>Mf,GreaterCompare:()=>am,GreaterDepth:()=>el,GreaterEqualCompare:()=>lm,GreaterEqualDepth:()=>tl,GreaterEqualStencilFunc:()=>d0,GreaterStencilFunc:()=>h0,GridHelper:()=>Yh,Group:()=>nn,HalfFloatType:()=>ws,HemisphereLight:()=>vs,HemisphereLightHelper:()=>qh,IcosahedronGeometry:()=>_c,ImageBitmapLoader:()=>Go,ImageLoader:()=>Lr,ImageUtils:()=>as,IncrementStencilOp:()=>n0,IncrementWrapStencilOp:()=>r0,InstancedBufferAttribute:()=>ti,InstancedBufferGeometry:()=>Wc,InstancedInterleavedBuffer:()=>Uh,InstancedMesh:()=>ei,Int16BufferAttribute:()=>uh,Int32BufferAttribute:()=>hh,Int8BufferAttribute:()=>ah,IntType:()=>rl,InterleavedBuffer:()=>Oi,InterleavedBufferAttribute:()=>pi,Interpolant:()=>Bi,InterpolateDiscrete:()=>Ni,InterpolateLinear:()=>Di,InterpolateSmooth:()=>Wa,InterpolationSamplingMode:()=>E0,InterpolationSamplingType:()=>T0,InvertStencilOp:()=>o0,KeepStencilOp:()=>br,KeyframeTrack:()=>vn,LOD:()=>ec,LatheGeometry:()=>yc,Layers:()=>us,LessCompare:()=>sm,LessDepth:()=>jc,LessEqualCompare:()=>vf,LessEqualDepth:()=>Ar,LessEqualStencilFunc:()=>u0,LessStencilFunc:()=>c0,Light:()=>yi,LightProbe:()=>Vc,Line:()=>Vn,Line3:()=>_e,LineBasicMaterial:()=>Xe,LineCurve:()=>Po,LineCurve3:()=>fc,LineDashedMaterial:()=>Dc,LineLoop:()=>ps,LineSegments:()=>yn,LinearFilter:()=>Ee,LinearInterpolant:()=>ko,LinearMipMapLinearFilter:()=>Z_,LinearMipMapNearestFilter:()=>K_,LinearMipmapLinearFilter:()=>un,LinearMipmapNearestFilter:()=>Xi,LinearSRGBColorSpace:()=>tn,LinearToneMapping:()=>Wp,LinearTransfer:()=>xo,Loader:()=>Ke,LoaderUtils:()=>ii,LoadingManager:()=>Pr,LoopOnce:()=>jp,LoopPingPong:()=>tm,LoopRepeat:()=>Qp,MOUSE:()=>G_,Material:()=>Ue,MaterialLoader:()=>Gc,MathUtils:()=>Yi,Matrix2:()=>Hh,Matrix3:()=>$t,Matrix4:()=>vt,MaxEquation:()=>Rp,Mesh:()=>ce,MeshBasicMaterial:()=>sn,MeshDepthMaterial:()=>Bo,MeshDistanceMaterial:()=>zo,MeshLambertMaterial:()=>Lc,MeshMatcapMaterial:()=>Nc,MeshNormalMaterial:()=>Pc,MeshPhongMaterial:()=>Cc,MeshPhysicalMaterial:()=>ln,MeshStandardMaterial:()=>xi,MeshToonMaterial:()=>Ic,MinEquation:()=>Ap,MirroredRepeatWrapping:()=>Li,MixOperation:()=>Vp,MultiplyBlending:()=>uf,MultiplyOperation:()=>qo,NearestFilter:()=>De,NearestMipMapLinearFilter:()=>$_,NearestMipMapNearestFilter:()=>Y_,NearestMipmapLinearFilter:()=>Mi,NearestMipmapNearestFilter:()=>Nr,NeutralToneMapping:()=>Zp,NeverCompare:()=>rm,NeverDepth:()=>Zc,NeverStencilFunc:()=>a0,NoBlending:()=>Vi,NoColorSpace:()=>si,NoToneMapping:()=>Gi,NormalAnimationBlendMode:()=>Bl,NormalBlending:()=>wr,NotEqualCompare:()=>cm,NotEqualDepth:()=>nl,NotEqualStencilFunc:()=>f0,NumberKeyframeTrack:()=>_i,Object3D:()=>re,ObjectLoader:()=>Eh,ObjectSpaceNormalMap:()=>im,OctahedronGeometry:()=>Fo,OneFactor:()=>Ip,OneMinusConstantAlphaFactor:()=>Hp,OneMinusConstantColorFactor:()=>zp,OneMinusDstAlphaFactor:()=>Dp,OneMinusDstColorFactor:()=>Fp,OneMinusSrcAlphaFactor:()=>Ka,OneMinusSrcColorFactor:()=>Lp,OrthographicCamera:()=>cr,PCFShadowMap:()=>af,PCFSoftShadowMap:()=>bp,PMREMGenerator:()=>kl,Path:()=>xs,PerspectiveCamera:()=>Re,Plane:()=>$e,PlaneGeometry:()=>ys,PlaneHelper:()=>Qh,PointLight:()=>Ss,PointLightHelper:()=>Xh,Points:()=>ms,PointsMaterial:()=>Ir,PolarGridHelper:()=>$h,PolyhedronGeometry:()=>ar,PositionalAudio:()=>Ch,PropertyBinding:()=>ee,PropertyMixer:()=>$c,QuadraticBezierCurve:()=>Lo,QuadraticBezierCurve3:()=>No,Quaternion:()=>Ce,QuaternionKeyframeTrack:()=>Gn,QuaternionLinearInterpolant:()=>Oc,RED_GREEN_RGTC2_Format:()=>Fl,RED_RGTC1_Format:()=>Dl,REVISION:()=>Hi,RGBADepthPacking:()=>nm,RGBAFormat:()=>Qe,RGBAIntegerFormat:()=>ll,RGBA_ASTC_10x10_Format:()=>Rl,RGBA_ASTC_10x5_Format:()=>El,RGBA_ASTC_10x6_Format:()=>wl,RGBA_ASTC_10x8_Format:()=>Al,RGBA_ASTC_12x10_Format:()=>Cl,RGBA_ASTC_12x12_Format:()=>Il,RGBA_ASTC_4x4_Format:()=>xl,RGBA_ASTC_5x4_Format:()=>_l,RGBA_ASTC_5x5_Format:()=>yl,RGBA_ASTC_6x5_Format:()=>vl,RGBA_ASTC_6x6_Format:()=>Ml,RGBA_ASTC_8x5_Format:()=>Sl,RGBA_ASTC_8x6_Format:()=>bl,RGBA_ASTC_8x8_Format:()=>Tl,RGBA_BPTC_Format:()=>Pl,RGBA_ETC2_EAC_Format:()=>gl,RGBA_PVRTC_2BPPV1_Format:()=>dl,RGBA_PVRTC_4BPPV1_Format:()=>fl,RGBA_S3TC_DXT1_Format:()=>Jo,RGBA_S3TC_DXT3_Format:()=>jo,RGBA_S3TC_DXT5_Format:()=>Qo,RGBDepthPacking:()=>j_,RGBFormat:()=>gf,RGBIntegerFormat:()=>J_,RGB_BPTC_SIGNED_Format:()=>Ll,RGB_BPTC_UNSIGNED_Format:()=>Nl,RGB_ETC1_Format:()=>pl,RGB_ETC2_Format:()=>ml,RGB_PVRTC_2BPPV1_Format:()=>hl,RGB_PVRTC_4BPPV1_Format:()=>ul,RGB_S3TC_DXT1_Format:()=>Zo,RGDepthPacking:()=>Q_,RGFormat:()=>xf,RGIntegerFormat:()=>cl,RawShaderMaterial:()=>Rc,Ray:()=>_n,Raycaster:()=>Oh,RectAreaLight:()=>kc,RedFormat:()=>al,RedIntegerFormat:()=>Ko,ReinhardToneMapping:()=>Xp,RenderTarget:()=>Mo,RenderTarget3D:()=>Lh,RepeatWrapping:()=>An,ReplaceStencilOp:()=>e0,ReverseSubtractEquation:()=>wp,RingGeometry:()=>vc,SIGNED_RED_GREEN_RGTC2_Format:()=>Ol,SIGNED_RED_RGTC1_Format:()=>Ul,SRGBColorSpace:()=>Ae,SRGBTransfer:()=>ge,Scene:()=>Fi,ShaderChunk:()=>te,ShaderLib:()=>Si,ShaderMaterial:()=>Cn,ShadowMaterial:()=>Ac,Shape:()=>Pi,ShapeGeometry:()=>Mc,ShapePath:()=>nf,ShapeUtils:()=>Qn,ShortType:()=>ff,Skeleton:()=>ds,SkeletonHelper:()=>Wh,SkinnedMesh:()=>mi,Source:()=>On,Sphere:()=>Be,SphereGeometry:()=>Oo,Spherical:()=>zh,SphericalHarmonics3:()=>Hc,SplineCurve:()=>Do,SpotLight:()=>Ms,SpotLightHelper:()=>Gh,Sprite:()=>tc,SpriteMaterial:()=>To,SrcAlphaFactor:()=>$a,SrcAlphaSaturateFactor:()=>Op,SrcColorFactor:()=>Pp,StaticCopyUsage:()=>y0,StaticDrawUsage:()=>_o,StaticReadUsage:()=>g0,StereoCamera:()=>Ah,StreamCopyUsage:()=>M0,StreamDrawUsage:()=>m0,StreamReadUsage:()=>_0,StringKeyframeTrack:()=>ki,SubtractEquation:()=>Ep,SubtractiveBlending:()=>lf,TOUCH:()=>W_,TangentSpaceNormalMap:()=>hr,TetrahedronGeometry:()=>Sc,Texture:()=>Ie,TextureLoader:()=>Vo,TextureUtils:()=>sf,Timer:()=>Bh,TimestampQuery:()=>b0,TorusGeometry:()=>bc,TorusKnotGeometry:()=>Tc,Triangle:()=>me,TriangleFanDrawMode:()=>Cs,TriangleStripDrawMode:()=>ta,TrianglesDrawMode:()=>yf,TubeGeometry:()=>Ec,UVMapping:()=>il,Uint16BufferAttribute:()=>So,Uint32BufferAttribute:()=>bo,Uint8BufferAttribute:()=>ch,Uint8ClampedBufferAttribute:()=>lh,Uniform:()=>Nh,UniformsGroup:()=>Dh,UniformsLib:()=>Tt,UniformsUtils:()=>mm,UnsignedByteType:()=>ri,UnsignedInt101111Type:()=>pf,UnsignedInt248Type:()=>As,UnsignedInt5999Type:()=>df,UnsignedIntType:()=>qi,UnsignedShort4444Type:()=>sl,UnsignedShort5551Type:()=>ol,UnsignedShortType:()=>Es,VSMShadowMap:()=>vi,Vector2:()=>nt,Vector3:()=>I,Vector4:()=>Qt,VectorKeyframeTrack:()=>Wn,VideoFrameTexture:()=>mh,VideoTexture:()=>rc,WebGL3DRenderTarget:()=>sh,WebGLArrayRenderTarget:()=>rh,WebGLCoordinateSystem:()=>wn,WebGLCubeRenderTarget:()=>Ja,WebGLRenderTarget:()=>Hn,WebGLRenderer:()=>Hl,WebGLUtils:()=>uy,WebGPUCoordinateSystem:()=>ss,WebXRController:()=>fs,WireframeGeometry:()=>wc,WrapAroundEnding:()=>go,ZeroCurvatureEnding:()=>Tr,ZeroFactor:()=>Cp,ZeroSlopeEnding:()=>Er,ZeroStencilOp:()=>t0,createCanvasElement:()=>dm});var Hi="180",G_={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},W_={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Mp=0,of=1,Sp=2,X_=3,q_=0,af=1,bp=2,vi=3,rn=0,qe=1,Ve=2,Vi=0,wr=1,cf=2,lf=3,uf=4,Tp=5,sr=100,Ep=101,wp=102,Ap=103,Rp=104,Cp=200,Ip=201,Pp=202,Lp=203,$a=204,Ka=205,Np=206,Dp=207,Up=208,Fp=209,Op=210,Bp=211,zp=212,kp=213,Hp=214,Zc=0,Jc=1,jc=2,Ar=3,Qc=4,tl=5,el=6,nl=7,qo=0,Vp=1,Gp=2,Gi=0,Wp=1,Xp=2,qp=3,Yp=4,$p=5,Kp=6,Zp=7,nh="attached",Jp="detached",il=300,Wi=301,ur=302,Yo=303,$o=304,Ts=306,An=1e3,en=1001,Li=1002,De=1003,Nr=1004,Y_=1004,Mi=1005,$_=1005,Ee=1006,Xi=1007,K_=1007,un=1008,Z_=1008,ri=1009,hf=1010,ff=1011,Es=1012,rl=1013,qi=1014,xn=1015,ws=1016,sl=1017,ol=1018,As=1020,df=35902,pf=35899,mf=1021,gf=1022,Qe=1023,rs=1026,Rs=1027,al=1028,Ko=1029,xf=1030,cl=1031,J_=1032,ll=1033,Zo=33776,Jo=33777,jo=33778,Qo=33779,ul=35840,hl=35841,fl=35842,dl=35843,pl=36196,ml=37492,gl=37496,xl=37808,_l=37809,yl=37810,vl=37811,Ml=37812,Sl=37813,bl=37814,Tl=37815,El=37816,wl=37817,Al=37818,Rl=37819,Cl=37820,Il=37821,Pl=36492,Ll=36494,Nl=36495,Dl=36283,Ul=36284,Fl=36285,Ol=36286,jp=2200,Qp=2201,tm=2202,Ni=2300,Di=2301,Wa=2302,Tr=2400,Er=2401,go=2402,Bl=2500,_f=2501,yf=0,ta=1,Cs=2,em=3200,nm=3201,j_=3202,Q_=3203,hr=0,im=1,si="",Ae="srgb",tn="srgb-linear",xo="linear",ge="srgb",t0=0,br=7680,e0=7681,n0=7682,i0=7683,r0=34055,s0=34056,o0=5386,a0=512,c0=513,l0=514,u0=515,h0=516,f0=517,d0=518,ih=519,rm=512,sm=513,om=514,vf=515,am=516,cm=517,lm=518,um=519,_o=35044,p0=35048,m0=35040,g0=35045,x0=35049,_0=35041,y0=35046,v0=35050,M0=35042,S0="100",Mf="300 es",wn=2e3,ss=2001,b0={COMPUTE:"compute",RENDER:"render"},T0={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},E0={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},kn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,t);t.target=null}}},on=["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"],Fx=1234567,is=Math.PI/180,os=180/Math.PI;function Bn(){let s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(on[s&255]+on[s>>8&255]+on[s>>16&255]+on[s>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[e&63|128]+on[e>>8&255]+"-"+on[e>>16&255]+on[e>>24&255]+on[n&255]+on[n>>8&255]+on[n>>16&255]+on[n>>24&255]).toLowerCase()}function Xt(s,t,e){return Math.max(t,Math.min(e,s))}function hm(s,t){return(s%t+t)%t}function DM(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function UM(s,t,e){return s!==t?(e-s)/(t-s):0}function Xa(s,t,e){return(1-e)*s+e*t}function FM(s,t,e,n){return Xa(s,t,1-Math.exp(-e*n))}function OM(s,t=1){return t-Math.abs(hm(s,t*2)-t)}function BM(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function zM(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function kM(s,t){return s+Math.floor(Math.random()*(t-s+1))}function HM(s,t){return s+Math.random()*(t-s)}function VM(s){return s*(.5-Math.random())}function GM(s){s!==void 0&&(Fx=s);let t=Fx+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function WM(s){return s*is}function XM(s){return s*os}function qM(s){return(s&s-1)===0&&s!==0}function YM(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function $M(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function KM(s,t,e,n,i){let r=Math.cos,o=Math.sin,a=r(e/2),c=o(e/2),l=r((t+n)/2),u=o((t+n)/2),h=r((t-n)/2),f=o((t-n)/2),p=r((n-t)/2),x=o((n-t)/2);switch(i){case"XYX":s.set(a*u,c*h,c*f,a*l);break;case"YZY":s.set(c*f,a*u,c*h,a*l);break;case"ZXZ":s.set(c*h,c*f,a*u,a*l);break;case"XZX":s.set(a*u,c*x,c*p,a*l);break;case"YXY":s.set(c*p,a*u,c*x,a*l);break;case"ZYZ":s.set(c*x,c*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function gn(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Jt(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var Yi={DEG2RAD:is,RAD2DEG:os,generateUUID:Bn,clamp:Xt,euclideanModulo:hm,mapLinear:DM,inverseLerp:UM,lerp:Xa,damp:FM,pingpong:OM,smoothstep:BM,smootherstep:zM,randInt:kM,randFloat:HM,randFloatSpread:VM,seededRandom:GM,degToRad:WM,radToDeg:XM,isPowerOfTwo:qM,ceilPowerOfTwo:YM,floorPowerOfTwo:$M,setQuaternionFromProperEuler:KM,normalize:Jt,denormalize:gn},nt=class s{constructor(t=0,e=0){s.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*i+t.x,this.y=r*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ce=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3],f=r[o+0],p=r[o+1],x=r[o+2],v=r[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=f,t[e+1]=p,t[e+2]=x,t[e+3]=v;return}if(h!==v||c!==f||l!==p||u!==x){let y=1-a,_=c*f+l*p+u*x+h*v,S=_>=0?1:-1,g=1-_*_;if(g>Number.EPSILON){let M=Math.sqrt(g),m=Math.atan2(M,_*S);y=Math.sin(y*m)/M,a=Math.sin(a*m)/M}let d=a*S;if(c=c*y+f*d,l=l*y+p*d,u=u*y+x*d,h=h*y+v*d,y===1-a){let M=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=M,l*=M,u*=M,h*=M}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,o){let a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=r[o],f=r[o+1],p=r[o+2],x=r[o+3];return t[e]=a*x+u*h+c*p-l*f,t[e+1]=c*x+u*f+l*h-a*p,t[e+2]=l*x+u*p+a*f-c*h,t[e+3]=u*x-a*h-c*f-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,i=t._y,r=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(r/2),f=c(n/2),p=c(i/2),x=c(r/2);switch(o){case"XYZ":this._x=f*u*h+l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h-f*p*x;break;case"YXZ":this._x=f*u*h+l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h+f*p*x;break;case"ZXY":this._x=f*u*h-l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h-f*p*x;break;case"ZYX":this._x=f*u*h-l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h+f*p*x;break;case"YZX":this._x=f*u*h+l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h-f*p*x;break;case"XZY":this._x=f*u*h-l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h+f*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=n+a+h;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(u-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>h){let p=2*Math.sqrt(1+n-a-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>h){let p=2*Math.sqrt(1+a-n-h);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{let p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Xt(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,i=t._y,r=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+i*l-r*c,this._y=i*u+o*c+r*a-n*l,this._z=r*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,i=this._y,r=this._z,o=this._w,a=o*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;let c=1-a*a;if(c<=Number.EPSILON){let p=1-e;return this._w=p*o+e*this._w,this._x=p*n+e*this._x,this._y=p*i+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=r*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},I=class s{constructor(t=0,e=0,n=0){s.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ox.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ox.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*i-a*n),u=2*(a*e-r*i),h=2*(r*n-o*e);return this.x=e+c*l+o*h-a*u,this.y=n+c*u+a*l-r*h,this.z=i+c*h+r*u-o*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,r=t.z,o=e.x,a=e.y,c=e.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ed.copy(this).projectOnVector(t),this.sub(Ed)}reflect(t){return this.sub(Ed.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Ed=new I,Ox=new Ce,$t=class s{constructor(t,e,n,i,r,o,a,c,l){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l)}set(t,e,n,i,r,o,a,c,l){let u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=r,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],p=n[5],x=n[8],v=i[0],y=i[3],_=i[6],S=i[1],g=i[4],d=i[7],M=i[2],m=i[5],R=i[8];return r[0]=o*v+a*S+c*M,r[3]=o*y+a*g+c*m,r[6]=o*_+a*d+c*R,r[1]=l*v+u*S+h*M,r[4]=l*y+u*g+h*m,r[7]=l*_+u*d+h*R,r[2]=f*v+p*S+x*M,r[5]=f*y+p*g+x*m,r[8]=f*_+p*d+x*R,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*r*u+n*a*c+i*r*l-i*o*c}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=u*o-a*l,f=a*c-u*r,p=l*r-o*c,x=e*h+n*f+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/x;return t[0]=h*v,t[1]=(i*l-u*n)*v,t[2]=(a*n-i*o)*v,t[3]=f*v,t[4]=(u*e-i*c)*v,t[5]=(i*r-a*e)*v,t[6]=p*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*r)*v,this}transpose(){let t,e=this.elements;return t=e[1],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(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+t,-i*l,i*c,-i*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(wd.makeScale(t,e)),this}rotate(t){return this.premultiply(wd.makeRotation(-t)),this}translate(t,e){return this.premultiply(wd.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},wd=new $t;function fm(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}var ZM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function po(s,t){return new ZM[s](t)}function yo(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function dm(){let s=yo("canvas");return s.style.display="block",s}var Bx={};function vo(s){s in Bx||(Bx[s]=!0,console.warn(s))}function w0(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var zx=new $t().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kx=new $t().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function JM(){let s={enabled:!0,workingColorSpace:tn,spaces:{},convert:function(i,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ge&&(i.r=rr(i.r),i.g=rr(i.g),i.b=rr(i.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ge&&(i.r=mo(i.r),i.g=mo(i.g),i.b=mo(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===si?xo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,o){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return vo("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return vo("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[tn]:{primaries:t,whitePoint:n,transfer:xo,toXYZ:zx,fromXYZ:kx,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ae},outputColorSpaceConfig:{drawingBufferColorSpace:Ae}},[Ae]:{primaries:t,whitePoint:n,transfer:ge,toXYZ:zx,fromXYZ:kx,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ae}}}),s}var ie=JM();function rr(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function mo(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var Ys,as=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Ys===void 0&&(Ys=yo("canvas")),Ys.width=t.width,Ys.height=t.height;let i=Ys.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Ys}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=yo("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=rr(r[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(rr(e[n]/255)*255):e[n]=rr(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},jM=0,On=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Bn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Ad(i[o].image)):r.push(Ad(i[o]))}else r=Ad(i);n.url=r}return e||(t.images[this.uuid]=n),n}};function Ad(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?as.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var QM=0,Rd=new I,Ie=class s extends kn{constructor(t=s.DEFAULT_IMAGE,e=s.DEFAULT_MAPPING,n=en,i=en,r=Ee,o=un,a=Qe,c=ri,l=s.DEFAULT_ANISOTROPY,u=si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:QM++}),this.uuid=Bn(),this.name="",this.source=new On(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new nt(0,0),this.repeat=new nt(1,1),this.center=new nt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $t,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Rd).x}get height(){return this.source.getSize(Rd).y}get depth(){return this.source.getSize(Rd).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==il)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case An:t.x=t.x-Math.floor(t.x);break;case en:t.x=t.x<0?0:1;break;case Li:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case An:t.y=t.y-Math.floor(t.y);break;case en:t.y=t.y<0?0:1;break;case Li:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Ie.DEFAULT_IMAGE=null;Ie.DEFAULT_MAPPING=il;Ie.DEFAULT_ANISOTROPY=1;var Qt=class s{constructor(t=0,e=0,n=0,i=1){s.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r,c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],p=c[5],x=c[9],v=c[2],y=c[6],_=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+y)<.1&&Math.abs(l+p+_-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let g=(l+1)/2,d=(p+1)/2,M=(_+1)/2,m=(u+f)/4,R=(h+v)/4,E=(x+y)/4;return g>d&&g>M?g<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(g),i=m/n,r=R/n):d>M?d<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(d),n=m/i,r=E/i):M<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(M),n=R/r,i=E/r),this.set(n,i,r,e),this}let S=Math.sqrt((y-x)*(y-x)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(h-v)/S,this.z=(f-u)/S,this.w=Math.acos((l+p+_-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this.w=Xt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this.w=Xt(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}},Mo=class extends kn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ee,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Qt(0,0,t,e),this.scissorTest=!1,this.viewport=new Qt(0,0,t,e);let i={width:t,height:e,depth:n.depth},r=new Ie(i);this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){let e={minFilter:Ee,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new On(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Hn=class extends Mo{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},cs=class extends Ie{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=De,this.minFilter=De,this.wrapR=en,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},rh=class extends Hn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new cs(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},ls=class extends Ie{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=De,this.minFilter=De,this.wrapR=en,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},sh=class extends Hn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new ls(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},ne=class{constructor(t=new I(1/0,1/0,1/0),e=new I(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ui.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ui.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=ui.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,ui):ui.fromBufferAttribute(r,o),ui.applyMatrix4(t.matrixWorld),this.expandByPoint(ui);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),pu.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),pu.copy(n.boundingBox)),pu.applyMatrix4(t.matrixWorld),this.union(pu)}let i=t.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ui),ui.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ia),mu.subVectors(this.max,Ia),$s.subVectors(t.a,Ia),Ks.subVectors(t.b,Ia),Zs.subVectors(t.c,Ia),gr.subVectors(Ks,$s),xr.subVectors(Zs,Ks),Wr.subVectors($s,Zs);let e=[0,-gr.z,gr.y,0,-xr.z,xr.y,0,-Wr.z,Wr.y,gr.z,0,-gr.x,xr.z,0,-xr.x,Wr.z,0,-Wr.x,-gr.y,gr.x,0,-xr.y,xr.x,0,-Wr.y,Wr.x,0];return!Cd(e,$s,Ks,Zs,mu)||(e=[1,0,0,0,1,0,0,0,1],!Cd(e,$s,Ks,Zs,mu))?!1:(gu.crossVectors(gr,xr),e=[gu.x,gu.y,gu.z],Cd(e,$s,Ks,Zs,mu))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ui).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ui).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ji[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ji[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ji[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ji[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ji[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ji[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ji[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ji[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ji),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Ji=[new I,new I,new I,new I,new I,new I,new I,new I],ui=new I,pu=new ne,$s=new I,Ks=new I,Zs=new I,gr=new I,xr=new I,Wr=new I,Ia=new I,mu=new I,gu=new I,Xr=new I;function Cd(s,t,e,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Xr.fromArray(s,r);let a=i.x*Math.abs(Xr.x)+i.y*Math.abs(Xr.y)+i.z*Math.abs(Xr.z),c=t.dot(Xr),l=e.dot(Xr),u=n.dot(Xr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var tS=new ne,Pa=new I,Id=new I,Be=class{constructor(t=new I,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):tS.setFromPoints(t).getCenter(n);let i=0;for(let r=0,o=t.length;r<o;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Pa.subVectors(t,this.center);let e=Pa.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Pa,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Id.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Pa.copy(t.center).add(Id)),this.expandByPoint(Pa.copy(t.center).sub(Id))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},ji=new I,Pd=new I,xu=new I,_r=new I,Ld=new I,_u=new I,Nd=new I,_n=class{constructor(t=new I,e=new I(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ji)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=ji.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ji.copy(this.origin).addScaledVector(this.direction,e),ji.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Pd.copy(t).add(e).multiplyScalar(.5),xu.copy(e).sub(t).normalize(),_r.copy(this.origin).sub(Pd);let r=t.distanceTo(e)*.5,o=-this.direction.dot(xu),a=_r.dot(this.direction),c=-_r.dot(xu),l=_r.lengthSq(),u=Math.abs(1-o*o),h,f,p,x;if(u>0)if(h=o*c-a,f=o*a-c,x=r*u,h>=0)if(f>=-x)if(f<=x){let v=1/u;h*=v,f*=v,p=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f=-r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f<=-x?(h=Math.max(0,-(-o*r+a)),f=h>0?-r:Math.min(Math.max(-r,-c),r),p=-h*h+f*(f+2*c)+l):f<=x?(h=0,f=Math.min(Math.max(-r,-c),r),p=f*(f+2*c)+l):(h=Math.max(0,-(o*r+a)),f=h>0?r:Math.min(Math.max(-r,-c),r),p=-h*h+f*(f+2*c)+l);else f=o>0?-r:r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Pd).addScaledVector(xu,f),p}intersectSphere(t,e){ji.subVectors(t.center,this.origin);let n=ji.dot(this.direction),i=ji.dot(ji)-n*n,r=t.radius*t.radius;if(i>r)return null;let o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,i=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,i=(t.min.x-f.x)*l),u>=0?(r=(t.min.y-f.y)*u,o=(t.max.y-f.y)*u):(r=(t.max.y-f.y)*u,o=(t.min.y-f.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),h>=0?(a=(t.min.z-f.z)*h,c=(t.max.z-f.z)*h):(a=(t.max.z-f.z)*h,c=(t.min.z-f.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,ji)!==null}intersectTriangle(t,e,n,i,r){Ld.subVectors(e,t),_u.subVectors(n,t),Nd.crossVectors(Ld,_u);let o=this.direction.dot(Nd),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;_r.subVectors(this.origin,t);let c=a*this.direction.dot(_u.crossVectors(_r,_u));if(c<0)return null;let l=a*this.direction.dot(Ld.cross(_r));if(l<0||c+l>o)return null;let u=-a*_r.dot(Nd);return u<0?null:this.at(u/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vt=class s{constructor(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y)}set(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y){let _=this.elements;return _[0]=t,_[4]=e,_[8]=n,_[12]=i,_[1]=r,_[5]=o,_[9]=a,_[13]=c,_[2]=l,_[6]=u,_[10]=h,_[14]=f,_[3]=p,_[7]=x,_[11]=v,_[15]=y,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 s().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return 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(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/Js.setFromMatrixColumn(t,0).length(),r=1/Js.setFromMatrixColumn(t,1).length(),o=1/Js.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(t.order==="XYZ"){let f=o*u,p=o*h,x=a*u,v=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=p+x*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=x+p*l,e[10]=o*c}else if(t.order==="YXZ"){let f=c*u,p=c*h,x=l*u,v=l*h;e[0]=f+v*a,e[4]=x*a-p,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=p*a-x,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){let f=c*u,p=c*h,x=l*u,v=l*h;e[0]=f-v*a,e[4]=-o*h,e[8]=x+p*a,e[1]=p+x*a,e[5]=o*u,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){let f=o*u,p=o*h,x=a*u,v=a*h;e[0]=c*u,e[4]=x*l-p,e[8]=f*l+v,e[1]=c*h,e[5]=v*l+f,e[9]=p*l-x,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){let f=o*c,p=o*l,x=a*c,v=a*l;e[0]=c*u,e[4]=v-f*h,e[8]=x*h+p,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=p*h+x,e[10]=f-v*h}else if(t.order==="XZY"){let f=o*c,p=o*l,x=a*c,v=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+v,e[5]=o*u,e[9]=p*h-x,e[2]=x*h-p,e[6]=a*u,e[10]=v*h+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(eS,t,nS)}lookAt(t,e,n){let i=this.elements;return Un.subVectors(t,e),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),yr.crossVectors(n,Un),yr.lengthSq()===0&&(Math.abs(n.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),yr.crossVectors(n,Un)),yr.normalize(),yu.crossVectors(Un,yr),i[0]=yr.x,i[4]=yu.x,i[8]=Un.x,i[1]=yr.y,i[5]=yu.y,i[9]=Un.y,i[2]=yr.z,i[6]=yu.z,i[10]=Un.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],p=n[13],x=n[2],v=n[6],y=n[10],_=n[14],S=n[3],g=n[7],d=n[11],M=n[15],m=i[0],R=i[4],E=i[8],T=i[12],b=i[1],w=i[5],A=i[9],C=i[13],D=i[2],F=i[6],O=i[10],H=i[14],B=i[3],$=i[7],at=i[11],rt=i[15];return r[0]=o*m+a*b+c*D+l*B,r[4]=o*R+a*w+c*F+l*$,r[8]=o*E+a*A+c*O+l*at,r[12]=o*T+a*C+c*H+l*rt,r[1]=u*m+h*b+f*D+p*B,r[5]=u*R+h*w+f*F+p*$,r[9]=u*E+h*A+f*O+p*at,r[13]=u*T+h*C+f*H+p*rt,r[2]=x*m+v*b+y*D+_*B,r[6]=x*R+v*w+y*F+_*$,r[10]=x*E+v*A+y*O+_*at,r[14]=x*T+v*C+y*H+_*rt,r[3]=S*m+g*b+d*D+M*B,r[7]=S*R+g*w+d*F+M*$,r[11]=S*E+g*A+d*O+M*at,r[15]=S*T+g*C+d*H+M*rt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],p=t[14],x=t[3],v=t[7],y=t[11],_=t[15];return x*(+r*c*h-i*l*h-r*a*f+n*l*f+i*a*p-n*c*p)+v*(+e*c*p-e*l*f+r*o*f-i*o*p+i*l*u-r*c*u)+y*(+e*l*h-e*a*p-r*o*h+n*o*p+r*a*u-n*l*u)+_*(-i*a*u-e*c*h+e*a*f+i*o*h-n*o*f+n*c*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],p=t[11],x=t[12],v=t[13],y=t[14],_=t[15],S=h*y*l-v*f*l+v*c*p-a*y*p-h*c*_+a*f*_,g=x*f*l-u*y*l-x*c*p+o*y*p+u*c*_-o*f*_,d=u*v*l-x*h*l+x*a*p-o*v*p-u*a*_+o*h*_,M=x*h*c-u*v*c-x*a*f+o*v*f+u*a*y-o*h*y,m=e*S+n*g+i*d+r*M;if(m===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/m;return t[0]=S*R,t[1]=(v*f*r-h*y*r-v*i*p+n*y*p+h*i*_-n*f*_)*R,t[2]=(a*y*r-v*c*r+v*i*l-n*y*l-a*i*_+n*c*_)*R,t[3]=(h*c*r-a*f*r-h*i*l+n*f*l+a*i*p-n*c*p)*R,t[4]=g*R,t[5]=(u*y*r-x*f*r+x*i*p-e*y*p-u*i*_+e*f*_)*R,t[6]=(x*c*r-o*y*r-x*i*l+e*y*l+o*i*_-e*c*_)*R,t[7]=(o*f*r-u*c*r+u*i*l-e*f*l-o*i*p+e*c*p)*R,t[8]=d*R,t[9]=(x*h*r-u*v*r-x*n*p+e*v*p+u*n*_-e*h*_)*R,t[10]=(o*v*r-x*a*r+x*n*l-e*v*l-o*n*_+e*a*_)*R,t[11]=(u*a*r-o*h*r-u*n*l+e*h*l+o*n*p-e*a*p)*R,t[12]=M*R,t[13]=(u*v*i-x*h*i+x*n*f-e*v*f-u*n*y+e*h*y)*R,t[14]=(x*a*i-o*v*i-x*n*c+e*v*c+o*n*y-e*a*y)*R,t[15]=(o*h*i-u*a*i+u*n*c-e*h*c-o*n*f+e*a*f)*R,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,o=t.x,a=t.y,c=t.z,l=r*o,u=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,o){return this.set(1,n,r,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,o=e._y,a=e._z,c=e._w,l=r+r,u=o+o,h=a+a,f=r*l,p=r*u,x=r*h,v=o*u,y=o*h,_=a*h,S=c*l,g=c*u,d=c*h,M=n.x,m=n.y,R=n.z;return i[0]=(1-(v+_))*M,i[1]=(p+d)*M,i[2]=(x-g)*M,i[3]=0,i[4]=(p-d)*m,i[5]=(1-(f+_))*m,i[6]=(y+S)*m,i[7]=0,i[8]=(x+g)*R,i[9]=(y-S)*R,i[10]=(1-(f+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=Js.set(i[0],i[1],i[2]).length(),o=Js.set(i[4],i[5],i[6]).length(),a=Js.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],hi.copy(this);let l=1/r,u=1/o,h=1/a;return hi.elements[0]*=l,hi.elements[1]*=l,hi.elements[2]*=l,hi.elements[4]*=u,hi.elements[5]*=u,hi.elements[6]*=u,hi.elements[8]*=h,hi.elements[9]*=h,hi.elements[10]*=h,e.setFromRotationMatrix(hi),n.x=r,n.y=o,n.z=a,this}makePerspective(t,e,n,i,r,o,a=wn,c=!1){let l=this.elements,u=2*r/(e-t),h=2*r/(n-i),f=(e+t)/(e-t),p=(n+i)/(n-i),x,v;if(c)x=r/(o-r),v=o*r/(o-r);else if(a===wn)x=-(o+r)/(o-r),v=-2*o*r/(o-r);else if(a===ss)x=-o/(o-r),v=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=x,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,o,a=wn,c=!1){let l=this.elements,u=2/(e-t),h=2/(n-i),f=-(e+t)/(e-t),p=-(n+i)/(n-i),x,v;if(c)x=1/(o-r),v=o/(o-r);else if(a===wn)x=-2/(o-r),v=-(o+r)/(o-r);else if(a===ss)x=-1/(o-r),v=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=f,l[1]=0,l[5]=h,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=x,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Js=new I,hi=new vt,eS=new I(0,0,0),nS=new I(1,1,1),yr=new I,yu=new I,Un=new I,Hx=new vt,Vx=new Ce,Rn=class s{constructor(t=0,e=0,n=0,i=s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(Xt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Xt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Xt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Xt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Hx.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Hx,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Vx.setFromEuler(this),this.setFromQuaternion(Vx,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Rn.DEFAULT_ORDER="XYZ";var us=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},iS=0,Gx=new I,js=new Ce,Qi=new vt,vu=new I,La=new I,rS=new I,sS=new Ce,Wx=new I(1,0,0),Xx=new I(0,1,0),qx=new I(0,0,1),Yx={type:"added"},oS={type:"removed"},Qs={type:"childadded",child:null},Dd={type:"childremoved",child:null},re=class s extends kn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:iS++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=s.DEFAULT_UP.clone();let t=new I,e=new Rn,n=new Ce,i=new I(1,1,1);function r(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vt},normalMatrix:{value:new $t}}),this.matrix=new vt,this.matrixWorld=new vt,this.matrixAutoUpdate=s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new us,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return js.setFromAxisAngle(t,e),this.quaternion.multiply(js),this}rotateOnWorldAxis(t,e){return js.setFromAxisAngle(t,e),this.quaternion.premultiply(js),this}rotateX(t){return this.rotateOnAxis(Wx,t)}rotateY(t){return this.rotateOnAxis(Xx,t)}rotateZ(t){return this.rotateOnAxis(qx,t)}translateOnAxis(t,e){return Gx.copy(t).applyQuaternion(this.quaternion),this.position.add(Gx.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Wx,t)}translateY(t){return this.translateOnAxis(Xx,t)}translateZ(t){return this.translateOnAxis(qx,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Qi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?vu.copy(t):vu.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),La.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Qi.lookAt(La,vu,this.up):Qi.lookAt(vu,La,this.up),this.quaternion.setFromRotationMatrix(Qi),i&&(Qi.extractRotation(i.matrixWorld),js.setFromRotationMatrix(Qi),this.quaternion.premultiply(js.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Yx),Qs.child=t,this.dispatchEvent(Qs),Qs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(oS),Dd.child=t,this.dispatchEvent(Dd),Dd.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Qi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Qi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Qi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Yx),Qs.child=t,this.dispatchEvent(Qs),Qs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,t,rS),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,sS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let h=c[l];r(t.shapes,h)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(t.materials,this.material[c]));i.material=a}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];i.animations.push(r(t.animations,c))}}if(e){let a=o(t.geometries),c=o(t.materials),l=o(t.textures),u=o(t.images),h=o(t.shapes),f=o(t.skeletons),p=o(t.animations),x=o(t.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),x.length>0&&(n.nodes=x)}return n.object=i,n;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};re.DEFAULT_UP=new I(0,1,0);re.DEFAULT_MATRIX_AUTO_UPDATE=!0;re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var fi=new I,tr=new I,Ud=new I,er=new I,to=new I,eo=new I,$x=new I,Fd=new I,Od=new I,Bd=new I,zd=new Qt,kd=new Qt,Hd=new Qt,me=class s{constructor(t=new I,e=new I,n=new I){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),fi.subVectors(t,e),i.cross(fi);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){fi.subVectors(i,e),tr.subVectors(n,e),Ud.subVectors(t,e);let o=fi.dot(fi),a=fi.dot(tr),c=fi.dot(Ud),l=tr.dot(tr),u=tr.dot(Ud),h=o*l-a*a;if(h===0)return r.set(0,0,0),null;let f=1/h,p=(l*c-a*u)*f,x=(o*u-a*c)*f;return r.set(1-p-x,x,p)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,er)===null?!1:er.x>=0&&er.y>=0&&er.x+er.y<=1}static getInterpolation(t,e,n,i,r,o,a,c){return this.getBarycoord(t,e,n,i,er)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,er.x),c.addScaledVector(o,er.y),c.addScaledVector(a,er.z),c)}static getInterpolatedAttribute(t,e,n,i,r,o){return zd.setScalar(0),kd.setScalar(0),Hd.setScalar(0),zd.fromBufferAttribute(t,e),kd.fromBufferAttribute(t,n),Hd.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(zd,r.x),o.addScaledVector(kd,r.y),o.addScaledVector(Hd,r.z),o}static isFrontFacing(t,e,n,i){return fi.subVectors(n,e),tr.subVectors(t,e),fi.cross(tr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return fi.subVectors(this.c,this.b),tr.subVectors(this.a,this.b),fi.cross(tr).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return s.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,o,a;to.subVectors(i,n),eo.subVectors(r,n),Fd.subVectors(t,n);let c=to.dot(Fd),l=eo.dot(Fd);if(c<=0&&l<=0)return e.copy(n);Od.subVectors(t,i);let u=to.dot(Od),h=eo.dot(Od);if(u>=0&&h<=u)return e.copy(i);let f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(n).addScaledVector(to,o);Bd.subVectors(t,r);let p=to.dot(Bd),x=eo.dot(Bd);if(x>=0&&p<=x)return e.copy(r);let v=p*l-c*x;if(v<=0&&l>=0&&x<=0)return a=l/(l-x),e.copy(n).addScaledVector(eo,a);let y=u*x-p*h;if(y<=0&&h-u>=0&&p-x>=0)return $x.subVectors(r,i),a=(h-u)/(h-u+(p-x)),e.copy(i).addScaledVector($x,a);let _=1/(y+v+f);return o=v*_,a=f*_,e.copy(n).addScaledVector(to,o).addScaledVector(eo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},A0={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},vr={h:0,s:0,l:0},Mu={h:0,s:0,l:0};function Vd(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}var yt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ae){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ie.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=ie.workingColorSpace){return this.r=t,this.g=e,this.b=n,ie.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=ie.workingColorSpace){if(t=hm(t,1),e=Xt(e,0,1),n=Xt(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=Vd(o,r,t+1/3),this.g=Vd(o,r,t),this.b=Vd(o,r,t-1/3)}return ie.colorSpaceToWorking(this,i),this}setStyle(t,e=Ae){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ae){let n=A0[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=rr(t.r),this.g=rr(t.g),this.b=rr(t.b),this}copyLinearToSRGB(t){return this.r=mo(t.r),this.g=mo(t.g),this.b=mo(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ae){return ie.workingToColorSpace(an.copy(this),t),Math.round(Xt(an.r*255,0,255))*65536+Math.round(Xt(an.g*255,0,255))*256+Math.round(Xt(an.b*255,0,255))}getHexString(t=Ae){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ie.workingColorSpace){ie.workingToColorSpace(an.copy(this),e);let n=an.r,i=an.g,r=an.b,o=Math.max(n,i,r),a=Math.min(n,i,r),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-r)/h+(i<r?6:0);break;case i:c=(r-n)/h+2;break;case r:c=(n-i)/h+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=ie.workingColorSpace){return ie.workingToColorSpace(an.copy(this),e),t.r=an.r,t.g=an.g,t.b=an.b,t}getStyle(t=Ae){ie.workingToColorSpace(an.copy(this),t);let e=an.r,n=an.g,i=an.b;return t!==Ae?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(vr),this.setHSL(vr.h+t,vr.s+e,vr.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(vr),t.getHSL(Mu);let n=Xa(vr.h,Mu.h,e),i=Xa(vr.s,Mu.s,e),r=Xa(vr.l,Mu.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},an=new yt;yt.NAMES=A0;var aS=0,Ue=class extends kn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:aS++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=wr,this.side=rn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=$a,this.blendDst=Ka,this.blendEquation=sr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new yt(0,0,0),this.blendAlpha=0,this.depthFunc=Ar,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ih,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=br,this.stencilZFail=br,this.stencilZPass=br,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==wr&&(n.blending=this.blending),this.side!==rn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==$a&&(n.blendSrc=this.blendSrc),this.blendDst!==Ka&&(n.blendDst=this.blendDst),this.blendEquation!==sr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ar&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ih&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==br&&(n.stencilFail=this.stencilFail),this.stencilZFail!==br&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==br&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(e){let r=i(t.textures),o=i(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},sn=class extends Ue{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yt(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.envMapRotation=new Rn,this.combine=qo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},ir=cS();function cS(){let s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}let r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;!(l&8388608);)l<<=1,u-=8388608;l&=-8388609,u+=947912704,r[c]=l|u}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function En(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=Xt(s,-65504,65504),ir.floatView[0]=s;let t=ir.uint32View[0],e=t>>23&511;return ir.baseTable[e]+((t&8388607)>>ir.shiftTable[e])}function Va(s){let t=s>>10;return ir.uint32View[0]=ir.mantissaTable[ir.offsetTable[t]+(s&1023)]+ir.exponentTable[t],ir.floatView[0]}var oh=class{static toHalfFloat(t){return En(t)}static fromHalfFloat(t){return Va(t)}},We=new I,Su=new nt,lS=0,kt=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=_o,this.updateRanges=[],this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Su.fromBufferAttribute(this,e),Su.applyMatrix3(t),this.setXY(e,Su.x,Su.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyMatrix3(t),this.setXYZ(e,We.x,We.y,We.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyMatrix4(t),this.setXYZ(e,We.x,We.y,We.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyNormalMatrix(t),this.setXYZ(e,We.x,We.y,We.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.transformDirection(t),this.setXYZ(e,We.x,We.y,We.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=gn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Jt(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=gn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=gn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=gn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=gn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==_o&&(t.usage=this.usage),t}},ah=class extends kt{constructor(t,e,n){super(new Int8Array(t),e,n)}},ch=class extends kt{constructor(t,e,n){super(new Uint8Array(t),e,n)}},lh=class extends kt{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}},uh=class extends kt{constructor(t,e,n){super(new Int16Array(t),e,n)}},So=class extends kt{constructor(t,e,n){super(new Uint16Array(t),e,n)}},hh=class extends kt{constructor(t,e,n){super(new Int32Array(t),e,n)}},bo=class extends kt{constructor(t,e,n){super(new Uint32Array(t),e,n)}},fh=class extends kt{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=Va(this.array[t*this.itemSize]);return this.normalized&&(e=gn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize]=En(e),this}getY(t){let e=Va(this.array[t*this.itemSize+1]);return this.normalized&&(e=gn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+1]=En(e),this}getZ(t){let e=Va(this.array[t*this.itemSize+2]);return this.normalized&&(e=gn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+2]=En(e),this}getW(t){let e=Va(this.array[t*this.itemSize+3]);return this.normalized&&(e=gn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+3]=En(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this.array[t+2]=En(i),this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this.array[t+2]=En(i),this.array[t+3]=En(r),this}},Lt=class extends kt{constructor(t,e,n){super(new Float32Array(t),e,n)}},uS=0,jn=new vt,Gd=new re,no=new I,Fn=new ne,Na=new ne,je=new I,Vt=class s extends kn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:uS++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(t){return Array.isArray(t)?this.index=new(fm(t)?bo:So)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new $t().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return jn.makeRotationFromQuaternion(t),this.applyMatrix4(jn),this}rotateX(t){return jn.makeRotationX(t),this.applyMatrix4(jn),this}rotateY(t){return jn.makeRotationY(t),this.applyMatrix4(jn),this}rotateZ(t){return jn.makeRotationZ(t),this.applyMatrix4(jn),this}translate(t,e,n){return jn.makeTranslation(t,e,n),this.applyMatrix4(jn),this}scale(t,e,n){return jn.makeScale(t,e,n),this.applyMatrix4(jn),this}lookAt(t){return Gd.lookAt(t),Gd.updateMatrix(),this.applyMatrix4(Gd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(no).negate(),this.translate(no.x,no.y,no.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,r=t.length;i<r;i++){let o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Lt(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ne);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let r=e[n];Fn.setFromBufferAttribute(r),this.morphTargetsRelative?(je.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(je),je.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(je)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.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(){this.boundingSphere===null&&(this.boundingSphere=new Be);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new I,1/0);return}if(t){let n=this.boundingSphere.center;if(Fn.setFromBufferAttribute(t),e)for(let r=0,o=e.length;r<o;r++){let a=e[r];Na.setFromBufferAttribute(a),this.morphTargetsRelative?(je.addVectors(Fn.min,Na.min),Fn.expandByPoint(je),je.addVectors(Fn.max,Na.max),Fn.expandByPoint(je)):(Fn.expandByPoint(Na.min),Fn.expandByPoint(Na.max))}Fn.getCenter(n);let i=0;for(let r=0,o=t.count;r<o;r++)je.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(je));if(e)for(let r=0,o=e.length;r<o;r++){let a=e[r],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)je.fromBufferAttribute(a,l),c&&(no.fromBufferAttribute(t,l),je.add(no)),i=Math.max(i,n.distanceToSquared(je))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new kt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let E=0;E<n.count;E++)a[E]=new I,c[E]=new I;let l=new I,u=new I,h=new I,f=new nt,p=new nt,x=new nt,v=new I,y=new I;function _(E,T,b){l.fromBufferAttribute(n,E),u.fromBufferAttribute(n,T),h.fromBufferAttribute(n,b),f.fromBufferAttribute(r,E),p.fromBufferAttribute(r,T),x.fromBufferAttribute(r,b),u.sub(l),h.sub(l),p.sub(f),x.sub(f);let w=1/(p.x*x.y-x.x*p.y);isFinite(w)&&(v.copy(u).multiplyScalar(x.y).addScaledVector(h,-p.y).multiplyScalar(w),y.copy(h).multiplyScalar(p.x).addScaledVector(u,-x.x).multiplyScalar(w),a[E].add(v),a[T].add(v),a[b].add(v),c[E].add(y),c[T].add(y),c[b].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let E=0,T=S.length;E<T;++E){let b=S[E],w=b.start,A=b.count;for(let C=w,D=w+A;C<D;C+=3)_(t.getX(C+0),t.getX(C+1),t.getX(C+2))}let g=new I,d=new I,M=new I,m=new I;function R(E){M.fromBufferAttribute(i,E),m.copy(M);let T=a[E];g.copy(T),g.sub(M.multiplyScalar(M.dot(T))).normalize(),d.crossVectors(m,T);let w=d.dot(c[E])<0?-1:1;o.setXYZW(E,g.x,g.y,g.z,w)}for(let E=0,T=S.length;E<T;++E){let b=S[E],w=b.start,A=b.count;for(let C=w,D=w+A;C<D;C+=3)R(t.getX(C+0)),R(t.getX(C+1)),R(t.getX(C+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new kt(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let i=new I,r=new I,o=new I,a=new I,c=new I,l=new I,u=new I,h=new I;if(t)for(let f=0,p=t.count;f<p;f+=3){let x=t.getX(f+0),v=t.getX(f+1),y=t.getX(f+2);i.fromBufferAttribute(e,x),r.fromBufferAttribute(e,v),o.fromBufferAttribute(e,y),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),a.fromBufferAttribute(n,x),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,y),a.add(u),c.add(u),l.add(u),n.setXYZ(x,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(y,l.x,l.y,l.z)}else for(let f=0,p=e.count;f<p;f+=3)i.fromBufferAttribute(e,f+0),r.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)je.fromBufferAttribute(t,e),je.normalize(),t.setXYZ(e,je.x,je.y,je.z)}toNonIndexed(){function t(a,c){let l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u),p=0,x=0;for(let v=0,y=c.length;v<y;v++){a.isInterleavedBufferAttribute?p=c[v]*a.data.stride+a.offset:p=c[v]*u;for(let _=0;_<u;_++)f[x++]=l[p++]}return new kt(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new s,n=this.index.array,i=this.attributes;for(let a in i){let c=i[a],l=t(c,n);e.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let u=0,h=l.length;u<h;u++){let f=l[u],p=t(f,n);c.push(p)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){let p=l[h];u.push(p.toJSON(t.data))}u.length>0&&(i[c]=u,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let i=t.attributes;for(let l in i){let u=i[l];this.setAttribute(l,u.clone(e))}let r=t.morphAttributes;for(let l in r){let u=[],h=r[l];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let l=0,u=o.length;l<u;l++){let h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Kx=new vt,qr=new _n,bu=new Be,Zx=new I,Tu=new I,Eu=new I,wu=new I,Wd=new I,Au=new I,Jx=new I,Ru=new I,ce=class extends re{constructor(t=new Vt,e=new sn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(r&&a){Au.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let u=a[c],h=r[c];u!==0&&(Wd.fromBufferAttribute(h,t),o?Au.addScaledVector(Wd,u):Au.addScaledVector(Wd.sub(e),u))}e.add(Au)}return e}raycast(t,e){let n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),bu.copy(n.boundingSphere),bu.applyMatrix4(r),qr.copy(t.ray).recast(t.near),!(bu.containsPoint(qr.origin)===!1&&(qr.intersectSphere(bu,Zx)===null||qr.origin.distanceToSquared(Zx)>(t.far-t.near)**2))&&(Kx.copy(r).invert(),qr.copy(t.ray).applyMatrix4(Kx),!(n.boundingBox!==null&&qr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,qr)))}_computeIntersections(t,e,n){let i,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,f=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){let y=f[x],_=o[y.materialIndex],S=Math.max(y.start,p.start),g=Math.min(a.count,Math.min(y.start+y.count,p.start+p.count));for(let d=S,M=g;d<M;d+=3){let m=a.getX(d),R=a.getX(d+1),E=a.getX(d+2);i=Cu(this,_,t,n,l,u,h,m,R,E),i&&(i.faceIndex=Math.floor(d/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{let x=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let y=x,_=v;y<_;y+=3){let S=a.getX(y),g=a.getX(y+1),d=a.getX(y+2);i=Cu(this,o,t,n,l,u,h,S,g,d),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){let y=f[x],_=o[y.materialIndex],S=Math.max(y.start,p.start),g=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let d=S,M=g;d<M;d+=3){let m=d,R=d+1,E=d+2;i=Cu(this,_,t,n,l,u,h,m,R,E),i&&(i.faceIndex=Math.floor(d/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{let x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,_=v;y<_;y+=3){let S=y,g=y+1,d=y+2;i=Cu(this,o,t,n,l,u,h,S,g,d),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}}};function hS(s,t,e,n,i,r,o,a){let c;if(t.side===qe?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,t.side===rn,a),c===null)return null;Ru.copy(a),Ru.applyMatrix4(s.matrixWorld);let l=e.ray.origin.distanceTo(Ru);return l<e.near||l>e.far?null:{distance:l,point:Ru.clone(),object:s}}function Cu(s,t,e,n,i,r,o,a,c,l){s.getVertexPosition(a,Tu),s.getVertexPosition(c,Eu),s.getVertexPosition(l,wu);let u=hS(s,t,e,n,Tu,Eu,wu,Jx);if(u){let h=new I;me.getBarycoord(Jx,Tu,Eu,wu,h),i&&(u.uv=me.getInterpolatedAttribute(i,a,c,l,h,new nt)),r&&(u.uv1=me.getInterpolatedAttribute(r,a,c,l,h,new nt)),o&&(u.normal=me.getInterpolatedAttribute(o,a,c,l,h,new I),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:c,c:l,normal:new I,materialIndex:0};me.getNormal(Tu,Eu,wu,f.normal),u.face=f,u.barycoord=h}return u}var Ui=class s extends Vt{constructor(t=1,e=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};let a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],u=[],h=[],f=0,p=0;x("z","y","x",-1,-1,n,e,t,o,r,0),x("z","y","x",1,-1,n,e,-t,o,r,1),x("x","z","y",1,1,t,n,e,i,o,2),x("x","z","y",1,-1,t,n,-e,i,o,3),x("x","y","z",1,-1,t,e,n,i,r,4),x("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Lt(l,3)),this.setAttribute("normal",new Lt(u,3)),this.setAttribute("uv",new Lt(h,2));function x(v,y,_,S,g,d,M,m,R,E,T){let b=d/R,w=M/E,A=d/2,C=M/2,D=m/2,F=R+1,O=E+1,H=0,B=0,$=new I;for(let at=0;at<O;at++){let rt=at*w-C;for(let ht=0;ht<F;ht++){let bt=ht*b-A;$[v]=bt*S,$[y]=rt*g,$[_]=D,l.push($.x,$.y,$.z),$[v]=0,$[y]=0,$[_]=m>0?1:-1,u.push($.x,$.y,$.z),h.push(ht/R),h.push(1-at/E),H+=1}}for(let at=0;at<E;at++)for(let rt=0;rt<R;rt++){let ht=f+rt+F*at,bt=f+rt+F*(at+1),Et=f+(rt+1)+F*(at+1),Mt=f+(rt+1)+F*at;c.push(ht,bt,Mt),c.push(bt,Et,Mt),B+=6}a.addGroup(p,B,T),p+=B,f+=H}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function Is(s){let t={};for(let e in s){t[e]={};for(let n in s[e]){let i=s[e][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[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function hn(s){let t={};for(let e=0;e<s.length;e++){let n=Is(s[e]);for(let i in n)t[i]=n[i]}return t}function fS(s){let t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function pm(s){let t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ie.workingColorSpace}var mm={clone:Is,merge:hn},dS=`void main() {
|
|
1
|
+
"use strict";(()=>{var LM=Object.defineProperty;var NM=(s,t)=>{for(var e in t)LM(s,e,{get:t[e],enumerable:!0})};var Vl={};NM(Vl,{ACESFilmicToneMapping:()=>$p,AddEquation:()=>sr,AddOperation:()=>Wp,AdditiveAnimationBlendMode:()=>_f,AdditiveBlending:()=>cf,AgXToneMapping:()=>Zp,AlphaFormat:()=>mf,AlwaysCompare:()=>hm,AlwaysDepth:()=>Jc,AlwaysStencilFunc:()=>ih,AmbientLight:()=>zc,AnimationAction:()=>Kc,AnimationClip:()=>ni,AnimationLoader:()=>Mh,AnimationMixer:()=>Xo,AnimationObjectGroup:()=>Ph,AnimationUtils:()=>vh,ArcCurve:()=>lc,ArrayCamera:()=>qc,ArrowHelper:()=>tf,AttachedBindMode:()=>nh,Audio:()=>Yc,AudioAnalyser:()=>Ih,AudioContext:()=>Wo,AudioListener:()=>Rh,AudioLoader:()=>wh,AxesHelper:()=>ef,BackSide:()=>qe,BasicDepthPacking:()=>nm,BasicShadowMap:()=>q_,BatchedMesh:()=>ic,Bone:()=>Cr,BooleanKeyframeTrack:()=>zi,Box2:()=>Vh,Box3:()=>ne,Box3Helper:()=>jh,BoxGeometry:()=>Ui,BoxHelper:()=>Jh,BufferAttribute:()=>kt,BufferGeometry:()=>Vt,BufferGeometryLoader:()=>Xc,ByteType:()=>hf,Cache:()=>di,Camera:()=>hs,CameraHelper:()=>Zh,CanvasTexture:()=>Eo,CapsuleGeometry:()=>sc,CatmullRomCurve3:()=>uc,CineonToneMapping:()=>Yp,CircleGeometry:()=>oc,ClampToEdgeWrapping:()=>en,Clock:()=>bs,Color:()=>yt,ColorKeyframeTrack:()=>Ho,ColorManagement:()=>ie,CompressedArrayTexture:()=>xh,CompressedCubeTexture:()=>_h,CompressedTexture:()=>gi,CompressedTextureLoader:()=>Sh,ConeGeometry:()=>Co,ConstantAlphaFactor:()=>Hp,ConstantColorFactor:()=>zp,Controls:()=>rf,CubeCamera:()=>Za,CubeReflectionMapping:()=>Wi,CubeRefractionMapping:()=>ur,CubeTexture:()=>Rr,CubeTextureLoader:()=>bh,CubeUVReflectionMapping:()=>Ts,CubicBezierCurve:()=>Io,CubicBezierCurve3:()=>hc,CubicInterpolant:()=>Uc,CullFaceBack:()=>of,CullFaceFront:()=>bp,CullFaceFrontBack:()=>X_,CullFaceNone:()=>Sp,Curve:()=>In,CurvePath:()=>dc,CustomBlending:()=>Ep,CustomToneMapping:()=>Kp,CylinderGeometry:()=>Ro,Cylindrical:()=>kh,Data3DTexture:()=>ls,DataArrayTexture:()=>cs,DataTexture:()=>zn,DataTextureLoader:()=>Th,DataUtils:()=>oh,DecrementStencilOp:()=>i0,DecrementWrapStencilOp:()=>s0,DefaultLoadingManager:()=>ym,DepthFormat:()=>rs,DepthStencilFormat:()=>Rs,DepthTexture:()=>wo,DetachedBindMode:()=>jp,DirectionalLight:()=>lr,DirectionalLightHelper:()=>Kh,DiscreteInterpolant:()=>Fc,DodecahedronGeometry:()=>ac,DoubleSide:()=>Ve,DstAlphaFactor:()=>Dp,DstColorFactor:()=>Fp,DynamicCopyUsage:()=>v0,DynamicDrawUsage:()=>p0,DynamicReadUsage:()=>x0,EdgesGeometry:()=>cc,EllipseCurve:()=>gs,EqualCompare:()=>am,EqualDepth:()=>Qc,EqualStencilFunc:()=>l0,EquirectangularReflectionMapping:()=>Yo,EquirectangularRefractionMapping:()=>$o,Euler:()=>Rn,EventDispatcher:()=>kn,ExternalTexture:()=>Ao,ExtrudeGeometry:()=>xc,FileLoader:()=>Mn,Float16BufferAttribute:()=>fh,Float32BufferAttribute:()=>Lt,FloatType:()=>xn,Fog:()=>Qa,FogExp2:()=>ja,FramebufferTexture:()=>gh,FrontSide:()=>rn,Frustum:()=>or,FrustumArray:()=>nc,GLBufferAttribute:()=>Fh,GLSL1:()=>S0,GLSL3:()=>Mf,GreaterCompare:()=>cm,GreaterDepth:()=>el,GreaterEqualCompare:()=>um,GreaterEqualDepth:()=>tl,GreaterEqualStencilFunc:()=>d0,GreaterStencilFunc:()=>h0,GridHelper:()=>Yh,Group:()=>nn,HalfFloatType:()=>ws,HemisphereLight:()=>vs,HemisphereLightHelper:()=>qh,IcosahedronGeometry:()=>_c,ImageBitmapLoader:()=>Go,ImageLoader:()=>Lr,ImageUtils:()=>as,IncrementStencilOp:()=>n0,IncrementWrapStencilOp:()=>r0,InstancedBufferAttribute:()=>ti,InstancedBufferGeometry:()=>Wc,InstancedInterleavedBuffer:()=>Uh,InstancedMesh:()=>ei,Int16BufferAttribute:()=>uh,Int32BufferAttribute:()=>hh,Int8BufferAttribute:()=>ah,IntType:()=>rl,InterleavedBuffer:()=>Oi,InterleavedBufferAttribute:()=>pi,Interpolant:()=>Bi,InterpolateDiscrete:()=>Ni,InterpolateLinear:()=>Di,InterpolateSmooth:()=>Wa,InterpolationSamplingMode:()=>E0,InterpolationSamplingType:()=>T0,InvertStencilOp:()=>o0,KeepStencilOp:()=>br,KeyframeTrack:()=>vn,LOD:()=>ec,LatheGeometry:()=>yc,Layers:()=>us,LessCompare:()=>om,LessDepth:()=>jc,LessEqualCompare:()=>vf,LessEqualDepth:()=>Ar,LessEqualStencilFunc:()=>u0,LessStencilFunc:()=>c0,Light:()=>yi,LightProbe:()=>Vc,Line:()=>Vn,Line3:()=>_e,LineBasicMaterial:()=>Xe,LineCurve:()=>Po,LineCurve3:()=>fc,LineDashedMaterial:()=>Dc,LineLoop:()=>ps,LineSegments:()=>yn,LinearFilter:()=>Ee,LinearInterpolant:()=>ko,LinearMipMapLinearFilter:()=>Z_,LinearMipMapNearestFilter:()=>K_,LinearMipmapLinearFilter:()=>un,LinearMipmapNearestFilter:()=>Xi,LinearSRGBColorSpace:()=>tn,LinearToneMapping:()=>Xp,LinearTransfer:()=>xo,Loader:()=>Ke,LoaderUtils:()=>ii,LoadingManager:()=>Pr,LoopOnce:()=>Qp,LoopPingPong:()=>em,LoopRepeat:()=>tm,MOUSE:()=>G_,Material:()=>Ue,MaterialLoader:()=>Gc,MathUtils:()=>Yi,Matrix2:()=>Hh,Matrix3:()=>$t,Matrix4:()=>vt,MaxEquation:()=>Cp,Mesh:()=>ce,MeshBasicMaterial:()=>sn,MeshDepthMaterial:()=>Bo,MeshDistanceMaterial:()=>zo,MeshLambertMaterial:()=>Lc,MeshMatcapMaterial:()=>Nc,MeshNormalMaterial:()=>Pc,MeshPhongMaterial:()=>Cc,MeshPhysicalMaterial:()=>ln,MeshStandardMaterial:()=>xi,MeshToonMaterial:()=>Ic,MinEquation:()=>Rp,MirroredRepeatWrapping:()=>Li,MixOperation:()=>Gp,MultiplyBlending:()=>uf,MultiplyOperation:()=>qo,NearestFilter:()=>De,NearestMipMapLinearFilter:()=>$_,NearestMipMapNearestFilter:()=>Y_,NearestMipmapLinearFilter:()=>Mi,NearestMipmapNearestFilter:()=>Nr,NeutralToneMapping:()=>Jp,NeverCompare:()=>sm,NeverDepth:()=>Zc,NeverStencilFunc:()=>a0,NoBlending:()=>Vi,NoColorSpace:()=>si,NoToneMapping:()=>Gi,NormalAnimationBlendMode:()=>Bl,NormalBlending:()=>wr,NotEqualCompare:()=>lm,NotEqualDepth:()=>nl,NotEqualStencilFunc:()=>f0,NumberKeyframeTrack:()=>_i,Object3D:()=>re,ObjectLoader:()=>Eh,ObjectSpaceNormalMap:()=>rm,OctahedronGeometry:()=>Fo,OneFactor:()=>Pp,OneMinusConstantAlphaFactor:()=>Vp,OneMinusConstantColorFactor:()=>kp,OneMinusDstAlphaFactor:()=>Up,OneMinusDstColorFactor:()=>Op,OneMinusSrcAlphaFactor:()=>Ka,OneMinusSrcColorFactor:()=>Np,OrthographicCamera:()=>cr,PCFShadowMap:()=>af,PCFSoftShadowMap:()=>Tp,PMREMGenerator:()=>kl,Path:()=>xs,PerspectiveCamera:()=>Re,Plane:()=>$e,PlaneGeometry:()=>ys,PlaneHelper:()=>Qh,PointLight:()=>Ss,PointLightHelper:()=>Xh,Points:()=>ms,PointsMaterial:()=>Ir,PolarGridHelper:()=>$h,PolyhedronGeometry:()=>ar,PositionalAudio:()=>Ch,PropertyBinding:()=>ee,PropertyMixer:()=>$c,QuadraticBezierCurve:()=>Lo,QuadraticBezierCurve3:()=>No,Quaternion:()=>Ce,QuaternionKeyframeTrack:()=>Gn,QuaternionLinearInterpolant:()=>Oc,RED_GREEN_RGTC2_Format:()=>Fl,RED_RGTC1_Format:()=>Dl,REVISION:()=>Hi,RGBADepthPacking:()=>im,RGBAFormat:()=>Qe,RGBAIntegerFormat:()=>ll,RGBA_ASTC_10x10_Format:()=>Rl,RGBA_ASTC_10x5_Format:()=>El,RGBA_ASTC_10x6_Format:()=>wl,RGBA_ASTC_10x8_Format:()=>Al,RGBA_ASTC_12x10_Format:()=>Cl,RGBA_ASTC_12x12_Format:()=>Il,RGBA_ASTC_4x4_Format:()=>xl,RGBA_ASTC_5x4_Format:()=>_l,RGBA_ASTC_5x5_Format:()=>yl,RGBA_ASTC_6x5_Format:()=>vl,RGBA_ASTC_6x6_Format:()=>Ml,RGBA_ASTC_8x5_Format:()=>Sl,RGBA_ASTC_8x6_Format:()=>bl,RGBA_ASTC_8x8_Format:()=>Tl,RGBA_BPTC_Format:()=>Pl,RGBA_ETC2_EAC_Format:()=>gl,RGBA_PVRTC_2BPPV1_Format:()=>dl,RGBA_PVRTC_4BPPV1_Format:()=>fl,RGBA_S3TC_DXT1_Format:()=>Jo,RGBA_S3TC_DXT3_Format:()=>jo,RGBA_S3TC_DXT5_Format:()=>Qo,RGBDepthPacking:()=>j_,RGBFormat:()=>gf,RGBIntegerFormat:()=>J_,RGB_BPTC_SIGNED_Format:()=>Ll,RGB_BPTC_UNSIGNED_Format:()=>Nl,RGB_ETC1_Format:()=>pl,RGB_ETC2_Format:()=>ml,RGB_PVRTC_2BPPV1_Format:()=>hl,RGB_PVRTC_4BPPV1_Format:()=>ul,RGB_S3TC_DXT1_Format:()=>Zo,RGDepthPacking:()=>Q_,RGFormat:()=>xf,RGIntegerFormat:()=>cl,RawShaderMaterial:()=>Rc,Ray:()=>_n,Raycaster:()=>Oh,RectAreaLight:()=>kc,RedFormat:()=>al,RedIntegerFormat:()=>Ko,ReinhardToneMapping:()=>qp,RenderTarget:()=>Mo,RenderTarget3D:()=>Lh,RepeatWrapping:()=>An,ReplaceStencilOp:()=>e0,ReverseSubtractEquation:()=>Ap,RingGeometry:()=>vc,SIGNED_RED_GREEN_RGTC2_Format:()=>Ol,SIGNED_RED_RGTC1_Format:()=>Ul,SRGBColorSpace:()=>Ae,SRGBTransfer:()=>ge,Scene:()=>Fi,ShaderChunk:()=>te,ShaderLib:()=>Si,ShaderMaterial:()=>Cn,ShadowMaterial:()=>Ac,Shape:()=>Pi,ShapeGeometry:()=>Mc,ShapePath:()=>nf,ShapeUtils:()=>Qn,ShortType:()=>ff,Skeleton:()=>ds,SkeletonHelper:()=>Wh,SkinnedMesh:()=>mi,Source:()=>On,Sphere:()=>Be,SphereGeometry:()=>Oo,Spherical:()=>zh,SphericalHarmonics3:()=>Hc,SplineCurve:()=>Do,SpotLight:()=>Ms,SpotLightHelper:()=>Gh,Sprite:()=>tc,SpriteMaterial:()=>To,SrcAlphaFactor:()=>$a,SrcAlphaSaturateFactor:()=>Bp,SrcColorFactor:()=>Lp,StaticCopyUsage:()=>y0,StaticDrawUsage:()=>_o,StaticReadUsage:()=>g0,StereoCamera:()=>Ah,StreamCopyUsage:()=>M0,StreamDrawUsage:()=>m0,StreamReadUsage:()=>_0,StringKeyframeTrack:()=>ki,SubtractEquation:()=>wp,SubtractiveBlending:()=>lf,TOUCH:()=>W_,TangentSpaceNormalMap:()=>hr,TetrahedronGeometry:()=>Sc,Texture:()=>Ie,TextureLoader:()=>Vo,TextureUtils:()=>sf,Timer:()=>Bh,TimestampQuery:()=>b0,TorusGeometry:()=>bc,TorusKnotGeometry:()=>Tc,Triangle:()=>me,TriangleFanDrawMode:()=>Cs,TriangleStripDrawMode:()=>ta,TrianglesDrawMode:()=>yf,TubeGeometry:()=>Ec,UVMapping:()=>il,Uint16BufferAttribute:()=>So,Uint32BufferAttribute:()=>bo,Uint8BufferAttribute:()=>ch,Uint8ClampedBufferAttribute:()=>lh,Uniform:()=>Nh,UniformsGroup:()=>Dh,UniformsLib:()=>Tt,UniformsUtils:()=>gm,UnsignedByteType:()=>ri,UnsignedInt101111Type:()=>pf,UnsignedInt248Type:()=>As,UnsignedInt5999Type:()=>df,UnsignedIntType:()=>qi,UnsignedShort4444Type:()=>sl,UnsignedShort5551Type:()=>ol,UnsignedShortType:()=>Es,VSMShadowMap:()=>vi,Vector2:()=>nt,Vector3:()=>I,Vector4:()=>Qt,VectorKeyframeTrack:()=>Wn,VideoFrameTexture:()=>mh,VideoTexture:()=>rc,WebGL3DRenderTarget:()=>sh,WebGLArrayRenderTarget:()=>rh,WebGLCoordinateSystem:()=>wn,WebGLCubeRenderTarget:()=>Ja,WebGLRenderTarget:()=>Hn,WebGLRenderer:()=>Hl,WebGLUtils:()=>uy,WebGPUCoordinateSystem:()=>ss,WebXRController:()=>fs,WireframeGeometry:()=>wc,WrapAroundEnding:()=>go,ZeroCurvatureEnding:()=>Tr,ZeroFactor:()=>Ip,ZeroSlopeEnding:()=>Er,ZeroStencilOp:()=>t0,createCanvasElement:()=>pm});var Hi="180",G_={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},W_={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Sp=0,of=1,bp=2,X_=3,q_=0,af=1,Tp=2,vi=3,rn=0,qe=1,Ve=2,Vi=0,wr=1,cf=2,lf=3,uf=4,Ep=5,sr=100,wp=101,Ap=102,Rp=103,Cp=104,Ip=200,Pp=201,Lp=202,Np=203,$a=204,Ka=205,Dp=206,Up=207,Fp=208,Op=209,Bp=210,zp=211,kp=212,Hp=213,Vp=214,Zc=0,Jc=1,jc=2,Ar=3,Qc=4,tl=5,el=6,nl=7,qo=0,Gp=1,Wp=2,Gi=0,Xp=1,qp=2,Yp=3,$p=4,Kp=5,Zp=6,Jp=7,nh="attached",jp="detached",il=300,Wi=301,ur=302,Yo=303,$o=304,Ts=306,An=1e3,en=1001,Li=1002,De=1003,Nr=1004,Y_=1004,Mi=1005,$_=1005,Ee=1006,Xi=1007,K_=1007,un=1008,Z_=1008,ri=1009,hf=1010,ff=1011,Es=1012,rl=1013,qi=1014,xn=1015,ws=1016,sl=1017,ol=1018,As=1020,df=35902,pf=35899,mf=1021,gf=1022,Qe=1023,rs=1026,Rs=1027,al=1028,Ko=1029,xf=1030,cl=1031,J_=1032,ll=1033,Zo=33776,Jo=33777,jo=33778,Qo=33779,ul=35840,hl=35841,fl=35842,dl=35843,pl=36196,ml=37492,gl=37496,xl=37808,_l=37809,yl=37810,vl=37811,Ml=37812,Sl=37813,bl=37814,Tl=37815,El=37816,wl=37817,Al=37818,Rl=37819,Cl=37820,Il=37821,Pl=36492,Ll=36494,Nl=36495,Dl=36283,Ul=36284,Fl=36285,Ol=36286,Qp=2200,tm=2201,em=2202,Ni=2300,Di=2301,Wa=2302,Tr=2400,Er=2401,go=2402,Bl=2500,_f=2501,yf=0,ta=1,Cs=2,nm=3200,im=3201,j_=3202,Q_=3203,hr=0,rm=1,si="",Ae="srgb",tn="srgb-linear",xo="linear",ge="srgb",t0=0,br=7680,e0=7681,n0=7682,i0=7683,r0=34055,s0=34056,o0=5386,a0=512,c0=513,l0=514,u0=515,h0=516,f0=517,d0=518,ih=519,sm=512,om=513,am=514,vf=515,cm=516,lm=517,um=518,hm=519,_o=35044,p0=35048,m0=35040,g0=35045,x0=35049,_0=35041,y0=35046,v0=35050,M0=35042,S0="100",Mf="300 es",wn=2e3,ss=2001,b0={COMPUTE:"compute",RENDER:"render"},T0={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},E0={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"},kn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){let n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){let n=this._listeners;if(n===void 0)return;let i=n[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){let e=this._listeners;if(e===void 0)return;let n=e[t.type];if(n!==void 0){t.target=this;let i=n.slice(0);for(let r=0,o=i.length;r<o;r++)i[r].call(this,t);t.target=null}}},on=["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"],Fx=1234567,is=Math.PI/180,os=180/Math.PI;function Bn(){let s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(on[s&255]+on[s>>8&255]+on[s>>16&255]+on[s>>24&255]+"-"+on[t&255]+on[t>>8&255]+"-"+on[t>>16&15|64]+on[t>>24&255]+"-"+on[e&63|128]+on[e>>8&255]+"-"+on[e>>16&255]+on[e>>24&255]+on[n&255]+on[n>>8&255]+on[n>>16&255]+on[n>>24&255]).toLowerCase()}function Xt(s,t,e){return Math.max(t,Math.min(e,s))}function fm(s,t){return(s%t+t)%t}function DM(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function UM(s,t,e){return s!==t?(e-s)/(t-s):0}function Xa(s,t,e){return(1-e)*s+e*t}function FM(s,t,e,n){return Xa(s,t,1-Math.exp(-e*n))}function OM(s,t=1){return t-Math.abs(fm(s,t*2)-t)}function BM(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function zM(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function kM(s,t){return s+Math.floor(Math.random()*(t-s+1))}function HM(s,t){return s+Math.random()*(t-s)}function VM(s){return s*(.5-Math.random())}function GM(s){s!==void 0&&(Fx=s);let t=Fx+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function WM(s){return s*is}function XM(s){return s*os}function qM(s){return(s&s-1)===0&&s!==0}function YM(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function $M(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function KM(s,t,e,n,i){let r=Math.cos,o=Math.sin,a=r(e/2),c=o(e/2),l=r((t+n)/2),u=o((t+n)/2),h=r((t-n)/2),f=o((t-n)/2),p=r((n-t)/2),x=o((n-t)/2);switch(i){case"XYX":s.set(a*u,c*h,c*f,a*l);break;case"YZY":s.set(c*f,a*u,c*h,a*l);break;case"ZXZ":s.set(c*h,c*f,a*u,a*l);break;case"XZX":s.set(a*u,c*x,c*p,a*l);break;case"YXY":s.set(c*p,a*u,c*x,a*l);break;case"ZYZ":s.set(c*x,c*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function gn(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function Jt(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var Yi={DEG2RAD:is,RAD2DEG:os,generateUUID:Bn,clamp:Xt,euclideanModulo:fm,mapLinear:DM,inverseLerp:UM,lerp:Xa,damp:FM,pingpong:OM,smoothstep:BM,smootherstep:zM,randInt:kM,randFloat:HM,randFloatSpread:VM,seededRandom:GM,degToRad:WM,radToDeg:XM,isPowerOfTwo:qM,ceilPowerOfTwo:YM,floorPowerOfTwo:$M,setQuaternionFromProperEuler:KM,normalize:Jt,denormalize:gn},nt=class s{constructor(t=0,e=0){s.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*i+t.x,this.y=r*i+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ce=class{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,o,a){let c=n[i+0],l=n[i+1],u=n[i+2],h=n[i+3],f=r[o+0],p=r[o+1],x=r[o+2],v=r[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h;return}if(a===1){t[e+0]=f,t[e+1]=p,t[e+2]=x,t[e+3]=v;return}if(h!==v||c!==f||l!==p||u!==x){let y=1-a,_=c*f+l*p+u*x+h*v,S=_>=0?1:-1,g=1-_*_;if(g>Number.EPSILON){let M=Math.sqrt(g),m=Math.atan2(M,_*S);y=Math.sin(y*m)/M,a=Math.sin(a*m)/M}let d=a*S;if(c=c*y+f*d,l=l*y+p*d,u=u*y+x*d,h=h*y+v*d,y===1-a){let M=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=M,l*=M,u*=M,h*=M}}t[e]=c,t[e+1]=l,t[e+2]=u,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,o){let a=n[i],c=n[i+1],l=n[i+2],u=n[i+3],h=r[o],f=r[o+1],p=r[o+2],x=r[o+3];return t[e]=a*x+u*h+c*p-l*f,t[e+1]=c*x+u*f+l*h-a*p,t[e+2]=l*x+u*p+a*f-c*h,t[e+3]=u*x-a*h-c*f-l*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let n=t._x,i=t._y,r=t._z,o=t._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(i/2),h=a(r/2),f=c(n/2),p=c(i/2),x=c(r/2);switch(o){case"XYZ":this._x=f*u*h+l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h-f*p*x;break;case"YXZ":this._x=f*u*h+l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h+f*p*x;break;case"ZXY":this._x=f*u*h-l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h-f*p*x;break;case"ZYX":this._x=f*u*h-l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h+f*p*x;break;case"YZX":this._x=f*u*h+l*p*x,this._y=l*p*h+f*u*x,this._z=l*u*x-f*p*h,this._w=l*u*h-f*p*x;break;case"XZY":this._x=f*u*h-l*p*x,this._y=l*p*h-f*u*x,this._z=l*u*x+f*p*h,this._w=l*u*h+f*p*x;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],o=e[1],a=e[5],c=e[9],l=e[2],u=e[6],h=e[10],f=n+a+h;if(f>0){let p=.5/Math.sqrt(f+1);this._w=.25/p,this._x=(u-c)*p,this._y=(r-l)*p,this._z=(o-i)*p}else if(n>a&&n>h){let p=2*Math.sqrt(1+n-a-h);this._w=(u-c)/p,this._x=.25*p,this._y=(i+o)/p,this._z=(r+l)/p}else if(a>h){let p=2*Math.sqrt(1+a-n-h);this._w=(r-l)/p,this._x=(i+o)/p,this._y=.25*p,this._z=(c+u)/p}else{let p=2*Math.sqrt(1+h-n-a);this._w=(o-i)/p,this._x=(r+l)/p,this._y=(c+u)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Xt(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,i),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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,i=t._y,r=t._z,o=t._w,a=e._x,c=e._y,l=e._z,u=e._w;return this._x=n*u+o*a+i*l-r*c,this._y=i*u+o*c+r*a-n*l,this._z=r*u+o*l+n*c-i*a,this._w=o*u-n*a-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,i=this._y,r=this._z,o=this._w,a=o*t._w+n*t._x+i*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=n,this._y=i,this._z=r,this;let c=1-a*a;if(c<=Number.EPSILON){let p=1-e;return this._w=p*o+e*this._w,this._x=p*n+e*this._x,this._y=p*i+e*this._y,this._z=p*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-e)*u)/l,f=Math.sin(e*u)/l;return this._w=o*h+this._w*f,this._x=n*h+this._x*f,this._y=i*h+this._y*f,this._z=r*h+this._z*f,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},I=class s{constructor(t=0,e=0,n=0){s.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ox.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ox.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,o=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*o,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*o,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*o,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*i-a*n),u=2*(a*e-r*i),h=2*(r*n-o*e);return this.x=e+c*l+o*h-a*u,this.y=n+c*u+a*l-r*h,this.z=i+c*h+r*u-o*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,i=t.y,r=t.z,o=e.x,a=e.y,c=e.z;return this.x=i*c-r*a,this.y=r*o-n*c,this.z=n*a-i*o,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return wd.copy(this).projectOnVector(t),this.sub(wd)}reflect(t){return this.sub(wd.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},wd=new I,Ox=new Ce,$t=class s{constructor(t,e,n,i,r,o,a,c,l){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l)}set(t,e,n,i,r,o,a,c,l){let u=this.elements;return u[0]=t,u[1]=i,u[2]=a,u[3]=e,u[4]=r,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],f=n[2],p=n[5],x=n[8],v=i[0],y=i[3],_=i[6],S=i[1],g=i[4],d=i[7],M=i[2],m=i[5],R=i[8];return r[0]=o*v+a*S+c*M,r[3]=o*y+a*g+c*m,r[6]=o*_+a*d+c*R,r[1]=l*v+u*S+h*M,r[4]=l*y+u*g+h*m,r[7]=l*_+u*d+h*R,r[2]=f*v+p*S+x*M,r[5]=f*y+p*g+x*m,r[8]=f*_+p*d+x*R,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8];return e*o*u-e*a*l-n*r*u+n*a*c+i*r*l-i*o*c}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=u*o-a*l,f=a*c-u*r,p=l*r-o*c,x=e*h+n*f+i*p;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);let v=1/x;return t[0]=h*v,t[1]=(i*l-u*n)*v,t[2]=(a*n-i*o)*v,t[3]=f*v,t[4]=(u*e-i*c)*v,t[5]=(i*r-a*e)*v,t[6]=p*v,t[7]=(n*c-l*e)*v,t[8]=(o*e-n*r)*v,this}transpose(){let t,e=this.elements;return t=e[1],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(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*o+l*a)+o+t,-i*l,i*c,-i*(-l*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Ad.makeScale(t,e)),this}rotate(t){return this.premultiply(Ad.makeRotation(-t)),this}translate(t,e){return this.premultiply(Ad.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},Ad=new $t;function dm(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}var ZM={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function po(s,t){return new ZM[s](t)}function yo(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function pm(){let s=yo("canvas");return s.style.display="block",s}var Bx={};function vo(s){s in Bx||(Bx[s]=!0,console.warn(s))}function w0(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}var zx=new $t().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),kx=new $t().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function JM(){let s={enabled:!0,workingColorSpace:tn,spaces:{},convert:function(i,r,o){return this.enabled===!1||r===o||!r||!o||(this.spaces[r].transfer===ge&&(i.r=rr(i.r),i.g=rr(i.g),i.b=rr(i.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===ge&&(i.r=mo(i.r),i.g=mo(i.g),i.b=mo(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===si?xo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,o){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return vo("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return vo("THREE.ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[tn]:{primaries:t,whitePoint:n,transfer:xo,toXYZ:zx,fromXYZ:kx,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Ae},outputColorSpaceConfig:{drawingBufferColorSpace:Ae}},[Ae]:{primaries:t,whitePoint:n,transfer:ge,toXYZ:zx,fromXYZ:kx,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Ae}}}),s}var ie=JM();function rr(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function mo(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var Ys,as=class{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Ys===void 0&&(Ys=yo("canvas")),Ys.width=t.width,Ys.height=t.height;let i=Ys.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Ys}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=yo("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let o=0;o<r.length;o++)r[o]=rr(r[o]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){let e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(rr(e[n]/255)*255):e[n]=rr(e[n]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}},jM=0,On=class{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:jM++}),this.uuid=Bn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){let e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let o=0,a=i.length;o<a;o++)i[o].isDataTexture?r.push(Rd(i[o].image)):r.push(Rd(i[o]))}else r=Rd(i);n.url=r}return e||(t.images[this.uuid]=n),n}};function Rd(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?as.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var QM=0,Cd=new I,Ie=class s extends kn{constructor(t=s.DEFAULT_IMAGE,e=s.DEFAULT_MAPPING,n=en,i=en,r=Ee,o=un,a=Qe,c=ri,l=s.DEFAULT_ANISOTROPY,u=si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:QM++}),this.uuid=Bn(),this.name="",this.source=new On(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new nt(0,0),this.repeat=new nt(1,1),this.center=new nt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $t,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(Cd).x}get height(){return this.source.getSize(Cd).y}get depth(){return this.source.getSize(Cd).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).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};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==il)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case An:t.x=t.x-Math.floor(t.x);break;case en:t.x=t.x<0?0:1;break;case Li:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case An:t.y=t.y-Math.floor(t.y);break;case en:t.y=t.y<0?0:1;break;case Li:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};Ie.DEFAULT_IMAGE=null;Ie.DEFAULT_MAPPING=il;Ie.DEFAULT_ANISOTROPY=1;var Qt=class s{constructor(t=0,e=0,n=0,i=1){s.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){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: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*i+o[12]*r,this.y=o[1]*e+o[5]*n+o[9]*i+o[13]*r,this.z=o[2]*e+o[6]*n+o[10]*i+o[14]*r,this.w=o[3]*e+o[7]*n+o[11]*i+o[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r,c=t.elements,l=c[0],u=c[4],h=c[8],f=c[1],p=c[5],x=c[9],v=c[2],y=c[6],_=c[10];if(Math.abs(u-f)<.01&&Math.abs(h-v)<.01&&Math.abs(x-y)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+v)<.1&&Math.abs(x+y)<.1&&Math.abs(l+p+_-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let g=(l+1)/2,d=(p+1)/2,M=(_+1)/2,m=(u+f)/4,R=(h+v)/4,E=(x+y)/4;return g>d&&g>M?g<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(g),i=m/n,r=R/n):d>M?d<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(d),n=m/i,r=E/i):M<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(M),n=R/r,i=E/r),this.set(n,i,r,e),this}let S=Math.sqrt((y-x)*(y-x)+(h-v)*(h-v)+(f-u)*(f-u));return Math.abs(S)<.001&&(S=1),this.x=(y-x)/S,this.y=(h-v)/S,this.z=(f-u)/S,this.w=Math.acos((l+p+_-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this.w=Xt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this.w=Xt(this.w,t,e),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(n,t,e))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),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}},Mo=class extends kn{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ee,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new Qt(0,0,t,e),this.scissorTest=!1,this.viewport=new Qt(0,0,t,e);let i={width:t,height:e,depth:n.depth},r=new Ie(i);this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=r.clone(),this.textures[a].isRenderTargetTexture=!0,this.textures[a].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(t={}){let e={minFilter:Ee,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isArrayTexture=this.textures[i].image.depth>1;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;let i=Object.assign({},t.textures[e].image);this.textures[e].source=new On(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Hn=class extends Mo{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},cs=class extends Ie{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=De,this.minFilter=De,this.wrapR=en,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},rh=class extends Hn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new cs(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},ls=class extends Ie{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=De,this.minFilter=De,this.wrapR=en,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},sh=class extends Hn{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new ls(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},ne=class{constructor(t=new I(1/0,1/0,1/0),e=new I(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ui.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ui.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=ui.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);let n=t.geometry;if(n!==void 0){let r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=r.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,ui):ui.fromBufferAttribute(r,o),ui.applyMatrix4(t.matrixWorld),this.expandByPoint(ui);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),pu.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),pu.copy(n.boundingBox)),pu.applyMatrix4(t.matrixWorld),this.union(pu)}let i=t.children;for(let r=0,o=i.length;r<o;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,ui),ui.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ia),mu.subVectors(this.max,Ia),$s.subVectors(t.a,Ia),Ks.subVectors(t.b,Ia),Zs.subVectors(t.c,Ia),gr.subVectors(Ks,$s),xr.subVectors(Zs,Ks),Wr.subVectors($s,Zs);let e=[0,-gr.z,gr.y,0,-xr.z,xr.y,0,-Wr.z,Wr.y,gr.z,0,-gr.x,xr.z,0,-xr.x,Wr.z,0,-Wr.x,-gr.y,gr.x,0,-xr.y,xr.x,0,-Wr.y,Wr.x,0];return!Id(e,$s,Ks,Zs,mu)||(e=[1,0,0,0,1,0,0,0,1],!Id(e,$s,Ks,Zs,mu))?!1:(gu.crossVectors(gr,xr),e=[gu.x,gu.y,gu.z],Id(e,$s,Ks,Zs,mu))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ui).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(ui).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ji[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ji[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ji[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ji[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ji[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ji[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ji[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ji[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ji),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}},Ji=[new I,new I,new I,new I,new I,new I,new I,new I],ui=new I,pu=new ne,$s=new I,Ks=new I,Zs=new I,gr=new I,xr=new I,Wr=new I,Ia=new I,mu=new I,gu=new I,Xr=new I;function Id(s,t,e,n,i){for(let r=0,o=s.length-3;r<=o;r+=3){Xr.fromArray(s,r);let a=i.x*Math.abs(Xr.x)+i.y*Math.abs(Xr.y)+i.z*Math.abs(Xr.z),c=t.dot(Xr),l=e.dot(Xr),u=n.dot(Xr);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var tS=new ne,Pa=new I,Pd=new I,Be=class{constructor(t=new I,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):tS.setFromPoints(t).getCenter(n);let i=0;for(let r=0,o=t.length;r<o;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){let e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){let n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Pa.subVectors(t,this.center);let e=Pa.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Pa,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Pd.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Pa.copy(t.center).add(Pd)),this.expandByPoint(Pa.copy(t.center).sub(Pd))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}},ji=new I,Ld=new I,xu=new I,_r=new I,Nd=new I,_u=new I,Dd=new I,_n=class{constructor(t=new I,e=new I(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ji)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=ji.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ji.copy(this.origin).addScaledVector(this.direction,e),ji.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Ld.copy(t).add(e).multiplyScalar(.5),xu.copy(e).sub(t).normalize(),_r.copy(this.origin).sub(Ld);let r=t.distanceTo(e)*.5,o=-this.direction.dot(xu),a=_r.dot(this.direction),c=-_r.dot(xu),l=_r.lengthSq(),u=Math.abs(1-o*o),h,f,p,x;if(u>0)if(h=o*c-a,f=o*a-c,x=r*u,h>=0)if(f>=-x)if(f<=x){let v=1/u;h*=v,f*=v,p=h*(h+o*f+2*a)+f*(o*h+f+2*c)+l}else f=r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f=-r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;else f<=-x?(h=Math.max(0,-(-o*r+a)),f=h>0?-r:Math.min(Math.max(-r,-c),r),p=-h*h+f*(f+2*c)+l):f<=x?(h=0,f=Math.min(Math.max(-r,-c),r),p=f*(f+2*c)+l):(h=Math.max(0,-(o*r+a)),f=h>0?r:Math.min(Math.max(-r,-c),r),p=-h*h+f*(f+2*c)+l);else f=o>0?-r:r,h=Math.max(0,-(o*f+a)),p=-h*h+f*(f+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Ld).addScaledVector(xu,f),p}intersectSphere(t,e){ji.subVectors(t.center,this.origin);let n=ji.dot(this.direction),i=ji.dot(ji)-n*n,r=t.radius*t.radius;if(i>r)return null;let o=Math.sqrt(r-i),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return l>=0?(n=(t.min.x-f.x)*l,i=(t.max.x-f.x)*l):(n=(t.max.x-f.x)*l,i=(t.min.x-f.x)*l),u>=0?(r=(t.min.y-f.y)*u,o=(t.max.y-f.y)*u):(r=(t.max.y-f.y)*u,o=(t.min.y-f.y)*u),n>o||r>i||((r>n||isNaN(n))&&(n=r),(o<i||isNaN(i))&&(i=o),h>=0?(a=(t.min.z-f.z)*h,c=(t.max.z-f.z)*h):(a=(t.max.z-f.z)*h,c=(t.min.z-f.z)*h),n>c||a>i)||((a>n||n!==n)&&(n=a),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,ji)!==null}intersectTriangle(t,e,n,i,r){Nd.subVectors(e,t),_u.subVectors(n,t),Dd.crossVectors(Nd,_u);let o=this.direction.dot(Dd),a;if(o>0){if(i)return null;a=1}else if(o<0)a=-1,o=-o;else return null;_r.subVectors(this.origin,t);let c=a*this.direction.dot(_u.crossVectors(_r,_u));if(c<0)return null;let l=a*this.direction.dot(Nd.cross(_r));if(l<0||c+l>o)return null;let u=-a*_r.dot(Dd);return u<0?null:this.at(u/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},vt=class s{constructor(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y){s.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y)}set(t,e,n,i,r,o,a,c,l,u,h,f,p,x,v,y){let _=this.elements;return _[0]=t,_[4]=e,_[8]=n,_[12]=i,_[1]=r,_[5]=o,_[9]=a,_[13]=c,_[2]=l,_[6]=u,_[10]=h,_[14]=f,_[3]=p,_[7]=x,_[11]=v,_[15]=y,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 s().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return 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(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,i=1/Js.setFromMatrixColumn(t,0).length(),r=1/Js.setFromMatrixColumn(t,1).length(),o=1/Js.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*o,e[9]=n[9]*o,e[10]=n[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,i=t.y,r=t.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(i),l=Math.sin(i),u=Math.cos(r),h=Math.sin(r);if(t.order==="XYZ"){let f=o*u,p=o*h,x=a*u,v=a*h;e[0]=c*u,e[4]=-c*h,e[8]=l,e[1]=p+x*l,e[5]=f-v*l,e[9]=-a*c,e[2]=v-f*l,e[6]=x+p*l,e[10]=o*c}else if(t.order==="YXZ"){let f=c*u,p=c*h,x=l*u,v=l*h;e[0]=f+v*a,e[4]=x*a-p,e[8]=o*l,e[1]=o*h,e[5]=o*u,e[9]=-a,e[2]=p*a-x,e[6]=v+f*a,e[10]=o*c}else if(t.order==="ZXY"){let f=c*u,p=c*h,x=l*u,v=l*h;e[0]=f-v*a,e[4]=-o*h,e[8]=x+p*a,e[1]=p+x*a,e[5]=o*u,e[9]=v-f*a,e[2]=-o*l,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){let f=o*u,p=o*h,x=a*u,v=a*h;e[0]=c*u,e[4]=x*l-p,e[8]=f*l+v,e[1]=c*h,e[5]=v*l+f,e[9]=p*l-x,e[2]=-l,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){let f=o*c,p=o*l,x=a*c,v=a*l;e[0]=c*u,e[4]=v-f*h,e[8]=x*h+p,e[1]=h,e[5]=o*u,e[9]=-a*u,e[2]=-l*u,e[6]=p*h+x,e[10]=f-v*h}else if(t.order==="XZY"){let f=o*c,p=o*l,x=a*c,v=a*l;e[0]=c*u,e[4]=-h,e[8]=l*u,e[1]=f*h+v,e[5]=o*u,e[9]=p*h-x,e[2]=x*h-p,e[6]=a*u,e[10]=v*h+f}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(eS,t,nS)}lookAt(t,e,n){let i=this.elements;return Un.subVectors(t,e),Un.lengthSq()===0&&(Un.z=1),Un.normalize(),yr.crossVectors(n,Un),yr.lengthSq()===0&&(Math.abs(n.z)===1?Un.x+=1e-4:Un.z+=1e-4,Un.normalize(),yr.crossVectors(n,Un)),yr.normalize(),yu.crossVectors(Un,yr),i[0]=yr.x,i[4]=yu.x,i[8]=Un.x,i[1]=yr.y,i[5]=yu.y,i[9]=Un.y,i[2]=yr.z,i[6]=yu.z,i[10]=Un.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],f=n[9],p=n[13],x=n[2],v=n[6],y=n[10],_=n[14],S=n[3],g=n[7],d=n[11],M=n[15],m=i[0],R=i[4],E=i[8],T=i[12],b=i[1],w=i[5],A=i[9],C=i[13],D=i[2],F=i[6],O=i[10],H=i[14],B=i[3],$=i[7],at=i[11],rt=i[15];return r[0]=o*m+a*b+c*D+l*B,r[4]=o*R+a*w+c*F+l*$,r[8]=o*E+a*A+c*O+l*at,r[12]=o*T+a*C+c*H+l*rt,r[1]=u*m+h*b+f*D+p*B,r[5]=u*R+h*w+f*F+p*$,r[9]=u*E+h*A+f*O+p*at,r[13]=u*T+h*C+f*H+p*rt,r[2]=x*m+v*b+y*D+_*B,r[6]=x*R+v*w+y*F+_*$,r[10]=x*E+v*A+y*O+_*at,r[14]=x*T+v*C+y*H+_*rt,r[3]=S*m+g*b+d*D+M*B,r[7]=S*R+g*w+d*F+M*$,r[11]=S*E+g*A+d*O+M*at,r[15]=S*T+g*C+d*H+M*rt,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],o=t[1],a=t[5],c=t[9],l=t[13],u=t[2],h=t[6],f=t[10],p=t[14],x=t[3],v=t[7],y=t[11],_=t[15];return x*(+r*c*h-i*l*h-r*a*f+n*l*f+i*a*p-n*c*p)+v*(+e*c*p-e*l*f+r*o*f-i*o*p+i*l*u-r*c*u)+y*(+e*l*h-e*a*p-r*o*h+n*o*p+r*a*u-n*l*u)+_*(-i*a*u-e*c*h+e*a*f+i*o*h-n*o*f+n*c*u)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],u=t[8],h=t[9],f=t[10],p=t[11],x=t[12],v=t[13],y=t[14],_=t[15],S=h*y*l-v*f*l+v*c*p-a*y*p-h*c*_+a*f*_,g=x*f*l-u*y*l-x*c*p+o*y*p+u*c*_-o*f*_,d=u*v*l-x*h*l+x*a*p-o*v*p-u*a*_+o*h*_,M=x*h*c-u*v*c-x*a*f+o*v*f+u*a*y-o*h*y,m=e*S+n*g+i*d+r*M;if(m===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let R=1/m;return t[0]=S*R,t[1]=(v*f*r-h*y*r-v*i*p+n*y*p+h*i*_-n*f*_)*R,t[2]=(a*y*r-v*c*r+v*i*l-n*y*l-a*i*_+n*c*_)*R,t[3]=(h*c*r-a*f*r-h*i*l+n*f*l+a*i*p-n*c*p)*R,t[4]=g*R,t[5]=(u*y*r-x*f*r+x*i*p-e*y*p-u*i*_+e*f*_)*R,t[6]=(x*c*r-o*y*r-x*i*l+e*y*l+o*i*_-e*c*_)*R,t[7]=(o*f*r-u*c*r+u*i*l-e*f*l-o*i*p+e*c*p)*R,t[8]=d*R,t[9]=(x*h*r-u*v*r-x*n*p+e*v*p+u*n*_-e*h*_)*R,t[10]=(o*v*r-x*a*r+x*n*l-e*v*l-o*n*_+e*a*_)*R,t[11]=(u*a*r-o*h*r-u*n*l+e*h*l+o*n*p-e*a*p)*R,t[12]=M*R,t[13]=(u*v*i-x*h*i+x*n*f-e*v*f-u*n*y+e*h*y)*R,t[14]=(x*a*i-o*v*i-x*n*c+e*v*c+o*n*y-e*a*y)*R,t[15]=(o*h*i-u*a*i+u*n*c-e*h*c-o*n*f+e*a*f)*R,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),i=Math.sin(e),r=1-n,o=t.x,a=t.y,c=t.z,l=r*o,u=r*a;return this.set(l*o+n,l*a-i*c,l*c+i*a,0,l*a+i*c,u*a+n,u*c-i*o,0,l*c-i*a,u*c+i*o,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,o){return this.set(1,n,r,0,t,1,o,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,o=e._y,a=e._z,c=e._w,l=r+r,u=o+o,h=a+a,f=r*l,p=r*u,x=r*h,v=o*u,y=o*h,_=a*h,S=c*l,g=c*u,d=c*h,M=n.x,m=n.y,R=n.z;return i[0]=(1-(v+_))*M,i[1]=(p+d)*M,i[2]=(x-g)*M,i[3]=0,i[4]=(p-d)*m,i[5]=(1-(f+_))*m,i[6]=(y+S)*m,i[7]=0,i[8]=(x+g)*R,i[9]=(y-S)*R,i[10]=(1-(f+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=Js.set(i[0],i[1],i[2]).length(),o=Js.set(i[4],i[5],i[6]).length(),a=Js.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],hi.copy(this);let l=1/r,u=1/o,h=1/a;return hi.elements[0]*=l,hi.elements[1]*=l,hi.elements[2]*=l,hi.elements[4]*=u,hi.elements[5]*=u,hi.elements[6]*=u,hi.elements[8]*=h,hi.elements[9]*=h,hi.elements[10]*=h,e.setFromRotationMatrix(hi),n.x=r,n.y=o,n.z=a,this}makePerspective(t,e,n,i,r,o,a=wn,c=!1){let l=this.elements,u=2*r/(e-t),h=2*r/(n-i),f=(e+t)/(e-t),p=(n+i)/(n-i),x,v;if(c)x=r/(o-r),v=o*r/(o-r);else if(a===wn)x=-(o+r)/(o-r),v=-2*o*r/(o-r);else if(a===ss)x=-o/(o-r),v=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=f,l[12]=0,l[1]=0,l[5]=h,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=x,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,o,a=wn,c=!1){let l=this.elements,u=2/(e-t),h=2/(n-i),f=-(e+t)/(e-t),p=-(n+i)/(n-i),x,v;if(c)x=1/(o-r),v=o/(o-r);else if(a===wn)x=-2/(o-r),v=-(o+r)/(o-r);else if(a===ss)x=-1/(o-r),v=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=f,l[1]=0,l[5]=h,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=x,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Js=new I,hi=new vt,eS=new I(0,0,0),nS=new I(1,1,1),yr=new I,yu=new I,Un=new I,Hx=new vt,Vx=new Ce,Rn=class s{constructor(t=0,e=0,n=0,i=s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let i=t.elements,r=i[0],o=i[4],a=i[8],c=i[1],l=i[5],u=i[9],h=i[2],f=i[6],p=i[10];switch(e){case"XYZ":this._y=Math.asin(Xt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(f,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Xt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(Xt(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(-h,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Xt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(f,p),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(Xt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Xt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(f,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-u,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Hx.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Hx,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Vx.setFromEuler(this),this.setFromQuaternion(Vx,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Rn.DEFAULT_ORDER="XYZ";var us=class{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}},iS=0,Gx=new I,js=new Ce,Qi=new vt,vu=new I,La=new I,rS=new I,sS=new Ce,Wx=new I(1,0,0),Xx=new I(0,1,0),qx=new I(0,0,1),Yx={type:"added"},oS={type:"removed"},Qs={type:"childadded",child:null},Ud={type:"childremoved",child:null},re=class s extends kn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:iS++}),this.uuid=Bn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=s.DEFAULT_UP.clone();let t=new I,e=new Rn,n=new Ce,i=new I(1,1,1);function r(){n.setFromEuler(e,!1)}function o(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new vt},normalMatrix:{value:new $t}}),this.matrix=new vt,this.matrixWorld=new vt,this.matrixAutoUpdate=s.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=s.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new us,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return js.setFromAxisAngle(t,e),this.quaternion.multiply(js),this}rotateOnWorldAxis(t,e){return js.setFromAxisAngle(t,e),this.quaternion.premultiply(js),this}rotateX(t){return this.rotateOnAxis(Wx,t)}rotateY(t){return this.rotateOnAxis(Xx,t)}rotateZ(t){return this.rotateOnAxis(qx,t)}translateOnAxis(t,e){return Gx.copy(t).applyQuaternion(this.quaternion),this.position.add(Gx.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Wx,t)}translateY(t){return this.translateOnAxis(Xx,t)}translateZ(t){return this.translateOnAxis(qx,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Qi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?vu.copy(t):vu.set(t,e,n);let i=this.parent;this.updateWorldMatrix(!0,!1),La.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Qi.lookAt(La,vu,this.up):Qi.lookAt(vu,La,this.up),this.quaternion.setFromRotationMatrix(Qi),i&&(Qi.extractRotation(i.matrixWorld),js.setFromRotationMatrix(Qi),this.quaternion.premultiply(js.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Yx),Qs.child=t,this.dispatchEvent(Qs),Qs.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(oS),Ud.child=t,this.dispatchEvent(Ud),Ud.child=null),this}removeFromParent(){let t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Qi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Qi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Qi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Yx),Qs.child=t,this.dispatchEvent(Qs),Qs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){let o=this.children[n].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,t,rS),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,sS,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){let e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);let e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e){let n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),e===!0){let i=this.children;for(let r=0,o=i.length;r<o;r++)i[r].updateWorldMatrix(!1,!0)}}toJSON(t){let e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});let i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(a=>({...a})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let h=c[l];r(t.shapes,h)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(r(t.materials,this.material[c]));i.material=a}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let a=0;a<this.children.length;a++)i.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];i.animations.push(r(t.animations,c))}}if(e){let a=o(t.geometries),c=o(t.materials),l=o(t.textures),u=o(t.images),h=o(t.shapes),f=o(t.skeletons),p=o(t.animations),x=o(t.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),p.length>0&&(n.animations=p),x.length>0&&(n.nodes=x)}return n.object=i,n;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){let i=t.children[n];this.add(i.clone())}return this}};re.DEFAULT_UP=new I(0,1,0);re.DEFAULT_MATRIX_AUTO_UPDATE=!0;re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var fi=new I,tr=new I,Fd=new I,er=new I,to=new I,eo=new I,$x=new I,Od=new I,Bd=new I,zd=new I,kd=new Qt,Hd=new Qt,Vd=new Qt,me=class s{constructor(t=new I,e=new I,n=new I){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),fi.subVectors(t,e),i.cross(fi);let r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){fi.subVectors(i,e),tr.subVectors(n,e),Fd.subVectors(t,e);let o=fi.dot(fi),a=fi.dot(tr),c=fi.dot(Fd),l=tr.dot(tr),u=tr.dot(Fd),h=o*l-a*a;if(h===0)return r.set(0,0,0),null;let f=1/h,p=(l*c-a*u)*f,x=(o*u-a*c)*f;return r.set(1-p-x,x,p)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,er)===null?!1:er.x>=0&&er.y>=0&&er.x+er.y<=1}static getInterpolation(t,e,n,i,r,o,a,c){return this.getBarycoord(t,e,n,i,er)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,er.x),c.addScaledVector(o,er.y),c.addScaledVector(a,er.z),c)}static getInterpolatedAttribute(t,e,n,i,r,o){return kd.setScalar(0),Hd.setScalar(0),Vd.setScalar(0),kd.fromBufferAttribute(t,e),Hd.fromBufferAttribute(t,n),Vd.fromBufferAttribute(t,i),o.setScalar(0),o.addScaledVector(kd,r.x),o.addScaledVector(Hd,r.y),o.addScaledVector(Vd,r.z),o}static isFrontFacing(t,e,n,i){return fi.subVectors(n,e),tr.subVectors(t,e),fi.cross(tr).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return fi.subVectors(this.c,this.b),tr.subVectors(this.a,this.b),fi.cross(tr).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return s.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,o,a;to.subVectors(i,n),eo.subVectors(r,n),Od.subVectors(t,n);let c=to.dot(Od),l=eo.dot(Od);if(c<=0&&l<=0)return e.copy(n);Bd.subVectors(t,i);let u=to.dot(Bd),h=eo.dot(Bd);if(u>=0&&h<=u)return e.copy(i);let f=c*h-u*l;if(f<=0&&c>=0&&u<=0)return o=c/(c-u),e.copy(n).addScaledVector(to,o);zd.subVectors(t,r);let p=to.dot(zd),x=eo.dot(zd);if(x>=0&&p<=x)return e.copy(r);let v=p*l-c*x;if(v<=0&&l>=0&&x<=0)return a=l/(l-x),e.copy(n).addScaledVector(eo,a);let y=u*x-p*h;if(y<=0&&h-u>=0&&p-x>=0)return $x.subVectors(r,i),a=(h-u)/(h-u+(p-x)),e.copy(i).addScaledVector($x,a);let _=1/(y+v+f);return o=v*_,a=f*_,e.copy(n).addScaledVector(to,o).addScaledVector(eo,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},A0={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},vr={h:0,s:0,l:0},Mu={h:0,s:0,l:0};function Gd(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}var yt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Ae){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ie.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=ie.workingColorSpace){return this.r=t,this.g=e,this.b=n,ie.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=ie.workingColorSpace){if(t=fm(t,1),e=Xt(e,0,1),n=Xt(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,o=2*n-r;this.r=Gd(o,r,t+1/3),this.g=Gd(o,r,t),this.b=Gd(o,r,t-1/3)}return ie.colorSpaceToWorking(this,i),this}setStyle(t,e=Ae){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,o=i[1],a=i[2];switch(o){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Ae){let n=A0[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=rr(t.r),this.g=rr(t.g),this.b=rr(t.b),this}copyLinearToSRGB(t){return this.r=mo(t.r),this.g=mo(t.g),this.b=mo(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Ae){return ie.workingToColorSpace(an.copy(this),t),Math.round(Xt(an.r*255,0,255))*65536+Math.round(Xt(an.g*255,0,255))*256+Math.round(Xt(an.b*255,0,255))}getHexString(t=Ae){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ie.workingColorSpace){ie.workingToColorSpace(an.copy(this),e);let n=an.r,i=an.g,r=an.b,o=Math.max(n,i,r),a=Math.min(n,i,r),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(i-r)/h+(i<r?6:0);break;case i:c=(r-n)/h+2;break;case r:c=(n-i)/h+4;break}c/=6}return t.h=c,t.s=l,t.l=u,t}getRGB(t,e=ie.workingColorSpace){return ie.workingToColorSpace(an.copy(this),e),t.r=an.r,t.g=an.g,t.b=an.b,t}getStyle(t=Ae){ie.workingToColorSpace(an.copy(this),t);let e=an.r,n=an.g,i=an.b;return t!==Ae?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(vr),this.setHSL(vr.h+t,vr.s+e,vr.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(vr),t.getHSL(Mu);let n=Xa(vr.h,Mu.h,e),i=Xa(vr.s,Mu.s,e),r=Xa(vr.l,Mu.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){let e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},an=new yt;yt.NAMES=A0;var aS=0,Ue=class extends kn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:aS++}),this.uuid=Bn(),this.name="",this.type="Material",this.blending=wr,this.side=rn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=$a,this.blendDst=Ka,this.blendEquation=sr,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new yt(0,0,0),this.blendAlpha=0,this.depthFunc=Ar,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=ih,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=br,this.stencilZFail=br,this.stencilZPass=br,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.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}let i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==wr&&(n.blending=this.blending),this.side!==rn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==$a&&(n.blendSrc=this.blendSrc),this.blendDst!==Ka&&(n.blendDst=this.blendDst),this.blendEquation!==sr&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Ar&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==ih&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==br&&(n.stencilFail=this.stencilFail),this.stencilZFail!==br&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==br&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){let o=[];for(let a in r){let c=r[a];delete c.metadata,o.push(c)}return o}if(e){let r=i(t.textures),o=i(t.images);r.length>0&&(n.textures=r),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},sn=class extends Ue{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yt(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.envMapRotation=new Rn,this.combine=qo,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},ir=cS();function cS(){let s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}let r=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;!(l&8388608);)l<<=1,u-=8388608;l&=-8388609,u+=947912704,r[c]=l|u}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:o,offsetTable:a}}function En(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=Xt(s,-65504,65504),ir.floatView[0]=s;let t=ir.uint32View[0],e=t>>23&511;return ir.baseTable[e]+((t&8388607)>>ir.shiftTable[e])}function Va(s){let t=s>>10;return ir.uint32View[0]=ir.mantissaTable[ir.offsetTable[t]+(s&1023)]+ir.exponentTable[t],ir.floatView[0]}var oh=class{static toHalfFloat(t){return En(t)}static fromHalfFloat(t){return Va(t)}},We=new I,Su=new nt,lS=0,kt=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lS++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=_o,this.updateRanges=[],this.gpuType=xn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Su.fromBufferAttribute(this,e),Su.applyMatrix3(t),this.setXY(e,Su.x,Su.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyMatrix3(t),this.setXYZ(e,We.x,We.y,We.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyMatrix4(t),this.setXYZ(e,We.x,We.y,We.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.applyNormalMatrix(t),this.setXYZ(e,We.x,We.y,We.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)We.fromBufferAttribute(this,e),We.transformDirection(t),this.setXYZ(e,We.x,We.y,We.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=gn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Jt(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=gn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=gn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=gn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=gn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==_o&&(t.usage=this.usage),t}},ah=class extends kt{constructor(t,e,n){super(new Int8Array(t),e,n)}},ch=class extends kt{constructor(t,e,n){super(new Uint8Array(t),e,n)}},lh=class extends kt{constructor(t,e,n){super(new Uint8ClampedArray(t),e,n)}},uh=class extends kt{constructor(t,e,n){super(new Int16Array(t),e,n)}},So=class extends kt{constructor(t,e,n){super(new Uint16Array(t),e,n)}},hh=class extends kt{constructor(t,e,n){super(new Int32Array(t),e,n)}},bo=class extends kt{constructor(t,e,n){super(new Uint32Array(t),e,n)}},fh=class extends kt{constructor(t,e,n){super(new Uint16Array(t),e,n),this.isFloat16BufferAttribute=!0}getX(t){let e=Va(this.array[t*this.itemSize]);return this.normalized&&(e=gn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize]=En(e),this}getY(t){let e=Va(this.array[t*this.itemSize+1]);return this.normalized&&(e=gn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+1]=En(e),this}getZ(t){let e=Va(this.array[t*this.itemSize+2]);return this.normalized&&(e=gn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+2]=En(e),this}getW(t){let e=Va(this.array[t*this.itemSize+3]);return this.normalized&&(e=gn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.array[t*this.itemSize+3]=En(e),this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this.array[t+2]=En(i),this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.array[t+0]=En(e),this.array[t+1]=En(n),this.array[t+2]=En(i),this.array[t+3]=En(r),this}},Lt=class extends kt{constructor(t,e,n){super(new Float32Array(t),e,n)}},uS=0,jn=new vt,Wd=new re,no=new I,Fn=new ne,Na=new ne,je=new I,Vt=class s extends kn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:uS++}),this.uuid=Bn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=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(t){return Array.isArray(t)?this.index=new(dm(t)?bo:So)(t,1):this.index=t,this}setIndirect(t){return this.indirect=t,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){let e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let r=new $t().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}let i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return jn.makeRotationFromQuaternion(t),this.applyMatrix4(jn),this}rotateX(t){return jn.makeRotationX(t),this.applyMatrix4(jn),this}rotateY(t){return jn.makeRotationY(t),this.applyMatrix4(jn),this}rotateZ(t){return jn.makeRotationZ(t),this.applyMatrix4(jn),this}translate(t,e,n){return jn.makeTranslation(t,e,n),this.applyMatrix4(jn),this}scale(t,e,n){return jn.makeScale(t,e,n),this.applyMatrix4(jn),this}lookAt(t){return Wd.lookAt(t),Wd.updateMatrix(),this.applyMatrix4(Wd.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(no).negate(),this.translate(no.x,no.y,no.z),this}setFromPoints(t){let e=this.getAttribute("position");if(e===void 0){let n=[];for(let i=0,r=t.length;i<r;i++){let o=t[i];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Lt(n,3))}else{let n=Math.min(t.length,e.count);for(let i=0;i<n;i++){let r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ne);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new I(-1/0,-1/0,-1/0),new I(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){let r=e[n];Fn.setFromBufferAttribute(r),this.morphTargetsRelative?(je.addVectors(this.boundingBox.min,Fn.min),this.boundingBox.expandByPoint(je),je.addVectors(this.boundingBox.max,Fn.max),this.boundingBox.expandByPoint(je)):(this.boundingBox.expandByPoint(Fn.min),this.boundingBox.expandByPoint(Fn.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(){this.boundingSphere===null&&(this.boundingSphere=new Be);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new I,1/0);return}if(t){let n=this.boundingSphere.center;if(Fn.setFromBufferAttribute(t),e)for(let r=0,o=e.length;r<o;r++){let a=e[r];Na.setFromBufferAttribute(a),this.morphTargetsRelative?(je.addVectors(Fn.min,Na.min),Fn.expandByPoint(je),je.addVectors(Fn.max,Na.max),Fn.expandByPoint(je)):(Fn.expandByPoint(Na.min),Fn.expandByPoint(Na.max))}Fn.getCenter(n);let i=0;for(let r=0,o=t.count;r<o;r++)je.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(je));if(e)for(let r=0,o=e.length;r<o;r++){let a=e[r],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)je.fromBufferAttribute(a,l),c&&(no.fromBufferAttribute(t,l),je.add(no)),i=Math.max(i,n.distanceToSquared(je))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){let t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=e.position,i=e.normal,r=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new kt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let E=0;E<n.count;E++)a[E]=new I,c[E]=new I;let l=new I,u=new I,h=new I,f=new nt,p=new nt,x=new nt,v=new I,y=new I;function _(E,T,b){l.fromBufferAttribute(n,E),u.fromBufferAttribute(n,T),h.fromBufferAttribute(n,b),f.fromBufferAttribute(r,E),p.fromBufferAttribute(r,T),x.fromBufferAttribute(r,b),u.sub(l),h.sub(l),p.sub(f),x.sub(f);let w=1/(p.x*x.y-x.x*p.y);isFinite(w)&&(v.copy(u).multiplyScalar(x.y).addScaledVector(h,-p.y).multiplyScalar(w),y.copy(h).multiplyScalar(p.x).addScaledVector(u,-x.x).multiplyScalar(w),a[E].add(v),a[T].add(v),a[b].add(v),c[E].add(y),c[T].add(y),c[b].add(y))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let E=0,T=S.length;E<T;++E){let b=S[E],w=b.start,A=b.count;for(let C=w,D=w+A;C<D;C+=3)_(t.getX(C+0),t.getX(C+1),t.getX(C+2))}let g=new I,d=new I,M=new I,m=new I;function R(E){M.fromBufferAttribute(i,E),m.copy(M);let T=a[E];g.copy(T),g.sub(M.multiplyScalar(M.dot(T))).normalize(),d.crossVectors(m,T);let w=d.dot(c[E])<0?-1:1;o.setXYZW(E,g.x,g.y,g.z,w)}for(let E=0,T=S.length;E<T;++E){let b=S[E],w=b.start,A=b.count;for(let C=w,D=w+A;C<D;C+=3)R(t.getX(C+0)),R(t.getX(C+1)),R(t.getX(C+2))}}computeVertexNormals(){let t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new kt(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let f=0,p=n.count;f<p;f++)n.setXYZ(f,0,0,0);let i=new I,r=new I,o=new I,a=new I,c=new I,l=new I,u=new I,h=new I;if(t)for(let f=0,p=t.count;f<p;f+=3){let x=t.getX(f+0),v=t.getX(f+1),y=t.getX(f+2);i.fromBufferAttribute(e,x),r.fromBufferAttribute(e,v),o.fromBufferAttribute(e,y),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),a.fromBufferAttribute(n,x),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,y),a.add(u),c.add(u),l.add(u),n.setXYZ(x,a.x,a.y,a.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(y,l.x,l.y,l.z)}else for(let f=0,p=e.count;f<p;f+=3)i.fromBufferAttribute(e,f+0),r.fromBufferAttribute(e,f+1),o.fromBufferAttribute(e,f+2),u.subVectors(o,r),h.subVectors(i,r),u.cross(h),n.setXYZ(f+0,u.x,u.y,u.z),n.setXYZ(f+1,u.x,u.y,u.z),n.setXYZ(f+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)je.fromBufferAttribute(t,e),je.normalize(),t.setXYZ(e,je.x,je.y,je.z)}toNonIndexed(){function t(a,c){let l=a.array,u=a.itemSize,h=a.normalized,f=new l.constructor(c.length*u),p=0,x=0;for(let v=0,y=c.length;v<y;v++){a.isInterleavedBufferAttribute?p=c[v]*a.data.stride+a.offset:p=c[v]*u;for(let _=0;_<u;_++)f[x++]=l[p++]}return new kt(f,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let e=new s,n=this.index.array,i=this.attributes;for(let a in i){let c=i[a],l=t(c,n);e.setAttribute(a,l)}let r=this.morphAttributes;for(let a in r){let c=[],l=r[a];for(let u=0,h=l.length;u<h;u++){let f=l[u],p=t(f,n);c.push(p)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){let t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,f=l.length;h<f;h++){let p=l[h];u.push(p.toJSON(t.data))}u.length>0&&(i[c]=u,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone());let i=t.attributes;for(let l in i){let u=i[l];this.setAttribute(l,u.clone(e))}let r=t.morphAttributes;for(let l in r){let u=[],h=r[l];for(let f=0,p=h.length;f<p;f++)u.push(h[f].clone(e));this.morphAttributes[l]=u}this.morphTargetsRelative=t.morphTargetsRelative;let o=t.groups;for(let l=0,u=o.length;l<u;l++){let h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}let a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Kx=new vt,qr=new _n,bu=new Be,Zx=new I,Tu=new I,Eu=new I,wu=new I,Xd=new I,Au=new I,Jx=new I,Ru=new I,ce=class extends re{constructor(t=new Vt,e=new sn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}getVertexPosition(t,e){let n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,o=n.morphTargetsRelative;e.fromBufferAttribute(i,t);let a=this.morphTargetInfluences;if(r&&a){Au.set(0,0,0);for(let c=0,l=r.length;c<l;c++){let u=a[c],h=r[c];u!==0&&(Xd.fromBufferAttribute(h,t),o?Au.addScaledVector(Xd,u):Au.addScaledVector(Xd.sub(e),u))}e.add(Au)}return e}raycast(t,e){let n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),bu.copy(n.boundingSphere),bu.applyMatrix4(r),qr.copy(t.ray).recast(t.near),!(bu.containsPoint(qr.origin)===!1&&(qr.intersectSphere(bu,Zx)===null||qr.origin.distanceToSquared(Zx)>(t.far-t.near)**2))&&(Kx.copy(r).invert(),qr.copy(t.ray).applyMatrix4(Kx),!(n.boundingBox!==null&&qr.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,qr)))}_computeIntersections(t,e,n){let i,r=this.geometry,o=this.material,a=r.index,c=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,h=r.attributes.normal,f=r.groups,p=r.drawRange;if(a!==null)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){let y=f[x],_=o[y.materialIndex],S=Math.max(y.start,p.start),g=Math.min(a.count,Math.min(y.start+y.count,p.start+p.count));for(let d=S,M=g;d<M;d+=3){let m=a.getX(d),R=a.getX(d+1),E=a.getX(d+2);i=Cu(this,_,t,n,l,u,h,m,R,E),i&&(i.faceIndex=Math.floor(d/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{let x=Math.max(0,p.start),v=Math.min(a.count,p.start+p.count);for(let y=x,_=v;y<_;y+=3){let S=a.getX(y),g=a.getX(y+1),d=a.getX(y+2);i=Cu(this,o,t,n,l,u,h,S,g,d),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,v=f.length;x<v;x++){let y=f[x],_=o[y.materialIndex],S=Math.max(y.start,p.start),g=Math.min(c.count,Math.min(y.start+y.count,p.start+p.count));for(let d=S,M=g;d<M;d+=3){let m=d,R=d+1,E=d+2;i=Cu(this,_,t,n,l,u,h,m,R,E),i&&(i.faceIndex=Math.floor(d/3),i.face.materialIndex=y.materialIndex,e.push(i))}}else{let x=Math.max(0,p.start),v=Math.min(c.count,p.start+p.count);for(let y=x,_=v;y<_;y+=3){let S=y,g=y+1,d=y+2;i=Cu(this,o,t,n,l,u,h,S,g,d),i&&(i.faceIndex=Math.floor(y/3),e.push(i))}}}};function hS(s,t,e,n,i,r,o,a){let c;if(t.side===qe?c=n.intersectTriangle(o,r,i,!0,a):c=n.intersectTriangle(i,r,o,t.side===rn,a),c===null)return null;Ru.copy(a),Ru.applyMatrix4(s.matrixWorld);let l=e.ray.origin.distanceTo(Ru);return l<e.near||l>e.far?null:{distance:l,point:Ru.clone(),object:s}}function Cu(s,t,e,n,i,r,o,a,c,l){s.getVertexPosition(a,Tu),s.getVertexPosition(c,Eu),s.getVertexPosition(l,wu);let u=hS(s,t,e,n,Tu,Eu,wu,Jx);if(u){let h=new I;me.getBarycoord(Jx,Tu,Eu,wu,h),i&&(u.uv=me.getInterpolatedAttribute(i,a,c,l,h,new nt)),r&&(u.uv1=me.getInterpolatedAttribute(r,a,c,l,h,new nt)),o&&(u.normal=me.getInterpolatedAttribute(o,a,c,l,h,new I),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:c,c:l,normal:new I,materialIndex:0};me.getNormal(Tu,Eu,wu,f.normal),u.face=f,u.barycoord=h}return u}var Ui=class s extends Vt{constructor(t=1,e=1,n=1,i=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:o};let a=this;i=Math.floor(i),r=Math.floor(r),o=Math.floor(o);let c=[],l=[],u=[],h=[],f=0,p=0;x("z","y","x",-1,-1,n,e,t,o,r,0),x("z","y","x",1,-1,n,e,-t,o,r,1),x("x","z","y",1,1,t,n,e,i,o,2),x("x","z","y",1,-1,t,n,-e,i,o,3),x("x","y","z",1,-1,t,e,n,i,r,4),x("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Lt(l,3)),this.setAttribute("normal",new Lt(u,3)),this.setAttribute("uv",new Lt(h,2));function x(v,y,_,S,g,d,M,m,R,E,T){let b=d/R,w=M/E,A=d/2,C=M/2,D=m/2,F=R+1,O=E+1,H=0,B=0,$=new I;for(let at=0;at<O;at++){let rt=at*w-C;for(let ht=0;ht<F;ht++){let bt=ht*b-A;$[v]=bt*S,$[y]=rt*g,$[_]=D,l.push($.x,$.y,$.z),$[v]=0,$[y]=0,$[_]=m>0?1:-1,u.push($.x,$.y,$.z),h.push(ht/R),h.push(1-at/E),H+=1}}for(let at=0;at<E;at++)for(let rt=0;rt<R;rt++){let ht=f+rt+F*at,bt=f+rt+F*(at+1),Et=f+(rt+1)+F*(at+1),Mt=f+(rt+1)+F*at;c.push(ht,bt,Mt),c.push(bt,Et,Mt),B+=6}a.addGroup(p,B,T),p+=B,f+=H}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}};function Is(s){let t={};for(let e in s){t[e]={};for(let n in s[e]){let i=s[e][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[e][n]=null):t[e][n]=i.clone():Array.isArray(i)?t[e][n]=i.slice():t[e][n]=i}}return t}function hn(s){let t={};for(let e=0;e<s.length;e++){let n=Is(s[e]);for(let i in n)t[i]=n[i]}return t}function fS(s){let t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function mm(s){let t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ie.workingColorSpace}var gm={clone:Is,merge:hn},dS=`void main() {
|
|
2
2
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
3
3
|
}`,pS=`void main() {
|
|
4
4
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
`},i=new Ui(5,5,5),r=new Cn({name:"CubemapFromEquirect",uniforms:Is(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:qe,blending:Vi});r.uniforms.tEquirect.value=e;let o=new ce(i,r),a=e.minFilter;return e.minFilter===un&&(e.minFilter=Ee),new Za(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,i);t.setRenderTarget(r)}},nn=class extends re{constructor(){super(),this.isGroup=!0,this.type="Group"}},mS={type:"move"},fs=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new nn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new I,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new I),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new I,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new I),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(let v of t.hand.values()){let y=e.getJointPose(v,n),_=this._getHandJoint(l,v);y!==null&&(_.matrix.fromArray(y.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=y.radius),_.visible=y!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,x=.005;l.inputState.pinching&&f>p+x?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=p-x&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(mS)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new nn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},ja=class s{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new yt(t),this.density=e}clone(){return new s(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Qa=class s{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new yt(t),this.near=e,this.far=n}clone(){return new s(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Fi=class extends re{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Rn,this.environmentIntensity=1,this.environmentRotation=new Rn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},Oi=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=_o,this.updateRanges=[],this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},mn=new I,pi=class s{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.applyMatrix4(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.applyNormalMatrix(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.transformDirection(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=gn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Jt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=gn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=gn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=gn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=gn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new kt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new s(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},To=class extends Ue{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},so,Da=new I,oo=new I,ao=new I,co=new nt,Ua=new nt,R0=new vt,Iu=new I,Fa=new I,Pu=new I,t_=new nt,Xd=new nt,e_=new nt,tc=class extends re{constructor(t=new To){if(super(),this.isSprite=!0,this.type="Sprite",so===void 0){so=new Vt;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Oi(e,5);so.setIndex([0,1,2,0,2,3]),so.setAttribute("position",new pi(n,3,0,!1)),so.setAttribute("uv",new pi(n,2,3,!1))}this.geometry=so,this.material=t,this.center=new nt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),oo.setFromMatrixScale(this.matrixWorld),R0.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ao.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&oo.multiplyScalar(-ao.z);let n=this.material.rotation,i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));let o=this.center;Lu(Iu.set(-.5,-.5,0),ao,o,oo,i,r),Lu(Fa.set(.5,-.5,0),ao,o,oo,i,r),Lu(Pu.set(.5,.5,0),ao,o,oo,i,r),t_.set(0,0),Xd.set(1,0),e_.set(1,1);let a=t.ray.intersectTriangle(Iu,Fa,Pu,!1,Da);if(a===null&&(Lu(Fa.set(-.5,.5,0),ao,o,oo,i,r),Xd.set(0,1),a=t.ray.intersectTriangle(Iu,Pu,Fa,!1,Da),a===null))return;let c=t.ray.origin.distanceTo(Da);c<t.near||c>t.far||e.push({distance:c,point:Da.clone(),uv:me.getInterpolation(Da,Iu,Fa,Pu,t_,Xd,e_,new nt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};function Lu(s,t,e,n,i,r){co.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(Ua.x=r*co.x-i*co.y,Ua.y=i*co.x+r*co.y):Ua.copy(co),s.copy(t),s.x+=Ua.x,s.y+=Ua.y,s.applyMatrix4(R0)}var Nu=new I,n_=new I,ec=class extends re{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let n=0,i=e.length;n<i;n++){let r=e[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);let i=this.levels,r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){let e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){let i=e.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){let e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let r=e[n].distance;if(e[n].object.visible&&(r-=r*e[n].hysteresis),t<r)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Nu.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(Nu);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){Nu.setFromMatrixPosition(t.matrixWorld),n_.setFromMatrixPosition(this.matrixWorld);let n=Nu.distanceTo(n_)/t.zoom;e[0].object.visible=!0;let i,r;for(i=1,r=e.length;i<r;i++){let o=e[i].distance;if(e[i].object.visible&&(o-=o*e[i].hysteresis),n>=o)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){let e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];let n=this.levels;for(let i=0,r=n.length;i<r;i++){let o=n[i];e.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return e}},i_=new I,r_=new Qt,s_=new Qt,gS=new I,o_=new vt,Du=new I,qd=new Be,a_=new vt,Yd=new _n,mi=class extends ce{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nh,this.bindMatrix=new vt,this.bindMatrixInverse=new vt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let t=this.geometry;this.boundingBox===null&&(this.boundingBox=new ne),this.boundingBox.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Du),this.boundingBox.expandByPoint(Du)}computeBoundingSphere(){let t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Be),this.boundingSphere.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Du),this.boundingSphere.expandByPoint(Du)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){let n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),qd.copy(this.boundingSphere),qd.applyMatrix4(i),t.ray.intersectsSphere(qd)!==!1&&(a_.copy(i).invert(),Yd.copy(t.ray).applyMatrix4(a_),!(this.boundingBox!==null&&Yd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,Yd)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let t=new Qt,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);let r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===nh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Jp?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){let n=this.skeleton,i=this.geometry;r_.fromBufferAttribute(i.attributes.skinIndex,t),s_.fromBufferAttribute(i.attributes.skinWeight,t),i_.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let o=s_.getComponent(r);if(o!==0){let a=r_.getComponent(r);o_.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),e.addScaledVector(gS.copy(i_).applyMatrix4(o_),o)}}return e.applyMatrix4(this.bindMatrixInverse)}},Cr=class extends re{constructor(){super(),this.isBone=!0,this.type="Bone"}},zn=class extends Ie{constructor(t=null,e=1,n=1,i,r,o,a,c,l=De,u=De,h,f){super(null,o,a,c,l,u,i,r,h,f),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},c_=new vt,xS=new vt,ds=class s{constructor(t=[],e=[]){this.uuid=Bn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new vt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new vt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=t.length;r<o;r++){let a=t[r]?t[r].matrixWorld:xS;c_.multiplyMatrices(a,e[r]),c_.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new s(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new zn(e,t,t,Qe,xn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){let r=t.bones[n],o=e[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Cr),this.bones.push(o),this.boneInverses.push(new vt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){let o=e[i];t.bones.push(o.uuid);let a=n[i];t.boneInverses.push(a.toArray())}return t}},ti=class extends kt{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},lo=new vt,l_=new vt,Uu=[],u_=new ne,_S=new vt,Oa=new ce,Ba=new Be,ei=class extends ce{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ti(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,_S)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new ne),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,lo),u_.copy(t.boundingBox).applyMatrix4(lo),this.boundingBox.union(u_)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Be),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,lo),Ba.copy(t.boundingSphere).applyMatrix4(lo),this.boundingSphere.union(Ba)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=t*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(t,e){let n=this.matrixWorld,i=this.count;if(Oa.geometry=this.geometry,Oa.material=this.material,Oa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ba.copy(this.boundingSphere),Ba.applyMatrix4(n),t.ray.intersectsSphere(Ba)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,lo),l_.multiplyMatrices(n,lo),Oa.matrixWorld=l_,Oa.raycast(t,Uu);for(let o=0,a=Uu.length;o<a;o++){let c=Uu[o];c.instanceId=r,c.object=this,e.push(c)}Uu.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new ti(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new zn(new Float32Array(i*this.count),i,this.count,al,xn));let r=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=i*t;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},$d=new I,yS=new I,vS=new $t,$e=class{constructor(t=new I(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=$d.subVectors(n,e).cross(yS.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta($d),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||vS.getNormalMatrix(t),i=this.coplanarPoint($d).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Yr=new Be,MS=new nt(.5,.5),Fu=new I,or=class{constructor(t=new $e,e=new $e,n=new $e,i=new $e,r=new $e,o=new $e){this.planes=[t,e,n,i,r,o]}set(t,e,n,i,r,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=wn,n=!1){let i=this.planes,r=t.elements,o=r[0],a=r[1],c=r[2],l=r[3],u=r[4],h=r[5],f=r[6],p=r[7],x=r[8],v=r[9],y=r[10],_=r[11],S=r[12],g=r[13],d=r[14],M=r[15];if(i[0].setComponents(l-o,p-u,_-x,M-S).normalize(),i[1].setComponents(l+o,p+u,_+x,M+S).normalize(),i[2].setComponents(l+a,p+h,_+v,M+g).normalize(),i[3].setComponents(l-a,p-h,_-v,M-g).normalize(),n)i[4].setComponents(c,f,y,d).normalize(),i[5].setComponents(l-c,p-f,_-y,M-d).normalize();else if(i[4].setComponents(l-c,p-f,_-y,M-d).normalize(),e===wn)i[5].setComponents(l+c,p+f,_+y,M+d).normalize();else if(e===ss)i[5].setComponents(c,f,y,d).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Yr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Yr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Yr)}intersectsSprite(t){Yr.center.set(0,0,0);let e=MS.distanceTo(t.center);return Yr.radius=.7071067811865476+e,Yr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Yr)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(Fu.x=i.normal.x>0?t.max.x:t.min.x,Fu.y=i.normal.y>0?t.max.y:t.min.y,Fu.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Fu)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Ci=new vt,Ii=new or,nc=class s{constructor(){this.coordinateSystem=wn}intersectsObject(t,e){if(!e.isArrayCamera||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.containsPoint(t))return!0}return!1}clone(){return new s}};function Kd(s,t){return s-t}function SS(s,t){return s.z-t.z}function bS(s,t){return t.z-s.z}var lp=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){let r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];o.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}},Tn=new vt,TS=new yt(1,1,1),h_=new or,ES=new nc,Ou=new ne,$r=new Be,za=new I,f_=new I,wS=new I,Zd=new lp,cn=new ce,Bu=[];function AS(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)t.setComponent(r+e,o,s.getComponent(r,o))}else t.array.set(s.array,e*n);t.needsUpdate=!0}function Kr(s,t){if(s.constructor!==t.constructor){let e=Math.min(s.length,t.length);for(let n=0;n<e;n++)t[n]=s[n]}else{let e=Math.min(s.length,t.length);t.set(new s.constructor(s.buffer,0,e))}}var ic=class extends ce{constructor(t,e,n=e*2,i){super(new Vt,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4),n=new zn(e,t,t,Qe,xn);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Uint32Array(t*t),n=new zn(e,t,t,Ko,qi);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Float32Array(t*t*4).fill(1),n=new zn(e,t,t,Qe,xn);n.colorSpace=ie.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){let e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in t.attributes){let o=t.getAttribute(r),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new kt(u,c,l);e.setAttribute(r,h)}if(t.getIndex()!==null){let r=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new kt(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){let e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){let e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ne);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Tn),this.getBoundingBoxAt(r,Ou).applyMatrix4(Tn),t.union(Ou)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Be);let t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Tn),this.getBoundingSphereAt(r,$r).applyMatrix4(Tn),t.union($r)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Kd),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let r=this._matricesTexture;Tn.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;let o=this._colorsTexture;return o&&(TS.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);let i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;let o=t.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Kd),c=this._availableGeometryIds.shift(),r[c]=i):(c=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(c,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=e.getIndex(),a=this._geometryInfo[t];if(i&&o.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(let u in n.attributes){let h=e.getAttribute(u),f=n.getAttribute(u);AS(h,f,c);let p=h.itemSize;for(let x=h.count,v=l;x<v;x++){let y=c+x;for(let _=0;_<p;_++)f.setComponent(y,_,0)}f.needsUpdate=!0,f.addUpdateRange(c*p,l*p)}if(i){let u=a.indexStart,h=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let f=0;f<o.count;f++)r.setX(u+f,c+o.getX(f));for(let f=o.count,p=h;f<p;f++)r.setX(u+f,c);r.needsUpdate=!0,r.addUpdateRange(u,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,e.boundingBox!==null&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,e.boundingSphere!==null&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){let e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;let n=this._instanceInfo;for(let i=0,r=n.length;i<r;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0,n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),r=this.geometry;for(let o=0,a=n.length;o<a;o++){let c=i[o],l=n[c];if(l.active!==!1){if(r.index!==null){if(l.indexStart!==e){let{indexStart:u,vertexStart:h,reservedIndexCount:f}=l,p=r.index,x=p.array,v=t-h;for(let y=u;y<u+f;y++)x[y]=x[y]+v;p.array.copyWithin(e,u,u+f),p.addUpdateRange(e,f),l.indexStart=e}e+=l.reservedIndexCount}if(l.vertexStart!==t){let{vertexStart:u,reservedVertexCount:h}=l,f=r.attributes;for(let p in f){let x=f[p],{array:v,itemSize:y}=x;v.copyWithin(t*y,u*y,(u+h)*y),x.addUpdateRange(t*y,h*y)}l.vertexStart=t}t+=l.reservedVertexCount,l.start=r.index?l.indexStart:l.vertexStart,this._nextIndexStart=r.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){let r=new ne,o=n.index,a=n.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let u=c;o&&(u=o.getX(u)),r.expandByPoint(za.fromBufferAttribute(a,u))}i.boundingBox=r}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){let r=new Be;this.getBoundingBoxAt(t,Ou),Ou.getCenter(r.center);let o=n.index,a=n.attributes.position,c=0;for(let l=i.start,u=i.start+i.count;l<u;l++){let h=l;o&&(h=o.getX(h)),za.fromBufferAttribute(a,h),c=Math.max(c,r.center.distanceToSquared(za))}r.radius=Math.sqrt(c),i.boundingSphere=r}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);let n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,t*16),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);let n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){let e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(Kd);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);let i=new Int32Array(t),r=new Int32Array(t);Kr(this._multiDrawCounts,i),Kr(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;let o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),Kr(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Kr(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),Kr(c.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){let n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Vt,this._initializeGeometry(r));let o=this.geometry;r.index&&Kr(r.index.array,o.index.array);for(let a in r.attributes)Kr(r.attributes[a].array,o.attributes[a].array)}raycast(t,e){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;cn.material=this.material,cn.geometry.index=o.index,cn.geometry.attributes=o.attributes,cn.geometry.boundingBox===null&&(cn.geometry.boundingBox=new ne),cn.geometry.boundingSphere===null&&(cn.geometry.boundingSphere=new Be);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;let l=n[a].geometryIndex,u=i[l];cn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,cn.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,cn.geometry.boundingBox),this.getBoundingSphereAt(l,cn.geometry.boundingSphere),cn.raycast(t,Bu);for(let h=0,f=Bu.length;h<f;h++){let p=Bu[h];p.object=this,p.batchId=a,e.push(p)}Bu.length=0}cn.material=null,cn.geometry.index=null,cn.geometry.attributes={},cn.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,x=p.image.data,v=n.isArrayCamera?ES:h_;f&&!n.isArrayCamera&&(Tn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),h_.setFromProjectionMatrix(Tn,n.coordinateSystem,n.reversedDepth));let y=0;if(this.sortObjects){Tn.copy(this.matrixWorld).invert(),za.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Tn),f_.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Tn);for(let g=0,d=c.length;g<d;g++)if(c[g].visible&&c[g].active){let M=c[g].geometryIndex;this.getMatrixAt(g,Tn),this.getBoundingSphereAt(M,$r).applyMatrix4(Tn);let m=!1;if(f&&(m=!v.intersectsSphere($r,n)),!m){let R=h[M],E=wS.subVectors($r.center,za).dot(f_);Zd.push(R.start,R.count,E,g)}}let _=Zd.list,S=this.customSort;S===null?_.sort(r.transparent?bS:SS):S.call(this,_,n);for(let g=0,d=_.length;g<d;g++){let M=_[g];l[y]=M.start*a,u[y]=M.count,x[y]=M.index,y++}Zd.reset()}else for(let _=0,S=c.length;_<S;_++)if(c[_].visible&&c[_].active){let g=c[_].geometryIndex,d=!1;if(f&&(this.getMatrixAt(_,Tn),this.getBoundingSphereAt(g,$r).applyMatrix4(Tn),d=!v.intersectsSphere($r,n)),!d){let M=h[g];l[y]=M.start*a,u[y]=M.count,x[y]=_,y++}}p.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,o){this.onBeforeRender(t,null,i,r,o)}},Xe=class extends Ue{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},dh=new I,ph=new I,d_=new vt,ka=new _n,zu=new Be,Jd=new I,p_=new I,Vn=class extends re{constructor(t=new Vt,e=new Xe){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)dh.fromBufferAttribute(e,i-1),ph.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=dh.distanceTo(ph);t.setAttribute("lineDistance",new Lt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zu.copy(n.boundingSphere),zu.applyMatrix4(i),zu.radius+=r,t.ray.intersectsSphere(zu)===!1)return;d_.copy(i).invert(),ka.copy(t.ray).applyMatrix4(d_);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,f=n.attributes.position;if(u!==null){let p=Math.max(0,o.start),x=Math.min(u.count,o.start+o.count);for(let v=p,y=x-1;v<y;v+=l){let _=u.getX(v),S=u.getX(v+1),g=ku(this,t,ka,c,_,S,v);g&&e.push(g)}if(this.isLineLoop){let v=u.getX(x-1),y=u.getX(p),_=ku(this,t,ka,c,v,y,x-1);_&&e.push(_)}}else{let p=Math.max(0,o.start),x=Math.min(f.count,o.start+o.count);for(let v=p,y=x-1;v<y;v+=l){let _=ku(this,t,ka,c,v,v+1,v);_&&e.push(_)}if(this.isLineLoop){let v=ku(this,t,ka,c,x-1,p,x-1);v&&e.push(v)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function ku(s,t,e,n,i,r,o){let a=s.geometry.attributes.position;if(dh.fromBufferAttribute(a,i),ph.fromBufferAttribute(a,r),e.distanceSqToSegment(dh,ph,Jd,p_)>n)return;Jd.applyMatrix4(s.matrixWorld);let l=t.ray.origin.distanceTo(Jd);if(!(l<t.near||l>t.far))return{distance:l,point:p_.clone().applyMatrix4(s.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:s}}var m_=new I,g_=new I,yn=class extends Vn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)m_.fromBufferAttribute(e,i),g_.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+m_.distanceTo(g_);t.setAttribute("lineDistance",new Lt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},ps=class extends Vn{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}},Ir=class extends Ue{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},x_=new vt,up=new _n,Hu=new Be,Vu=new I,ms=class extends re{constructor(t=new Vt,e=new Ir){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Hu.copy(n.boundingSphere),Hu.applyMatrix4(i),Hu.radius+=r,t.ray.intersectsSphere(Hu)===!1)return;x_.copy(i).invert(),up.copy(t.ray).applyMatrix4(x_);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){let f=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let x=f,v=p;x<v;x++){let y=l.getX(x);Vu.fromBufferAttribute(h,y),__(Vu,y,c,i,t,e,this)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let x=f,v=p;x<v;x++)Vu.fromBufferAttribute(h,x),__(Vu,x,c,i,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function __(s,t,e,n,i,r,o){let a=up.distanceSqToPoint(s);if(a<e){let c=new I;up.closestPointToPoint(s,c),c.applyMatrix4(n);let l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var rc=class extends Ie{constructor(t,e,n,i,r=Ee,o=Ee,a,c,l){super(t,e,n,i,r,o,a,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let u=this;function h(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(h))}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}},mh=class extends rc{constructor(t,e,n,i,r,o,a,c){super({},t,e,n,i,r,o,a,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},gh=class extends Ie{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=De,this.minFilter=De,this.generateMipmaps=!1,this.needsUpdate=!0}},gi=class extends Ie{constructor(t,e,n,i,r,o,a,c,l,u,h,f){super(null,o,a,c,l,u,i,r,h,f),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}},xh=class extends gi{constructor(t,e,n,i,r,o){super(t,e,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=en,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},_h=class extends gi{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Wi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},Eo=class extends Ie{constructor(t,e,n,i,r,o,a,c,l){super(t,e,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},wo=class extends Ie{constructor(t,e,n=qi,i,r,o,a=De,c=De,l,u=rs,h=1){if(u!==rs&&u!==Rs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:t,height:e,depth:h};super(f,i,r,o,a,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new On(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},Ao=class extends Ie{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},sc=class s extends Vt{constructor(t=1,e=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:r},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));let o=[],a=[],c=[],l=[],u=e/2,h=Math.PI/2*t,f=e,p=2*h+f,x=n*2+r,v=i+1,y=new I,_=new I;for(let S=0;S<=x;S++){let g=0,d=0,M=0,m=0;if(S<=n){let T=S/n,b=T*Math.PI/2;d=-u-t*Math.cos(b),M=t*Math.sin(b),m=-t*Math.cos(b),g=T*h}else if(S<=n+r){let T=(S-n)/r;d=-u+T*e,M=t,m=0,g=h+T*f}else{let T=(S-n-r)/n,b=T*Math.PI/2;d=u+t*Math.sin(b),M=t*Math.cos(b),m=t*Math.sin(b),g=h+f+T*h}let R=Math.max(0,Math.min(1,g/p)),E=0;S===0?E=.5/i:S===x&&(E=-.5/i);for(let T=0;T<=i;T++){let b=T/i,w=b*Math.PI*2,A=Math.sin(w),C=Math.cos(w);_.x=-M*C,_.y=d,_.z=M*A,a.push(_.x,_.y,_.z),y.set(-M*C,m,M*A),y.normalize(),c.push(y.x,y.y,y.z),l.push(b+E,R)}if(S>0){let T=(S-1)*v;for(let b=0;b<i;b++){let w=T+b,A=T+b+1,C=S*v+b,D=S*v+b+1;o.push(w,A,C),o.push(A,D,C)}}}this.setIndex(o),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},oc=class s extends Vt{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);let r=[],o=[],a=[],c=[],l=new I,u=new nt;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=e;h++,f+=3){let p=n+h/e*i;l.x=t*Math.cos(p),l.y=t*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/t+1)/2,u.y=(o[f+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Lt(o,3)),this.setAttribute("normal",new Lt(a,3)),this.setAttribute("uv",new Lt(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.segments,t.thetaStart,t.thetaLength)}},Ro=class s extends Vt{constructor(t=1,e=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};let l=this;i=Math.floor(i),r=Math.floor(r);let u=[],h=[],f=[],p=[],x=0,v=[],y=n/2,_=0;S(),o===!1&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(u),this.setAttribute("position",new Lt(h,3)),this.setAttribute("normal",new Lt(f,3)),this.setAttribute("uv",new Lt(p,2));function S(){let d=new I,M=new I,m=0,R=(e-t)/n;for(let E=0;E<=r;E++){let T=[],b=E/r,w=b*(e-t)+t;for(let A=0;A<=i;A++){let C=A/i,D=C*c+a,F=Math.sin(D),O=Math.cos(D);M.x=w*F,M.y=-b*n+y,M.z=w*O,h.push(M.x,M.y,M.z),d.set(F,R,O).normalize(),f.push(d.x,d.y,d.z),p.push(C,1-b),T.push(x++)}v.push(T)}for(let E=0;E<i;E++)for(let T=0;T<r;T++){let b=v[T][E],w=v[T+1][E],A=v[T+1][E+1],C=v[T][E+1];(t>0||T!==0)&&(u.push(b,w,C),m+=3),(e>0||T!==r-1)&&(u.push(w,A,C),m+=3)}l.addGroup(_,m,0),_+=m}function g(d){let M=x,m=new nt,R=new I,E=0,T=d===!0?t:e,b=d===!0?1:-1;for(let A=1;A<=i;A++)h.push(0,y*b,0),f.push(0,b,0),p.push(.5,.5),x++;let w=x;for(let A=0;A<=i;A++){let D=A/i*c+a,F=Math.cos(D),O=Math.sin(D);R.x=T*O,R.y=y*b,R.z=T*F,h.push(R.x,R.y,R.z),f.push(0,b,0),m.x=F*.5+.5,m.y=O*.5*b+.5,p.push(m.x,m.y),x++}for(let A=0;A<i;A++){let C=M+A,D=w+A;d===!0?u.push(D,D+1,C):u.push(D+1,D,C),E+=3}l.addGroup(_,E,d===!0?1:2),_+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Co=class s extends Ro{constructor(t=1,e=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(t){return new s(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ar=class s extends Vt{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let r=[],o=[];a(i),l(n),u(),this.setAttribute("position",new Lt(r,3)),this.setAttribute("normal",new Lt(r.slice(),3)),this.setAttribute("uv",new Lt(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(S){let g=new I,d=new I,M=new I;for(let m=0;m<e.length;m+=3)p(e[m+0],g),p(e[m+1],d),p(e[m+2],M),c(g,d,M,S)}function c(S,g,d,M){let m=M+1,R=[];for(let E=0;E<=m;E++){R[E]=[];let T=S.clone().lerp(d,E/m),b=g.clone().lerp(d,E/m),w=m-E;for(let A=0;A<=w;A++)A===0&&E===m?R[E][A]=T:R[E][A]=T.clone().lerp(b,A/w)}for(let E=0;E<m;E++)for(let T=0;T<2*(m-E)-1;T++){let b=Math.floor(T/2);T%2===0?(f(R[E][b+1]),f(R[E+1][b]),f(R[E][b])):(f(R[E][b+1]),f(R[E+1][b+1]),f(R[E+1][b]))}}function l(S){let g=new I;for(let d=0;d<r.length;d+=3)g.x=r[d+0],g.y=r[d+1],g.z=r[d+2],g.normalize().multiplyScalar(S),r[d+0]=g.x,r[d+1]=g.y,r[d+2]=g.z}function u(){let S=new I;for(let g=0;g<r.length;g+=3){S.x=r[g+0],S.y=r[g+1],S.z=r[g+2];let d=y(S)/2/Math.PI+.5,M=_(S)/Math.PI+.5;o.push(d,1-M)}x(),h()}function h(){for(let S=0;S<o.length;S+=6){let g=o[S+0],d=o[S+2],M=o[S+4],m=Math.max(g,d,M),R=Math.min(g,d,M);m>.9&&R<.1&&(g<.2&&(o[S+0]+=1),d<.2&&(o[S+2]+=1),M<.2&&(o[S+4]+=1))}}function f(S){r.push(S.x,S.y,S.z)}function p(S,g){let d=S*3;g.x=t[d+0],g.y=t[d+1],g.z=t[d+2]}function x(){let S=new I,g=new I,d=new I,M=new I,m=new nt,R=new nt,E=new nt;for(let T=0,b=0;T<r.length;T+=9,b+=6){S.set(r[T+0],r[T+1],r[T+2]),g.set(r[T+3],r[T+4],r[T+5]),d.set(r[T+6],r[T+7],r[T+8]),m.set(o[b+0],o[b+1]),R.set(o[b+2],o[b+3]),E.set(o[b+4],o[b+5]),M.copy(S).add(g).add(d).divideScalar(3);let w=y(M);v(m,b+0,S,w),v(R,b+2,g,w),v(E,b+4,d,w)}}function v(S,g,d,M){M<0&&S.x===1&&(o[g]=S.x-1),d.x===0&&d.z===0&&(o[g]=M/2/Math.PI+.5)}function y(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.vertices,t.indices,t.radius,t.details)}},ac=class s extends ar{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,r=[-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[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];super(r,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},Gu=new I,Wu=new I,jd=new I,Xu=new me,cc=class extends Vt{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){let i=Math.pow(10,4),r=Math.cos(is*e),o=t.getIndex(),a=t.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},p=[];for(let x=0;x<c;x+=3){o?(l[0]=o.getX(x),l[1]=o.getX(x+1),l[2]=o.getX(x+2)):(l[0]=x,l[1]=x+1,l[2]=x+2);let{a:v,b:y,c:_}=Xu;if(v.fromBufferAttribute(a,l[0]),y.fromBufferAttribute(a,l[1]),_.fromBufferAttribute(a,l[2]),Xu.getNormal(jd),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,h[2]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let S=0;S<3;S++){let g=(S+1)%3,d=h[S],M=h[g],m=Xu[u[S]],R=Xu[u[g]],E=`${d}_${M}`,T=`${M}_${d}`;T in f&&f[T]?(jd.dot(f[T].normal)<=r&&(p.push(m.x,m.y,m.z),p.push(R.x,R.y,R.z)),f[T]=null):E in f||(f[E]={index0:l[S],index1:l[g],normal:jd.clone()})}}for(let x in f)if(f[x]){let{index0:v,index1:y}=f[x];Gu.fromBufferAttribute(a,v),Wu.fromBufferAttribute(a,y),p.push(Gu.x,Gu.y,Gu.z),p.push(Wu.x,Wu.y,Wu.z)}this.setAttribute("position",new Lt(p,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}},In=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){let n=this.getLengths(),i=0,r=n.length,o;e?o=e:o=t*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);let u=n[i],f=n[i+1]-u,p=(o-u)/f;return(i+p)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let o=this.getPoint(i),a=this.getPoint(r),c=e||(o.isVector2?new nt:new I);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){let n=new I,i=[],r=[],o=[],a=new I,c=new vt;for(let p=0;p<=t;p++){let x=p/t;i[p]=this.getTangentAt(x,new I)}r[0]=new I,o[0]=new I;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=t;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();let x=Math.acos(Xt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(a,x))}o[p].crossVectors(i[p],r[p])}if(e===!0){let p=Math.acos(Xt(r[0].dot(r[t]),-1,1));p/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(p=-p);for(let x=1;x<=t;x++)r[x].applyMatrix4(c.makeRotationAxis(i[x],p*x)),o[x].crossVectors(i[x],r[x])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},gs=class extends In{constructor(t=0,e=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new nt){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);let a=this.aStartAngle+t*r,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,p=l-this.aY;c=f*u-p*h+this.aX,l=f*h+p*u+this.aY}return n.set(c,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},lc=class extends gs{constructor(t,e,n,i,r,o){super(t,e,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}};function gm(){let s=0,t=0,e=0,n=0;function i(r,o,a,c){s=r,t=a,e=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,u,h){let f=(o-r)/l-(a-r)/(l+u)+(a-o)/u,p=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,p*=u,i(o,a,f,p)},calc:function(r){let o=r*r,a=o*r;return s+t*r+e*o+n*a}}}var qu=new I,Qd=new gm,tp=new gm,ep=new gm,uc=class extends In{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new I){let n=e,i=this.points,r=i.length,o=(r-(this.closed?0:1))*t,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%r]:(qu.subVectors(i[0],i[1]).add(i[0]),l=qu);let h=i[a%r],f=i[(a+1)%r];if(this.closed||a+2<r?u=i[(a+2)%r]:(qu.subVectors(i[r-1],i[r-2]).add(i[r-1]),u=qu),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,x=Math.pow(l.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(f),p),y=Math.pow(f.distanceToSquared(u),p);v<1e-4&&(v=1),x<1e-4&&(x=v),y<1e-4&&(y=v),Qd.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,x,v,y),tp.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,x,v,y),ep.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,x,v,y)}else this.curveType==="catmullrom"&&(Qd.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),tp.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),ep.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(Qd.calc(c),tp.calc(c),ep.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new I().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function y_(s,t,e,n,i){let r=(n-t)*.5,o=(i-e)*.5,a=s*s,c=s*a;return(2*e-2*n+r+o)*c+(-3*e+3*n-2*r-o)*a+r*s+e}function RS(s,t){let e=1-s;return e*e*t}function CS(s,t){return 2*(1-s)*s*t}function IS(s,t){return s*s*t}function qa(s,t,e,n){return RS(s,t)+CS(s,e)+IS(s,n)}function PS(s,t){let e=1-s;return e*e*e*t}function LS(s,t){let e=1-s;return 3*e*e*s*t}function NS(s,t){return 3*(1-s)*s*s*t}function DS(s,t){return s*s*s*t}function Ya(s,t,e,n,i){return PS(s,t)+LS(s,e)+NS(s,n)+DS(s,i)}var Io=class extends In{constructor(t=new nt,e=new nt,n=new nt,i=new nt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new nt){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ya(t,i.x,r.x,o.x,a.x),Ya(t,i.y,r.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},hc=class extends In{constructor(t=new I,e=new I,n=new I,i=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new I){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ya(t,i.x,r.x,o.x,a.x),Ya(t,i.y,r.y,o.y,a.y),Ya(t,i.z,r.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Po=class extends In{constructor(t=new nt,e=new nt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new nt){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new nt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},fc=class extends In{constructor(t=new I,e=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new I){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new I){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Lo=class extends In{constructor(t=new nt,e=new nt,n=new nt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new nt){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(qa(t,i.x,r.x,o.x),qa(t,i.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},No=class extends In{constructor(t=new I,e=new I,n=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new I){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(qa(t,i.x,r.x,o.x),qa(t,i.y,r.y,o.y),qa(t,i.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Do=class extends In{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new nt){let n=e,i=this.points,r=(i.length-1)*t,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(y_(a,c.x,l.x,u.x,h.x),y_(a,c.y,l.y,u.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new nt().fromArray(i))}return this}},yh=Object.freeze({__proto__:null,ArcCurve:lc,CatmullRomCurve3:uc,CubicBezierCurve:Io,CubicBezierCurve3:hc,EllipseCurve:gs,LineCurve:Po,LineCurve3:fc,QuadraticBezierCurve:Lo,QuadraticBezierCurve3:No,SplineCurve:Do}),dc=class extends In{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new yh[n](e,t))}return this}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,r=this.curves;i<r.length;i++){let o=r[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];n&&n.equals(u)||(e.push(u),n=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new yh[i.type]().fromJSON(i))}return this}},xs=class extends dc{constructor(t){super(),this.type="Path",this.currentPoint=new nt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Po(this.currentPoint.clone(),new nt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let r=new Lo(this.currentPoint.clone(),new nt(t,e),new nt(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,o){let a=new Io(this.currentPoint.clone(),new nt(t,e),new nt(n,i),new nt(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Do(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,i,r,o),this}absarc(t,e,n,i,r,o){return this.absellipse(t,e,n,n,i,r,o),this}ellipse(t,e,n,i,r,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,i,r,o,a,c),this}absellipse(t,e,n,i,r,o,a,c){let l=new gs(t,e,n,i,r,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Pi=class extends xs{constructor(t){super(t),this.uuid=Bn(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new xs().fromJSON(i))}return this}};function US(s,t,e=2){let n=t&&t.length,i=n?t[0]*e:s.length,r=C0(s,0,i,e,!0),o=[];if(!r||r.next===r.prev)return o;let a,c,l;if(n&&(r=kS(s,t,r,e)),s.length>80*e){a=1/0,c=1/0;let u=-1/0,h=-1/0;for(let f=e;f<i;f+=e){let p=s[f],x=s[f+1];p<a&&(a=p),x<c&&(c=x),p>u&&(u=p),x>h&&(h=x)}l=Math.max(u-a,h-c),l=l!==0?32767/l:0}return pc(r,o,e,a,c,l,0),o}function C0(s,t,e,n,i){let r;if(i===JS(s,t,e,n)>0)for(let o=t;o<e;o+=n)r=v_(o/n|0,s[o],s[o+1],r);else for(let o=e-n;o>=t;o-=n)r=v_(o/n|0,s[o],s[o+1],r);return r&&Uo(r,r.next)&&(gc(r),r=r.next),r}function _s(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Uo(e,e.next)||Ne(e.prev,e,e.next)===0)){if(gc(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function pc(s,t,e,n,i,r,o){if(!s)return;!o&&r&&XS(s,n,i,r);let a=s;for(;s.prev!==s.next;){let c=s.prev,l=s.next;if(r?OS(s,n,i,r):FS(s)){t.push(c.i,s.i,l.i),gc(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=BS(_s(s),t),pc(s,t,e,n,i,r,2)):o===2&&zS(s,t,e,n,i,r):pc(_s(s),t,e,n,i,r,1);break}}}function FS(s){let t=s.prev,e=s,n=s.next;if(Ne(t,e,n)>=0)return!1;let i=t.x,r=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=Math.min(i,r,o),h=Math.min(a,c,l),f=Math.max(i,r,o),p=Math.max(a,c,l),x=n.next;for(;x!==t;){if(x.x>=u&&x.x<=f&&x.y>=h&&x.y<=p&&Ga(i,a,r,c,o,l,x.x,x.y)&&Ne(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function OS(s,t,e,n){let i=s.prev,r=s,o=s.next;if(Ne(i,r,o)>=0)return!1;let a=i.x,c=r.x,l=o.x,u=i.y,h=r.y,f=o.y,p=Math.min(a,c,l),x=Math.min(u,h,f),v=Math.max(a,c,l),y=Math.max(u,h,f),_=hp(p,x,t,e,n),S=hp(v,y,t,e,n),g=s.prevZ,d=s.nextZ;for(;g&&g.z>=_&&d&&d.z<=S;){if(g.x>=p&&g.x<=v&&g.y>=x&&g.y<=y&&g!==i&&g!==o&&Ga(a,u,c,h,l,f,g.x,g.y)&&Ne(g.prev,g,g.next)>=0||(g=g.prevZ,d.x>=p&&d.x<=v&&d.y>=x&&d.y<=y&&d!==i&&d!==o&&Ga(a,u,c,h,l,f,d.x,d.y)&&Ne(d.prev,d,d.next)>=0))return!1;d=d.nextZ}for(;g&&g.z>=_;){if(g.x>=p&&g.x<=v&&g.y>=x&&g.y<=y&&g!==i&&g!==o&&Ga(a,u,c,h,l,f,g.x,g.y)&&Ne(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;d&&d.z<=S;){if(d.x>=p&&d.x<=v&&d.y>=x&&d.y<=y&&d!==i&&d!==o&&Ga(a,u,c,h,l,f,d.x,d.y)&&Ne(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function BS(s,t){let e=s;do{let n=e.prev,i=e.next.next;!Uo(n,i)&&P0(n,e,e.next,i)&&mc(n,i)&&mc(i,n)&&(t.push(n.i,e.i,i.i),gc(e),gc(e.next),e=s=i),e=e.next}while(e!==s);return _s(e)}function zS(s,t,e,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&$S(o,a)){let c=L0(o,a);o=_s(o,o.next),c=_s(c,c.next),pc(o,t,e,n,i,r,0),pc(c,t,e,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function kS(s,t,e,n){let i=[];for(let r=0,o=t.length;r<o;r++){let a=t[r]*n,c=r<o-1?t[r+1]*n:s.length,l=C0(s,a,c,n,!1);l===l.next&&(l.steiner=!0),i.push(YS(l))}i.sort(HS);for(let r=0;r<i.length;r++)e=VS(i[r],e);return e}function HS(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){let n=(s.next.y-s.y)/(s.next.x-s.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=n-i}return e}function VS(s,t){let e=GS(s,t);if(!e)return t;let n=L0(e,s);return _s(n,n.next),_s(e,e.next)}function GS(s,t){let e=t,n=s.x,i=s.y,r=-1/0,o;if(Uo(s,e))return e;do{if(Uo(s,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let h=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=n&&h>r&&(r=h,o=e.x<e.next.x?e:e.next,h===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0;e=o;do{if(n>=e.x&&e.x>=c&&n!==e.x&&I0(i<l?n:r,i,c,l,i<l?r:n,i,e.x,e.y)){let h=Math.abs(i-e.y)/(n-e.x);mc(e,s)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&WS(o,e)))&&(o=e,u=h)}e=e.next}while(e!==a);return o}function WS(s,t){return Ne(s.prev,s,t.prev)<0&&Ne(t.next,s,s.next)<0}function XS(s,t,e,n){let i=s;do i.z===0&&(i.z=hp(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,qS(i)}function qS(s){let t,e=1;do{let n=s,i;s=null;let r=null;for(t=0;n;){t++;let o=n,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let c=e;for(;a>0||c>0&&o;)a!==0&&(c===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=o}r.nextZ=null,e*=2}while(t>1);return s}function hp(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function YS(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function I0(s,t,e,n,i,r,o,a){return(i-o)*(t-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(i-o)*(n-a)}function Ga(s,t,e,n,i,r,o,a){return!(s===o&&t===a)&&I0(s,t,e,n,i,r,o,a)}function $S(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!KS(s,t)&&(mc(s,t)&&mc(t,s)&&ZS(s,t)&&(Ne(s.prev,s,t.prev)||Ne(s,t.prev,t))||Uo(s,t)&&Ne(s.prev,s,s.next)>0&&Ne(t.prev,t,t.next)>0)}function Ne(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Uo(s,t){return s.x===t.x&&s.y===t.y}function P0(s,t,e,n){let i=$u(Ne(s,t,e)),r=$u(Ne(s,t,n)),o=$u(Ne(e,n,s)),a=$u(Ne(e,n,t));return!!(i!==r&&o!==a||i===0&&Yu(s,e,t)||r===0&&Yu(s,n,t)||o===0&&Yu(e,s,n)||a===0&&Yu(e,t,n))}function Yu(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function $u(s){return s>0?1:s<0?-1:0}function KS(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&P0(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function mc(s,t){return Ne(s.prev,s,s.next)<0?Ne(s,t,s.next)>=0&&Ne(s,s.prev,t)>=0:Ne(s,t,s.prev)<0||Ne(s,s.next,t)<0}function ZS(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function L0(s,t){let e=fp(s.i,s.x,s.y),n=fp(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function v_(s,t,e,n){let i=fp(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function gc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function fp(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function JS(s,t,e,n){let i=0;for(let r=t,o=e-n;r<e;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}var dp=class{static triangulate(t,e,n=2){return US(t,e,n)}},Qn=class s{static area(t){let e=t.length,n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return n*.5}static isClockWise(t){return s.area(t)<0}static triangulateShape(t,e){let n=[],i=[],r=[];M_(t),S_(n,t);let o=t.length;e.forEach(M_);for(let c=0;c<e.length;c++)i.push(o),o+=e[c].length,S_(n,e[c]);let a=dp.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}};function M_(s){let t=s.length;t>2&&s[t-1].equals(s[0])&&s.pop()}function S_(s,t){for(let e=0;e<t.length;e++)s.push(t[e].x),s.push(t[e].y)}var xc=class s extends Vt{constructor(t=new Pi([new nt(.5,.5),new nt(-.5,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let n=this,i=[],r=[];for(let a=0,c=t.length;a<c;a++){let l=t[a];o(l)}this.setAttribute("position",new Lt(i,3)),this.setAttribute("uv",new Lt(r,2)),this.computeVertexNormals();function o(a){let c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1,f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,p=e.bevelThickness!==void 0?e.bevelThickness:.2,x=e.bevelSize!==void 0?e.bevelSize:p-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,y=e.bevelSegments!==void 0?e.bevelSegments:3,_=e.extrudePath,S=e.UVGenerator!==void 0?e.UVGenerator:jS,g,d=!1,M,m,R,E;_&&(g=_.getSpacedPoints(u),d=!0,f=!1,M=_.computeFrenetFrames(u,!1),m=new I,R=new I,E=new I),f||(y=0,p=0,x=0,v=0);let T=a.extractPoints(l),b=T.shape,w=T.holes;if(!Qn.isClockWise(b)){b=b.reverse();for(let tt=0,Z=w.length;tt<Z;tt++){let Y=w[tt];Qn.isClockWise(Y)&&(w[tt]=Y.reverse())}}function C(tt){let Y=10000000000000001e-36,q=tt[0];for(let mt=1;mt<=tt.length;mt++){let it=mt%tt.length,st=tt[it],Pt=st.x-q.x,It=st.y-q.y,N=Pt*Pt+It*It,P=Math.max(Math.abs(st.x),Math.abs(st.y),Math.abs(q.x),Math.abs(q.y)),k=Y*P*P;if(N<=k){tt.splice(it,1),mt--;continue}q=st}}C(b),w.forEach(C);let D=w.length,F=b;for(let tt=0;tt<D;tt++){let Z=w[tt];b=b.concat(Z)}function O(tt,Z,Y){return Z||console.error("THREE.ExtrudeGeometry: vec does not exist"),tt.clone().addScaledVector(Z,Y)}let H=b.length;function B(tt,Z,Y){let q,mt,it,st=tt.x-Z.x,Pt=tt.y-Z.y,It=Y.x-tt.x,N=Y.y-tt.y,P=st*st+Pt*Pt,k=st*N-Pt*It;if(Math.abs(k)>Number.EPSILON){let W=Math.sqrt(P),et=Math.sqrt(It*It+N*N),X=Z.x-Pt/W,_t=Z.y+st/W,xt=Y.x-N/et,Ft=Y.y+It/et,Dt=((xt-X)*N-(Ft-_t)*It)/(st*N-Pt*It);q=X+st*Dt-tt.x,mt=_t+Pt*Dt-tt.y;let ft=q*q+mt*mt;if(ft<=2)return new nt(q,mt);it=Math.sqrt(ft/2)}else{let W=!1;st>Number.EPSILON?It>Number.EPSILON&&(W=!0):st<-Number.EPSILON?It<-Number.EPSILON&&(W=!0):Math.sign(Pt)===Math.sign(N)&&(W=!0),W?(q=-Pt,mt=st,it=Math.sqrt(P)):(q=st,mt=Pt,it=Math.sqrt(P/2))}return new nt(q/it,mt/it)}let $=[];for(let tt=0,Z=F.length,Y=Z-1,q=tt+1;tt<Z;tt++,Y++,q++)Y===Z&&(Y=0),q===Z&&(q=0),$[tt]=B(F[tt],F[Y],F[q]);let at=[],rt,ht=$.concat();for(let tt=0,Z=D;tt<Z;tt++){let Y=w[tt];rt=[];for(let q=0,mt=Y.length,it=mt-1,st=q+1;q<mt;q++,it++,st++)it===mt&&(it=0),st===mt&&(st=0),rt[q]=B(Y[q],Y[it],Y[st]);at.push(rt),ht=ht.concat(rt)}let bt;if(y===0)bt=Qn.triangulateShape(F,w);else{let tt=[],Z=[];for(let Y=0;Y<y;Y++){let q=Y/y,mt=p*Math.cos(q*Math.PI/2),it=x*Math.sin(q*Math.PI/2)+v;for(let st=0,Pt=F.length;st<Pt;st++){let It=O(F[st],$[st],it);lt(It.x,It.y,-mt),q===0&&tt.push(It)}for(let st=0,Pt=D;st<Pt;st++){let It=w[st];rt=at[st];let N=[];for(let P=0,k=It.length;P<k;P++){let W=O(It[P],rt[P],it);lt(W.x,W.y,-mt),q===0&&N.push(W)}q===0&&Z.push(N)}}bt=Qn.triangulateShape(tt,Z)}let Et=bt.length,Mt=x+v;for(let tt=0;tt<H;tt++){let Z=f?O(b[tt],ht[tt],Mt):b[tt];d?(R.copy(M.normals[0]).multiplyScalar(Z.x),m.copy(M.binormals[0]).multiplyScalar(Z.y),E.copy(g[0]).add(R).add(m),lt(E.x,E.y,E.z)):lt(Z.x,Z.y,0)}for(let tt=1;tt<=u;tt++)for(let Z=0;Z<H;Z++){let Y=f?O(b[Z],ht[Z],Mt):b[Z];d?(R.copy(M.normals[tt]).multiplyScalar(Y.x),m.copy(M.binormals[tt]).multiplyScalar(Y.y),E.copy(g[tt]).add(R).add(m),lt(E.x,E.y,E.z)):lt(Y.x,Y.y,h/u*tt)}for(let tt=y-1;tt>=0;tt--){let Z=tt/y,Y=p*Math.cos(Z*Math.PI/2),q=x*Math.sin(Z*Math.PI/2)+v;for(let mt=0,it=F.length;mt<it;mt++){let st=O(F[mt],$[mt],q);lt(st.x,st.y,h+Y)}for(let mt=0,it=w.length;mt<it;mt++){let st=w[mt];rt=at[mt];for(let Pt=0,It=st.length;Pt<It;Pt++){let N=O(st[Pt],rt[Pt],q);d?lt(N.x,N.y+g[u-1].y,g[u-1].x+Y):lt(N.x,N.y,h+Y)}}}K(),Q();function K(){let tt=i.length/3;if(f){let Z=0,Y=H*Z;for(let q=0;q<Et;q++){let mt=bt[q];ut(mt[2]+Y,mt[1]+Y,mt[0]+Y)}Z=u+y*2,Y=H*Z;for(let q=0;q<Et;q++){let mt=bt[q];ut(mt[0]+Y,mt[1]+Y,mt[2]+Y)}}else{for(let Z=0;Z<Et;Z++){let Y=bt[Z];ut(Y[2],Y[1],Y[0])}for(let Z=0;Z<Et;Z++){let Y=bt[Z];ut(Y[0]+H*u,Y[1]+H*u,Y[2]+H*u)}}n.addGroup(tt,i.length/3-tt,0)}function Q(){let tt=i.length/3,Z=0;ct(F,Z),Z+=F.length;for(let Y=0,q=w.length;Y<q;Y++){let mt=w[Y];ct(mt,Z),Z+=mt.length}n.addGroup(tt,i.length/3-tt,1)}function ct(tt,Z){let Y=tt.length;for(;--Y>=0;){let q=Y,mt=Y-1;mt<0&&(mt=tt.length-1);for(let it=0,st=u+y*2;it<st;it++){let Pt=H*it,It=H*(it+1),N=Z+q+Pt,P=Z+mt+Pt,k=Z+mt+It,W=Z+q+It;Ct(N,P,k,W)}}}function lt(tt,Z,Y){c.push(tt),c.push(Z),c.push(Y)}function ut(tt,Z,Y){Kt(tt),Kt(Z),Kt(Y);let q=i.length/3,mt=S.generateTopUV(n,i,q-3,q-2,q-1);U(mt[0]),U(mt[1]),U(mt[2])}function Ct(tt,Z,Y,q){Kt(tt),Kt(Z),Kt(q),Kt(Z),Kt(Y),Kt(q);let mt=i.length/3,it=S.generateSideWallUV(n,i,mt-6,mt-3,mt-2,mt-1);U(it[0]),U(it[1]),U(it[3]),U(it[1]),U(it[2]),U(it[3])}function Kt(tt){i.push(c[tt*3+0]),i.push(c[tt*3+1]),i.push(c[tt*3+2])}function U(tt){r.push(tt.x),r.push(tt.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return QS(e,n,t)}static fromJSON(t,e){let n=[];for(let r=0,o=t.shapes.length;r<o;r++){let a=e[t.shapes[r]];n.push(a)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new yh[i.type]().fromJSON(i)),new s(n,t.options)}},jS={generateTopUV:function(s,t,e,n,i){let r=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[i*3],u=t[i*3+1];return[new nt(r,o),new nt(a,c),new nt(l,u)]},generateSideWallUV:function(s,t,e,n,i,r){let o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],u=t[n*3+1],h=t[n*3+2],f=t[i*3],p=t[i*3+1],x=t[i*3+2],v=t[r*3],y=t[r*3+1],_=t[r*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new nt(o,1-c),new nt(l,1-h),new nt(f,1-x),new nt(v,1-_)]:[new nt(a,1-c),new nt(u,1-h),new nt(p,1-x),new nt(y,1-_)]}};function QS(s,t,e){if(e.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){let r=s[n];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}var _c=class s extends ar{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[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];super(i,r,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},yc=class s extends Vt{constructor(t=[new nt(0,-.5),new nt(.5,0),new nt(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Xt(i,0,Math.PI*2);let r=[],o=[],a=[],c=[],l=[],u=1/e,h=new I,f=new nt,p=new I,x=new I,v=new I,y=0,_=0;for(let S=0;S<=t.length-1;S++)switch(S){case 0:y=t[S+1].x-t[S].x,_=t[S+1].y-t[S].y,p.x=_*1,p.y=-y,p.z=_*0,v.copy(p),p.normalize(),c.push(p.x,p.y,p.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:y=t[S+1].x-t[S].x,_=t[S+1].y-t[S].y,p.x=_*1,p.y=-y,p.z=_*0,x.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),c.push(p.x,p.y,p.z),v.copy(x)}for(let S=0;S<=e;S++){let g=n+S*u*i,d=Math.sin(g),M=Math.cos(g);for(let m=0;m<=t.length-1;m++){h.x=t[m].x*d,h.y=t[m].y,h.z=t[m].x*M,o.push(h.x,h.y,h.z),f.x=S/e,f.y=m/(t.length-1),a.push(f.x,f.y);let R=c[3*m+0]*d,E=c[3*m+1],T=c[3*m+0]*M;l.push(R,E,T)}}for(let S=0;S<e;S++)for(let g=0;g<t.length-1;g++){let d=g+S*t.length,M=d,m=d+t.length,R=d+t.length+1,E=d+1;r.push(M,m,E),r.push(R,E,m)}this.setIndex(r),this.setAttribute("position",new Lt(o,3)),this.setAttribute("uv",new Lt(a,2)),this.setAttribute("normal",new Lt(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.points,t.segments,t.phiStart,t.phiLength)}},Fo=class s extends ar{constructor(t=1,e=0){let n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},ys=class s extends Vt{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let r=t/2,o=e/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=t/a,f=e/c,p=[],x=[],v=[],y=[];for(let _=0;_<u;_++){let S=_*f-o;for(let g=0;g<l;g++){let d=g*h-r;x.push(d,-S,0),v.push(0,0,1),y.push(g/a),y.push(1-_/c)}}for(let _=0;_<c;_++)for(let S=0;S<a;S++){let g=S+l*_,d=S+l*(_+1),M=S+1+l*(_+1),m=S+1+l*_;p.push(g,d,m),p.push(d,M,m)}this.setIndex(p),this.setAttribute("position",new Lt(x,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.widthSegments,t.heightSegments)}},vc=class s extends Vt{constructor(t=.5,e=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);let a=[],c=[],l=[],u=[],h=t,f=(e-t)/i,p=new I,x=new nt;for(let v=0;v<=i;v++){for(let y=0;y<=n;y++){let _=r+y/n*o;p.x=h*Math.cos(_),p.y=h*Math.sin(_),c.push(p.x,p.y,p.z),l.push(0,0,1),x.x=(p.x/e+1)/2,x.y=(p.y/e+1)/2,u.push(x.x,x.y)}h+=f}for(let v=0;v<i;v++){let y=v*(n+1);for(let _=0;_<n;_++){let S=_+y,g=S,d=S+n+1,M=S+n+2,m=S+1;a.push(g,d,m),a.push(d,M,m)}}this.setIndex(a),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(l,3)),this.setAttribute("uv",new Lt(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},Mc=class s extends Vt{constructor(t=new Pi([new nt(0,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};let n=[],i=[],r=[],o=[],a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Lt(i,3)),this.setAttribute("normal",new Lt(r,3)),this.setAttribute("uv",new Lt(o,2));function l(u){let h=i.length/3,f=u.extractPoints(e),p=f.shape,x=f.holes;Qn.isClockWise(p)===!1&&(p=p.reverse());for(let y=0,_=x.length;y<_;y++){let S=x[y];Qn.isClockWise(S)===!0&&(x[y]=S.reverse())}let v=Qn.triangulateShape(p,x);for(let y=0,_=x.length;y<_;y++){let S=x[y];p=p.concat(S)}for(let y=0,_=p.length;y<_;y++){let S=p[y];i.push(S.x,S.y,0),r.push(0,0,1),o.push(S.x,S.y)}for(let y=0,_=v.length;y<_;y++){let S=v[y],g=S[0]+h,d=S[1]+h,M=S[2]+h;n.push(g,d,M),c+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes;return tb(e,t)}static fromJSON(t,e){let n=[];for(let i=0,r=t.shapes.length;i<r;i++){let o=e[t.shapes[i]];n.push(o)}return new s(n,t.curveSegments)}};function tb(s,t){if(t.shapes=[],Array.isArray(s))for(let e=0,n=s.length;e<n;e++){let i=s[e];t.shapes.push(i.uuid)}else t.shapes.push(s.uuid);return t}var Oo=class s extends Vt{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new I,f=new I,p=[],x=[],v=[],y=[];for(let _=0;_<=n;_++){let S=[],g=_/n,d=0;_===0&&o===0?d=.5/e:_===n&&c===Math.PI&&(d=-.5/e);for(let M=0;M<=e;M++){let m=M/e;h.x=-t*Math.cos(i+m*r)*Math.sin(o+g*a),h.y=t*Math.cos(o+g*a),h.z=t*Math.sin(i+m*r)*Math.sin(o+g*a),x.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),y.push(m+d,1-g),S.push(l++)}u.push(S)}for(let _=0;_<n;_++)for(let S=0;S<e;S++){let g=u[_][S+1],d=u[_][S],M=u[_+1][S],m=u[_+1][S+1];(_!==0||o>0)&&p.push(g,d,m),(_!==n-1||c<Math.PI)&&p.push(d,M,m)}this.setIndex(p),this.setAttribute("position",new Lt(x,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},Sc=class s extends ar{constructor(t=1,e=0){let n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},bc=class s extends Vt{constructor(t=1,e=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);let o=[],a=[],c=[],l=[],u=new I,h=new I,f=new I;for(let p=0;p<=n;p++)for(let x=0;x<=i;x++){let v=x/i*r,y=p/n*Math.PI*2;h.x=(t+e*Math.cos(y))*Math.cos(v),h.y=(t+e*Math.cos(y))*Math.sin(v),h.z=e*Math.sin(y),a.push(h.x,h.y,h.z),u.x=t*Math.cos(v),u.y=t*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(x/i),l.push(p/n)}for(let p=1;p<=n;p++)for(let x=1;x<=i;x++){let v=(i+1)*p+x-1,y=(i+1)*(p-1)+x-1,_=(i+1)*(p-1)+x,S=(i+1)*p+x;o.push(v,y,S),o.push(y,_,S)}this.setIndex(o),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},Tc=class s extends Vt{constructor(t=1,e=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],c=[],l=[],u=[],h=new I,f=new I,p=new I,x=new I,v=new I,y=new I,_=new I;for(let g=0;g<=n;++g){let d=g/n*r*Math.PI*2;S(d,r,o,t,p),S(d+.01,r,o,t,x),y.subVectors(x,p),_.addVectors(x,p),v.crossVectors(y,_),_.crossVectors(v,y),v.normalize(),_.normalize();for(let M=0;M<=i;++M){let m=M/i*Math.PI*2,R=-e*Math.cos(m),E=e*Math.sin(m);h.x=p.x+(R*_.x+E*v.x),h.y=p.y+(R*_.y+E*v.y),h.z=p.z+(R*_.z+E*v.z),c.push(h.x,h.y,h.z),f.subVectors(h,p).normalize(),l.push(f.x,f.y,f.z),u.push(g/n),u.push(M/i)}}for(let g=1;g<=n;g++)for(let d=1;d<=i;d++){let M=(i+1)*(g-1)+(d-1),m=(i+1)*g+(d-1),R=(i+1)*g+d,E=(i+1)*(g-1)+d;a.push(M,m,E),a.push(m,R,E)}this.setIndex(a),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(l,3)),this.setAttribute("uv",new Lt(u,2));function S(g,d,M,m,R){let E=Math.cos(g),T=Math.sin(g),b=M/d*g,w=Math.cos(b);R.x=m*(2+w)*.5*E,R.y=m*(2+w)*T*.5,R.z=m*Math.sin(b)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},Ec=class s extends Vt{constructor(t=new No(new I(-1,-1,0),new I(-1,1,0),new I(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};let o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new I,c=new I,l=new nt,u=new I,h=[],f=[],p=[],x=[];v(),this.setIndex(x),this.setAttribute("position",new Lt(h,3)),this.setAttribute("normal",new Lt(f,3)),this.setAttribute("uv",new Lt(p,2));function v(){for(let g=0;g<e;g++)y(g);y(r===!1?e:0),S(),_()}function y(g){u=t.getPointAt(g/e,u);let d=o.normals[g],M=o.binormals[g];for(let m=0;m<=i;m++){let R=m/i*Math.PI*2,E=Math.sin(R),T=-Math.cos(R);c.x=T*d.x+E*M.x,c.y=T*d.y+E*M.y,c.z=T*d.z+E*M.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function _(){for(let g=1;g<=e;g++)for(let d=1;d<=i;d++){let M=(i+1)*(g-1)+(d-1),m=(i+1)*g+(d-1),R=(i+1)*g+d,E=(i+1)*(g-1)+d;x.push(M,m,E),x.push(m,R,E)}}function S(){for(let g=0;g<=e;g++)for(let d=0;d<=i;d++)l.x=g/e,l.y=d/i,p.push(l.x,l.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new s(new yh[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},wc=class extends Vt{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){let e=[],n=new Set,i=new I,r=new I;if(t.index!==null){let o=t.attributes.position,a=t.index,c=t.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],f=h.start,p=h.count;for(let x=f,v=f+p;x<v;x+=3)for(let y=0;y<3;y++){let _=a.getX(x+y),S=a.getX(x+(y+1)%3);i.fromBufferAttribute(o,_),r.fromBufferAttribute(o,S),b_(i,r,n)===!0&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{let o=t.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),r.fromBufferAttribute(o,h),b_(i,r,n)===!0&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new Lt(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}};function b_(s,t,e){let n=`${s.x},${s.y},${s.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${s.x},${s.y},${s.z}`;return e.has(n)===!0||e.has(i)===!0?!1:(e.add(n),e.add(i),!0)}var T_=Object.freeze({__proto__:null,BoxGeometry:Ui,CapsuleGeometry:sc,CircleGeometry:oc,ConeGeometry:Co,CylinderGeometry:Ro,DodecahedronGeometry:ac,EdgesGeometry:cc,ExtrudeGeometry:xc,IcosahedronGeometry:_c,LatheGeometry:yc,OctahedronGeometry:Fo,PlaneGeometry:ys,PolyhedronGeometry:ar,RingGeometry:vc,ShapeGeometry:Mc,SphereGeometry:Oo,TetrahedronGeometry:Sc,TorusGeometry:bc,TorusKnotGeometry:Tc,TubeGeometry:Ec,WireframeGeometry:wc}),Ac=class extends Ue{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new yt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}},Rc=class extends Cn{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},xi=class extends Ue{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new yt(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 yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},ln=class extends xi{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new nt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xt(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 yt(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 yt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new yt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}},Cc=class extends Ue{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.combine=qo,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Ic=class extends Ue{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Pc=class extends Ue{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}},Lc=class extends Ue{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.combine=qo,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Bo=class extends Ue{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=em,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},zo=class extends Ue{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},Nc=class extends Ue{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}},Dc=class extends Xe{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}};function ns(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function N0(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function D0(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function pp(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){let a=e[r]*t;for(let c=0;c!==t;++c)i[o++]=s[a+c]}return i}function xm(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(t.push(r.time),e.push(...o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(t.push(r.time),o.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(t.push(r.time),e.push(o)),r=s[i++];while(r!==void 0)}function eb(s,t,e,n,i=30){let r=s.clone();r.name=t;let o=[];for(let c=0;c<r.tracks.length;++c){let l=r.tracks[c],u=l.getValueSize(),h=[],f=[];for(let p=0;p<l.times.length;++p){let x=l.times[p]*i;if(!(x<e||x>=n)){h.push(l.times[p]);for(let v=0;v<u;++v)f.push(l.values[p*u+v])}}h.length!==0&&(l.times=ns(h,l.times.constructor),l.values=ns(f,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r}function nb(s,t=0,e=s,n=30){n<=0&&(n=30);let i=e.tracks.length,r=t/n;for(let o=0;o<i;++o){let a=e.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=s.tracks.find(function(_){return _.name===a.name&&_.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let f=0,p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=p/3);let x=a.times.length-1,v;if(r<=a.times[0]){let _=u,S=h-u;v=a.values.slice(_,S)}else if(r>=a.times[x]){let _=x*h+u,S=_+h-u;v=a.values.slice(_,S)}else{let _=a.createInterpolant(),S=u,g=h-u;_.evaluate(r),v=_.resultBuffer.slice(S,g)}c==="quaternion"&&new Ce().fromArray(v).normalize().conjugate().toArray(v);let y=l.times.length;for(let _=0;_<y;++_){let S=_*p+f;if(c==="quaternion")Ce.multiplyQuaternionsFlat(l.values,S,v,0,l.values,S);else{let g=p-f*2;for(let d=0;d<g;++d)l.values[S+d]-=v[d]}}}return s.blendMode=_f,s}var vh=class{static convertArray(t,e){return ns(t,e)}static isTypedArray(t){return N0(t)}static getKeyframeOrder(t){return D0(t)}static sortedArray(t,e,n){return pp(t,e,n)}static flattenJSON(t,e,n,i){xm(t,e,n,i)}static subclip(t,e,n,i,r=30){return eb(t,e,n,i,r)}static makeClipAdditive(t,e=0,n=t,i=30){return nb(t,e,n,i)}},Bi=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let o;n:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=e[++n],t<i)break e}o=e.length;break n}if(!(t>=r)){let a=e[1];t<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break e}o=n,n=0;break n}break t}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let o=0;o!==i;++o)e[o]=n[r+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Uc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Tr,endingEnd:Tr}}intervalChanged_(t,e,n){let i=this.parameterPositions,r=t-2,o=t+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Er:r=t,a=2*e-n;break;case go:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Er:o=t,c=2*n-e;break;case go:o=1,c=n+i[1]-i[0];break;default:o=t-1,c=e}let l=(n-e)*.5,u=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(c-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,p=this._weightNext,x=(n-e)/(i-e),v=x*x,y=v*x,_=-f*y+2*f*v-f*x,S=(1+f)*y+(-1.5-2*f)*v+(-.5+f)*x+1,g=(-1-p)*y+(1.5+p)*v+.5*x,d=p*y-p*v;for(let M=0;M!==a;++M)r[M]=_*o[u+M]+S*o[l+M]+g*o[c+M]+d*o[h+M];return r}},ko=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,u=(n-e)/(i-e),h=1-u;for(let f=0;f!==a;++f)r[f]=o[l+f]*h+o[c+f]*u;return r}},Fc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},vn=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ns(e,this.TimeBufferType),this.values=ns(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ns(t.times,Array),values:ns(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Fc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ko(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Uc(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ni:e=this.InterpolantFactoryMethodDiscrete;break;case Di:e=this.InterpolantFactoryMethodLinear;break;case Wa:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ni;case this.InterpolantFactoryMethodLinear:return Di;case this.InterpolantFactoryMethodSmooth:return Wa}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,r=0,o=i-1;for(;r!==i&&n[r]<t;)++r;for(;o!==-1&&n[o]>e;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),t=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),t=!1;break}o=c}if(i!==void 0&&N0(i))for(let a=0,c=i.length;a!==c;++a){let l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Wa,r=t.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=t[a],u=t[a+1];if(l!==u&&(a!==1||l!==t[0]))if(i)c=!0;else{let h=a*n,f=h-n,p=h+n;for(let x=0;x!==n;++x){let v=e[h+x];if(v!==e[f+x]||v!==e[p+x]){c=!0;break}}}if(c){if(a!==o){t[o]=t[a];let h=a*n,f=o*n;for(let p=0;p!==n;++p)e[f+p]=e[h+p]}++o}}if(r>0){t[o]=t[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)e[c+l]=e[a+l];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=Di;var zi=class extends vn{constructor(t,e,n){super(t,e,n)}};zi.prototype.ValueTypeName="bool";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=Ni;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;var Ho=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};Ho.prototype.ValueTypeName="color";var _i=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};_i.prototype.ValueTypeName="number";var Oc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-e)/(i-e),l=t*a;for(let u=l+a;l!==u;l+=4)Ce.slerpFlat(r,0,o,l-a,o,l,c);return r}},Gn=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Oc(this.times,this.values,this.getValueSize(),t)}};Gn.prototype.ValueTypeName="quaternion";Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var ki=class extends vn{constructor(t,e,n){super(t,e,n)}};ki.prototype.ValueTypeName="string";ki.prototype.ValueBufferType=Array;ki.prototype.DefaultInterpolation=Ni;ki.prototype.InterpolantFactoryMethodLinear=void 0;ki.prototype.InterpolantFactoryMethodSmooth=void 0;var Wn=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};Wn.prototype.ValueTypeName="vector";var ni=class{constructor(t="",e=-1,n=[],i=Bl){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Bn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(rb(n[o]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,o=n.length;r!==o;++r)e.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);let u=D0(c);c=pp(c,1,u),l=pp(l,1,u),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new _i(".morphTargetInfluences["+e[a].name+"]",c,l).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=t.length;a<c;a++){let l=t[a],u=l.name.match(r);if(u&&u.length>1){let h=u[1],f=i[h];f||(i[h]=f=[]),f.push(l)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,f,p,x,v){if(p.length!==0){let y=[],_=[];xm(p,y,_,x),y.length!==0&&v.push(new h(f,y,_))}},i=[],r=t.name||"default",o=t.fps||30,a=t.blendMode,c=t.length||-1,l=t.hierarchy||[];for(let h=0;h<l.length;h++){let f=l[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},x;for(x=0;x<f.length;x++)if(f[x].morphTargets)for(let v=0;v<f[x].morphTargets.length;v++)p[f[x].morphTargets[v]]=-1;for(let v in p){let y=[],_=[];for(let S=0;S!==f[x].morphTargets.length;++S){let g=f[x];y.push(g.time),_.push(g.morphTarget===v?1:0)}i.push(new _i(".morphTargetInfluence["+v+"]",y,_))}c=p.length*o}else{let p=".bones["+e[h].name+"]";n(Wn,p+".position",f,"pos",i),n(Gn,p+".quaternion",f,"rot",i),n(Wn,p+".scale",f,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,i=t.length;n!==i;++n){let r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());let e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}};function ib(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _i;case"vector":case"vector2":case"vector3":case"vector4":return Wn;case"color":return Ho;case"quaternion":return Gn;case"bool":case"boolean":return zi;case"string":return ki}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function rb(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ib(s.type);if(s.times===void 0){let e=[],n=[];xm(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}var di={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(this.files[s]=t)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}},Pr=class{constructor(t,e,n){let i=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.abortController=new AbortController,this.itemStart=function(u){a++,r===!1&&i.onStart!==void 0&&i.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){let p=l[h],x=l[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return x}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}},_m=new Pr,Ke=class{constructor(t){this.manager=t!==void 0?t:_m,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};Ke.DEFAULT_MATERIAL_NAME="__DEFAULT";var nr={},mp=class extends Error{constructor(t,e){super(t),this.response=e}},Mn=class extends Ke{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=di.get(`file:${t}`);if(r!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(nr[t]!==void 0){nr[t].push({onLoad:e,onProgress:n,onError:i});return}nr[t]=[],nr[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=nr[t],h=l.body.getReader(),f=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=f?parseInt(f):0,x=p!==0,v=0,y=new ReadableStream({start(_){S();function S(){h.read().then(({done:g,value:d})=>{if(g)_.close();else{v+=d.byteLength;let M=new ProgressEvent("progress",{lengthComputable:x,loaded:v,total:p});for(let m=0,R=u.length;m<R;m++){let E=u[m];E.onProgress&&E.onProgress(M)}_.enqueue(d),S()}},g=>{_.error(g)})}}});return new Response(y)}else throw new mp(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a==="")return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return l.arrayBuffer().then(x=>p.decode(x))}}}).then(l=>{di.add(`file:${t}`,l);let u=nr[t];delete nr[t];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onLoad&&p.onLoad(l)}}).catch(l=>{let u=nr[t];if(u===void 0)throw this.manager.itemError(t),l;delete nr[t];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onError&&p.onError(l)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Mh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=[];for(let n=0;n<t.length;n++){let i=ni.parse(t[n]);e.push(i)}return e}},Sh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=[],a=new gi,c=new Mn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let l=0;function u(h){c.load(t[h],function(f){let p=r.parse(f,!0);o[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},l+=1,l===6&&(p.mipmapCount===1&&(a.minFilter=Ee),a.image=o,a.format=p.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let h=0,f=t.length;h<f;++h)u(h);else c.load(t,function(h){let f=r.parse(h,!0);if(f.isCubemap){let p=f.mipmaps.length/f.mipmapCount;for(let x=0;x<p;x++){o[x]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)o[x].mipmaps.push(f.mipmaps[x*f.mipmapCount+v]),o[x].format=f.format,o[x].width=f.width,o[x].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=Ee),a.format=f.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}},uo=new WeakMap,Lr=class extends Ke{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=di.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0);else{let h=uo.get(o);h===void 0&&(h=[],uo.set(o,h)),h.push({onLoad:e,onError:i})}return o}let a=yo("img");function c(){u(),e&&e(this);let h=uo.get(this)||[];for(let f=0;f<h.length;f++){let p=h[f];p.onLoad&&p.onLoad(this)}uo.delete(this),r.manager.itemEnd(t)}function l(h){u(),i&&i(h),di.remove(`image:${t}`);let f=uo.get(this)||[];for(let p=0;p<f.length;p++){let x=f[p];x.onError&&x.onError(h)}uo.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),di.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}},bh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=new Rr;r.colorSpace=Ae;let o=new Lr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(t[l],function(u){r.images[l]=u,a++,a===6&&(r.needsUpdate=!0,e&&e(r))},void 0,i)}for(let l=0;l<t.length;++l)c(l);return r}},Th=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new zn,a=new Mn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(c){let l;try{l=r.parse(c)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:en,o.wrapT=l.wrapT!==void 0?l.wrapT:en,o.magFilter=l.magFilter!==void 0?l.magFilter:Ee,o.minFilter=l.minFilter!==void 0?l.minFilter:Ee,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=un),l.mipmapCount===1&&(o.minFilter=Ee),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,e&&e(o,l)},n,i),o}},Vo=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=new Ie,o=new Lr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){r.image=a,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}},yi=class extends re{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}},vs=class extends yi{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},np=new vt,E_=new I,w_=new I,Bc=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new nt(512,512),this.mapType=ri,this.map=null,this.mapPass=null,this.matrix=new vt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new nt(1,1),this._viewportCount=1,this._viewports=[new Qt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;E_.setFromMatrixPosition(t.matrixWorld),e.position.copy(E_),w_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(w_),e.updateMatrixWorld(),np.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(np,e.coordinateSystem,e.reversedDepth),e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(np)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},gp=class extends Bc{constructor(){super(new Re(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){let e=this.camera,n=os*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Ms=class extends yi{constructor(t,e,n=0,i=Math.PI/3,r=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.target=new re,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new gp}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},A_=new vt,Ha=new I,ip=new I,xp=class extends Bc{constructor(){super(new Re(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new nt(4,2),this._viewportCount=6,this._viewports=[new Qt(2,1,1,1),new Qt(0,1,1,1),new Qt(3,1,1,1),new Qt(1,1,1,1),new Qt(3,0,1,1),new Qt(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Ha.setFromMatrixPosition(t.matrixWorld),n.position.copy(Ha),ip.copy(n.position),ip.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(ip),n.updateMatrixWorld(),i.makeTranslation(-Ha.x,-Ha.y,-Ha.z),A_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(A_,n.coordinateSystem,n.reversedDepth)}},Ss=class extends yi{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new xp}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},cr=class extends hs{constructor(t=-1,e=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,o=n+t,a=i+e,c=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return 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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},_p=class extends Bc{constructor(){super(new cr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},lr=class extends yi{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.target=new re,this.shadow=new _p}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},zc=class extends yi{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}},kc=class extends yi{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){let e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}},Hc=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new I)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){let n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*r),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*r)),e.addScaledVector(o[6],.315392*(3*r*r-1)),e.addScaledVector(o[7],1.092548*(n*r)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){let n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*r),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*r),e.addScaledVector(o[6],.743125*r*r-.247708),e.addScaledVector(o[7],2*.429043*n*r),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){let n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}},Vc=class extends yi{constructor(t=new Hc,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){let e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}},Gc=class s extends Ke{constructor(t){super(t),this.textures={}}load(t,e,n,i){let r=this,o=new Mn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=this.textures;function n(r){return e[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),e[r]}let i=this.createMaterialFromType(t.type);if(t.uuid!==void 0&&(i.uuid=t.uuid),t.name!==void 0&&(i.name=t.name),t.color!==void 0&&i.color!==void 0&&i.color.setHex(t.color),t.roughness!==void 0&&(i.roughness=t.roughness),t.metalness!==void 0&&(i.metalness=t.metalness),t.sheen!==void 0&&(i.sheen=t.sheen),t.sheenColor!==void 0&&(i.sheenColor=new yt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(i.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(t.emissive),t.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(t.specular),t.specularIntensity!==void 0&&(i.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(i.shininess=t.shininess),t.clearcoat!==void 0&&(i.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(i.dispersion=t.dispersion),t.iridescence!==void 0&&(i.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(i.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(i.transmission=t.transmission),t.thickness!==void 0&&(i.thickness=t.thickness),t.attenuationDistance!==void 0&&(i.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(i.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(i.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(i.fog=t.fog),t.flatShading!==void 0&&(i.flatShading=t.flatShading),t.blending!==void 0&&(i.blending=t.blending),t.combine!==void 0&&(i.combine=t.combine),t.side!==void 0&&(i.side=t.side),t.shadowSide!==void 0&&(i.shadowSide=t.shadowSide),t.opacity!==void 0&&(i.opacity=t.opacity),t.transparent!==void 0&&(i.transparent=t.transparent),t.alphaTest!==void 0&&(i.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(i.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(i.depthFunc=t.depthFunc),t.depthTest!==void 0&&(i.depthTest=t.depthTest),t.depthWrite!==void 0&&(i.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(i.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(i.blendSrc=t.blendSrc),t.blendDst!==void 0&&(i.blendDst=t.blendDst),t.blendEquation!==void 0&&(i.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(i.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(i.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(i.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(i.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(i.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(i.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(i.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(i.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(i.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(i.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(i.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(i.rotation=t.rotation),t.linewidth!==void 0&&(i.linewidth=t.linewidth),t.dashSize!==void 0&&(i.dashSize=t.dashSize),t.gapSize!==void 0&&(i.gapSize=t.gapSize),t.scale!==void 0&&(i.scale=t.scale),t.polygonOffset!==void 0&&(i.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(i.dithering=t.dithering),t.alphaToCoverage!==void 0&&(i.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(i.forceSinglePass=t.forceSinglePass),t.visible!==void 0&&(i.visible=t.visible),t.toneMapped!==void 0&&(i.toneMapped=t.toneMapped),t.userData!==void 0&&(i.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let r in t.uniforms){let o=t.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new yt().setHex(o.value);break;case"v2":i.uniforms[r].value=new nt().fromArray(o.value);break;case"v3":i.uniforms[r].value=new I().fromArray(o.value);break;case"v4":i.uniforms[r].value=new Qt().fromArray(o.value);break;case"m3":i.uniforms[r].value=new $t().fromArray(o.value);break;case"m4":i.uniforms[r].value=new vt().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let r in t.extensions)i.extensions[r]=t.extensions[r];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let r=t.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new nt().fromArray(r)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new nt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return s.createMaterialFromType(t)}static createMaterialFromType(t){let e={ShadowMaterial:Ac,SpriteMaterial:To,RawShaderMaterial:Rc,ShaderMaterial:Cn,PointsMaterial:Ir,MeshPhysicalMaterial:ln,MeshStandardMaterial:xi,MeshPhongMaterial:Cc,MeshToonMaterial:Ic,MeshNormalMaterial:Pc,MeshLambertMaterial:Lc,MeshDepthMaterial:Bo,MeshDistanceMaterial:zo,MeshBasicMaterial:sn,MeshMatcapMaterial:Nc,LineDashedMaterial:Dc,LineBasicMaterial:Xe,Material:Ue};return new e[t]}},ii=class{static extractUrlBase(t){let e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}},Wc=class extends Vt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Xc=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(p,x){if(e[x]!==void 0)return e[x];let y=p.interleavedBuffers[x],_=r(p,y.buffer),S=po(y.type,_),g=new Oi(S,y.stride);return g.uuid=y.uuid,e[x]=g,g}function r(p,x){if(n[x]!==void 0)return n[x];let y=p.arrayBuffers[x],_=new Uint32Array(y).buffer;return n[x]=_,_}let o=t.isInstancedBufferGeometry?new Wc:new Vt,a=t.data.index;if(a!==void 0){let p=po(a.type,a.array);o.setIndex(new kt(p,1))}let c=t.data.attributes;for(let p in c){let x=c[p],v;if(x.isInterleavedBufferAttribute){let y=i(t.data,x.data);v=new pi(y,x.itemSize,x.offset,x.normalized)}else{let y=po(x.type,x.array),_=x.isInstancedBufferAttribute?ti:kt;v=new _(y,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),x.usage!==void 0&&v.setUsage(x.usage),o.setAttribute(p,v)}let l=t.data.morphAttributes;if(l)for(let p in l){let x=l[p],v=[];for(let y=0,_=x.length;y<_;y++){let S=x[y],g;if(S.isInterleavedBufferAttribute){let d=i(t.data,S.data);g=new pi(d,S.itemSize,S.offset,S.normalized)}else{let d=po(S.type,S.array);g=new kt(d,S.itemSize,S.normalized)}S.name!==void 0&&(g.name=S.name),v.push(g)}o.morphAttributes[p]=v}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let p=0,x=h.length;p!==x;++p){let v=h[p];o.addGroup(v.start,v.count,v.materialIndex)}let f=t.data.boundingSphere;return f!==void 0&&(o.boundingSphere=new Be().fromJSON(f)),t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}},Eh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=this.path===""?ii.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;let a=new Mn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(c){let l=null;try{l=JSON.parse(c)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+t+".",h.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+t)),console.error("THREE.ObjectLoader: Can't load "+t);return}r.parse(l,e)},n,i)}async loadAsync(t,e){let n=this,i=this.path===""?ii.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;let r=new Mn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);let o=await r.loadAsync(t,e),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await n.parseAsync(a)}parse(t,e){let n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),o=this.parseImages(t.images,function(){e!==void 0&&e(l)}),a=this.parseTextures(t.textures,o),c=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,r,c,a,n),u=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),e!==void 0){let h=!1;for(let f in o)if(o[f].data instanceof HTMLImageElement){h=!0;break}h===!1&&e(l)}return l}async parseAsync(t){let e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,o),c=this.parseObject(t.object,i,a,o,e),l=this.parseSkeletons(t.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(t){let e={};if(t!==void 0)for(let n=0,i=t.length;n<i;n++){let r=new Pi().fromJSON(t[n]);e[r.uuid]=r}return e}parseSkeletons(t,e){let n={},i={};if(e.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),t!==void 0)for(let r=0,o=t.length;r<o;r++){let a=new ds().fromJSON(t[r],i);n[a.uuid]=a}return n}parseGeometries(t,e){let n={};if(t!==void 0){let i=new Xc;for(let r=0,o=t.length;r<o;r++){let a,c=t[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in T_?a=T_[c.type].fromJSON(c,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(t,e){let n={},i={};if(t!==void 0){let r=new Gc;r.setTextures(e);for(let o=0,a=t.length;o<a;o++){let c=t[o];n[c.uuid]===void 0&&(n[c.uuid]=r.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(t){let e={};if(t!==void 0)for(let n=0;n<t.length;n++){let i=t[n],r=ni.parse(i);e[r.uuid]=r}return e}parseImages(t,e){let n=this,i={},r;function o(c){return n.manager.itemStart(c),r.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:po(c.type,c.data),width:c.width,height:c.height}:null}if(t!==void 0&&t.length>0){let c=new Pr(e);r=new Lr(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=t.length;l<u;l++){let h=t[l],f=h.url;if(Array.isArray(f)){let p=[];for(let x=0,v=f.length;x<v;x++){let y=f[x],_=a(y);_!==null&&(_ instanceof HTMLImageElement?p.push(_):p.push(new zn(_.data,_.width,_.height)))}i[h.uuid]=new On(p)}else{let p=a(h.url);i[h.uuid]=new On(p)}}}return i}async parseImagesAsync(t){let e=this,n={},i;async function r(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:e.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:po(o.type,o.data),width:o.width,height:o.height}:null}if(t!==void 0&&t.length>0){i=new Lr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=t.length;o<a;o++){let c=t[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,f=l.length;h<f;h++){let p=l[h],x=await r(p);x!==null&&(x instanceof HTMLImageElement?u.push(x):u.push(new zn(x.data,x.width,x.height)))}n[c.uuid]=new On(u)}else{let u=await r(c.url);n[c.uuid]=new On(u)}}}return n}parseTextures(t,e){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}let i={};if(t!==void 0)for(let r=0,o=t.length;r<o;r++){let a=t[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),e[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=e[a.image],l=c.data,u;Array.isArray(l)?(u=new Rr,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new zn:u=new Ie,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,sb)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],R_),u.wrapT=n(a.wrap[1],R_)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,C_)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,C_)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(t,e,n,i,r){let o;function a(f){return e[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),e[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){let p=[];for(let x=0,v=f.length;x<v;x++){let y=f[x];n[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",y),p.push(n[y])}return p}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function l(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let u,h;switch(t.type){case"Scene":o=new Fi,t.background!==void 0&&(Number.isInteger(t.background)?o.background=new yt(t.background):o.background=l(t.background)),t.environment!==void 0&&(o.environment=l(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?o.fog=new Qa(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(o.fog=new ja(t.fog.color,t.fog.density)),t.fog.name!==""&&(o.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(o.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(o.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&o.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":o=new Re(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(o.focus=t.focus),t.zoom!==void 0&&(o.zoom=t.zoom),t.filmGauge!==void 0&&(o.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(o.filmOffset=t.filmOffset),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new cr(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(o.zoom=t.zoom),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new zc(t.color,t.intensity);break;case"DirectionalLight":o=new lr(t.color,t.intensity),o.target=t.target||"";break;case"PointLight":o=new Ss(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new kc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new Ms(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),o.target=t.target||"";break;case"HemisphereLight":o=new vs(t.color,t.groundColor,t.intensity);break;case"LightProbe":o=new Vc().fromJSON(t);break;case"SkinnedMesh":u=a(t.geometry),h=c(t.material),o=new mi(u,h),t.bindMode!==void 0&&(o.bindMode=t.bindMode),t.bindMatrix!==void 0&&o.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(o.skeleton=t.skeleton);break;case"Mesh":u=a(t.geometry),h=c(t.material),o=new ce(u,h);break;case"InstancedMesh":u=a(t.geometry),h=c(t.material);let f=t.count,p=t.instanceMatrix,x=t.instanceColor;o=new ei(u,h,f),o.instanceMatrix=new ti(new Float32Array(p.array),16),x!==void 0&&(o.instanceColor=new ti(new Float32Array(x.array),x.itemSize));break;case"BatchedMesh":u=a(t.geometry),h=c(t.material),o=new ic(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=t.perObjectFrustumCulled,o.sortObjects=t.sortObjects,o._drawRanges=t.drawRanges,o._reservedRanges=t.reservedRanges,o._geometryInfo=t.geometryInfo.map(v=>{let y=null,_=null;return v.boundingBox!==void 0&&(y=new ne().fromJSON(v.boundingBox)),v.boundingSphere!==void 0&&(_=new Be().fromJSON(v.boundingSphere)),{...v,boundingBox:y,boundingSphere:_}}),o._instanceInfo=t.instanceInfo,o._availableInstanceIds=t._availableInstanceIds,o._availableGeometryIds=t._availableGeometryIds,o._nextIndexStart=t.nextIndexStart,o._nextVertexStart=t.nextVertexStart,o._geometryCount=t.geometryCount,o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._matricesTexture=l(t.matricesTexture.uuid),o._indirectTexture=l(t.indirectTexture.uuid),t.colorsTexture!==void 0&&(o._colorsTexture=l(t.colorsTexture.uuid)),t.boundingSphere!==void 0&&(o.boundingSphere=new Be().fromJSON(t.boundingSphere)),t.boundingBox!==void 0&&(o.boundingBox=new ne().fromJSON(t.boundingBox));break;case"LOD":o=new ec;break;case"Line":o=new Vn(a(t.geometry),c(t.material));break;case"LineLoop":o=new ps(a(t.geometry),c(t.material));break;case"LineSegments":o=new yn(a(t.geometry),c(t.material));break;case"PointCloud":case"Points":o=new ms(a(t.geometry),c(t.material));break;case"Sprite":o=new tc(c(t.material));break;case"Group":o=new nn;break;case"Bone":o=new Cr;break;default:o=new re}if(o.uuid=t.uuid,t.name!==void 0&&(o.name=t.name),t.matrix!==void 0?(o.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(t.position!==void 0&&o.position.fromArray(t.position),t.rotation!==void 0&&o.rotation.fromArray(t.rotation),t.quaternion!==void 0&&o.quaternion.fromArray(t.quaternion),t.scale!==void 0&&o.scale.fromArray(t.scale)),t.up!==void 0&&o.up.fromArray(t.up),t.castShadow!==void 0&&(o.castShadow=t.castShadow),t.receiveShadow!==void 0&&(o.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(o.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(o.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(o.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(o.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(o.visible=t.visible),t.frustumCulled!==void 0&&(o.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(o.renderOrder=t.renderOrder),t.userData!==void 0&&(o.userData=t.userData),t.layers!==void 0&&(o.layers.mask=t.layers),t.children!==void 0){let f=t.children;for(let p=0;p<f.length;p++)o.add(this.parseObject(f[p],e,n,i,r))}if(t.animations!==void 0){let f=t.animations;for(let p=0;p<f.length;p++){let x=f[p];o.animations.push(r[x])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(o.autoUpdate=t.autoUpdate);let f=t.levels;for(let p=0;p<f.length;p++){let x=f[p],v=o.getObjectByProperty("uuid",x.object);v!==void 0&&o.addLevel(v,x.distance,x.hysteresis)}}return o}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){let i=e[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){let n=e.target,i=t.getObjectByProperty("uuid",n);i!==void 0?e.target=i:e.target=new re}})}},sb={UVMapping:il,CubeReflectionMapping:Wi,CubeRefractionMapping:ur,EquirectangularReflectionMapping:Yo,EquirectangularRefractionMapping:$o,CubeUVReflectionMapping:Ts},R_={RepeatWrapping:An,ClampToEdgeWrapping:en,MirroredRepeatWrapping:Li},C_={NearestFilter:De,NearestMipmapNearestFilter:Nr,NearestMipmapLinearFilter:Mi,LinearFilter:Ee,LinearMipmapNearestFilter:Xi,LinearMipmapLinearFilter:un},rp=new WeakMap,Go=class extends Ke{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=di.get(`image-bitmap:${t}`);if(o!==void 0){if(r.manager.itemStart(t),o.then){o.then(l=>{if(rp.has(o)===!0)i&&i(rp.get(o)),r.manager.itemError(t),r.manager.itemEnd(t);else return e&&e(l),r.manager.itemEnd(t),l});return}return setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(t,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return di.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t),l}).catch(function(l){i&&i(l),rp.set(c,l),di.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});di.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Ku,Wo=class{static getContext(){return Ku===void 0&&(Ku=new(window.AudioContext||window.webkitAudioContext)),Ku}static setContext(t){Ku=t}},wh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{let l=c.slice(0);Wo.getContext().decodeAudioData(l,function(h){e(h)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),r.manager.itemError(t)}}},I_=new vt,P_=new vt,Zr=new vt,Ah=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Re,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Re,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(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Zr.copy(t.projectionMatrix);let i=e.eyeSep/2,r=i*e.near/e.focus,o=e.near*Math.tan(is*e.fov*.5)/e.zoom,a,c;P_.elements[12]=-i,I_.elements[12]=i,a=-o*e.aspect+r,c=o*e.aspect+r,Zr.elements[0]=2*e.near/(c-a),Zr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Zr),a=-o*e.aspect-r,c=o*e.aspect-r,Zr.elements[0]=2*e.near/(c-a),Zr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Zr)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(P_),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(I_)}},qc=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}},bs=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}},Jr=new I,sp=new Ce,ob=new I,jr=new I,Qr=new I,Rh=class extends re{constructor(){super(),this.type="AudioListener",this.context=Wo.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new bs}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(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(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Jr,sp,ob),jr.set(0,0,-1).applyQuaternion(sp),Qr.set(0,1,0).applyQuaternion(sp),e.positionX){let n=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Jr.x,n),e.positionY.linearRampToValueAtTime(Jr.y,n),e.positionZ.linearRampToValueAtTime(Jr.z,n),e.forwardX.linearRampToValueAtTime(jr.x,n),e.forwardY.linearRampToValueAtTime(jr.y,n),e.forwardZ.linearRampToValueAtTime(jr.z,n),e.upX.linearRampToValueAtTime(Qr.x,n),e.upY.linearRampToValueAtTime(Qr.y,n),e.upZ.linearRampToValueAtTime(Qr.z,n)}else e.setPosition(Jr.x,Jr.y,Jr.z),e.setOrientation(jr.x,jr.y,jr.z,Qr.x,Qr.y,Qr.z)}},Yc=class extends re{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.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()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);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(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),t.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}},ts=new I,L_=new Ce,ab=new I,es=new I,Ch=class extends Yc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(ts,L_,ab),es.set(0,0,1).applyQuaternion(L_);let e=this.panner;if(e.positionX){let n=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(ts.x,n),e.positionY.linearRampToValueAtTime(ts.y,n),e.positionZ.linearRampToValueAtTime(ts.z,n),e.orientationX.linearRampToValueAtTime(es.x,n),e.orientationY.linearRampToValueAtTime(es.y,n),e.orientationZ.linearRampToValueAtTime(es.z,n)}else e.setPosition(ts.x,ts.y,ts.z),e.setOrientation(es.x,es.y,es.z)}},Ih=class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0,e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}},$c=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,r,o;switch(e){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,i=this.valueSize,r=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let c=e*this._origIndex;this._mixBufferRegion(n,i,c,1-r,e)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(n[c]!==n[c+e]){a.setValue(n,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,o=i;r!==o;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)t[e+o]=t[n+o]}_slerp(t,e,n,i){Ce.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){let o=this._workIndex*r;Ce.multiplyQuaternionsFlat(t,o,t,e,t,n),Ce.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,r){let o=1-i;for(let a=0;a!==r;++a){let c=e+a;t[c]=t[c]*o+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let o=0;o!==r;++o){let a=e+o;t[a]=t[a]+t[n+o]*i}}},ym="\\[\\]\\.:\\/",cb=new RegExp("["+ym+"]","g"),vm="[^"+ym+"]",lb="[^"+ym.replace("\\.","")+"]",ub=/((?:WC+[\/:])*)/.source.replace("WC",vm),hb=/(WCOD+)?/.source.replace("WCOD",lb),fb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vm),db=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vm),pb=new RegExp("^"+ub+hb+fb+db+"$"),mb=["material","materials","bones","map"],yp=class{constructor(t,e,n){let i=n||ee.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},ee=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(cb,"")}static parseTrackName(t){let e=pb.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);mb.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===e||a.uuid===e)return a;let c=n(a.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=s.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===l){l=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let o=t[i];if(o===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ee.Composite=yp;ee.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ee.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ee.prototype.GetterByBindingType=[ee.prototype._getValue_direct,ee.prototype._getValue_array,ee.prototype._getValue_arrayElement,ee.prototype._getValue_toArray];ee.prototype.SetterByBindingTypeAndVersioning=[[ee.prototype._setValue_direct,ee.prototype._setValue_direct_setNeedsUpdate,ee.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_array,ee.prototype._setValue_array_setNeedsUpdate,ee.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_arrayElement,ee.prototype._setValue_arrayElement_setNeedsUpdate,ee.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_fromArray,ee.prototype._setValue_fromArray_setNeedsUpdate,ee.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ph=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Bn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){let t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length,a,c=t.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let f=arguments[u],p=f.uuid,x=e[p];if(x===void 0){x=c++,e[p]=x,t.push(f);for(let v=0,y=o;v!==y;++v)r[v].push(new ee(f,n[v],i[v]))}else if(x<l){a=t[x];let v=--l,y=t[v];e[y.uuid]=x,t[x]=y,e[p]=v,t[v]=f;for(let _=0,S=o;_!==S;++_){let g=r[_],d=g[v],M=g[x];g[x]=d,M===void 0&&(M=new ee(f,n[_],i[_])),g[v]=M}}else t[x]!==a&&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(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=e[l];if(u!==void 0&&u>=r){let h=r++,f=t[h];e[f.uuid]=u,t[u]=f,e[l]=h,t[h]=c;for(let p=0,x=i;p!==x;++p){let v=n[p],y=v[h],_=v[u];v[u]=y,v[h]=_}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,o=t.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=e[u];if(h!==void 0)if(delete e[u],h<r){let f=--r,p=t[f],x=--o,v=t[x];e[p.uuid]=h,t[h]=p,e[v.uuid]=f,t[f]=v,t.pop();for(let y=0,_=i;y!==_;++y){let S=n[y],g=S[f],d=S[x];S[h]=g,S[f]=d,S.pop()}}else{let f=--o,p=t[f];f>0&&(e[p.uuid]=h),t[h]=p,t.pop();for(let x=0,v=i;x!==v;++x){let y=n[x];y[h]=y[f],y.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(i!==void 0)return r[i];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,o.push(t),a.push(e),r.push(h);for(let f=u,p=c.length;f!==p;++f){let x=c[f];h[f]=new ee(x,t,e)}return h}unsubscribe_(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=t[a];e[l]=n,o[n]=c,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},Kc=class{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;let r=e.tracks,o=r.length,a=new Array(o),c={endingStart:Tr,endingEnd:Tr};for(let l=0;l!==o;++l){let u=r[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Qp,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&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),n===!0){let i=this._clip.duration,r=t._clip.duration,o=r/i,a=i/r;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let i=this._mixer,r=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}let r=this._startTime;if(r!==null){let c=(t-r)*n;c<0||n===0?e=0:(this._startTime=null,e=n*c)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case _f:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Bl:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,i=this.time+t,r=this._loopCount,o=n===tm;if(t===0)return r===-1?i:o&&(r&1)===1?e-i:i;if(n===jp){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,r+=Math.abs(a);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){let l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){let i=this._interpolantSettings;n?(i.endingStart=Er,i.endingEnd=Er):(t?i.endingStart=this.zeroSlopeAtStart?Er:Tr:i.endingStart=go,e?i.endingEnd=this.zeroSlopeAtEnd?Er:Tr:i.endingEnd=go)}_scheduleFading(t,e,n){let i=this._mixer,r=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=e,a[1]=r+t,c[1]=n,this}},gb=new Float32Array(1),Xo=class extends kn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,o=t._propertyBindings,a=t._interpolants,c=n.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==r;++h){let f=i[h],p=f.name,x=u[p];if(x!==void 0)++x.referenceCount,o[h]=x;else{if(x=o[h],x!==void 0){x._cacheIndex===null&&(++x.referenceCount,this._addInactiveBinding(x,c,p));continue}let v=e&&e._propertyBindings[h].binding.parsedPath;x=new $c(ee.create(n,p,v),f.ValueTypeName,f.getValueSize()),++x.referenceCount,this._addInactiveBinding(x,c,p),o[h]=x}a[h].resultBuffer=x.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let i=this._actions,r=this._actionsByClip,o=r[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;let r=t._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],u=t._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,f=(t._localRoot||this._root).uuid;delete h[f],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){let i=this._bindingsByRootAndName,r=this._bindings,o=i[e];o===void 0&&(o={},i[e]=o),o[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new ko(new Float32Array(2),new Float32Array(2),1,gb),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){let i=e||this._root,r=i.uuid,o=typeof t=="string"?ni.findByName(i,t):t,a=o!==null?o.uuid:t,c=this._actionsByClip[a],l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Bl),c!==void 0){let h=c.actionByRoot[r];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Kc(this,o,e,n);return this._bindAction(u,l),this._addInactiveAction(u,a,r),u}existingAction(t,e){let n=e||this._root,i=n.uuid,r=typeof t=="string"?ni.findByName(n,t):t,o=r?r.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let l=0;l!==n;++l)e[l]._update(i,t,r,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,c=a[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let i=this._bindingsByRootAndName,r=i[e];if(r!==void 0)for(let o in r){let a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Lh=class extends Mo{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new ls(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},Nh=class s{constructor(t){this.value=t}clone(){return new s(this.value.clone===void 0?this.value:this.value.clone())}},xb=0,Dh=class extends kn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:xb++}),this.name="",this.usage=_o,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){let e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;let e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){let r=Array.isArray(e[n])?e[n]:[e[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Uh=class extends Oi{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){let e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){let e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},Fh=class{constructor(t,e,n,i,r,o=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.normalized=o,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},N_=new vt,Oh=class{constructor(t,e,n=0,i=1/0){this.ray=new _n(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new us,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return N_.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(N_),this}intersectObject(t,e=!0,n=[]){return vp(t,this,n,e),n.sort(D_),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)vp(t[i],this,n,e);return n.sort(D_),n}};function D_(s,t){return s.distance-t.distance}function vp(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){let r=s.children;for(let o=0,a=r.length;o<a;o++)vp(r[o],t,e,!0)}}var Bh=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,t.hidden!==void 0&&(this._pageVisibilityHandler=_b.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(t!==void 0?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function _b(){this._document.hidden===!1&&this.reset()}var zh=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Xt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Xt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},kh=class{constructor(t=1,e=0,n=0){this.radius=t,this.theta=e,this.y=n}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return new this.constructor().copy(this)}},Hh=class s{constructor(t,e,n,i){s.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}},U_=new nt,Vh=class{constructor(t=new nt(1/0,1/0),e=new nt(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=U_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,U_).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},F_=new I,Zu=new I,ho=new I,fo=new I,op=new I,yb=new I,vb=new I,_e=class{constructor(t=new I,e=new I){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){F_.subVectors(t,this.start),Zu.subVectors(this.end,this.start);let n=Zu.dot(Zu),r=Zu.dot(F_)/n;return e&&(r=Xt(r,0,1)),r}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=yb,n=vb){let i=10000000000000001e-32,r,o,a=this.start,c=t.start,l=this.end,u=t.end;ho.subVectors(l,a),fo.subVectors(u,c),op.subVectors(a,c);let h=ho.dot(ho),f=fo.dot(fo),p=fo.dot(op);if(h<=i&&f<=i)return e.copy(a),n.copy(c),e.sub(n),e.dot(e);if(h<=i)r=0,o=p/f,o=Xt(o,0,1);else{let x=ho.dot(op);if(f<=i)o=0,r=Xt(-x/h,0,1);else{let v=ho.dot(fo),y=h*f-v*v;y!==0?r=Xt((v*p-x*f)/y,0,1):r=0,o=(v*r+p)/f,o<0?(o=0,r=Xt(-x/h,0,1)):o>1&&(o=1,r=Xt((v-x)/h,0,1))}}return e.copy(a).add(ho.multiplyScalar(r)),n.copy(c).add(fo.multiplyScalar(o)),e.sub(n),e.dot(e)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},O_=new I,Gh=class extends re{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Vt,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 o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Lt(i,3));let r=new Xe({fog:!1,toneMapped:!1});this.cone=new yn(n,r),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),O_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(O_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sr=new I,Ju=new vt,ap=new vt,Wh=class extends yn{constructor(t){let e=U0(t),n=new Vt,i=[],r=[];for(let l=0;l<e.length;l++){let u=e[l];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}n.setAttribute("position",new Lt(i,3)),n.setAttribute("color",new Lt(r,3));let o=new Xe({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,o),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;let a=new yt(255),c=new yt(65280);this.setColors(a,c)}updateMatrixWorld(t){let e=this.bones,n=this.geometry,i=n.getAttribute("position");ap.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<e.length;r++){let a=e[r];a.parent&&a.parent.isBone&&(Ju.multiplyMatrices(ap,a.matrixWorld),Sr.setFromMatrixPosition(Ju),i.setXYZ(o,Sr.x,Sr.y,Sr.z),Ju.multiplyMatrices(ap,a.parent.matrixWorld),Sr.setFromMatrixPosition(Ju),i.setXYZ(o+1,Sr.x,Sr.y,Sr.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){let i=this.geometry.getAttribute("color");for(let r=0;r<i.count;r+=2)i.setXYZ(r,t.r,t.g,t.b),i.setXYZ(r+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};function U0(s){let t=[];s.isBone===!0&&t.push(s);for(let e=0;e<s.children.length;e++)t.push(...U0(s.children[e]));return t}var Xh=class extends ce{constructor(t,e,n){let i=new Oo(e,4,2),r=new sn({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=t,this.color=n,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),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Mb=new I,B_=new yt,z_=new yt,qh=class extends re{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let i=new Fo(e);i.rotateY(Math.PI*.5),this.material=new sn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new kt(o,3)),this.add(new ce(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let e=t.geometry.getAttribute("color");B_.copy(this.light.color),z_.copy(this.light.groundColor);for(let n=0,i=e.count;n<i;n++){let r=n<i/2?B_:z_;e.setXYZ(n,r.r,r.g,r.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Mb.setFromMatrixPosition(this.light.matrixWorld).negate())}},Yh=class extends yn{constructor(t=10,e=10,n=4473924,i=8947848){n=new yt(n),i=new yt(i);let r=e/2,o=t/e,a=t/2,c=[],l=[];for(let f=0,p=0,x=-a;f<=e;f++,x+=o){c.push(-a,0,x,a,0,x),c.push(x,0,-a,x,0,a);let v=f===r?n:i;v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3}let u=new Vt;u.setAttribute("position",new Lt(c,3)),u.setAttribute("color",new Lt(l,3));let h=new Xe({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},$h=class extends yn{constructor(t=10,e=16,n=8,i=64,r=4473924,o=8947848){r=new yt(r),o=new yt(o);let a=[],c=[];if(e>1)for(let h=0;h<e;h++){let f=h/e*(Math.PI*2),p=Math.sin(f)*t,x=Math.cos(f)*t;a.push(0,0,0),a.push(p,0,x);let v=h&1?r:o;c.push(v.r,v.g,v.b),c.push(v.r,v.g,v.b)}for(let h=0;h<n;h++){let f=h&1?r:o,p=t-t/n*h;for(let x=0;x<i;x++){let v=x/i*(Math.PI*2),y=Math.sin(v)*p,_=Math.cos(v)*p;a.push(y,0,_),c.push(f.r,f.g,f.b),v=(x+1)/i*(Math.PI*2),y=Math.sin(v)*p,_=Math.cos(v)*p,a.push(y,0,_),c.push(f.r,f.g,f.b)}}let l=new Vt;l.setAttribute("position",new Lt(a,3)),l.setAttribute("color",new Lt(c,3));let u=new Xe({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},k_=new I,ju=new I,H_=new I,Kh=class extends re{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Vt;i.setAttribute("position",new Lt([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let r=new Xe({fog:!1,toneMapped:!1});this.lightPlane=new Vn(i,r),this.add(this.lightPlane),i=new Vt,i.setAttribute("position",new Lt([0,0,0,0,0,1],3)),this.targetLine=new Vn(i,r),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),k_.setFromMatrixPosition(this.light.matrixWorld),ju.setFromMatrixPosition(this.light.target.matrixWorld),H_.subVectors(ju,k_),this.lightPlane.lookAt(ju),this.color!==void 0?(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(ju),this.targetLine.scale.z=H_.length()}},Qu=new I,Oe=new hs,Zh=class extends yn{constructor(t){let e=new Vt,n=new Xe({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(x,v){c(x),c(v)}function c(x){i.push(0,0,0),r.push(0,0,0),o[x]===void 0&&(o[x]=[]),o[x].push(i.length/3-1)}e.setAttribute("position",new Lt(i,3)),e.setAttribute("color",new Lt(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new yt(16755200),u=new yt(16711680),h=new yt(43775),f=new yt(16777215),p=new yt(3355443);this.setColors(l,u,h,f,p)}setColors(t,e,n,i,r){let a=this.geometry.getAttribute("color");return a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0,this}update(){let t=this.geometry,e=this.pointMap,n=1,i=1,r,o;if(Oe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)r=1,o=0;else if(this.camera.coordinateSystem===wn)r=-1,o=1;else if(this.camera.coordinateSystem===ss)r=0,o=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);He("c",e,t,Oe,0,0,r),He("t",e,t,Oe,0,0,o),He("n1",e,t,Oe,-n,-i,r),He("n2",e,t,Oe,n,-i,r),He("n3",e,t,Oe,-n,i,r),He("n4",e,t,Oe,n,i,r),He("f1",e,t,Oe,-n,-i,o),He("f2",e,t,Oe,n,-i,o),He("f3",e,t,Oe,-n,i,o),He("f4",e,t,Oe,n,i,o),He("u1",e,t,Oe,n*.7,i*1.1,r),He("u2",e,t,Oe,-n*.7,i*1.1,r),He("u3",e,t,Oe,0,i*2,r),He("cf1",e,t,Oe,-n,0,o),He("cf2",e,t,Oe,n,0,o),He("cf3",e,t,Oe,0,-i,o),He("cf4",e,t,Oe,0,i,o),He("cn1",e,t,Oe,-n,0,r),He("cn2",e,t,Oe,n,0,r),He("cn3",e,t,Oe,0,-i,r),He("cn4",e,t,Oe,0,i,r),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function He(s,t,e,n,i,r,o){Qu.set(i,r,o).unproject(n);let a=t[s];if(a!==void 0){let c=e.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],Qu.x,Qu.y,Qu.z)}}var th=new ne,Jh=class extends yn{constructor(t,e=16776960){let n=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]),i=new Float32Array(8*3),r=new Vt;r.setIndex(new kt(n,1)),r.setAttribute("position",new kt(i,3)),super(r,new Xe({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&th.setFromObject(this.object),th.isEmpty())return;let t=th.min,e=th.max,n=this.geometry.attributes.position,i=n.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},jh=class extends yn{constructor(t,e=16776960){let n=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]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new Vt;r.setIndex(new kt(n,1)),r.setAttribute("position",new Lt(i,3)),super(r,new Xe({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},Qh=class extends Vn{constructor(t,e=1,n=16776960){let i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Vt;o.setAttribute("position",new Lt(r,3)),o.computeBoundingSphere(),super(o,new Xe({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new Vt;c.setAttribute("position",new Lt(a,3)),c.computeBoundingSphere(),this.add(new ce(c,new sn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){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(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},V_=new I,eh,cp,tf=class extends re{constructor(t=new I(0,0,1),e=new I(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",eh===void 0&&(eh=new Vt,eh.setAttribute("position",new Lt([0,0,0,0,1,0],3)),cp=new Co(.5,1,5,1),cp.translate(0,-.5,0)),this.position.copy(e),this.line=new Vn(eh,new Xe({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ce(cp,new sn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{V_.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(V_,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},ef=class extends yn{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Vt;i.setAttribute("position",new Lt(e,3)),i.setAttribute("color",new Lt(n,3));let r=new Xe({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new yt,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},nf=class{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new xs,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,o){return this.currentPath.bezierCurveTo(t,e,n,i,r,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(_){let S=[];for(let g=0,d=_.length;g<d;g++){let M=_[g],m=new Pi;m.curves=M.curves,S.push(m)}return S}function n(_,S){let g=S.length,d=!1;for(let M=g-1,m=0;m<g;M=m++){let R=S[M],E=S[m],T=E.x-R.x,b=E.y-R.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(R=S[m],T=-T,E=S[M],b=-b),_.y<R.y||_.y>E.y)continue;if(_.y===R.y){if(_.x===R.x)return!0}else{let w=b*(_.x-R.x)-T*(_.y-R.y);if(w===0)return!0;if(w<0)continue;d=!d}}else{if(_.y!==R.y)continue;if(E.x<=_.x&&_.x<=R.x||R.x<=_.x&&_.x<=E.x)return!0}}return d}let i=Qn.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,c,l=[];if(r.length===1)return a=r[0],c=new Pi,c.curves=a.curves,l.push(c),l;let u=!i(r[0].getPoints());u=t?!u:u;let h=[],f=[],p=[],x=0,v;f[x]=void 0,p[x]=[];for(let _=0,S=r.length;_<S;_++)a=r[_],v=a.getPoints(),o=i(v),o=t?!o:o,o?(!u&&f[x]&&x++,f[x]={s:new Pi,p:v},f[x].s.curves=a.curves,u&&x++,p[x]=[]):p[x].push({h:a,p:v[0]});if(!f[0])return e(r);if(f.length>1){let _=!1,S=0;for(let g=0,d=f.length;g<d;g++)h[g]=[];for(let g=0,d=f.length;g<d;g++){let M=p[g];for(let m=0;m<M.length;m++){let R=M[m],E=!0;for(let T=0;T<f.length;T++)n(R.p,f[T].p)&&(g!==T&&S++,E?(E=!1,h[T].push(R)):_=!0);E&&h[g].push(R)}}S>0&&_===!1&&(p=h)}let y;for(let _=0,S=f.length;_<S;_++){c=f[_].s,l.push(c),y=p[_];for(let g=0,d=y.length;g<d;g++)c.holes.push(y[g].h)}return l}},rf=class extends kn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function Sb(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function bb(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function Tb(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function Sf(s,t,e,n){let i=Eb(n);switch(e){case mf:return s*t;case al:return s*t/i.components*i.byteLength;case Ko:return s*t/i.components*i.byteLength;case xf:return s*t*2/i.components*i.byteLength;case cl:return s*t*2/i.components*i.byteLength;case gf:return s*t*3/i.components*i.byteLength;case Qe:return s*t*4/i.components*i.byteLength;case ll:return s*t*4/i.components*i.byteLength;case Zo:case Jo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case jo:case Qo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case hl:case dl:return Math.max(s,16)*Math.max(t,8)/4;case ul:case fl:return Math.max(s,8)*Math.max(t,8)/2;case pl:case ml:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case gl:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case xl:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case _l:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case yl:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case vl:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case Ml:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case Sl:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case bl:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case Tl:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case El:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case wl:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case Al:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case Rl:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case Cl:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case Il:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case Pl:case Ll:case Nl:return Math.ceil(s/4)*Math.ceil(t/4)*16;case Dl:case Ul:return Math.ceil(s/4)*Math.ceil(t/4)*8;case Fl:case Ol:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Eb(s){switch(s){case ri:case hf:return{byteLength:1,components:1};case Es:case ff:case ws:return{byteLength:2,components:1};case sl:case ol:return{byteLength:2,components:4};case qi:case rl:case xn:return{byteLength:4,components:1};case df:case pf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}var sf=class{static contain(t,e){return Sb(t,e)}static cover(t,e){return bb(t,e)}static fill(t){return Tb(t)}static getByteLength(t,e,n,i){return Sf(t,e,n,i)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Hi}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Hi);function sy(){let s=null,t=!1,e=null,n=null;function i(r,o){e(r,o),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function wb(s){let t=new WeakMap;function e(a,c){let l=a.array,u=a.usage,h=l.byteLength,f=s.createBuffer();s.bindBuffer(c,f),s.bufferData(c,l,u),a.onUploadCallback();let p;if(l instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=s.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=s.SHORT;else if(l instanceof Uint32Array)p=s.UNSIGNED_INT;else if(l instanceof Int32Array)p=s.INT;else if(l instanceof Int8Array)p=s.BYTE;else if(l instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){let u=c.array,h=c.updateRanges;if(s.bindBuffer(l,a),h.length===0)s.bufferSubData(l,0,u);else{h.sort((p,x)=>p.start-x.start);let f=0;for(let p=1;p<h.length;p++){let x=h[f],v=h[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++f,h[f]=v)}h.length=f+1;for(let p=0,x=h.length;p<x;p++){let v=h[p];s.bufferSubData(l,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=t.get(a);c&&(s.deleteBuffer(c.buffer),t.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,e(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}var Ab=`#ifdef USE_ALPHAHASH
|
|
40
|
+
`},i=new Ui(5,5,5),r=new Cn({name:"CubemapFromEquirect",uniforms:Is(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:qe,blending:Vi});r.uniforms.tEquirect.value=e;let o=new ce(i,r),a=e.minFilter;return e.minFilter===un&&(e.minFilter=Ee),new Za(1,10,this).update(t,o),e.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){let r=t.getRenderTarget();for(let o=0;o<6;o++)t.setRenderTarget(this,o),t.clear(e,n,i);t.setRenderTarget(r)}},nn=class extends re{constructor(){super(),this.isGroup=!0,this.type="Group"}},mS={type:"move"},fs=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new nn,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new nn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new I,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new I),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new nn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new I,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new I),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){o=!0;for(let v of t.hand.values()){let y=e.getJointPose(v,n),_=this._getHandJoint(l,v);y!==null&&(_.matrix.fromArray(y.transform.matrix),_.matrix.decompose(_.position,_.rotation,_.scale),_.matrixWorldNeedsUpdate=!0,_.jointRadius=y.radius),_.visible=y!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],f=u.position.distanceTo(h.position),p=.02,x=.005;l.inputState.pinching&&f>p+x?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&f<=p-x&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(mS)))}return a!==null&&(a.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new nn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},ja=class s{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new yt(t),this.density=e}clone(){return new s(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},Qa=class s{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new yt(t),this.near=e,this.far=n}clone(){return new s(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},Fi=class extends re{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Rn,this.environmentIntensity=1,this.environmentRotation=new Rn,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},Oi=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=_o,this.updateRanges=[],this.version=0,this.uuid=Bn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Bn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.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}}},mn=new I,pi=class s{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.applyMatrix4(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.applyNormalMatrix(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)mn.fromBufferAttribute(this,e),mn.transformDirection(t),this.setXYZ(e,mn.x,mn.y,mn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=gn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=Jt(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Jt(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=gn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=gn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=gn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=gn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=Jt(e,this.array),n=Jt(n,this.array),i=Jt(i,this.array),r=Jt(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new kt(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new s(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let e=[];for(let n=0;n<this.count;n++){let i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}},To=class extends Ue{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},so,Da=new I,oo=new I,ao=new I,co=new nt,Ua=new nt,R0=new vt,Iu=new I,Fa=new I,Pu=new I,t_=new nt,qd=new nt,e_=new nt,tc=class extends re{constructor(t=new To){if(super(),this.isSprite=!0,this.type="Sprite",so===void 0){so=new Vt;let e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Oi(e,5);so.setIndex([0,1,2,0,2,3]),so.setAttribute("position",new pi(n,3,0,!1)),so.setAttribute("uv",new pi(n,2,3,!1))}this.geometry=so,this.material=t,this.center=new nt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),oo.setFromMatrixScale(this.matrixWorld),R0.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),ao.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&oo.multiplyScalar(-ao.z);let n=this.material.rotation,i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));let o=this.center;Lu(Iu.set(-.5,-.5,0),ao,o,oo,i,r),Lu(Fa.set(.5,-.5,0),ao,o,oo,i,r),Lu(Pu.set(.5,.5,0),ao,o,oo,i,r),t_.set(0,0),qd.set(1,0),e_.set(1,1);let a=t.ray.intersectTriangle(Iu,Fa,Pu,!1,Da);if(a===null&&(Lu(Fa.set(-.5,.5,0),ao,o,oo,i,r),qd.set(0,1),a=t.ray.intersectTriangle(Iu,Pu,Fa,!1,Da),a===null))return;let c=t.ray.origin.distanceTo(Da);c<t.near||c>t.far||e.push({distance:c,point:Da.clone(),uv:me.getInterpolation(Da,Iu,Fa,Pu,t_,qd,e_,new nt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};function Lu(s,t,e,n,i,r){co.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(Ua.x=r*co.x-i*co.y,Ua.y=i*co.x+r*co.y):Ua.copy(co),s.copy(t),s.x+=Ua.x,s.y+=Ua.y,s.applyMatrix4(R0)}var Nu=new I,n_=new I,ec=class extends re{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let n=0,i=e.length;n<i;n++){let r=e[n];this.addLevel(r.object.clone(),r.distance,r.hysteresis)}return this.autoUpdate=t.autoUpdate,this}addLevel(t,e=0,n=0){e=Math.abs(e);let i=this.levels,r;for(r=0;r<i.length&&!(e<i[r].distance);r++);return i.splice(r,0,{distance:e,hysteresis:n,object:t}),this.add(t),this}removeLevel(t){let e=this.levels;for(let n=0;n<e.length;n++)if(e[n].distance===t){let i=e.splice(n,1);return this.remove(i[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(t){let e=this.levels;if(e.length>0){let n,i;for(n=1,i=e.length;n<i;n++){let r=e[n].distance;if(e[n].object.visible&&(r-=r*e[n].hysteresis),t<r)break}return e[n-1].object}return null}raycast(t,e){if(this.levels.length>0){Nu.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(Nu);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){Nu.setFromMatrixPosition(t.matrixWorld),n_.setFromMatrixPosition(this.matrixWorld);let n=Nu.distanceTo(n_)/t.zoom;e[0].object.visible=!0;let i,r;for(i=1,r=e.length;i<r;i++){let o=e[i].distance;if(e[i].object.visible&&(o-=o*e[i].hysteresis),n>=o)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i<r;i++)e[i].object.visible=!1}}toJSON(t){let e=super.toJSON(t);this.autoUpdate===!1&&(e.object.autoUpdate=!1),e.object.levels=[];let n=this.levels;for(let i=0,r=n.length;i<r;i++){let o=n[i];e.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return e}},i_=new I,r_=new Qt,s_=new Qt,gS=new I,o_=new vt,Du=new I,Yd=new Be,a_=new vt,$d=new _n,mi=class extends ce{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=nh,this.bindMatrix=new vt,this.bindMatrixInverse=new vt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let t=this.geometry;this.boundingBox===null&&(this.boundingBox=new ne),this.boundingBox.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Du),this.boundingBox.expandByPoint(Du)}computeBoundingSphere(){let t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Be),this.boundingSphere.makeEmpty();let e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,Du),this.boundingSphere.expandByPoint(Du)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){let n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Yd.copy(this.boundingSphere),Yd.applyMatrix4(i),t.ray.intersectsSphere(Yd)!==!1&&(a_.copy(i).invert(),$d.copy(t.ray).applyMatrix4(a_),!(this.boundingBox!==null&&$d.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,$d)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let t=new Qt,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);let r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===nh?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===jp?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){let n=this.skeleton,i=this.geometry;r_.fromBufferAttribute(i.attributes.skinIndex,t),s_.fromBufferAttribute(i.attributes.skinWeight,t),i_.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let r=0;r<4;r++){let o=s_.getComponent(r);if(o!==0){let a=r_.getComponent(r);o_.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),e.addScaledVector(gS.copy(i_).applyMatrix4(o_),o)}}return e.applyMatrix4(this.bindMatrixInverse)}},Cr=class extends re{constructor(){super(),this.isBone=!0,this.type="Bone"}},zn=class extends Ie{constructor(t=null,e=1,n=1,i,r,o,a,c,l=De,u=De,h,f){super(null,o,a,c,l,u,i,r,h,f),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},c_=new vt,xS=new vt,ds=class s{constructor(t=[],e=[]){this.uuid=Bn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new vt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){let n=new vt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){let n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,o=t.length;r<o;r++){let a=t[r]?t[r].matrixWorld:xS;c_.multiplyMatrices(a,e[r]),c_.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new s(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4);e.set(this.boneMatrices);let n=new zn(e,t,t,Qe,xn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){let i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){let r=t.bones[n],o=e[r];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",r),o=new Cr),this.bones.push(o),this.boneInverses.push(new vt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){let t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;let e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){let o=e[i];t.bones.push(o.uuid);let a=n[i];t.boneInverses.push(a.toArray())}return t}},ti=class extends kt{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){let t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}},lo=new vt,l_=new vt,Uu=[],u_=new ne,_S=new vt,Oa=new ce,Ba=new Be,ei=class extends ce{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new ti(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,_S)}computeBoundingBox(){let t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new ne),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,lo),u_.copy(t.boundingBox).applyMatrix4(lo),this.boundingBox.union(u_)}computeBoundingSphere(){let t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Be),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,lo),Ba.copy(t.boundingSphere).applyMatrix4(lo),this.boundingSphere.union(Ba)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){let n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,o=t*r+1;for(let a=0;a<n.length;a++)n[a]=i[o+a]}raycast(t,e){let n=this.matrixWorld,i=this.count;if(Oa.geometry=this.geometry,Oa.material=this.material,Oa.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Ba.copy(this.boundingSphere),Ba.applyMatrix4(n),t.ray.intersectsSphere(Ba)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,lo),l_.multiplyMatrices(n,lo),Oa.matrixWorld=l_,Oa.raycast(t,Uu);for(let o=0,a=Uu.length;o<a;o++){let c=Uu[o];c.instanceId=r,c.object=this,e.push(c)}Uu.length=0}}setColorAt(t,e){this.instanceColor===null&&(this.instanceColor=new ti(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,t*16)}setMorphAt(t,e){let n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new zn(new Float32Array(i*this.count),i,this.count,al,xn));let r=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=i*t;r[c]=a,r.set(n,c+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}},Kd=new I,yS=new I,vS=new $t,$e=class{constructor(t=new I(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=Kd.subVectors(n,e).cross(yS.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Kd),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||vS.getNormalMatrix(t),i=this.coplanarPoint(Kd).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Yr=new Be,MS=new nt(.5,.5),Fu=new I,or=class{constructor(t=new $e,e=new $e,n=new $e,i=new $e,r=new $e,o=new $e){this.planes=[t,e,n,i,r,o]}set(t,e,n,i,r,o){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(o),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=wn,n=!1){let i=this.planes,r=t.elements,o=r[0],a=r[1],c=r[2],l=r[3],u=r[4],h=r[5],f=r[6],p=r[7],x=r[8],v=r[9],y=r[10],_=r[11],S=r[12],g=r[13],d=r[14],M=r[15];if(i[0].setComponents(l-o,p-u,_-x,M-S).normalize(),i[1].setComponents(l+o,p+u,_+x,M+S).normalize(),i[2].setComponents(l+a,p+h,_+v,M+g).normalize(),i[3].setComponents(l-a,p-h,_-v,M-g).normalize(),n)i[4].setComponents(c,f,y,d).normalize(),i[5].setComponents(l-c,p-f,_-y,M-d).normalize();else if(i[4].setComponents(l-c,p-f,_-y,M-d).normalize(),e===wn)i[5].setComponents(l+c,p+f,_+y,M+d).normalize();else if(e===ss)i[5].setComponents(c,f,y,d).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Yr.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Yr.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Yr)}intersectsSprite(t){Yr.center.set(0,0,0);let e=MS.distanceTo(t.center);return Yr.radius=.7071067811865476+e,Yr.applyMatrix4(t.matrixWorld),this.intersectsSphere(Yr)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){let e=this.planes;for(let n=0;n<6;n++){let i=e[n];if(Fu.x=i.normal.x>0?t.max.x:t.min.x,Fu.y=i.normal.y>0?t.max.y:t.min.y,Fu.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Fu)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Ci=new vt,Ii=new or,nc=class s{constructor(){this.coordinateSystem=wn}intersectsObject(t,e){if(!e.isArrayCamera||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsObject(t))return!0}return!1}intersectsSprite(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsSprite(t))return!0}return!1}intersectsSphere(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsSphere(t))return!0}return!1}intersectsBox(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.intersectsBox(t))return!0}return!1}containsPoint(t,e){if(!e||!e.cameras||e.cameras.length===0)return!1;for(let n=0;n<e.cameras.length;n++){let i=e.cameras[n];if(Ci.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),Ii.setFromProjectionMatrix(Ci,i.coordinateSystem,i.reversedDepth),Ii.containsPoint(t))return!0}return!1}clone(){return new s}};function Zd(s,t){return s-t}function SS(s,t){return s.z-t.z}function bS(s,t){return t.z-s.z}var up=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(t,e,n,i){let r=this.pool,o=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];o.push(a),this.index++,a.start=t,a.count=e,a.z=n,a.index=i}reset(){this.list.length=0,this.index=0}},Tn=new vt,TS=new yt(1,1,1),h_=new or,ES=new nc,Ou=new ne,$r=new Be,za=new I,f_=new I,wS=new I,Jd=new up,cn=new ce,Bu=[];function AS(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r<i;r++)for(let o=0;o<n;o++)t.setComponent(r+e,o,s.getComponent(r,o))}else t.array.set(s.array,e*n);t.needsUpdate=!0}function Kr(s,t){if(s.constructor!==t.constructor){let e=Math.min(s.length,t.length);for(let n=0;n<e;n++)t[n]=s[n]}else{let e=Math.min(s.length,t.length);t.set(new s.constructor(s.buffer,0,e))}}var ic=class extends ce{constructor(t,e,n=e*2,i){super(new Vt,i),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=t,this._maxVertexCount=e,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(t),this._multiDrawStarts=new Int32Array(t),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let t=Math.sqrt(this._maxInstanceCount*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);let e=new Float32Array(t*t*4),n=new zn(e,t,t,Qe,xn);this._matricesTexture=n}_initIndirectTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Uint32Array(t*t),n=new zn(e,t,t,Ko,qi);this._indirectTexture=n}_initColorsTexture(){let t=Math.sqrt(this._maxInstanceCount);t=Math.ceil(t);let e=new Float32Array(t*t*4).fill(1),n=new zn(e,t,t,Qe,xn);n.colorSpace=ie.workingColorSpace,this._colorsTexture=n}_initializeGeometry(t){let e=this.geometry,n=this._maxVertexCount,i=this._maxIndexCount;if(this._geometryInitialized===!1){for(let r in t.attributes){let o=t.getAttribute(r),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new kt(u,c,l);e.setAttribute(r,h)}if(t.getIndex()!==null){let r=n>65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new kt(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(!t.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){let e=this._instanceInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){let e=this._geometryInfo;if(t<0||t>=e.length||e[t].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ne);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Tn),this.getBoundingBoxAt(r,Ou).applyMatrix4(Tn),t.union(Ou)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Be);let t=this.boundingSphere,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n<i;n++){if(e[n].active===!1)continue;let r=e[n].geometryIndex;this.getMatrixAt(n,Tn),this.getBoundingSphereAt(r,$r).applyMatrix4(Tn),t.union($r)}}addInstance(t){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Zd),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let r=this._matricesTexture;Tn.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;let o=this._colorsTexture;return o&&(TS.toArray(o.image.data,i*4),o.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);let i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;let o=t.getIndex();if(o!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?o.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Zd),c=this._availableGeometryIds.shift(),r[c]=i):(c=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(c,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),o=e.getIndex(),a=this._geometryInfo[t];if(i&&o.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=e.getAttribute("position").count;for(let u in n.attributes){let h=e.getAttribute(u),f=n.getAttribute(u);AS(h,f,c);let p=h.itemSize;for(let x=h.count,v=l;x<v;x++){let y=c+x;for(let _=0;_<p;_++)f.setComponent(y,_,0)}f.needsUpdate=!0,f.addUpdateRange(c*p,l*p)}if(i){let u=a.indexStart,h=a.reservedIndexCount;a.indexCount=e.getIndex().count;for(let f=0;f<o.count;f++)r.setX(u+f,c+o.getX(f));for(let f=o.count,p=h;f<p;f++)r.setX(u+f,c);r.needsUpdate=!0,r.addUpdateRange(u,a.reservedIndexCount)}return a.start=i?a.indexStart:a.vertexStart,a.count=i?a.indexCount:a.vertexCount,a.boundingBox=null,e.boundingBox!==null&&(a.boundingBox=e.boundingBox.clone()),a.boundingSphere=null,e.boundingSphere!==null&&(a.boundingSphere=e.boundingSphere.clone()),this._visibilityChanged=!0,t}deleteGeometry(t){let e=this._geometryInfo;if(t>=e.length||e[t].active===!1)return this;let n=this._instanceInfo;for(let i=0,r=n.length;i<r;i++)n[i].active&&n[i].geometryIndex===t&&this.deleteInstance(i);return e[t].active=!1,this._availableGeometryIds.push(t),this._visibilityChanged=!0,this}deleteInstance(t){return this.validateInstanceId(t),this._instanceInfo[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this}optimize(){let t=0,e=0,n=this._geometryInfo,i=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),r=this.geometry;for(let o=0,a=n.length;o<a;o++){let c=i[o],l=n[c];if(l.active!==!1){if(r.index!==null){if(l.indexStart!==e){let{indexStart:u,vertexStart:h,reservedIndexCount:f}=l,p=r.index,x=p.array,v=t-h;for(let y=u;y<u+f;y++)x[y]=x[y]+v;p.array.copyWithin(e,u,u+f),p.addUpdateRange(e,f),l.indexStart=e}e+=l.reservedIndexCount}if(l.vertexStart!==t){let{vertexStart:u,reservedVertexCount:h}=l,f=r.attributes;for(let p in f){let x=f[p],{array:v,itemSize:y}=x;v.copyWithin(t*y,u*y,(u+h)*y),x.addUpdateRange(t*y,h*y)}l.vertexStart=t}t+=l.reservedVertexCount,l.start=r.index?l.indexStart:l.vertexStart,this._nextIndexStart=r.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){let r=new ne,o=n.index,a=n.attributes.position;for(let c=i.start,l=i.start+i.count;c<l;c++){let u=c;o&&(u=o.getX(u)),r.expandByPoint(za.fromBufferAttribute(a,u))}i.boundingBox=r}return e.copy(i.boundingBox),e}getBoundingSphereAt(t,e){if(t>=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){let r=new Be;this.getBoundingBoxAt(t,Ou),Ou.getCenter(r.center);let o=n.index,a=n.attributes.position,c=0;for(let l=i.start,u=i.start+i.count;l<u;l++){let h=l;o&&(h=o.getX(h)),za.fromBufferAttribute(a,h),c=Math.max(c,r.center.distanceToSquared(za))}r.radius=Math.sqrt(c),i.boundingSphere=r}return e.copy(i.boundingSphere),e}setMatrixAt(t,e){this.validateInstanceId(t);let n=this._matricesTexture,i=this._matricesTexture.image.data;return e.toArray(i,t*16),n.needsUpdate=!0,this}getMatrixAt(t,e){return this.validateInstanceId(t),e.fromArray(this._matricesTexture.image.data,t*16)}setColorAt(t,e){return this.validateInstanceId(t),this._colorsTexture===null&&this._initColorsTexture(),e.toArray(this._colorsTexture.image.data,t*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(t,e){return this.validateInstanceId(t),e.fromArray(this._colorsTexture.image.data,t*4)}setVisibleAt(t,e){return this.validateInstanceId(t),this._instanceInfo[t].visible===e?this:(this._instanceInfo[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){return this.validateInstanceId(t),this._instanceInfo[t].visible}setGeometryIdAt(t,e){return this.validateInstanceId(t),this.validateGeometryId(e),this._instanceInfo[t].geometryIndex=e,this}getGeometryIdAt(t){return this.validateInstanceId(t),this._instanceInfo[t].geometryIndex}getGeometryRangeAt(t,e={}){this.validateGeometryId(t);let n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){let e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(Zd);e[e.length-1]===n.length-1;)n.pop(),e.pop();if(t<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${t} are being used. Cannot shrink instance count.`);let i=new Int32Array(t),r=new Int32Array(t);Kr(this._multiDrawCounts,i),Kr(this._multiDrawStarts,r),this._multiDrawCounts=i,this._multiDrawStarts=r,this._maxInstanceCount=t;let o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),Kr(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Kr(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),Kr(c.image.data,this._colorsTexture.image.data))}setGeometrySize(t,e){let n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Vt,this._initializeGeometry(r));let o=this.geometry;r.index&&Kr(r.index.array,o.index.array);for(let a in r.attributes)Kr(r.attributes[a].array,o.attributes[a].array)}raycast(t,e){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,o=this.geometry;cn.material=this.material,cn.geometry.index=o.index,cn.geometry.attributes=o.attributes,cn.geometry.boundingBox===null&&(cn.geometry.boundingBox=new ne),cn.geometry.boundingSphere===null&&(cn.geometry.boundingSphere=new Be);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;let l=n[a].geometryIndex,u=i[l];cn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,cn.matrixWorld).premultiply(r),this.getBoundingBoxAt(l,cn.geometry.boundingBox),this.getBoundingSphereAt(l,cn.geometry.boundingSphere),cn.raycast(t,Bu);for(let h=0,f=Bu.length;h<f;h++){let p=Bu[h];p.object=this,p.batchId=a,e.push(p)}Bu.length=0}cn.material=null,cn.geometry.index=null,cn.geometry.attributes={},cn.geometry.setDrawRange(0,1/0)}copy(t){return super.copy(t),this.geometry=t.geometry.clone(),this.perObjectFrustumCulled=t.perObjectFrustumCulled,this.sortObjects=t.sortObjects,this.boundingBox=t.boundingBox!==null?t.boundingBox.clone():null,this.boundingSphere=t.boundingSphere!==null?t.boundingSphere.clone():null,this._geometryInfo=t._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=i.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,f=this.perObjectFrustumCulled,p=this._indirectTexture,x=p.image.data,v=n.isArrayCamera?ES:h_;f&&!n.isArrayCamera&&(Tn.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),h_.setFromProjectionMatrix(Tn,n.coordinateSystem,n.reversedDepth));let y=0;if(this.sortObjects){Tn.copy(this.matrixWorld).invert(),za.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Tn),f_.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Tn);for(let g=0,d=c.length;g<d;g++)if(c[g].visible&&c[g].active){let M=c[g].geometryIndex;this.getMatrixAt(g,Tn),this.getBoundingSphereAt(M,$r).applyMatrix4(Tn);let m=!1;if(f&&(m=!v.intersectsSphere($r,n)),!m){let R=h[M],E=wS.subVectors($r.center,za).dot(f_);Jd.push(R.start,R.count,E,g)}}let _=Jd.list,S=this.customSort;S===null?_.sort(r.transparent?bS:SS):S.call(this,_,n);for(let g=0,d=_.length;g<d;g++){let M=_[g];l[y]=M.start*a,u[y]=M.count,x[y]=M.index,y++}Jd.reset()}else for(let _=0,S=c.length;_<S;_++)if(c[_].visible&&c[_].active){let g=c[_].geometryIndex,d=!1;if(f&&(this.getMatrixAt(_,Tn),this.getBoundingSphereAt(g,$r).applyMatrix4(Tn),d=!v.intersectsSphere($r,n)),!d){let M=h[g];l[y]=M.start*a,u[y]=M.count,x[y]=_,y++}}p.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(t,e,n,i,r,o){this.onBeforeRender(t,null,i,r,o)}},Xe=class extends Ue{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}},dh=new I,ph=new I,d_=new vt,ka=new _n,zu=new Be,jd=new I,p_=new I,Vn=class extends re{constructor(t=new Vt,e=new Xe){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)dh.fromBufferAttribute(e,i-1),ph.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=dh.distanceTo(ph);t.setAttribute("lineDistance",new Lt(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),zu.copy(n.boundingSphere),zu.applyMatrix4(i),zu.radius+=r,t.ray.intersectsSphere(zu)===!1)return;d_.copy(i).invert(),ka.copy(t.ray).applyMatrix4(d_);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,f=n.attributes.position;if(u!==null){let p=Math.max(0,o.start),x=Math.min(u.count,o.start+o.count);for(let v=p,y=x-1;v<y;v+=l){let _=u.getX(v),S=u.getX(v+1),g=ku(this,t,ka,c,_,S,v);g&&e.push(g)}if(this.isLineLoop){let v=u.getX(x-1),y=u.getX(p),_=ku(this,t,ka,c,v,y,x-1);_&&e.push(_)}}else{let p=Math.max(0,o.start),x=Math.min(f.count,o.start+o.count);for(let v=p,y=x-1;v<y;v+=l){let _=ku(this,t,ka,c,v,v+1,v);_&&e.push(_)}if(this.isLineLoop){let v=ku(this,t,ka,c,x-1,p,x-1);v&&e.push(v)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function ku(s,t,e,n,i,r,o){let a=s.geometry.attributes.position;if(dh.fromBufferAttribute(a,i),ph.fromBufferAttribute(a,r),e.distanceSqToSegment(dh,ph,jd,p_)>n)return;jd.applyMatrix4(s.matrixWorld);let l=t.ray.origin.distanceTo(jd);if(!(l<t.near||l>t.far))return{distance:l,point:p_.clone().applyMatrix4(s.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:s}}var m_=new I,g_=new I,yn=class extends Vn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)m_.fromBufferAttribute(e,i),g_.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+m_.distanceTo(g_);t.setAttribute("lineDistance",new Lt(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},ps=class extends Vn{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}},Ir=class extends Ue{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new yt(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}},x_=new vt,hp=new _n,Hu=new Be,Vu=new I,ms=class extends re{constructor(t=new Vt,e=new Ir){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){let n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Hu.copy(n.boundingSphere),Hu.applyMatrix4(i),Hu.radius+=r,t.ray.intersectsSphere(Hu)===!1)return;x_.copy(i).invert(),hp.copy(t.ray).applyMatrix4(x_);let a=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){let f=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let x=f,v=p;x<v;x++){let y=l.getX(x);Vu.fromBufferAttribute(h,y),__(Vu,y,c,i,t,e,this)}}else{let f=Math.max(0,o.start),p=Math.min(h.count,o.start+o.count);for(let x=f,v=p;x<v;x++)Vu.fromBufferAttribute(h,x),__(Vu,x,c,i,t,e,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,o=i.length;r<o;r++){let a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}};function __(s,t,e,n,i,r,o){let a=hp.distanceSqToPoint(s);if(a<e){let c=new I;hp.closestPointToPoint(s,c),c.applyMatrix4(n);let l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var rc=class extends Ie{constructor(t,e,n,i,r=Ee,o=Ee,a,c,l){super(t,e,n,i,r,o,a,c,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let u=this;function h(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=t.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(h))}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),super.dispose()}},mh=class extends rc{constructor(t,e,n,i,r,o,a,c){super({},t,e,n,i,r,o,a,c),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}},gh=class extends Ie{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=De,this.minFilter=De,this.generateMipmaps=!1,this.needsUpdate=!0}},gi=class extends Ie{constructor(t,e,n,i,r,o,a,c,l,u,h,f){super(null,o,a,c,l,u,i,r,h,f),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}},xh=class extends gi{constructor(t,e,n,i,r,o){super(t,e,n,r,o),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=en,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},_h=class extends gi{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Wi),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},Eo=class extends Ie{constructor(t,e,n,i,r,o,a,c,l){super(t,e,n,i,r,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},wo=class extends Ie{constructor(t,e,n=qi,i,r,o,a=De,c=De,l,u=rs,h=1){if(u!==rs&&u!==Rs)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:t,height:e,depth:h};super(f,i,r,o,a,c,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new On(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},Ao=class extends Ie{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}},sc=class s extends Vt{constructor(t=1,e=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:n,radialSegments:i,heightSegments:r},e=Math.max(0,e),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i)),r=Math.max(1,Math.floor(r));let o=[],a=[],c=[],l=[],u=e/2,h=Math.PI/2*t,f=e,p=2*h+f,x=n*2+r,v=i+1,y=new I,_=new I;for(let S=0;S<=x;S++){let g=0,d=0,M=0,m=0;if(S<=n){let T=S/n,b=T*Math.PI/2;d=-u-t*Math.cos(b),M=t*Math.sin(b),m=-t*Math.cos(b),g=T*h}else if(S<=n+r){let T=(S-n)/r;d=-u+T*e,M=t,m=0,g=h+T*f}else{let T=(S-n-r)/n,b=T*Math.PI/2;d=u+t*Math.sin(b),M=t*Math.cos(b),m=t*Math.sin(b),g=h+f+T*h}let R=Math.max(0,Math.min(1,g/p)),E=0;S===0?E=.5/i:S===x&&(E=-.5/i);for(let T=0;T<=i;T++){let b=T/i,w=b*Math.PI*2,A=Math.sin(w),C=Math.cos(w);_.x=-M*C,_.y=d,_.z=M*A,a.push(_.x,_.y,_.z),y.set(-M*C,m,M*A),y.normalize(),c.push(y.x,y.y,y.z),l.push(b+E,R)}if(S>0){let T=(S-1)*v;for(let b=0;b<i;b++){let w=T+b,A=T+b+1,C=S*v+b,D=S*v+b+1;o.push(w,A,C),o.push(A,D,C)}}}this.setIndex(o),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.height,t.capSegments,t.radialSegments,t.heightSegments)}},oc=class s extends Vt{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);let r=[],o=[],a=[],c=[],l=new I,u=new nt;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,f=3;h<=e;h++,f+=3){let p=n+h/e*i;l.x=t*Math.cos(p),l.y=t*Math.sin(p),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[f]/t+1)/2,u.y=(o[f+1]/t+1)/2,c.push(u.x,u.y)}for(let h=1;h<=e;h++)r.push(h,h+1,0);this.setIndex(r),this.setAttribute("position",new Lt(o,3)),this.setAttribute("normal",new Lt(a,3)),this.setAttribute("uv",new Lt(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.segments,t.thetaStart,t.thetaLength)}},Ro=class s extends Vt{constructor(t=1,e=1,n=1,i=32,r=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c};let l=this;i=Math.floor(i),r=Math.floor(r);let u=[],h=[],f=[],p=[],x=0,v=[],y=n/2,_=0;S(),o===!1&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(u),this.setAttribute("position",new Lt(h,3)),this.setAttribute("normal",new Lt(f,3)),this.setAttribute("uv",new Lt(p,2));function S(){let d=new I,M=new I,m=0,R=(e-t)/n;for(let E=0;E<=r;E++){let T=[],b=E/r,w=b*(e-t)+t;for(let A=0;A<=i;A++){let C=A/i,D=C*c+a,F=Math.sin(D),O=Math.cos(D);M.x=w*F,M.y=-b*n+y,M.z=w*O,h.push(M.x,M.y,M.z),d.set(F,R,O).normalize(),f.push(d.x,d.y,d.z),p.push(C,1-b),T.push(x++)}v.push(T)}for(let E=0;E<i;E++)for(let T=0;T<r;T++){let b=v[T][E],w=v[T+1][E],A=v[T+1][E+1],C=v[T][E+1];(t>0||T!==0)&&(u.push(b,w,C),m+=3),(e>0||T!==r-1)&&(u.push(w,A,C),m+=3)}l.addGroup(_,m,0),_+=m}function g(d){let M=x,m=new nt,R=new I,E=0,T=d===!0?t:e,b=d===!0?1:-1;for(let A=1;A<=i;A++)h.push(0,y*b,0),f.push(0,b,0),p.push(.5,.5),x++;let w=x;for(let A=0;A<=i;A++){let D=A/i*c+a,F=Math.cos(D),O=Math.sin(D);R.x=T*O,R.y=y*b,R.z=T*F,h.push(R.x,R.y,R.z),f.push(0,b,0),m.x=F*.5+.5,m.y=O*.5*b+.5,p.push(m.x,m.y),x++}for(let A=0;A<i;A++){let C=M+A,D=w+A;d===!0?u.push(D,D+1,C):u.push(D+1,D,C),E+=3}l.addGroup(_,E,d===!0?1:2),_+=E}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},Co=class s extends Ro{constructor(t=1,e=1,n=32,i=1,r=!1,o=0,a=Math.PI*2){super(0,t,e,n,i,r,o,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:o,thetaLength:a}}static fromJSON(t){return new s(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ar=class s extends Vt{constructor(t=[],e=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:n,detail:i};let r=[],o=[];a(i),l(n),u(),this.setAttribute("position",new Lt(r,3)),this.setAttribute("normal",new Lt(r.slice(),3)),this.setAttribute("uv",new Lt(o,2)),i===0?this.computeVertexNormals():this.normalizeNormals();function a(S){let g=new I,d=new I,M=new I;for(let m=0;m<e.length;m+=3)p(e[m+0],g),p(e[m+1],d),p(e[m+2],M),c(g,d,M,S)}function c(S,g,d,M){let m=M+1,R=[];for(let E=0;E<=m;E++){R[E]=[];let T=S.clone().lerp(d,E/m),b=g.clone().lerp(d,E/m),w=m-E;for(let A=0;A<=w;A++)A===0&&E===m?R[E][A]=T:R[E][A]=T.clone().lerp(b,A/w)}for(let E=0;E<m;E++)for(let T=0;T<2*(m-E)-1;T++){let b=Math.floor(T/2);T%2===0?(f(R[E][b+1]),f(R[E+1][b]),f(R[E][b])):(f(R[E][b+1]),f(R[E+1][b+1]),f(R[E+1][b]))}}function l(S){let g=new I;for(let d=0;d<r.length;d+=3)g.x=r[d+0],g.y=r[d+1],g.z=r[d+2],g.normalize().multiplyScalar(S),r[d+0]=g.x,r[d+1]=g.y,r[d+2]=g.z}function u(){let S=new I;for(let g=0;g<r.length;g+=3){S.x=r[g+0],S.y=r[g+1],S.z=r[g+2];let d=y(S)/2/Math.PI+.5,M=_(S)/Math.PI+.5;o.push(d,1-M)}x(),h()}function h(){for(let S=0;S<o.length;S+=6){let g=o[S+0],d=o[S+2],M=o[S+4],m=Math.max(g,d,M),R=Math.min(g,d,M);m>.9&&R<.1&&(g<.2&&(o[S+0]+=1),d<.2&&(o[S+2]+=1),M<.2&&(o[S+4]+=1))}}function f(S){r.push(S.x,S.y,S.z)}function p(S,g){let d=S*3;g.x=t[d+0],g.y=t[d+1],g.z=t[d+2]}function x(){let S=new I,g=new I,d=new I,M=new I,m=new nt,R=new nt,E=new nt;for(let T=0,b=0;T<r.length;T+=9,b+=6){S.set(r[T+0],r[T+1],r[T+2]),g.set(r[T+3],r[T+4],r[T+5]),d.set(r[T+6],r[T+7],r[T+8]),m.set(o[b+0],o[b+1]),R.set(o[b+2],o[b+3]),E.set(o[b+4],o[b+5]),M.copy(S).add(g).add(d).divideScalar(3);let w=y(M);v(m,b+0,S,w),v(R,b+2,g,w),v(E,b+4,d,w)}}function v(S,g,d,M){M<0&&S.x===1&&(o[g]=S.x-1),d.x===0&&d.z===0&&(o[g]=M/2/Math.PI+.5)}function y(S){return Math.atan2(S.z,-S.x)}function _(S){return Math.atan2(-S.y,Math.sqrt(S.x*S.x+S.z*S.z))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.vertices,t.indices,t.radius,t.details)}},ac=class s extends ar{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=1/n,r=[-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,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],o=[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];super(r,o,t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},Gu=new I,Wu=new I,Qd=new I,Xu=new me,cc=class extends Vt{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},t!==null){let i=Math.pow(10,4),r=Math.cos(is*e),o=t.getIndex(),a=t.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),f={},p=[];for(let x=0;x<c;x+=3){o?(l[0]=o.getX(x),l[1]=o.getX(x+1),l[2]=o.getX(x+2)):(l[0]=x,l[1]=x+1,l[2]=x+2);let{a:v,b:y,c:_}=Xu;if(v.fromBufferAttribute(a,l[0]),y.fromBufferAttribute(a,l[1]),_.fromBufferAttribute(a,l[2]),Xu.getNormal(Qd),h[0]=`${Math.round(v.x*i)},${Math.round(v.y*i)},${Math.round(v.z*i)}`,h[1]=`${Math.round(y.x*i)},${Math.round(y.y*i)},${Math.round(y.z*i)}`,h[2]=`${Math.round(_.x*i)},${Math.round(_.y*i)},${Math.round(_.z*i)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let S=0;S<3;S++){let g=(S+1)%3,d=h[S],M=h[g],m=Xu[u[S]],R=Xu[u[g]],E=`${d}_${M}`,T=`${M}_${d}`;T in f&&f[T]?(Qd.dot(f[T].normal)<=r&&(p.push(m.x,m.y,m.z),p.push(R.x,R.y,R.z)),f[T]=null):E in f||(f[E]={index0:l[S],index1:l[g],normal:Qd.clone()})}}for(let x in f)if(f[x]){let{index0:v,index1:y}=f[x];Gu.fromBufferAttribute(a,v),Wu.fromBufferAttribute(a,y),p.push(Gu.x,Gu.y,Gu.z),p.push(Wu.x,Wu.y,Wu.z)}this.setAttribute("position",new Lt(p,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}},In=class{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.Curve: .getPoint() not implemented.")}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)n=this.getPoint(o/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e=null){let n=this.getLengths(),i=0,r=n.length,o;e?o=e:o=t*n[r-1];let a=0,c=r-1,l;for(;a<=c;)if(i=Math.floor(a+(c-a)/2),l=n[i]-o,l<0)a=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===o)return i/(r-1);let u=n[i],f=n[i+1]-u,p=(o-u)/f;return(i+p)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let o=this.getPoint(i),a=this.getPoint(r),c=e||(o.isVector2?new nt:new I);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e=!1){let n=new I,i=[],r=[],o=[],a=new I,c=new vt;for(let p=0;p<=t;p++){let x=p/t;i[p]=this.getTangentAt(x,new I)}r[0]=new I,o[0]=new I;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),h=Math.abs(i[0].y),f=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),f<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),o[0].crossVectors(i[0],r[0]);for(let p=1;p<=t;p++){if(r[p]=r[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(i[p-1],i[p]),a.length()>Number.EPSILON){a.normalize();let x=Math.acos(Xt(i[p-1].dot(i[p]),-1,1));r[p].applyMatrix4(c.makeRotationAxis(a,x))}o[p].crossVectors(i[p],r[p])}if(e===!0){let p=Math.acos(Xt(r[0].dot(r[t]),-1,1));p/=t,i[0].dot(a.crossVectors(r[0],r[t]))>0&&(p=-p);for(let x=1;x<=t;x++)r[x].applyMatrix4(c.makeRotationAxis(i[x],p*x)),o[x].crossVectors(i[x],r[x])}return{tangents:i,normals:r,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},gs=class extends In{constructor(t=0,e=0,n=1,i=1,r=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(t,e=new nt){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(o?r=0:r=i),this.aClockwise===!0&&!o&&(r===i?r=-i:r=r-i);let a=this.aStartAngle+t*r,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),f=c-this.aX,p=l-this.aY;c=f*u-p*h+this.aX,l=f*h+p*u+this.aY}return n.set(c,l)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){let t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}},lc=class extends gs{constructor(t,e,n,i,r,o){super(t,e,n,n,i,r,o),this.isArcCurve=!0,this.type="ArcCurve"}};function xm(){let s=0,t=0,e=0,n=0;function i(r,o,a,c){s=r,t=a,e=-3*r+3*o-2*a-c,n=2*r-2*o+a+c}return{initCatmullRom:function(r,o,a,c,l){i(o,a,l*(a-r),l*(c-o))},initNonuniformCatmullRom:function(r,o,a,c,l,u,h){let f=(o-r)/l-(a-r)/(l+u)+(a-o)/u,p=(a-o)/u-(c-o)/(u+h)+(c-a)/h;f*=u,p*=u,i(o,a,f,p)},calc:function(r){let o=r*r,a=o*r;return s+t*r+e*o+n*a}}}var qu=new I,tp=new xm,ep=new xm,np=new xm,uc=class extends In{constructor(t=[],e=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=i}getPoint(t,e=new I){let n=e,i=this.points,r=i.length,o=(r-(this.closed?0:1))*t,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:c===0&&a===r-1&&(a=r-2,c=1);let l,u;this.closed||a>0?l=i[(a-1)%r]:(qu.subVectors(i[0],i[1]).add(i[0]),l=qu);let h=i[a%r],f=i[(a+1)%r];if(this.closed||a+2<r?u=i[(a+2)%r]:(qu.subVectors(i[r-1],i[r-2]).add(i[r-1]),u=qu),this.curveType==="centripetal"||this.curveType==="chordal"){let p=this.curveType==="chordal"?.5:.25,x=Math.pow(l.distanceToSquared(h),p),v=Math.pow(h.distanceToSquared(f),p),y=Math.pow(f.distanceToSquared(u),p);v<1e-4&&(v=1),x<1e-4&&(x=v),y<1e-4&&(y=v),tp.initNonuniformCatmullRom(l.x,h.x,f.x,u.x,x,v,y),ep.initNonuniformCatmullRom(l.y,h.y,f.y,u.y,x,v,y),np.initNonuniformCatmullRom(l.z,h.z,f.z,u.z,x,v,y)}else this.curveType==="catmullrom"&&(tp.initCatmullRom(l.x,h.x,f.x,u.x,this.tension),ep.initCatmullRom(l.y,h.y,f.y,u.y,this.tension),np.initCatmullRom(l.z,h.z,f.z,u.z,this.tension));return n.set(tp.calc(c),ep.calc(c),np.calc(c)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new I().fromArray(i))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}};function y_(s,t,e,n,i){let r=(n-t)*.5,o=(i-e)*.5,a=s*s,c=s*a;return(2*e-2*n+r+o)*c+(-3*e+3*n-2*r-o)*a+r*s+e}function RS(s,t){let e=1-s;return e*e*t}function CS(s,t){return 2*(1-s)*s*t}function IS(s,t){return s*s*t}function qa(s,t,e,n){return RS(s,t)+CS(s,e)+IS(s,n)}function PS(s,t){let e=1-s;return e*e*e*t}function LS(s,t){let e=1-s;return 3*e*e*s*t}function NS(s,t){return 3*(1-s)*s*s*t}function DS(s,t){return s*s*s*t}function Ya(s,t,e,n,i){return PS(s,t)+LS(s,e)+NS(s,n)+DS(s,i)}var Io=class extends In{constructor(t=new nt,e=new nt,n=new nt,i=new nt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new nt){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ya(t,i.x,r.x,o.x,a.x),Ya(t,i.y,r.y,o.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},hc=class extends In{constructor(t=new I,e=new I,n=new I,i=new I){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=i}getPoint(t,e=new I){let n=e,i=this.v0,r=this.v1,o=this.v2,a=this.v3;return n.set(Ya(t,i.x,r.x,o.x,a.x),Ya(t,i.y,r.y,o.y,a.y),Ya(t,i.z,r.z,o.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}},Po=class extends In{constructor(t=new nt,e=new nt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new nt){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new nt){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},fc=class extends In{constructor(t=new I,e=new I){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new I){let n=e;return t===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e=new I){return e.subVectors(this.v2,this.v1).normalize()}getTangentAt(t,e){return this.getTangent(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Lo=class extends In{constructor(t=new nt,e=new nt,n=new nt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new nt){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(qa(t,i.x,r.x,o.x),qa(t,i.y,r.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},No=class extends In{constructor(t=new I,e=new I,n=new I){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new I){let n=e,i=this.v0,r=this.v1,o=this.v2;return n.set(qa(t,i.x,r.x,o.x),qa(t,i.y,r.y,o.y),qa(t,i.z,r.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){let t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},Do=class extends In{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new nt){let n=e,i=this.points,r=(i.length-1)*t,o=Math.floor(r),a=r-o,c=i[o===0?o:o-1],l=i[o],u=i[o>i.length-2?i.length-1:o+1],h=i[o>i.length-3?i.length-1:o+2];return n.set(y_(a,c.x,l.x,u.x,h.x),y_(a,c.y,l.y,u.y,h.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){let i=this.points[e];t.points.push(i.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){let i=t.points[e];this.points.push(new nt().fromArray(i))}return this}},yh=Object.freeze({__proto__:null,ArcCurve:lc,CatmullRomCurve3:uc,CubicBezierCurve:Io,CubicBezierCurve3:hc,EllipseCurve:gs,LineCurve:Po,LineCurve3:fc,QuadraticBezierCurve:Lo,QuadraticBezierCurve3:No,SplineCurve:Do}),dc=class extends In{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){let t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);if(!t.equals(e)){let n=t.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new yh[n](e,t))}return this}getPoint(t,e){let n=t*this.getLength(),i=this.getCurveLengths(),r=0;for(;r<i.length;){if(i[r]>=n){let o=i[r]-n,a=this.curves[r],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let n=0,i=this.curves.length;n<i;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){let e=[],n;for(let i=0,r=this.curves;i<r.length;i++){let o=r[i],a=o.isEllipseCurve?t*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?t*o.points.length:t,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];n&&n.equals(u)||(e.push(u),n=u)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}toJSON(){let t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){let i=this.curves[e];t.curves.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){let i=t.curves[e];this.curves.push(new yh[i.type]().fromJSON(i))}return this}},xs=class extends dc{constructor(t){super(),this.type="Path",this.currentPoint=new nt,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){let n=new Po(this.currentPoint.clone(),new nt(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,i){let r=new Lo(this.currentPoint.clone(),new nt(t,e),new nt(n,i));return this.curves.push(r),this.currentPoint.set(n,i),this}bezierCurveTo(t,e,n,i,r,o){let a=new Io(this.currentPoint.clone(),new nt(t,e),new nt(n,i),new nt(r,o));return this.curves.push(a),this.currentPoint.set(r,o),this}splineThru(t){let e=[this.currentPoint.clone()].concat(t),n=new Do(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,i,r,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(t+a,e+c,n,i,r,o),this}absarc(t,e,n,i,r,o){return this.absellipse(t,e,n,n,i,r,o),this}ellipse(t,e,n,i,r,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(t+l,e+u,n,i,r,o,a,c),this}absellipse(t,e,n,i,r,o,a,c){let l=new gs(t,e,n,i,r,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Pi=class extends xs{constructor(t){super(t),this.uuid=Bn(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let n=0,i=this.holes.length;n<i;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(i.clone())}return this}toJSON(){let t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){let i=this.holes[e];t.holes.push(i.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){let i=t.holes[e];this.holes.push(new xs().fromJSON(i))}return this}};function US(s,t,e=2){let n=t&&t.length,i=n?t[0]*e:s.length,r=C0(s,0,i,e,!0),o=[];if(!r||r.next===r.prev)return o;let a,c,l;if(n&&(r=kS(s,t,r,e)),s.length>80*e){a=1/0,c=1/0;let u=-1/0,h=-1/0;for(let f=e;f<i;f+=e){let p=s[f],x=s[f+1];p<a&&(a=p),x<c&&(c=x),p>u&&(u=p),x>h&&(h=x)}l=Math.max(u-a,h-c),l=l!==0?32767/l:0}return pc(r,o,e,a,c,l,0),o}function C0(s,t,e,n,i){let r;if(i===JS(s,t,e,n)>0)for(let o=t;o<e;o+=n)r=v_(o/n|0,s[o],s[o+1],r);else for(let o=e-n;o>=t;o-=n)r=v_(o/n|0,s[o],s[o+1],r);return r&&Uo(r,r.next)&&(gc(r),r=r.next),r}function _s(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Uo(e,e.next)||Ne(e.prev,e,e.next)===0)){if(gc(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function pc(s,t,e,n,i,r,o){if(!s)return;!o&&r&&XS(s,n,i,r);let a=s;for(;s.prev!==s.next;){let c=s.prev,l=s.next;if(r?OS(s,n,i,r):FS(s)){t.push(c.i,s.i,l.i),gc(s),s=l.next,a=l.next;continue}if(s=l,s===a){o?o===1?(s=BS(_s(s),t),pc(s,t,e,n,i,r,2)):o===2&&zS(s,t,e,n,i,r):pc(_s(s),t,e,n,i,r,1);break}}}function FS(s){let t=s.prev,e=s,n=s.next;if(Ne(t,e,n)>=0)return!1;let i=t.x,r=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=Math.min(i,r,o),h=Math.min(a,c,l),f=Math.max(i,r,o),p=Math.max(a,c,l),x=n.next;for(;x!==t;){if(x.x>=u&&x.x<=f&&x.y>=h&&x.y<=p&&Ga(i,a,r,c,o,l,x.x,x.y)&&Ne(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function OS(s,t,e,n){let i=s.prev,r=s,o=s.next;if(Ne(i,r,o)>=0)return!1;let a=i.x,c=r.x,l=o.x,u=i.y,h=r.y,f=o.y,p=Math.min(a,c,l),x=Math.min(u,h,f),v=Math.max(a,c,l),y=Math.max(u,h,f),_=fp(p,x,t,e,n),S=fp(v,y,t,e,n),g=s.prevZ,d=s.nextZ;for(;g&&g.z>=_&&d&&d.z<=S;){if(g.x>=p&&g.x<=v&&g.y>=x&&g.y<=y&&g!==i&&g!==o&&Ga(a,u,c,h,l,f,g.x,g.y)&&Ne(g.prev,g,g.next)>=0||(g=g.prevZ,d.x>=p&&d.x<=v&&d.y>=x&&d.y<=y&&d!==i&&d!==o&&Ga(a,u,c,h,l,f,d.x,d.y)&&Ne(d.prev,d,d.next)>=0))return!1;d=d.nextZ}for(;g&&g.z>=_;){if(g.x>=p&&g.x<=v&&g.y>=x&&g.y<=y&&g!==i&&g!==o&&Ga(a,u,c,h,l,f,g.x,g.y)&&Ne(g.prev,g,g.next)>=0)return!1;g=g.prevZ}for(;d&&d.z<=S;){if(d.x>=p&&d.x<=v&&d.y>=x&&d.y<=y&&d!==i&&d!==o&&Ga(a,u,c,h,l,f,d.x,d.y)&&Ne(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function BS(s,t){let e=s;do{let n=e.prev,i=e.next.next;!Uo(n,i)&&P0(n,e,e.next,i)&&mc(n,i)&&mc(i,n)&&(t.push(n.i,e.i,i.i),gc(e),gc(e.next),e=s=i),e=e.next}while(e!==s);return _s(e)}function zS(s,t,e,n,i,r){let o=s;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&$S(o,a)){let c=L0(o,a);o=_s(o,o.next),c=_s(c,c.next),pc(o,t,e,n,i,r,0),pc(c,t,e,n,i,r,0);return}a=a.next}o=o.next}while(o!==s)}function kS(s,t,e,n){let i=[];for(let r=0,o=t.length;r<o;r++){let a=t[r]*n,c=r<o-1?t[r+1]*n:s.length,l=C0(s,a,c,n,!1);l===l.next&&(l.steiner=!0),i.push(YS(l))}i.sort(HS);for(let r=0;r<i.length;r++)e=VS(i[r],e);return e}function HS(s,t){let e=s.x-t.x;if(e===0&&(e=s.y-t.y,e===0)){let n=(s.next.y-s.y)/(s.next.x-s.x),i=(t.next.y-t.y)/(t.next.x-t.x);e=n-i}return e}function VS(s,t){let e=GS(s,t);if(!e)return t;let n=L0(e,s);return _s(n,n.next),_s(e,e.next)}function GS(s,t){let e=t,n=s.x,i=s.y,r=-1/0,o;if(Uo(s,e))return e;do{if(Uo(s,e.next))return e.next;if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let h=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=n&&h>r&&(r=h,o=e.x<e.next.x?e:e.next,h===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0;e=o;do{if(n>=e.x&&e.x>=c&&n!==e.x&&I0(i<l?n:r,i,c,l,i<l?r:n,i,e.x,e.y)){let h=Math.abs(i-e.y)/(n-e.x);mc(e,s)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&WS(o,e)))&&(o=e,u=h)}e=e.next}while(e!==a);return o}function WS(s,t){return Ne(s.prev,s,t.prev)<0&&Ne(t.next,s,s.next)<0}function XS(s,t,e,n){let i=s;do i.z===0&&(i.z=fp(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,qS(i)}function qS(s){let t,e=1;do{let n=s,i;s=null;let r=null;for(t=0;n;){t++;let o=n,a=0;for(let l=0;l<e&&(a++,o=o.nextZ,!!o);l++);let c=e;for(;a>0||c>0&&o;)a!==0&&(c===0||!o||n.z<=o.z)?(i=n,n=n.nextZ,a--):(i=o,o=o.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;n=o}r.nextZ=null,e*=2}while(t>1);return s}function fp(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function YS(s){let t=s,e=s;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==s);return e}function I0(s,t,e,n,i,r,o,a){return(i-o)*(t-a)>=(s-o)*(r-a)&&(s-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(r-a)>=(i-o)*(n-a)}function Ga(s,t,e,n,i,r,o,a){return!(s===o&&t===a)&&I0(s,t,e,n,i,r,o,a)}function $S(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!KS(s,t)&&(mc(s,t)&&mc(t,s)&&ZS(s,t)&&(Ne(s.prev,s,t.prev)||Ne(s,t.prev,t))||Uo(s,t)&&Ne(s.prev,s,s.next)>0&&Ne(t.prev,t,t.next)>0)}function Ne(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Uo(s,t){return s.x===t.x&&s.y===t.y}function P0(s,t,e,n){let i=$u(Ne(s,t,e)),r=$u(Ne(s,t,n)),o=$u(Ne(e,n,s)),a=$u(Ne(e,n,t));return!!(i!==r&&o!==a||i===0&&Yu(s,e,t)||r===0&&Yu(s,n,t)||o===0&&Yu(e,s,n)||a===0&&Yu(e,t,n))}function Yu(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function $u(s){return s>0?1:s<0?-1:0}function KS(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&P0(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function mc(s,t){return Ne(s.prev,s,s.next)<0?Ne(s,t,s.next)>=0&&Ne(s,s.prev,t)>=0:Ne(s,t,s.prev)<0||Ne(s,s.next,t)<0}function ZS(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function L0(s,t){let e=dp(s.i,s.x,s.y),n=dp(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function v_(s,t,e,n){let i=dp(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function gc(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function dp(s,t,e){return{i:s,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function JS(s,t,e,n){let i=0;for(let r=t,o=e-n;r<e;r+=n)i+=(s[o]-s[r])*(s[r+1]+s[o+1]),o=r;return i}var pp=class{static triangulate(t,e,n=2){return US(t,e,n)}},Qn=class s{static area(t){let e=t.length,n=0;for(let i=e-1,r=0;r<e;i=r++)n+=t[i].x*t[r].y-t[r].x*t[i].y;return n*.5}static isClockWise(t){return s.area(t)<0}static triangulateShape(t,e){let n=[],i=[],r=[];M_(t),S_(n,t);let o=t.length;e.forEach(M_);for(let c=0;c<e.length;c++)i.push(o),o+=e[c].length,S_(n,e[c]);let a=pp.triangulate(n,i);for(let c=0;c<a.length;c+=3)r.push(a.slice(c,c+3));return r}};function M_(s){let t=s.length;t>2&&s[t-1].equals(s[0])&&s.pop()}function S_(s,t){for(let e=0;e<t.length;e++)s.push(t[e].x),s.push(t[e].y)}var xc=class s extends Vt{constructor(t=new Pi([new nt(.5,.5),new nt(-.5,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];let n=this,i=[],r=[];for(let a=0,c=t.length;a<c;a++){let l=t[a];o(l)}this.setAttribute("position",new Lt(i,3)),this.setAttribute("uv",new Lt(r,2)),this.computeVertexNormals();function o(a){let c=[],l=e.curveSegments!==void 0?e.curveSegments:12,u=e.steps!==void 0?e.steps:1,h=e.depth!==void 0?e.depth:1,f=e.bevelEnabled!==void 0?e.bevelEnabled:!0,p=e.bevelThickness!==void 0?e.bevelThickness:.2,x=e.bevelSize!==void 0?e.bevelSize:p-.1,v=e.bevelOffset!==void 0?e.bevelOffset:0,y=e.bevelSegments!==void 0?e.bevelSegments:3,_=e.extrudePath,S=e.UVGenerator!==void 0?e.UVGenerator:jS,g,d=!1,M,m,R,E;_&&(g=_.getSpacedPoints(u),d=!0,f=!1,M=_.computeFrenetFrames(u,!1),m=new I,R=new I,E=new I),f||(y=0,p=0,x=0,v=0);let T=a.extractPoints(l),b=T.shape,w=T.holes;if(!Qn.isClockWise(b)){b=b.reverse();for(let tt=0,Z=w.length;tt<Z;tt++){let Y=w[tt];Qn.isClockWise(Y)&&(w[tt]=Y.reverse())}}function C(tt){let Y=10000000000000001e-36,q=tt[0];for(let mt=1;mt<=tt.length;mt++){let it=mt%tt.length,st=tt[it],Pt=st.x-q.x,It=st.y-q.y,N=Pt*Pt+It*It,P=Math.max(Math.abs(st.x),Math.abs(st.y),Math.abs(q.x),Math.abs(q.y)),k=Y*P*P;if(N<=k){tt.splice(it,1),mt--;continue}q=st}}C(b),w.forEach(C);let D=w.length,F=b;for(let tt=0;tt<D;tt++){let Z=w[tt];b=b.concat(Z)}function O(tt,Z,Y){return Z||console.error("THREE.ExtrudeGeometry: vec does not exist"),tt.clone().addScaledVector(Z,Y)}let H=b.length;function B(tt,Z,Y){let q,mt,it,st=tt.x-Z.x,Pt=tt.y-Z.y,It=Y.x-tt.x,N=Y.y-tt.y,P=st*st+Pt*Pt,k=st*N-Pt*It;if(Math.abs(k)>Number.EPSILON){let W=Math.sqrt(P),et=Math.sqrt(It*It+N*N),X=Z.x-Pt/W,_t=Z.y+st/W,xt=Y.x-N/et,Ft=Y.y+It/et,Dt=((xt-X)*N-(Ft-_t)*It)/(st*N-Pt*It);q=X+st*Dt-tt.x,mt=_t+Pt*Dt-tt.y;let ft=q*q+mt*mt;if(ft<=2)return new nt(q,mt);it=Math.sqrt(ft/2)}else{let W=!1;st>Number.EPSILON?It>Number.EPSILON&&(W=!0):st<-Number.EPSILON?It<-Number.EPSILON&&(W=!0):Math.sign(Pt)===Math.sign(N)&&(W=!0),W?(q=-Pt,mt=st,it=Math.sqrt(P)):(q=st,mt=Pt,it=Math.sqrt(P/2))}return new nt(q/it,mt/it)}let $=[];for(let tt=0,Z=F.length,Y=Z-1,q=tt+1;tt<Z;tt++,Y++,q++)Y===Z&&(Y=0),q===Z&&(q=0),$[tt]=B(F[tt],F[Y],F[q]);let at=[],rt,ht=$.concat();for(let tt=0,Z=D;tt<Z;tt++){let Y=w[tt];rt=[];for(let q=0,mt=Y.length,it=mt-1,st=q+1;q<mt;q++,it++,st++)it===mt&&(it=0),st===mt&&(st=0),rt[q]=B(Y[q],Y[it],Y[st]);at.push(rt),ht=ht.concat(rt)}let bt;if(y===0)bt=Qn.triangulateShape(F,w);else{let tt=[],Z=[];for(let Y=0;Y<y;Y++){let q=Y/y,mt=p*Math.cos(q*Math.PI/2),it=x*Math.sin(q*Math.PI/2)+v;for(let st=0,Pt=F.length;st<Pt;st++){let It=O(F[st],$[st],it);lt(It.x,It.y,-mt),q===0&&tt.push(It)}for(let st=0,Pt=D;st<Pt;st++){let It=w[st];rt=at[st];let N=[];for(let P=0,k=It.length;P<k;P++){let W=O(It[P],rt[P],it);lt(W.x,W.y,-mt),q===0&&N.push(W)}q===0&&Z.push(N)}}bt=Qn.triangulateShape(tt,Z)}let Et=bt.length,Mt=x+v;for(let tt=0;tt<H;tt++){let Z=f?O(b[tt],ht[tt],Mt):b[tt];d?(R.copy(M.normals[0]).multiplyScalar(Z.x),m.copy(M.binormals[0]).multiplyScalar(Z.y),E.copy(g[0]).add(R).add(m),lt(E.x,E.y,E.z)):lt(Z.x,Z.y,0)}for(let tt=1;tt<=u;tt++)for(let Z=0;Z<H;Z++){let Y=f?O(b[Z],ht[Z],Mt):b[Z];d?(R.copy(M.normals[tt]).multiplyScalar(Y.x),m.copy(M.binormals[tt]).multiplyScalar(Y.y),E.copy(g[tt]).add(R).add(m),lt(E.x,E.y,E.z)):lt(Y.x,Y.y,h/u*tt)}for(let tt=y-1;tt>=0;tt--){let Z=tt/y,Y=p*Math.cos(Z*Math.PI/2),q=x*Math.sin(Z*Math.PI/2)+v;for(let mt=0,it=F.length;mt<it;mt++){let st=O(F[mt],$[mt],q);lt(st.x,st.y,h+Y)}for(let mt=0,it=w.length;mt<it;mt++){let st=w[mt];rt=at[mt];for(let Pt=0,It=st.length;Pt<It;Pt++){let N=O(st[Pt],rt[Pt],q);d?lt(N.x,N.y+g[u-1].y,g[u-1].x+Y):lt(N.x,N.y,h+Y)}}}K(),Q();function K(){let tt=i.length/3;if(f){let Z=0,Y=H*Z;for(let q=0;q<Et;q++){let mt=bt[q];ut(mt[2]+Y,mt[1]+Y,mt[0]+Y)}Z=u+y*2,Y=H*Z;for(let q=0;q<Et;q++){let mt=bt[q];ut(mt[0]+Y,mt[1]+Y,mt[2]+Y)}}else{for(let Z=0;Z<Et;Z++){let Y=bt[Z];ut(Y[2],Y[1],Y[0])}for(let Z=0;Z<Et;Z++){let Y=bt[Z];ut(Y[0]+H*u,Y[1]+H*u,Y[2]+H*u)}}n.addGroup(tt,i.length/3-tt,0)}function Q(){let tt=i.length/3,Z=0;ct(F,Z),Z+=F.length;for(let Y=0,q=w.length;Y<q;Y++){let mt=w[Y];ct(mt,Z),Z+=mt.length}n.addGroup(tt,i.length/3-tt,1)}function ct(tt,Z){let Y=tt.length;for(;--Y>=0;){let q=Y,mt=Y-1;mt<0&&(mt=tt.length-1);for(let it=0,st=u+y*2;it<st;it++){let Pt=H*it,It=H*(it+1),N=Z+q+Pt,P=Z+mt+Pt,k=Z+mt+It,W=Z+q+It;Ct(N,P,k,W)}}}function lt(tt,Z,Y){c.push(tt),c.push(Z),c.push(Y)}function ut(tt,Z,Y){Kt(tt),Kt(Z),Kt(Y);let q=i.length/3,mt=S.generateTopUV(n,i,q-3,q-2,q-1);U(mt[0]),U(mt[1]),U(mt[2])}function Ct(tt,Z,Y,q){Kt(tt),Kt(Z),Kt(q),Kt(Z),Kt(Y),Kt(q);let mt=i.length/3,it=S.generateSideWallUV(n,i,mt-6,mt-3,mt-2,mt-1);U(it[0]),U(it[1]),U(it[3]),U(it[1]),U(it[2]),U(it[3])}function Kt(tt){i.push(c[tt*3+0]),i.push(c[tt*3+1]),i.push(c[tt*3+2])}function U(tt){r.push(tt.x),r.push(tt.y)}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes,n=this.parameters.options;return QS(e,n,t)}static fromJSON(t,e){let n=[];for(let r=0,o=t.shapes.length;r<o;r++){let a=e[t.shapes[r]];n.push(a)}let i=t.options.extrudePath;return i!==void 0&&(t.options.extrudePath=new yh[i.type]().fromJSON(i)),new s(n,t.options)}},jS={generateTopUV:function(s,t,e,n,i){let r=t[e*3],o=t[e*3+1],a=t[n*3],c=t[n*3+1],l=t[i*3],u=t[i*3+1];return[new nt(r,o),new nt(a,c),new nt(l,u)]},generateSideWallUV:function(s,t,e,n,i,r){let o=t[e*3],a=t[e*3+1],c=t[e*3+2],l=t[n*3],u=t[n*3+1],h=t[n*3+2],f=t[i*3],p=t[i*3+1],x=t[i*3+2],v=t[r*3],y=t[r*3+1],_=t[r*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new nt(o,1-c),new nt(l,1-h),new nt(f,1-x),new nt(v,1-_)]:[new nt(a,1-c),new nt(u,1-h),new nt(p,1-x),new nt(y,1-_)]}};function QS(s,t,e){if(e.shapes=[],Array.isArray(s))for(let n=0,i=s.length;n<i;n++){let r=s[n];e.shapes.push(r.uuid)}else e.shapes.push(s.uuid);return e.options=Object.assign({},t),t.extrudePath!==void 0&&(e.options.extrudePath=t.extrudePath.toJSON()),e}var _c=class s extends ar{constructor(t=1,e=0){let n=(1+Math.sqrt(5))/2,i=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],r=[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];super(i,r,t,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},yc=class s extends Vt{constructor(t=[new nt(0,-.5),new nt(.5,0),new nt(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=Xt(i,0,Math.PI*2);let r=[],o=[],a=[],c=[],l=[],u=1/e,h=new I,f=new nt,p=new I,x=new I,v=new I,y=0,_=0;for(let S=0;S<=t.length-1;S++)switch(S){case 0:y=t[S+1].x-t[S].x,_=t[S+1].y-t[S].y,p.x=_*1,p.y=-y,p.z=_*0,v.copy(p),p.normalize(),c.push(p.x,p.y,p.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:y=t[S+1].x-t[S].x,_=t[S+1].y-t[S].y,p.x=_*1,p.y=-y,p.z=_*0,x.copy(p),p.x+=v.x,p.y+=v.y,p.z+=v.z,p.normalize(),c.push(p.x,p.y,p.z),v.copy(x)}for(let S=0;S<=e;S++){let g=n+S*u*i,d=Math.sin(g),M=Math.cos(g);for(let m=0;m<=t.length-1;m++){h.x=t[m].x*d,h.y=t[m].y,h.z=t[m].x*M,o.push(h.x,h.y,h.z),f.x=S/e,f.y=m/(t.length-1),a.push(f.x,f.y);let R=c[3*m+0]*d,E=c[3*m+1],T=c[3*m+0]*M;l.push(R,E,T)}}for(let S=0;S<e;S++)for(let g=0;g<t.length-1;g++){let d=g+S*t.length,M=d,m=d+t.length,R=d+t.length+1,E=d+1;r.push(M,m,E),r.push(R,E,m)}this.setIndex(r),this.setAttribute("position",new Lt(o,3)),this.setAttribute("uv",new Lt(a,2)),this.setAttribute("normal",new Lt(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.points,t.segments,t.phiStart,t.phiLength)}},Fo=class s extends ar{constructor(t=1,e=0){let n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],i=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,i,t,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},ys=class s extends Vt{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};let r=t/2,o=e/2,a=Math.floor(n),c=Math.floor(i),l=a+1,u=c+1,h=t/a,f=e/c,p=[],x=[],v=[],y=[];for(let _=0;_<u;_++){let S=_*f-o;for(let g=0;g<l;g++){let d=g*h-r;x.push(d,-S,0),v.push(0,0,1),y.push(g/a),y.push(1-_/c)}}for(let _=0;_<c;_++)for(let S=0;S<a;S++){let g=S+l*_,d=S+l*(_+1),M=S+1+l*(_+1),m=S+1+l*_;p.push(g,d,m),p.push(d,M,m)}this.setIndex(p),this.setAttribute("position",new Lt(x,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.width,t.height,t.widthSegments,t.heightSegments)}},vc=class s extends Vt{constructor(t=.5,e=1,n=32,i=1,r=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:n,phiSegments:i,thetaStart:r,thetaLength:o},n=Math.max(3,n),i=Math.max(1,i);let a=[],c=[],l=[],u=[],h=t,f=(e-t)/i,p=new I,x=new nt;for(let v=0;v<=i;v++){for(let y=0;y<=n;y++){let _=r+y/n*o;p.x=h*Math.cos(_),p.y=h*Math.sin(_),c.push(p.x,p.y,p.z),l.push(0,0,1),x.x=(p.x/e+1)/2,x.y=(p.y/e+1)/2,u.push(x.x,x.y)}h+=f}for(let v=0;v<i;v++){let y=v*(n+1);for(let _=0;_<n;_++){let S=_+y,g=S,d=S+n+1,M=S+n+2,m=S+1;a.push(g,d,m),a.push(d,M,m)}}this.setIndex(a),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(l,3)),this.setAttribute("uv",new Lt(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.innerRadius,t.outerRadius,t.thetaSegments,t.phiSegments,t.thetaStart,t.thetaLength)}},Mc=class s extends Vt{constructor(t=new Pi([new nt(0,.5),new nt(-.5,-.5),new nt(.5,-.5)]),e=12){super(),this.type="ShapeGeometry",this.parameters={shapes:t,curveSegments:e};let n=[],i=[],r=[],o=[],a=0,c=0;if(Array.isArray(t)===!1)l(t);else for(let u=0;u<t.length;u++)l(t[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Lt(i,3)),this.setAttribute("normal",new Lt(r,3)),this.setAttribute("uv",new Lt(o,2));function l(u){let h=i.length/3,f=u.extractPoints(e),p=f.shape,x=f.holes;Qn.isClockWise(p)===!1&&(p=p.reverse());for(let y=0,_=x.length;y<_;y++){let S=x[y];Qn.isClockWise(S)===!0&&(x[y]=S.reverse())}let v=Qn.triangulateShape(p,x);for(let y=0,_=x.length;y<_;y++){let S=x[y];p=p.concat(S)}for(let y=0,_=p.length;y<_;y++){let S=p[y];i.push(S.x,S.y,0),r.push(0,0,1),o.push(S.x,S.y)}for(let y=0,_=v.length;y<_;y++){let S=v[y],g=S[0]+h,d=S[1]+h,M=S[2]+h;n.push(g,d,M),c+=3}}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON(),e=this.parameters.shapes;return tb(e,t)}static fromJSON(t,e){let n=[];for(let i=0,r=t.shapes.length;i<r;i++){let o=e[t.shapes[i]];n.push(o)}return new s(n,t.curveSegments)}};function tb(s,t){if(t.shapes=[],Array.isArray(s))for(let e=0,n=s.length;e<n;e++){let i=s[e];t.shapes.push(i.uuid)}else t.shapes.push(s.uuid);return t}var Oo=class s extends Vt{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:o,thetaLength:a},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new I,f=new I,p=[],x=[],v=[],y=[];for(let _=0;_<=n;_++){let S=[],g=_/n,d=0;_===0&&o===0?d=.5/e:_===n&&c===Math.PI&&(d=-.5/e);for(let M=0;M<=e;M++){let m=M/e;h.x=-t*Math.cos(i+m*r)*Math.sin(o+g*a),h.y=t*Math.cos(o+g*a),h.z=t*Math.sin(i+m*r)*Math.sin(o+g*a),x.push(h.x,h.y,h.z),f.copy(h).normalize(),v.push(f.x,f.y,f.z),y.push(m+d,1-g),S.push(l++)}u.push(S)}for(let _=0;_<n;_++)for(let S=0;S<e;S++){let g=u[_][S+1],d=u[_][S],M=u[_+1][S],m=u[_+1][S+1];(_!==0||o>0)&&p.push(g,d,m),(_!==n-1||c<Math.PI)&&p.push(d,M,m)}this.setIndex(p),this.setAttribute("position",new Lt(x,3)),this.setAttribute("normal",new Lt(v,3)),this.setAttribute("uv",new Lt(y,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}},Sc=class s extends ar{constructor(t=1,e=0){let n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],i=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,i,t,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new s(t.radius,t.detail)}},bc=class s extends Vt{constructor(t=1,e=.4,n=12,i=48,r=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:n,tubularSegments:i,arc:r},n=Math.floor(n),i=Math.floor(i);let o=[],a=[],c=[],l=[],u=new I,h=new I,f=new I;for(let p=0;p<=n;p++)for(let x=0;x<=i;x++){let v=x/i*r,y=p/n*Math.PI*2;h.x=(t+e*Math.cos(y))*Math.cos(v),h.y=(t+e*Math.cos(y))*Math.sin(v),h.z=e*Math.sin(y),a.push(h.x,h.y,h.z),u.x=t*Math.cos(v),u.y=t*Math.sin(v),f.subVectors(h,u).normalize(),c.push(f.x,f.y,f.z),l.push(x/i),l.push(p/n)}for(let p=1;p<=n;p++)for(let x=1;x<=i;x++){let v=(i+1)*p+x-1,y=(i+1)*(p-1)+x-1,_=(i+1)*(p-1)+x,S=(i+1)*p+x;o.push(v,y,S),o.push(y,_,S)}this.setIndex(o),this.setAttribute("position",new Lt(a,3)),this.setAttribute("normal",new Lt(c,3)),this.setAttribute("uv",new Lt(l,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}},Tc=class s extends Vt{constructor(t=1,e=.4,n=64,i=8,r=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,tubularSegments:n,radialSegments:i,p:r,q:o},n=Math.floor(n),i=Math.floor(i);let a=[],c=[],l=[],u=[],h=new I,f=new I,p=new I,x=new I,v=new I,y=new I,_=new I;for(let g=0;g<=n;++g){let d=g/n*r*Math.PI*2;S(d,r,o,t,p),S(d+.01,r,o,t,x),y.subVectors(x,p),_.addVectors(x,p),v.crossVectors(y,_),_.crossVectors(v,y),v.normalize(),_.normalize();for(let M=0;M<=i;++M){let m=M/i*Math.PI*2,R=-e*Math.cos(m),E=e*Math.sin(m);h.x=p.x+(R*_.x+E*v.x),h.y=p.y+(R*_.y+E*v.y),h.z=p.z+(R*_.z+E*v.z),c.push(h.x,h.y,h.z),f.subVectors(h,p).normalize(),l.push(f.x,f.y,f.z),u.push(g/n),u.push(M/i)}}for(let g=1;g<=n;g++)for(let d=1;d<=i;d++){let M=(i+1)*(g-1)+(d-1),m=(i+1)*g+(d-1),R=(i+1)*g+d,E=(i+1)*(g-1)+d;a.push(M,m,E),a.push(m,R,E)}this.setIndex(a),this.setAttribute("position",new Lt(c,3)),this.setAttribute("normal",new Lt(l,3)),this.setAttribute("uv",new Lt(u,2));function S(g,d,M,m,R){let E=Math.cos(g),T=Math.sin(g),b=M/d*g,w=Math.cos(b);R.x=m*(2+w)*.5*E,R.y=m*(2+w)*T*.5,R.z=m*Math.sin(b)*.5}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new s(t.radius,t.tube,t.tubularSegments,t.radialSegments,t.p,t.q)}},Ec=class s extends Vt{constructor(t=new No(new I(-1,-1,0),new I(-1,1,0),new I(1,1,0)),e=64,n=1,i=8,r=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:i,closed:r};let o=t.computeFrenetFrames(e,r);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new I,c=new I,l=new nt,u=new I,h=[],f=[],p=[],x=[];v(),this.setIndex(x),this.setAttribute("position",new Lt(h,3)),this.setAttribute("normal",new Lt(f,3)),this.setAttribute("uv",new Lt(p,2));function v(){for(let g=0;g<e;g++)y(g);y(r===!1?e:0),S(),_()}function y(g){u=t.getPointAt(g/e,u);let d=o.normals[g],M=o.binormals[g];for(let m=0;m<=i;m++){let R=m/i*Math.PI*2,E=Math.sin(R),T=-Math.cos(R);c.x=T*d.x+E*M.x,c.y=T*d.y+E*M.y,c.z=T*d.z+E*M.z,c.normalize(),f.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function _(){for(let g=1;g<=e;g++)for(let d=1;d<=i;d++){let M=(i+1)*(g-1)+(d-1),m=(i+1)*g+(d-1),R=(i+1)*g+d,E=(i+1)*(g-1)+d;x.push(M,m,E),x.push(m,R,E)}}function S(){for(let g=0;g<=e;g++)for(let d=0;d<=i;d++)l.x=g/e,l.y=d/i,p.push(l.x,l.y)}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}toJSON(){let t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new s(new yh[t.path.type]().fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}},wc=class extends Vt{constructor(t=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:t},t!==null){let e=[],n=new Set,i=new I,r=new I;if(t.index!==null){let o=t.attributes.position,a=t.index,c=t.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],f=h.start,p=h.count;for(let x=f,v=f+p;x<v;x+=3)for(let y=0;y<3;y++){let _=a.getX(x+y),S=a.getX(x+(y+1)%3);i.fromBufferAttribute(o,_),r.fromBufferAttribute(o,S),b_(i,r,n)===!0&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}}else{let o=t.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;i.fromBufferAttribute(o,u),r.fromBufferAttribute(o,h),b_(i,r,n)===!0&&(e.push(i.x,i.y,i.z),e.push(r.x,r.y,r.z))}}this.setAttribute("position",new Lt(e,3))}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}};function b_(s,t,e){let n=`${s.x},${s.y},${s.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${s.x},${s.y},${s.z}`;return e.has(n)===!0||e.has(i)===!0?!1:(e.add(n),e.add(i),!0)}var T_=Object.freeze({__proto__:null,BoxGeometry:Ui,CapsuleGeometry:sc,CircleGeometry:oc,ConeGeometry:Co,CylinderGeometry:Ro,DodecahedronGeometry:ac,EdgesGeometry:cc,ExtrudeGeometry:xc,IcosahedronGeometry:_c,LatheGeometry:yc,OctahedronGeometry:Fo,PlaneGeometry:ys,PolyhedronGeometry:ar,RingGeometry:vc,ShapeGeometry:Mc,SphereGeometry:Oo,TetrahedronGeometry:Sc,TorusGeometry:bc,TorusKnotGeometry:Tc,TubeGeometry:Ec,WireframeGeometry:wc}),Ac=class extends Ue{constructor(t){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new yt(0),this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.fog=t.fog,this}},Rc=class extends Cn{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},xi=class extends Ue{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new yt(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 yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},ln=class extends xi{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new nt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Xt(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 yt(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 yt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new yt(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}},Cc=class extends Ue{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.combine=qo,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Ic=class extends Ue{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Pc=class extends Ue{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}},Lc=class extends Ue{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Rn,this.combine=qo,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},Bo=class extends Ue{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=nm,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},zo=class extends Ue{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},Nc=class extends Ue{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=hr,this.normalScale=new nt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}},Dc=class extends Xe{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}};function ns(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function N0(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function D0(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function mp(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,o=0;o!==n;++r){let a=e[r]*t;for(let c=0;c!==t;++c)i[o++]=s[a+c]}return i}function _m(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let o=r[n];if(o!==void 0)if(Array.isArray(o))do o=r[n],o!==void 0&&(t.push(r.time),e.push(...o)),r=s[i++];while(r!==void 0);else if(o.toArray!==void 0)do o=r[n],o!==void 0&&(t.push(r.time),o.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do o=r[n],o!==void 0&&(t.push(r.time),e.push(o)),r=s[i++];while(r!==void 0)}function eb(s,t,e,n,i=30){let r=s.clone();r.name=t;let o=[];for(let c=0;c<r.tracks.length;++c){let l=r.tracks[c],u=l.getValueSize(),h=[],f=[];for(let p=0;p<l.times.length;++p){let x=l.times[p]*i;if(!(x<e||x>=n)){h.push(l.times[p]);for(let v=0;v<u;++v)f.push(l.values[p*u+v])}}h.length!==0&&(l.times=ns(h,l.times.constructor),l.values=ns(f,l.values.constructor),o.push(l))}r.tracks=o;let a=1/0;for(let c=0;c<r.tracks.length;++c)a>r.tracks[c].times[0]&&(a=r.tracks[c].times[0]);for(let c=0;c<r.tracks.length;++c)r.tracks[c].shift(-1*a);return r.resetDuration(),r}function nb(s,t=0,e=s,n=30){n<=0&&(n=30);let i=e.tracks.length,r=t/n;for(let o=0;o<i;++o){let a=e.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=s.tracks.find(function(_){return _.name===a.name&&_.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let f=0,p=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(f=p/3);let x=a.times.length-1,v;if(r<=a.times[0]){let _=u,S=h-u;v=a.values.slice(_,S)}else if(r>=a.times[x]){let _=x*h+u,S=_+h-u;v=a.values.slice(_,S)}else{let _=a.createInterpolant(),S=u,g=h-u;_.evaluate(r),v=_.resultBuffer.slice(S,g)}c==="quaternion"&&new Ce().fromArray(v).normalize().conjugate().toArray(v);let y=l.times.length;for(let _=0;_<y;++_){let S=_*p+f;if(c==="quaternion")Ce.multiplyQuaternionsFlat(l.values,S,v,0,l.values,S);else{let g=p-f*2;for(let d=0;d<g;++d)l.values[S+d]-=v[d]}}}return s.blendMode=_f,s}var vh=class{static convertArray(t,e){return ns(t,e)}static isTypedArray(t){return N0(t)}static getKeyframeOrder(t){return D0(t)}static sortedArray(t,e,n){return mp(t,e,n)}static flattenJSON(t,e,n,i){_m(t,e,n,i)}static subclip(t,e,n,i,r=30){return eb(t,e,n,i,r)}static makeClipAdditive(t,e=0,n=t,i=30){return nb(t,e,n,i)}},Bi=class{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,i=e[n],r=e[n-1];t:{e:{let o;n:{i:if(!(t<i)){for(let a=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(r=i,i=e[++n],t<i)break e}o=e.length;break n}if(!(t>=r)){let a=e[1];t<a&&(n=2,r=a);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break e}o=n,n=0;break n}break t}for(;n<o;){let a=n+o>>>1;t<e[a]?o=a:n=a+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let o=0;o!==i;++o)e[o]=n[r+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},Uc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Tr,endingEnd:Tr}}intervalChanged_(t,e,n){let i=this.parameterPositions,r=t-2,o=t+1,a=i[r],c=i[o];if(a===void 0)switch(this.getSettings_().endingStart){case Er:r=t,a=2*e-n;break;case go:r=i.length-2,a=e+i[r]-i[r+1];break;default:r=t,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Er:o=t,c=2*n-e;break;case go:o=1,c=n+i[1]-i[0];break;default:o=t-1,c=e}let l=(n-e)*.5,u=this.valueSize;this._weightPrev=l/(e-a),this._weightNext=l/(c-n),this._offsetPrev=r*u,this._offsetNext=o*u}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,f=this._weightPrev,p=this._weightNext,x=(n-e)/(i-e),v=x*x,y=v*x,_=-f*y+2*f*v-f*x,S=(1+f)*y+(-1.5-2*f)*v+(-.5+f)*x+1,g=(-1-p)*y+(1.5+p)*v+.5*x,d=p*y-p*v;for(let M=0;M!==a;++M)r[M]=_*o[u+M]+S*o[l+M]+g*o[c+M]+d*o[h+M];return r}},ko=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,l=c-a,u=(n-e)/(i-e),h=1-u;for(let f=0;f!==a;++f)r[f]=o[l+f]*h+o[c+f]*u;return r}},Fc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}},vn=class{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ns(e,this.TimeBufferType),this.values=ns(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ns(t.times,Array),values:ns(t.values,Array)};let i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Fc(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new ko(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Uc(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ni:e=this.InterpolantFactoryMethodDiscrete;break;case Di:e=this.InterpolantFactoryMethodLinear;break;case Wa:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ni;case this.InterpolantFactoryMethodLinear:return Di;case this.InterpolantFactoryMethodSmooth:return Wa}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){let n=this.times,i=n.length,r=0,o=i-1;for(;r!==i&&n[r]<t;)++r;for(;o!==-1&&n[o]>e;)--o;if(++o,r!==0||o!==i){r>=o&&(o=Math.max(o,1),r=o-1);let a=this.getValueSize();this.times=n.slice(r,o),this.values=this.values.slice(r*a,o*a)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,i=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==r;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),t=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),t=!1;break}o=c}if(i!==void 0&&N0(i))for(let a=0,c=i.length;a!==c;++a){let l=i[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Wa,r=t.length-1,o=1;for(let a=1;a<r;++a){let c=!1,l=t[a],u=t[a+1];if(l!==u&&(a!==1||l!==t[0]))if(i)c=!0;else{let h=a*n,f=h-n,p=h+n;for(let x=0;x!==n;++x){let v=e[h+x];if(v!==e[f+x]||v!==e[p+x]){c=!0;break}}}if(c){if(a!==o){t[o]=t[a];let h=a*n,f=o*n;for(let p=0;p!==n;++p)e[f+p]=e[h+p]}++o}}if(r>0){t[o]=t[r];for(let a=r*n,c=o*n,l=0;l!==n;++l)e[c+l]=e[a+l];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};vn.prototype.ValueTypeName="";vn.prototype.TimeBufferType=Float32Array;vn.prototype.ValueBufferType=Float32Array;vn.prototype.DefaultInterpolation=Di;var zi=class extends vn{constructor(t,e,n){super(t,e,n)}};zi.prototype.ValueTypeName="bool";zi.prototype.ValueBufferType=Array;zi.prototype.DefaultInterpolation=Ni;zi.prototype.InterpolantFactoryMethodLinear=void 0;zi.prototype.InterpolantFactoryMethodSmooth=void 0;var Ho=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};Ho.prototype.ValueTypeName="color";var _i=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};_i.prototype.ValueTypeName="number";var Oc=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-e)/(i-e),l=t*a;for(let u=l+a;l!==u;l+=4)Ce.slerpFlat(r,0,o,l-a,o,l,c);return r}},Gn=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Oc(this.times,this.values,this.getValueSize(),t)}};Gn.prototype.ValueTypeName="quaternion";Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var ki=class extends vn{constructor(t,e,n){super(t,e,n)}};ki.prototype.ValueTypeName="string";ki.prototype.ValueBufferType=Array;ki.prototype.DefaultInterpolation=Ni;ki.prototype.InterpolantFactoryMethodLinear=void 0;ki.prototype.InterpolantFactoryMethodSmooth=void 0;var Wn=class extends vn{constructor(t,e,n,i){super(t,e,n,i)}};Wn.prototype.ValueTypeName="vector";var ni=class{constructor(t="",e=-1,n=[],i=Bl){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Bn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let o=0,a=n.length;o!==a;++o)e.push(rb(n[o]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,o=n.length;r!==o;++r)e.push(vn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,o=[];for(let a=0;a<r;a++){let c=[],l=[];c.push((a+r-1)%r,a,(a+1)%r),l.push(0,1,0);let u=D0(c);c=mp(c,1,u),l=mp(l,1,u),!i&&c[0]===0&&(c.push(r),l.push(l[0])),o.push(new _i(".morphTargetInfluences["+e[a].name+"]",c,l).scale(1/n))}return new this(t,-1,o)}static findByName(t,e){let n=t;if(!Array.isArray(t)){let i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){let i={},r=/^([\w-]*?)([\d]+)$/;for(let a=0,c=t.length;a<c;a++){let l=t[a],u=l.name.match(r);if(u&&u.length>1){let h=u[1],f=i[h];f||(i[h]=f=[]),f.push(l)}}let o=[];for(let a in i)o.push(this.CreateFromMorphTargetSequence(a,i[a],e,n));return o}static parseAnimation(t,e){if(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,f,p,x,v){if(p.length!==0){let y=[],_=[];_m(p,y,_,x),y.length!==0&&v.push(new h(f,y,_))}},i=[],r=t.name||"default",o=t.fps||30,a=t.blendMode,c=t.length||-1,l=t.hierarchy||[];for(let h=0;h<l.length;h++){let f=l[h].keys;if(!(!f||f.length===0))if(f[0].morphTargets){let p={},x;for(x=0;x<f.length;x++)if(f[x].morphTargets)for(let v=0;v<f[x].morphTargets.length;v++)p[f[x].morphTargets[v]]=-1;for(let v in p){let y=[],_=[];for(let S=0;S!==f[x].morphTargets.length;++S){let g=f[x];y.push(g.time),_.push(g.morphTarget===v?1:0)}i.push(new _i(".morphTargetInfluence["+v+"]",y,_))}c=p.length*o}else{let p=".bones["+e[h].name+"]";n(Wn,p+".position",f,"pos",i),n(Gn,p+".quaternion",f,"rot",i),n(Wn,p+".scale",f,"scl",i)}}return i.length===0?null:new this(r,c,i,a)}resetDuration(){let t=this.tracks,e=0;for(let n=0,i=t.length;n!==i;++n){let r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){let t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());let e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}};function ib(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return _i;case"vector":case"vector2":case"vector3":case"vector4":return Wn;case"color":return Ho;case"quaternion":return Gn;case"bool":case"boolean":return zi;case"string":return ki}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function rb(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=ib(s.type);if(s.times===void 0){let e=[],n=[];_m(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}var di={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(this.files[s]=t)},get:function(s){if(this.enabled!==!1)return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}},Pr=class{constructor(t,e,n){let i=this,r=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.abortController=new AbortController,this.itemStart=function(u){a++,r===!1&&i.onStart!==void 0&&i.onStart(u,o,a),r=!0},this.itemEnd=function(u){o++,i.onProgress!==void 0&&i.onProgress(u,o,a),o===a&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(u){i.onError!==void 0&&i.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,f=l.length;h<f;h+=2){let p=l[h],x=l[h+1];if(p.global&&(p.lastIndex=0),p.test(u))return x}return null},this.abort=function(){return this.abortController.abort(),this.abortController=new AbortController,this}}},ym=new Pr,Ke=class{constructor(t){this.manager=t!==void 0?t:ym,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}};Ke.DEFAULT_MATERIAL_NAME="__DEFAULT";var nr={},gp=class extends Error{constructor(t,e){super(t),this.response=e}},Mn=class extends Ke{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=di.get(`file:${t}`);if(r!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0),r;if(nr[t]!==void 0){nr[t].push({onLoad:e,onProgress:n,onError:i});return}nr[t]=[],nr[t].push({onLoad:e,onProgress:n,onError:i});let o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=nr[t],h=l.body.getReader(),f=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),p=f?parseInt(f):0,x=p!==0,v=0,y=new ReadableStream({start(_){S();function S(){h.read().then(({done:g,value:d})=>{if(g)_.close();else{v+=d.byteLength;let M=new ProgressEvent("progress",{lengthComputable:x,loaded:v,total:p});for(let m=0,R=u.length;m<R;m++){let E=u[m];E.onProgress&&E.onProgress(M)}_.enqueue(d),S()}},g=>{_.error(g)})}}});return new Response(y)}else throw new gp(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a==="")return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,p=new TextDecoder(f);return l.arrayBuffer().then(x=>p.decode(x))}}}).then(l=>{di.add(`file:${t}`,l);let u=nr[t];delete nr[t];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onLoad&&p.onLoad(l)}}).catch(l=>{let u=nr[t];if(u===void 0)throw this.manager.itemError(t),l;delete nr[t];for(let h=0,f=u.length;h<f;h++){let p=u[h];p.onError&&p.onError(l)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Mh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=[];for(let n=0;n<t.length;n++){let i=ni.parse(t[n]);e.push(i)}return e}},Sh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=[],a=new gi,c=new Mn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(r.withCredentials);let l=0;function u(h){c.load(t[h],function(f){let p=r.parse(f,!0);o[h]={width:p.width,height:p.height,format:p.format,mipmaps:p.mipmaps},l+=1,l===6&&(p.mipmapCount===1&&(a.minFilter=Ee),a.image=o,a.format=p.format,a.needsUpdate=!0,e&&e(a))},n,i)}if(Array.isArray(t))for(let h=0,f=t.length;h<f;++h)u(h);else c.load(t,function(h){let f=r.parse(h,!0);if(f.isCubemap){let p=f.mipmaps.length/f.mipmapCount;for(let x=0;x<p;x++){o[x]={mipmaps:[]};for(let v=0;v<f.mipmapCount;v++)o[x].mipmaps.push(f.mipmaps[x*f.mipmapCount+v]),o[x].format=f.format,o[x].width=f.width,o[x].height=f.height}a.image=o}else a.image.width=f.width,a.image.height=f.height,a.mipmaps=f.mipmaps;f.mipmapCount===1&&(a.minFilter=Ee),a.format=f.format,a.needsUpdate=!0,e&&e(a)},n,i);return a}},uo=new WeakMap,Lr=class extends Ke{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=di.get(`image:${t}`);if(o!==void 0){if(o.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0);else{let h=uo.get(o);h===void 0&&(h=[],uo.set(o,h)),h.push({onLoad:e,onError:i})}return o}let a=yo("img");function c(){u(),e&&e(this);let h=uo.get(this)||[];for(let f=0;f<h.length;f++){let p=h[f];p.onLoad&&p.onLoad(this)}uo.delete(this),r.manager.itemEnd(t)}function l(h){u(),i&&i(h),di.remove(`image:${t}`);let f=uo.get(this)||[];for(let p=0;p<f.length;p++){let x=f[p];x.onError&&x.onError(h)}uo.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),di.add(`image:${t}`,a),r.manager.itemStart(t),a.src=t,a}},bh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=new Rr;r.colorSpace=Ae;let o=new Lr(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(t[l],function(u){r.images[l]=u,a++,a===6&&(r.needsUpdate=!0,e&&e(r))},void 0,i)}for(let l=0;l<t.length;++l)c(l);return r}},Th=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new zn,a=new Mn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(r.withCredentials),a.load(t,function(c){let l;try{l=r.parse(c)}catch(u){if(i!==void 0)i(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:en,o.wrapT=l.wrapT!==void 0?l.wrapT:en,o.magFilter=l.magFilter!==void 0?l.magFilter:Ee,o.minFilter=l.minFilter!==void 0?l.minFilter:Ee,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=un),l.mipmapCount===1&&(o.minFilter=Ee),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,e&&e(o,l)},n,i),o}},Vo=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=new Ie,o=new Lr(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){r.image=a,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}},yi=class extends re{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){let e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(e.object.target=this.target.uuid),e}},vs=class extends yi{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.groundColor=new yt(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}},ip=new vt,E_=new I,w_=new I,Bc=class{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new nt(512,512),this.mapType=ri,this.map=null,this.mapPass=null,this.matrix=new vt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new or,this._frameExtents=new nt(1,1),this._viewportCount=1,this._viewports=[new Qt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){let e=this.camera,n=this.matrix;E_.setFromMatrixPosition(t.matrixWorld),e.position.copy(E_),w_.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(w_),e.updateMatrixWorld(),ip.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ip,e.coordinateSystem,e.reversedDepth),e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(ip)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}},xp=class extends Bc{constructor(){super(new Re(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){let e=this.camera,n=os*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}},Ms=class extends yi{constructor(t,e,n=0,i=Math.PI/3,r=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.target=new re,this.distance=n,this.angle=i,this.penumbra=r,this.decay=o,this.map=null,this.shadow=new xp}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},A_=new vt,Ha=new I,rp=new I,_p=class extends Bc{constructor(){super(new Re(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new nt(4,2),this._viewportCount=6,this._viewports=[new Qt(2,1,1,1),new Qt(0,1,1,1),new Qt(3,1,1,1),new Qt(1,1,1,1),new Qt(3,0,1,1),new Qt(1,0,1,1)],this._cubeDirections=[new I(1,0,0),new I(-1,0,0),new I(0,0,1),new I(0,0,-1),new I(0,1,0),new I(0,-1,0)],this._cubeUps=[new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,1,0),new I(0,0,1),new I(0,0,-1)]}updateMatrices(t,e=0){let n=this.camera,i=this.matrix,r=t.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Ha.setFromMatrixPosition(t.matrixWorld),n.position.copy(Ha),rp.copy(n.position),rp.add(this._cubeDirections[e]),n.up.copy(this._cubeUps[e]),n.lookAt(rp),n.updateMatrixWorld(),i.makeTranslation(-Ha.x,-Ha.y,-Ha.z),A_.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(A_,n.coordinateSystem,n.reversedDepth)}},Ss=class extends yi{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new _p}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}},cr=class extends hs{constructor(t=-1,e=1,n=1,i=-1,r=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-t,o=n+t,a=i+e,c=i-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,o=r+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(r,o,a,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return 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,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},yp=class extends Bc{constructor(){super(new cr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},lr=class extends yi{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(re.DEFAULT_UP),this.updateMatrix(),this.target=new re,this.shadow=new yp}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}},zc=class extends yi{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}},kc=class extends yi{constructor(t,e,n=10,i=10){super(t,e),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(t){this.intensity=t/(this.width*this.height*Math.PI)}copy(t){return super.copy(t),this.width=t.width,this.height=t.height,this}toJSON(t){let e=super.toJSON(t);return e.object.width=this.width,e.object.height=this.height,e}},Hc=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let t=0;t<9;t++)this.coefficients.push(new I)}set(t){for(let e=0;e<9;e++)this.coefficients[e].copy(t[e]);return this}zero(){for(let t=0;t<9;t++)this.coefficients[t].set(0,0,0);return this}getAt(t,e){let n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.282095),e.addScaledVector(o[1],.488603*i),e.addScaledVector(o[2],.488603*r),e.addScaledVector(o[3],.488603*n),e.addScaledVector(o[4],1.092548*(n*i)),e.addScaledVector(o[5],1.092548*(i*r)),e.addScaledVector(o[6],.315392*(3*r*r-1)),e.addScaledVector(o[7],1.092548*(n*r)),e.addScaledVector(o[8],.546274*(n*n-i*i)),e}getIrradianceAt(t,e){let n=t.x,i=t.y,r=t.z,o=this.coefficients;return e.copy(o[0]).multiplyScalar(.886227),e.addScaledVector(o[1],2*.511664*i),e.addScaledVector(o[2],2*.511664*r),e.addScaledVector(o[3],2*.511664*n),e.addScaledVector(o[4],2*.429043*n*i),e.addScaledVector(o[5],2*.429043*i*r),e.addScaledVector(o[6],.743125*r*r-.247708),e.addScaledVector(o[7],2*.429043*n*r),e.addScaledVector(o[8],.429043*(n*n-i*i)),e}add(t){for(let e=0;e<9;e++)this.coefficients[e].add(t.coefficients[e]);return this}addScaledSH(t,e){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(t.coefficients[n],e);return this}scale(t){for(let e=0;e<9;e++)this.coefficients[e].multiplyScalar(t);return this}lerp(t,e){for(let n=0;n<9;n++)this.coefficients[n].lerp(t.coefficients[n],e);return this}equals(t){for(let e=0;e<9;e++)if(!this.coefficients[e].equals(t.coefficients[e]))return!1;return!0}copy(t){return this.set(t.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(t,e=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(t,e+i*3);return this}toArray(t=[],e=0){let n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(t,e+i*3);return t}static getBasisAt(t,e){let n=t.x,i=t.y,r=t.z;e[0]=.282095,e[1]=.488603*i,e[2]=.488603*r,e[3]=.488603*n,e[4]=1.092548*n*i,e[5]=1.092548*i*r,e[6]=.315392*(3*r*r-1),e[7]=1.092548*n*r,e[8]=.546274*(n*n-i*i)}},Vc=class extends yi{constructor(t=new Hc,e=1){super(void 0,e),this.isLightProbe=!0,this.sh=t}copy(t){return super.copy(t),this.sh.copy(t.sh),this}fromJSON(t){return this.intensity=t.intensity,this.sh.fromArray(t.sh),this}toJSON(t){let e=super.toJSON(t);return e.object.sh=this.sh.toArray(),e}},Gc=class s extends Ke{constructor(t){super(t),this.textures={}}load(t,e,n,i){let r=this,o=new Mn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=this.textures;function n(r){return e[r]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",r),e[r]}let i=this.createMaterialFromType(t.type);if(t.uuid!==void 0&&(i.uuid=t.uuid),t.name!==void 0&&(i.name=t.name),t.color!==void 0&&i.color!==void 0&&i.color.setHex(t.color),t.roughness!==void 0&&(i.roughness=t.roughness),t.metalness!==void 0&&(i.metalness=t.metalness),t.sheen!==void 0&&(i.sheen=t.sheen),t.sheenColor!==void 0&&(i.sheenColor=new yt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(i.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&i.emissive!==void 0&&i.emissive.setHex(t.emissive),t.specular!==void 0&&i.specular!==void 0&&i.specular.setHex(t.specular),t.specularIntensity!==void 0&&(i.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&i.specularColor!==void 0&&i.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(i.shininess=t.shininess),t.clearcoat!==void 0&&(i.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(i.dispersion=t.dispersion),t.iridescence!==void 0&&(i.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(i.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(i.transmission=t.transmission),t.thickness!==void 0&&(i.thickness=t.thickness),t.attenuationDistance!==void 0&&(i.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&i.attenuationColor!==void 0&&i.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(i.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(i.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(i.fog=t.fog),t.flatShading!==void 0&&(i.flatShading=t.flatShading),t.blending!==void 0&&(i.blending=t.blending),t.combine!==void 0&&(i.combine=t.combine),t.side!==void 0&&(i.side=t.side),t.shadowSide!==void 0&&(i.shadowSide=t.shadowSide),t.opacity!==void 0&&(i.opacity=t.opacity),t.transparent!==void 0&&(i.transparent=t.transparent),t.alphaTest!==void 0&&(i.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(i.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(i.depthFunc=t.depthFunc),t.depthTest!==void 0&&(i.depthTest=t.depthTest),t.depthWrite!==void 0&&(i.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(i.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(i.blendSrc=t.blendSrc),t.blendDst!==void 0&&(i.blendDst=t.blendDst),t.blendEquation!==void 0&&(i.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(i.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(i.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(i.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&i.blendColor!==void 0&&i.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(i.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(i.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(i.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(i.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(i.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(i.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(i.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(i.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(i.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(i.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(i.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(i.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(i.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(i.rotation=t.rotation),t.linewidth!==void 0&&(i.linewidth=t.linewidth),t.dashSize!==void 0&&(i.dashSize=t.dashSize),t.gapSize!==void 0&&(i.gapSize=t.gapSize),t.scale!==void 0&&(i.scale=t.scale),t.polygonOffset!==void 0&&(i.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(i.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(i.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(i.dithering=t.dithering),t.alphaToCoverage!==void 0&&(i.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(i.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(i.forceSinglePass=t.forceSinglePass),t.visible!==void 0&&(i.visible=t.visible),t.toneMapped!==void 0&&(i.toneMapped=t.toneMapped),t.userData!==void 0&&(i.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?i.vertexColors=t.vertexColors>0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let r in t.uniforms){let o=t.uniforms[r];switch(i.uniforms[r]={},o.type){case"t":i.uniforms[r].value=n(o.value);break;case"c":i.uniforms[r].value=new yt().setHex(o.value);break;case"v2":i.uniforms[r].value=new nt().fromArray(o.value);break;case"v3":i.uniforms[r].value=new I().fromArray(o.value);break;case"v4":i.uniforms[r].value=new Qt().fromArray(o.value);break;case"m3":i.uniforms[r].value=new $t().fromArray(o.value);break;case"m4":i.uniforms[r].value=new vt().fromArray(o.value);break;default:i.uniforms[r].value=o.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let r in t.extensions)i.extensions[r]=t.extensions[r];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let r=t.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new nt().fromArray(r)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new nt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return s.createMaterialFromType(t)}static createMaterialFromType(t){let e={ShadowMaterial:Ac,SpriteMaterial:To,RawShaderMaterial:Rc,ShaderMaterial:Cn,PointsMaterial:Ir,MeshPhysicalMaterial:ln,MeshStandardMaterial:xi,MeshPhongMaterial:Cc,MeshToonMaterial:Ic,MeshNormalMaterial:Pc,MeshLambertMaterial:Lc,MeshDepthMaterial:Bo,MeshDistanceMaterial:zo,MeshBasicMaterial:sn,MeshMatcapMaterial:Nc,LineDashedMaterial:Dc,LineBasicMaterial:Xe,Material:Ue};return new e[t]}},ii=class{static extractUrlBase(t){let e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}},Wc=class extends Vt{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}},Xc=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(r.manager);o.setPath(r.path),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,function(a){try{e(r.parse(JSON.parse(a)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e={},n={};function i(p,x){if(e[x]!==void 0)return e[x];let y=p.interleavedBuffers[x],_=r(p,y.buffer),S=po(y.type,_),g=new Oi(S,y.stride);return g.uuid=y.uuid,e[x]=g,g}function r(p,x){if(n[x]!==void 0)return n[x];let y=p.arrayBuffers[x],_=new Uint32Array(y).buffer;return n[x]=_,_}let o=t.isInstancedBufferGeometry?new Wc:new Vt,a=t.data.index;if(a!==void 0){let p=po(a.type,a.array);o.setIndex(new kt(p,1))}let c=t.data.attributes;for(let p in c){let x=c[p],v;if(x.isInterleavedBufferAttribute){let y=i(t.data,x.data);v=new pi(y,x.itemSize,x.offset,x.normalized)}else{let y=po(x.type,x.array),_=x.isInstancedBufferAttribute?ti:kt;v=new _(y,x.itemSize,x.normalized)}x.name!==void 0&&(v.name=x.name),x.usage!==void 0&&v.setUsage(x.usage),o.setAttribute(p,v)}let l=t.data.morphAttributes;if(l)for(let p in l){let x=l[p],v=[];for(let y=0,_=x.length;y<_;y++){let S=x[y],g;if(S.isInterleavedBufferAttribute){let d=i(t.data,S.data);g=new pi(d,S.itemSize,S.offset,S.normalized)}else{let d=po(S.type,S.array);g=new kt(d,S.itemSize,S.normalized)}S.name!==void 0&&(g.name=S.name),v.push(g)}o.morphAttributes[p]=v}t.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=t.data.groups||t.data.drawcalls||t.data.offsets;if(h!==void 0)for(let p=0,x=h.length;p!==x;++p){let v=h[p];o.addGroup(v.start,v.count,v.materialIndex)}let f=t.data.boundingSphere;return f!==void 0&&(o.boundingSphere=new Be().fromJSON(f)),t.name&&(o.name=t.name),t.userData&&(o.userData=t.userData),o}},Eh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=this.path===""?ii.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||o;let a=new Mn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(c){let l=null;try{l=JSON.parse(c)}catch(h){i!==void 0&&i(h),console.error("THREE:ObjectLoader: Can't parse "+t+".",h.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){i!==void 0&&i(new Error("THREE.ObjectLoader: Can't load "+t)),console.error("THREE.ObjectLoader: Can't load "+t);return}r.parse(l,e)},n,i)}async loadAsync(t,e){let n=this,i=this.path===""?ii.extractUrlBase(t):this.path;this.resourcePath=this.resourcePath||i;let r=new Mn(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials);let o=await r.loadAsync(t,e),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+t);return await n.parseAsync(a)}parse(t,e){let n=this.parseAnimations(t.animations),i=this.parseShapes(t.shapes),r=this.parseGeometries(t.geometries,i),o=this.parseImages(t.images,function(){e!==void 0&&e(l)}),a=this.parseTextures(t.textures,o),c=this.parseMaterials(t.materials,a),l=this.parseObject(t.object,r,c,a,n),u=this.parseSkeletons(t.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),e!==void 0){let h=!1;for(let f in o)if(o[f].data instanceof HTMLImageElement){h=!0;break}h===!1&&e(l)}return l}async parseAsync(t){let e=this.parseAnimations(t.animations),n=this.parseShapes(t.shapes),i=this.parseGeometries(t.geometries,n),r=await this.parseImagesAsync(t.images),o=this.parseTextures(t.textures,r),a=this.parseMaterials(t.materials,o),c=this.parseObject(t.object,i,a,o,e),l=this.parseSkeletons(t.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(t){let e={};if(t!==void 0)for(let n=0,i=t.length;n<i;n++){let r=new Pi().fromJSON(t[n]);e[r.uuid]=r}return e}parseSkeletons(t,e){let n={},i={};if(e.traverse(function(r){r.isBone&&(i[r.uuid]=r)}),t!==void 0)for(let r=0,o=t.length;r<o;r++){let a=new ds().fromJSON(t[r],i);n[a.uuid]=a}return n}parseGeometries(t,e){let n={};if(t!==void 0){let i=new Xc;for(let r=0,o=t.length;r<o;r++){let a,c=t[r];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=i.parse(c);break;default:c.type in T_?a=T_[c.type].fromJSON(c,e):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(t,e){let n={},i={};if(t!==void 0){let r=new Gc;r.setTextures(e);for(let o=0,a=t.length;o<a;o++){let c=t[o];n[c.uuid]===void 0&&(n[c.uuid]=r.parse(c)),i[c.uuid]=n[c.uuid]}}return i}parseAnimations(t){let e={};if(t!==void 0)for(let n=0;n<t.length;n++){let i=t[n],r=ni.parse(i);e[r.uuid]=r}return e}parseImages(t,e){let n=this,i={},r;function o(c){return n.manager.itemStart(c),r.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:po(c.type,c.data),width:c.width,height:c.height}:null}if(t!==void 0&&t.length>0){let c=new Pr(e);r=new Lr(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,u=t.length;l<u;l++){let h=t[l],f=h.url;if(Array.isArray(f)){let p=[];for(let x=0,v=f.length;x<v;x++){let y=f[x],_=a(y);_!==null&&(_ instanceof HTMLImageElement?p.push(_):p.push(new zn(_.data,_.width,_.height)))}i[h.uuid]=new On(p)}else{let p=a(h.url);i[h.uuid]=new On(p)}}}return i}async parseImagesAsync(t){let e=this,n={},i;async function r(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:e.resourcePath+a;return await i.loadAsync(c)}else return o.data?{data:po(o.type,o.data),width:o.width,height:o.height}:null}if(t!==void 0&&t.length>0){i=new Lr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let o=0,a=t.length;o<a;o++){let c=t[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,f=l.length;h<f;h++){let p=l[h],x=await r(p);x!==null&&(x instanceof HTMLImageElement?u.push(x):u.push(new zn(x.data,x.width,x.height)))}n[c.uuid]=new On(u)}else{let u=await r(c.url);n[c.uuid]=new On(u)}}}return n}parseTextures(t,e){function n(r,o){return typeof r=="number"?r:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",r),o[r])}let i={};if(t!==void 0)for(let r=0,o=t.length;r<o;r++){let a=t[r];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),e[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=e[a.image],l=c.data,u;Array.isArray(l)?(u=new Rr,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new zn:u=new Ie,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,sb)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],R_),u.wrapT=n(a.wrap[1],R_)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,C_)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,C_)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),i[a.uuid]=u}return i}parseObject(t,e,n,i,r){let o;function a(f){return e[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",f),e[f]}function c(f){if(f!==void 0){if(Array.isArray(f)){let p=[];for(let x=0,v=f.length;x<v;x++){let y=f[x];n[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",y),p.push(n[y])}return p}return n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),n[f]}}function l(f){return i[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",f),i[f]}let u,h;switch(t.type){case"Scene":o=new Fi,t.background!==void 0&&(Number.isInteger(t.background)?o.background=new yt(t.background):o.background=l(t.background)),t.environment!==void 0&&(o.environment=l(t.environment)),t.fog!==void 0&&(t.fog.type==="Fog"?o.fog=new Qa(t.fog.color,t.fog.near,t.fog.far):t.fog.type==="FogExp2"&&(o.fog=new ja(t.fog.color,t.fog.density)),t.fog.name!==""&&(o.fog.name=t.fog.name)),t.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=t.backgroundBlurriness),t.backgroundIntensity!==void 0&&(o.backgroundIntensity=t.backgroundIntensity),t.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(t.backgroundRotation),t.environmentIntensity!==void 0&&(o.environmentIntensity=t.environmentIntensity),t.environmentRotation!==void 0&&o.environmentRotation.fromArray(t.environmentRotation);break;case"PerspectiveCamera":o=new Re(t.fov,t.aspect,t.near,t.far),t.focus!==void 0&&(o.focus=t.focus),t.zoom!==void 0&&(o.zoom=t.zoom),t.filmGauge!==void 0&&(o.filmGauge=t.filmGauge),t.filmOffset!==void 0&&(o.filmOffset=t.filmOffset),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"OrthographicCamera":o=new cr(t.left,t.right,t.top,t.bottom,t.near,t.far),t.zoom!==void 0&&(o.zoom=t.zoom),t.view!==void 0&&(o.view=Object.assign({},t.view));break;case"AmbientLight":o=new zc(t.color,t.intensity);break;case"DirectionalLight":o=new lr(t.color,t.intensity),o.target=t.target||"";break;case"PointLight":o=new Ss(t.color,t.intensity,t.distance,t.decay);break;case"RectAreaLight":o=new kc(t.color,t.intensity,t.width,t.height);break;case"SpotLight":o=new Ms(t.color,t.intensity,t.distance,t.angle,t.penumbra,t.decay),o.target=t.target||"";break;case"HemisphereLight":o=new vs(t.color,t.groundColor,t.intensity);break;case"LightProbe":o=new Vc().fromJSON(t);break;case"SkinnedMesh":u=a(t.geometry),h=c(t.material),o=new mi(u,h),t.bindMode!==void 0&&(o.bindMode=t.bindMode),t.bindMatrix!==void 0&&o.bindMatrix.fromArray(t.bindMatrix),t.skeleton!==void 0&&(o.skeleton=t.skeleton);break;case"Mesh":u=a(t.geometry),h=c(t.material),o=new ce(u,h);break;case"InstancedMesh":u=a(t.geometry),h=c(t.material);let f=t.count,p=t.instanceMatrix,x=t.instanceColor;o=new ei(u,h,f),o.instanceMatrix=new ti(new Float32Array(p.array),16),x!==void 0&&(o.instanceColor=new ti(new Float32Array(x.array),x.itemSize));break;case"BatchedMesh":u=a(t.geometry),h=c(t.material),o=new ic(t.maxInstanceCount,t.maxVertexCount,t.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=t.perObjectFrustumCulled,o.sortObjects=t.sortObjects,o._drawRanges=t.drawRanges,o._reservedRanges=t.reservedRanges,o._geometryInfo=t.geometryInfo.map(v=>{let y=null,_=null;return v.boundingBox!==void 0&&(y=new ne().fromJSON(v.boundingBox)),v.boundingSphere!==void 0&&(_=new Be().fromJSON(v.boundingSphere)),{...v,boundingBox:y,boundingSphere:_}}),o._instanceInfo=t.instanceInfo,o._availableInstanceIds=t._availableInstanceIds,o._availableGeometryIds=t._availableGeometryIds,o._nextIndexStart=t.nextIndexStart,o._nextVertexStart=t.nextVertexStart,o._geometryCount=t.geometryCount,o._maxInstanceCount=t.maxInstanceCount,o._maxVertexCount=t.maxVertexCount,o._maxIndexCount=t.maxIndexCount,o._geometryInitialized=t.geometryInitialized,o._matricesTexture=l(t.matricesTexture.uuid),o._indirectTexture=l(t.indirectTexture.uuid),t.colorsTexture!==void 0&&(o._colorsTexture=l(t.colorsTexture.uuid)),t.boundingSphere!==void 0&&(o.boundingSphere=new Be().fromJSON(t.boundingSphere)),t.boundingBox!==void 0&&(o.boundingBox=new ne().fromJSON(t.boundingBox));break;case"LOD":o=new ec;break;case"Line":o=new Vn(a(t.geometry),c(t.material));break;case"LineLoop":o=new ps(a(t.geometry),c(t.material));break;case"LineSegments":o=new yn(a(t.geometry),c(t.material));break;case"PointCloud":case"Points":o=new ms(a(t.geometry),c(t.material));break;case"Sprite":o=new tc(c(t.material));break;case"Group":o=new nn;break;case"Bone":o=new Cr;break;default:o=new re}if(o.uuid=t.uuid,t.name!==void 0&&(o.name=t.name),t.matrix!==void 0?(o.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=t.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(t.position!==void 0&&o.position.fromArray(t.position),t.rotation!==void 0&&o.rotation.fromArray(t.rotation),t.quaternion!==void 0&&o.quaternion.fromArray(t.quaternion),t.scale!==void 0&&o.scale.fromArray(t.scale)),t.up!==void 0&&o.up.fromArray(t.up),t.castShadow!==void 0&&(o.castShadow=t.castShadow),t.receiveShadow!==void 0&&(o.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(o.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(o.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(o.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(o.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(o.visible=t.visible),t.frustumCulled!==void 0&&(o.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(o.renderOrder=t.renderOrder),t.userData!==void 0&&(o.userData=t.userData),t.layers!==void 0&&(o.layers.mask=t.layers),t.children!==void 0){let f=t.children;for(let p=0;p<f.length;p++)o.add(this.parseObject(f[p],e,n,i,r))}if(t.animations!==void 0){let f=t.animations;for(let p=0;p<f.length;p++){let x=f[p];o.animations.push(r[x])}}if(t.type==="LOD"){t.autoUpdate!==void 0&&(o.autoUpdate=t.autoUpdate);let f=t.levels;for(let p=0;p<f.length;p++){let x=f[p],v=o.getObjectByProperty("uuid",x.object);v!==void 0&&o.addLevel(v,x.distance,x.hysteresis)}}return o}bindSkeletons(t,e){Object.keys(e).length!==0&&t.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){let i=e[n.skeleton];i===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(i,n.bindMatrix)}})}bindLightTargets(t){t.traverse(function(e){if(e.isDirectionalLight||e.isSpotLight){let n=e.target,i=t.getObjectByProperty("uuid",n);i!==void 0?e.target=i:e.target=new re}})}},sb={UVMapping:il,CubeReflectionMapping:Wi,CubeRefractionMapping:ur,EquirectangularReflectionMapping:Yo,EquirectangularRefractionMapping:$o,CubeUVReflectionMapping:Ts},R_={RepeatWrapping:An,ClampToEdgeWrapping:en,MirroredRepeatWrapping:Li},C_={NearestFilter:De,NearestMipmapNearestFilter:Nr,NearestMipmapLinearFilter:Mi,LinearFilter:Ee,LinearMipmapNearestFilter:Xi,LinearMipmapLinearFilter:un},sp=new WeakMap,Go=class extends Ke{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,o=di.get(`image-bitmap:${t}`);if(o!==void 0){if(r.manager.itemStart(t),o.then){o.then(l=>{if(sp.has(o)===!0)i&&i(sp.get(o)),r.manager.itemError(t),r.manager.itemEnd(t);else return e&&e(l),r.manager.itemEnd(t),l});return}return setTimeout(function(){e&&e(o),r.manager.itemEnd(t)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let c=fetch(t,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return di.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t),l}).catch(function(l){i&&i(l),sp.set(c,l),di.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});di.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}},Ku,Wo=class{static getContext(){return Ku===void 0&&(Ku=new(window.AudioContext||window.webkitAudioContext)),Ku}static setContext(t){Ku=t}},wh=class extends Ke{constructor(t){super(t)}load(t,e,n,i){let r=this,o=new Mn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(c){try{let l=c.slice(0);Wo.getContext().decodeAudioData(l,function(h){e(h)}).catch(a)}catch(l){a(l)}},n,i);function a(c){i?i(c):console.error(c),r.manager.itemError(t)}}},I_=new vt,P_=new vt,Zr=new vt,Ah=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Re,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Re,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(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,Zr.copy(t.projectionMatrix);let i=e.eyeSep/2,r=i*e.near/e.focus,o=e.near*Math.tan(is*e.fov*.5)/e.zoom,a,c;P_.elements[12]=-i,I_.elements[12]=i,a=-o*e.aspect+r,c=o*e.aspect+r,Zr.elements[0]=2*e.near/(c-a),Zr.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Zr),a=-o*e.aspect-r,c=o*e.aspect-r,Zr.elements[0]=2*e.near/(c-a),Zr.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Zr)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(P_),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(I_)}},qc=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}},bs=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}},Jr=new I,op=new Ce,ob=new I,jr=new I,Qr=new I,Rh=class extends re{constructor(){super(),this.type="AudioListener",this.context=Wo.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new bs}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(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(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Jr,op,ob),jr.set(0,0,-1).applyQuaternion(op),Qr.set(0,1,0).applyQuaternion(op),e.positionX){let n=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Jr.x,n),e.positionY.linearRampToValueAtTime(Jr.y,n),e.positionZ.linearRampToValueAtTime(Jr.z,n),e.forwardX.linearRampToValueAtTime(jr.x,n),e.forwardY.linearRampToValueAtTime(jr.y,n),e.forwardZ.linearRampToValueAtTime(jr.z,n),e.upX.linearRampToValueAtTime(Qr.x,n),e.upY.linearRampToValueAtTime(Qr.y,n),e.upZ.linearRampToValueAtTime(Qr.z,n)}else e.setPosition(Jr.x,Jr.y,Jr.z),e.setOrientation(jr.x,jr.y,jr.z,Qr.x,Qr.y,Qr.z)}},Yc=class extends re{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.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(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.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()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].connect(this.filters[t]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t<e;t++)this.filters[t-1].disconnect(this.filters[t]);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(t){return t||(t=[]),this._connected===!0?(this.disconnect(),this.filters=t.slice(),this.connect()):this.filters=t.slice(),this}setDetune(t){return this.detune=t,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(t){return this.setFilters(t?[t]:[])}setPlaybackRate(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=t,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(t){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=t,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(t){return this.loopStart=t,this}setLoopEnd(t){return this.loopEnd=t,this}getVolume(){return this.gain.gain.value}setVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}copy(t,e){return super.copy(t,e),t.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=t.autoplay,this.buffer=t.buffer,this.detune=t.detune,this.loop=t.loop,this.loopStart=t.loopStart,this.loopEnd=t.loopEnd,this.offset=t.offset,this.duration=t.duration,this.playbackRate=t.playbackRate,this.hasPlaybackControl=t.hasPlaybackControl,this.sourceType=t.sourceType,this.filters=t.filters.slice(),this)}clone(t){return new this.constructor(this.listener).copy(this,t)}},ts=new I,L_=new Ce,ab=new I,es=new I,Ch=class extends Yc{constructor(t){super(t),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(t){return this.panner.refDistance=t,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(t){return this.panner.rolloffFactor=t,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(t){return this.panner.distanceModel=t,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(t){return this.panner.maxDistance=t,this}setDirectionalCone(t,e,n){return this.panner.coneInnerAngle=t,this.panner.coneOuterAngle=e,this.panner.coneOuterGain=n,this}updateMatrixWorld(t){if(super.updateMatrixWorld(t),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(ts,L_,ab),es.set(0,0,1).applyQuaternion(L_);let e=this.panner;if(e.positionX){let n=this.context.currentTime+this.listener.timeDelta;e.positionX.linearRampToValueAtTime(ts.x,n),e.positionY.linearRampToValueAtTime(ts.y,n),e.positionZ.linearRampToValueAtTime(ts.z,n),e.orientationX.linearRampToValueAtTime(es.x,n),e.orientationY.linearRampToValueAtTime(es.y,n),e.orientationZ.linearRampToValueAtTime(es.z,n)}else e.setPosition(ts.x,ts.y,ts.z),e.setOrientation(es.x,es.y,es.z)}},Ih=class{constructor(t,e=2048){this.analyser=t.context.createAnalyser(),this.analyser.fftSize=e,this.data=new Uint8Array(this.analyser.frequencyBinCount),t.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let t=0,e=this.getFrequencyData();for(let n=0;n<e.length;n++)t+=e[n];return t/e.length}},$c=class{constructor(t,e,n){this.binding=t,this.valueSize=n;let i,r,o;switch(e){case"quaternion":i=this._slerp,r=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":i=this._select,r=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:i=this._lerp,r=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=r,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){let n=this.buffer,i=this.valueSize,r=t*i+i,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==i;++a)n[r+a]=n[a];o=e}else{o+=e;let a=e/o;this._mixBufferRegion(n,r,0,a,i)}this.cumulativeWeight=o}accumulateAdditive(t){let e=this.buffer,n=this.valueSize,i=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,i,0,t,n),this.cumulativeWeightAdditive+=t}apply(t){let e=this.valueSize,n=this.buffer,i=t*e+e,r=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,r<1){let c=e*this._origIndex;this._mixBufferRegion(n,i,c,1-r,e)}o>0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(n[c]!==n[c+e]){a.setValue(n,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,o=i;r!==o;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n<e;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[e+n]=this.buffer[t+n]}_select(t,e,n,i,r){if(i>=.5)for(let o=0;o!==r;++o)t[e+o]=t[n+o]}_slerp(t,e,n,i){Ce.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){let o=this._workIndex*r;Ce.multiplyQuaternionsFlat(t,o,t,e,t,n),Ce.slerpFlat(t,e,t,e,t,o,i)}_lerp(t,e,n,i,r){let o=1-i;for(let a=0;a!==r;++a){let c=e+a;t[c]=t[c]*o+t[n+a]*i}}_lerpAdditive(t,e,n,i,r){for(let o=0;o!==r;++o){let a=e+o;t[a]=t[a]+t[n+o]*i}}},vm="\\[\\]\\.:\\/",cb=new RegExp("["+vm+"]","g"),Mm="[^"+vm+"]",lb="[^"+vm.replace("\\.","")+"]",ub=/((?:WC+[\/:])*)/.source.replace("WC",Mm),hb=/(WCOD+)?/.source.replace("WCOD",lb),fb=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Mm),db=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Mm),pb=new RegExp("^"+ub+hb+fb+db+"$"),mb=["material","materials","bones","map"],vp=class{constructor(t,e,n){let i=n||ee.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},ee=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(cb,"")}static parseTrackName(t){let e=pb.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);mb.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let o=0;o<r.length;o++){let a=r[o];if(a.name===e||a.uuid===e)return a;let c=n(a.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,n=e.objectName,i=e.propertyName,r=e.propertyIndex;if(t||(t=s.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let u=0;u<t.length;u++)if(t[u].name===l){l=u;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}let o=t[i];if(o===void 0){let l=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?a=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=r}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};ee.Composite=vp;ee.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ee.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ee.prototype.GetterByBindingType=[ee.prototype._getValue_direct,ee.prototype._getValue_array,ee.prototype._getValue_arrayElement,ee.prototype._getValue_toArray];ee.prototype.SetterByBindingTypeAndVersioning=[[ee.prototype._setValue_direct,ee.prototype._setValue_direct_setNeedsUpdate,ee.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_array,ee.prototype._setValue_array_setNeedsUpdate,ee.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_arrayElement,ee.prototype._setValue_arrayElement_setNeedsUpdate,ee.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ee.prototype._setValue_fromArray,ee.prototype._setValue_fromArray_setNeedsUpdate,ee.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Ph=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Bn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let t={};this._indicesByUUID=t;for(let n=0,i=arguments.length;n!==i;++n)t[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}add(){let t=this._objects,e=this._indicesByUUID,n=this._paths,i=this._parsedPaths,r=this._bindings,o=r.length,a,c=t.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let f=arguments[u],p=f.uuid,x=e[p];if(x===void 0){x=c++,e[p]=x,t.push(f);for(let v=0,y=o;v!==y;++v)r[v].push(new ee(f,n[v],i[v]))}else if(x<l){a=t[x];let v=--l,y=t[v];e[y.uuid]=x,t[x]=y,e[p]=v,t[v]=f;for(let _=0,S=o;_!==S;++_){let g=r[_],d=g[v],M=g[x];g[x]=d,M===void 0&&(M=new ee(f,n[_],i[_])),g[v]=M}}else t[x]!==a&&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(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=e[l];if(u!==void 0&&u>=r){let h=r++,f=t[h];e[f.uuid]=u,t[u]=f,e[l]=h,t[h]=c;for(let p=0,x=i;p!==x;++p){let v=n[p],y=v[h],_=v[u];v[u]=y,v[h]=_}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,o=t.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=e[u];if(h!==void 0)if(delete e[u],h<r){let f=--r,p=t[f],x=--o,v=t[x];e[p.uuid]=h,t[h]=p,e[v.uuid]=f,t[f]=v,t.pop();for(let y=0,_=i;y!==_;++y){let S=n[y],g=S[f],d=S[x];S[h]=g,S[f]=d,S.pop()}}else{let f=--o,p=t[f];f>0&&(e[p.uuid]=h),t[h]=p,t.pop();for(let x=0,v=i;x!==v;++x){let y=n[x];y[h]=y[f],y.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(i!==void 0)return r[i];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);i=r.length,n[t]=i,o.push(t),a.push(e),r.push(h);for(let f=u,p=c.length;f!==p;++f){let x=c[f];h[f]=new ee(x,t,e)}return h}unsubscribe_(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let i=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=t[a];e[l]=n,o[n]=c,o.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},Kc=class{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;let r=e.tracks,o=r.length,a=new Array(o),c={endingStart:Tr,endingEnd:Tr};for(let l=0;l!==o;++l){let u=r[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=tm,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&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n=!1){if(t.fadeOut(e),this.fadeIn(e),n===!0){let i=this._clip.duration,r=t._clip.duration,o=r/i,a=i/r;t.warp(1,o,e),this.warp(a,1,e)}return this}crossFadeTo(t,e,n=!1){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let i=this._mixer,r=i.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=r,c[1]=r+n,l[0]=t/o,l[1]=e/o,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}let r=this._startTime;if(r!==null){let c=(t-r)*n;c<0||n===0?e=0:(this._startTime=null,e=n*c)}e*=this._updateTimeScale(t);let o=this._updateTime(e),a=this._updateWeight(t);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case _f:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case Bl:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(i,a)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,i=this.time+t,r=this._loopCount,o=n===em;if(t===0)return r===-1?i:o&&(r&1)===1?e-i:i;if(n===Qp){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),i>=e||i<0){let a=Math.floor(i/e);i-=e*a,r+=Math.abs(a);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){let l=t<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=i;if(o&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){let i=this._interpolantSettings;n?(i.endingStart=Er,i.endingEnd=Er):(t?i.endingStart=this.zeroSlopeAtStart?Er:Tr:i.endingStart=go,e?i.endingEnd=this.zeroSlopeAtEnd?Er:Tr:i.endingEnd=go)}_scheduleFading(t,e,n){let i=this._mixer,r=i.time,o=this._weightInterpolant;o===null&&(o=i._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=r,c[0]=e,a[1]=r+t,c[1]=n,this}},gb=new Float32Array(1),Xo=class extends kn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,o=t._propertyBindings,a=t._interpolants,c=n.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==r;++h){let f=i[h],p=f.name,x=u[p];if(x!==void 0)++x.referenceCount,o[h]=x;else{if(x=o[h],x!==void 0){x._cacheIndex===null&&(++x.referenceCount,this._addInactiveBinding(x,c,p));continue}let v=e&&e._propertyBindings[h].binding.parsedPath;x=new $c(ee.create(n,p,v),f.ValueTypeName,f.getValueSize()),++x.referenceCount,this._addInactiveBinding(x,c,p),o[h]=x}a[h].resultBuffer=x.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,n){let i=this._actions,r=this._actionsByClip,o=r[e];if(o===void 0)o={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,r[e]=o;else{let a=o.knownActions;t._byClipCacheIndex=a.length,a.push(t)}t._cacheIndex=i.length,i.push(t),o.actionByRoot[n]=t}_removeInactiveAction(t){let e=this._actions,n=e[e.length-1],i=t._cacheIndex;n._cacheIndex=i,e[i]=n,e.pop(),t._cacheIndex=null;let r=t._clip.uuid,o=this._actionsByClip,a=o[r],c=a.knownActions,l=c[c.length-1],u=t._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),t._byClipCacheIndex=null;let h=a.actionByRoot,f=(t._localRoot||this._root).uuid;delete h[f],c.length===0&&delete o[r],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.referenceCount===0&&this._removeInactiveBinding(r)}}_lendAction(t){let e=this._actions,n=t._cacheIndex,i=this._nActiveActions++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackAction(t){let e=this._actions,n=t._cacheIndex,i=--this._nActiveActions,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_addInactiveBinding(t,e,n){let i=this._bindingsByRootAndName,r=this._bindings,o=i[e];o===void 0&&(o={},i[e]=o),o[n]=t,t._cacheIndex=r.length,r.push(t)}_removeInactiveBinding(t){let e=this._bindings,n=t.binding,i=n.rootNode.uuid,r=n.path,o=this._bindingsByRootAndName,a=o[i],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete a[r],Object.keys(a).length===0&&delete o[i]}_lendBinding(t){let e=this._bindings,n=t._cacheIndex,i=this._nActiveBindings++,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_takeBackBinding(t){let e=this._bindings,n=t._cacheIndex,i=--this._nActiveBindings,r=e[i];t._cacheIndex=i,e[i]=t,r._cacheIndex=n,e[n]=r}_lendControlInterpolant(){let t=this._controlInterpolants,e=this._nActiveControlInterpolants++,n=t[e];return n===void 0&&(n=new ko(new Float32Array(2),new Float32Array(2),1,gb),n.__cacheIndex=e,t[e]=n),n}_takeBackControlInterpolant(t){let e=this._controlInterpolants,n=t.__cacheIndex,i=--this._nActiveControlInterpolants,r=e[i];t.__cacheIndex=i,e[i]=t,r.__cacheIndex=n,e[n]=r}clipAction(t,e,n){let i=e||this._root,r=i.uuid,o=typeof t=="string"?ni.findByName(i,t):t,a=o!==null?o.uuid:t,c=this._actionsByClip[a],l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=Bl),c!==void 0){let h=c.actionByRoot[r];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Kc(this,o,e,n);return this._bindAction(u,l),this._addInactiveAction(u,a,r),u}existingAction(t,e){let n=e||this._root,i=n.uuid,r=typeof t=="string"?ni.findByName(n,t):t,o=r?r.uuid:t,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[i]||null}stopAllAction(){let t=this._actions,e=this._nActiveActions;for(let n=e-1;n>=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let l=0;l!==n;++l)e[l]._update(i,t,r,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){let e=this._actions,n=t.uuid,i=this._actionsByClip,r=i[n];if(r!==void 0){let o=r.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,e[u]=h,e.pop(),this._removeInactiveBindingsForAction(l)}delete i[n]}}uncacheRoot(t){let e=t.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,c=a[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let i=this._bindingsByRootAndName,r=i[e];if(r!==void 0)for(let o in r){let a=r[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(t,e){let n=this.existingAction(t,e);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Lh=class extends Mo{constructor(t=1,e=1,n=1,i={}){super(t,e,i),this.isRenderTarget3D=!0,this.depth=n,this.texture=new ls(null,t,e,n),this._setTextureOptions(i),this.texture.isRenderTargetTexture=!0}},Nh=class s{constructor(t){this.value=t}clone(){return new s(this.value.clone===void 0?this.value:this.value.clone())}},xb=0,Dh=class extends kn{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:xb++}),this.name="",this.usage=_o,this.uniforms=[]}add(t){return this.uniforms.push(t),this}remove(t){let e=this.uniforms.indexOf(t);return e!==-1&&this.uniforms.splice(e,1),this}setName(t){return this.name=t,this}setUsage(t){return this.usage=t,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(t){this.name=t.name,this.usage=t.usage;let e=t.uniforms;this.uniforms.length=0;for(let n=0,i=e.length;n<i;n++){let r=Array.isArray(e[n])?e[n]:[e[n]];for(let o=0;o<r.length;o++)this.uniforms.push(r[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Uh=class extends Oi{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){let e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){let e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}},Fh=class{constructor(t,e,n,i,r,o=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=t,this.type=e,this.itemSize=n,this.elementSize=i,this.count=r,this.normalized=o,this.version=0}set needsUpdate(t){t===!0&&this.version++}setBuffer(t){return this.buffer=t,this}setType(t,e){return this.type=t,this.elementSize=e,this}setItemSize(t){return this.itemSize=t,this}setCount(t){return this.count=t,this}},N_=new vt,Oh=class{constructor(t,e,n=0,i=1/0){this.ray=new _n(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new us,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,(e.near+e.far)/(e.near-e.far)).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):console.error("THREE.Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return N_.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(N_),this}intersectObject(t,e=!0,n=[]){return Mp(t,this,n,e),n.sort(D_),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Mp(t[i],this,n,e);return n.sort(D_),n}};function D_(s,t){return s.distance-t.distance}function Mp(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){let r=s.children;for(let o=0,a=r.length;o<a;o++)Mp(r[o],t,e,!0)}}var Bh=class{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(t){this._document=t,t.hidden!==void 0&&(this._pageVisibilityHandler=_b.bind(this),t.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(t){return this._timescale=t,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(t){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(t!==void 0?t:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}};function _b(){this._document.hidden===!1&&this.reset()}var zh=class{constructor(t=1,e=0,n=0){this.radius=t,this.phi=e,this.theta=n}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){return this.phi=Xt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(Xt(e/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},kh=class{constructor(t=1,e=0,n=0){this.radius=t,this.theta=e,this.y=n}set(t,e,n){return this.radius=t,this.theta=e,this.y=n,this}copy(t){return this.radius=t.radius,this.theta=t.theta,this.y=t.y,this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+n*n),this.theta=Math.atan2(t,n),this.y=e,this}clone(){return new this.constructor().copy(this)}},Hh=class s{constructor(t,e,n,i){s.prototype.isMatrix2=!0,this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){let r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}},U_=new nt,Vh=class{constructor(t=new nt(1/0,1/0),e=new nt(-1/0,-1/0)){this.isBox2=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){let n=U_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.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(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,U_).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},F_=new I,Zu=new I,ho=new I,fo=new I,ap=new I,yb=new I,vb=new I,_e=class{constructor(t=new I,e=new I){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){F_.subVectors(t,this.start),Zu.subVectors(this.end,this.start);let n=Zu.dot(Zu),r=Zu.dot(F_)/n;return e&&(r=Xt(r,0,1)),r}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(t,e=yb,n=vb){let i=10000000000000001e-32,r,o,a=this.start,c=t.start,l=this.end,u=t.end;ho.subVectors(l,a),fo.subVectors(u,c),ap.subVectors(a,c);let h=ho.dot(ho),f=fo.dot(fo),p=fo.dot(ap);if(h<=i&&f<=i)return e.copy(a),n.copy(c),e.sub(n),e.dot(e);if(h<=i)r=0,o=p/f,o=Xt(o,0,1);else{let x=ho.dot(ap);if(f<=i)o=0,r=Xt(-x/h,0,1);else{let v=ho.dot(fo),y=h*f-v*v;y!==0?r=Xt((v*p-x*f)/y,0,1):r=0,o=(v*r+p)/f,o<0?(o=0,r=Xt(-x/h,0,1)):o>1&&(o=1,r=Xt((v-x)/h,0,1))}}return e.copy(a).add(ho.multiplyScalar(r)),n.copy(c).add(fo.multiplyScalar(o)),e.sub(n),e.dot(e)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},O_=new I,Gh=class extends re{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Vt,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 o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;i.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Lt(i,3));let r=new Xe({fog:!1,toneMapped:!1});this.cone=new yn(n,r),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),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),O_.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(O_),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Sr=new I,Ju=new vt,cp=new vt,Wh=class extends yn{constructor(t){let e=U0(t),n=new Vt,i=[],r=[];for(let l=0;l<e.length;l++){let u=e[l];u.parent&&u.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),r.push(0,0,0),r.push(0,0,0))}n.setAttribute("position",new Lt(i,3)),n.setAttribute("color",new Lt(r,3));let o=new Xe({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,o),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=t,this.bones=e,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;let a=new yt(255),c=new yt(65280);this.setColors(a,c)}updateMatrixWorld(t){let e=this.bones,n=this.geometry,i=n.getAttribute("position");cp.copy(this.root.matrixWorld).invert();for(let r=0,o=0;r<e.length;r++){let a=e[r];a.parent&&a.parent.isBone&&(Ju.multiplyMatrices(cp,a.matrixWorld),Sr.setFromMatrixPosition(Ju),i.setXYZ(o,Sr.x,Sr.y,Sr.z),Ju.multiplyMatrices(cp,a.parent.matrixWorld),Sr.setFromMatrixPosition(Ju),i.setXYZ(o+1,Sr.x,Sr.y,Sr.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(t)}setColors(t,e){let i=this.geometry.getAttribute("color");for(let r=0;r<i.count;r+=2)i.setXYZ(r,t.r,t.g,t.b),i.setXYZ(r+1,e.r,e.g,e.b);return i.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}};function U0(s){let t=[];s.isBone===!0&&t.push(s);for(let e=0;e<s.children.length;e++)t.push(...U0(s.children[e]));return t}var Xh=class extends ce{constructor(t,e,n){let i=new Oo(e,4,2),r=new sn({wireframe:!0,fog:!1,toneMapped:!1});super(i,r),this.light=t,this.color=n,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),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},Mb=new I,B_=new yt,z_=new yt,qh=class extends re{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let i=new Fo(e);i.rotateY(Math.PI*.5),this.material=new sn({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let r=i.getAttribute("position"),o=new Float32Array(r.count*3);i.setAttribute("color",new kt(o,3)),this.add(new ce(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let t=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let e=t.geometry.getAttribute("color");B_.copy(this.light.color),z_.copy(this.light.groundColor);for(let n=0,i=e.count;n<i;n++){let r=n<i/2?B_:z_;e.setXYZ(n,r.r,r.g,r.b)}e.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),t.lookAt(Mb.setFromMatrixPosition(this.light.matrixWorld).negate())}},Yh=class extends yn{constructor(t=10,e=10,n=4473924,i=8947848){n=new yt(n),i=new yt(i);let r=e/2,o=t/e,a=t/2,c=[],l=[];for(let f=0,p=0,x=-a;f<=e;f++,x+=o){c.push(-a,0,x,a,0,x),c.push(x,0,-a,x,0,a);let v=f===r?n:i;v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3,v.toArray(l,p),p+=3}let u=new Vt;u.setAttribute("position",new Lt(c,3)),u.setAttribute("color",new Lt(l,3));let h=new Xe({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},$h=class extends yn{constructor(t=10,e=16,n=8,i=64,r=4473924,o=8947848){r=new yt(r),o=new yt(o);let a=[],c=[];if(e>1)for(let h=0;h<e;h++){let f=h/e*(Math.PI*2),p=Math.sin(f)*t,x=Math.cos(f)*t;a.push(0,0,0),a.push(p,0,x);let v=h&1?r:o;c.push(v.r,v.g,v.b),c.push(v.r,v.g,v.b)}for(let h=0;h<n;h++){let f=h&1?r:o,p=t-t/n*h;for(let x=0;x<i;x++){let v=x/i*(Math.PI*2),y=Math.sin(v)*p,_=Math.cos(v)*p;a.push(y,0,_),c.push(f.r,f.g,f.b),v=(x+1)/i*(Math.PI*2),y=Math.sin(v)*p,_=Math.cos(v)*p,a.push(y,0,_),c.push(f.r,f.g,f.b)}}let l=new Vt;l.setAttribute("position",new Lt(a,3)),l.setAttribute("color",new Lt(c,3));let u=new Xe({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},k_=new I,ju=new I,H_=new I,Kh=class extends re{constructor(t,e,n){super(),this.light=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",e===void 0&&(e=1);let i=new Vt;i.setAttribute("position",new Lt([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));let r=new Xe({fog:!1,toneMapped:!1});this.lightPlane=new Vn(i,r),this.add(this.lightPlane),i=new Vt,i.setAttribute("position",new Lt([0,0,0,0,0,1],3)),this.targetLine=new Vn(i,r),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),k_.setFromMatrixPosition(this.light.matrixWorld),ju.setFromMatrixPosition(this.light.target.matrixWorld),H_.subVectors(ju,k_),this.lightPlane.lookAt(ju),this.color!==void 0?(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(ju),this.targetLine.scale.z=H_.length()}},Qu=new I,Oe=new hs,Zh=class extends yn{constructor(t){let e=new Vt,n=new Xe({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(x,v){c(x),c(v)}function c(x){i.push(0,0,0),r.push(0,0,0),o[x]===void 0&&(o[x]=[]),o[x].push(i.length/3-1)}e.setAttribute("position",new Lt(i,3)),e.setAttribute("color",new Lt(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new yt(16755200),u=new yt(16711680),h=new yt(43775),f=new yt(16777215),p=new yt(3355443);this.setColors(l,u,h,f,p)}setColors(t,e,n,i,r){let a=this.geometry.getAttribute("color");return a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0,this}update(){let t=this.geometry,e=this.pointMap,n=1,i=1,r,o;if(Oe.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)r=1,o=0;else if(this.camera.coordinateSystem===wn)r=-1,o=1;else if(this.camera.coordinateSystem===ss)r=0,o=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);He("c",e,t,Oe,0,0,r),He("t",e,t,Oe,0,0,o),He("n1",e,t,Oe,-n,-i,r),He("n2",e,t,Oe,n,-i,r),He("n3",e,t,Oe,-n,i,r),He("n4",e,t,Oe,n,i,r),He("f1",e,t,Oe,-n,-i,o),He("f2",e,t,Oe,n,-i,o),He("f3",e,t,Oe,-n,i,o),He("f4",e,t,Oe,n,i,o),He("u1",e,t,Oe,n*.7,i*1.1,r),He("u2",e,t,Oe,-n*.7,i*1.1,r),He("u3",e,t,Oe,0,i*2,r),He("cf1",e,t,Oe,-n,0,o),He("cf2",e,t,Oe,n,0,o),He("cf3",e,t,Oe,0,-i,o),He("cf4",e,t,Oe,0,i,o),He("cn1",e,t,Oe,-n,0,r),He("cn2",e,t,Oe,n,0,r),He("cn3",e,t,Oe,0,-i,r),He("cn4",e,t,Oe,0,i,r),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function He(s,t,e,n,i,r,o){Qu.set(i,r,o).unproject(n);let a=t[s];if(a!==void 0){let c=e.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],Qu.x,Qu.y,Qu.z)}}var th=new ne,Jh=class extends yn{constructor(t,e=16776960){let n=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]),i=new Float32Array(8*3),r=new Vt;r.setIndex(new kt(n,1)),r.setAttribute("position",new kt(i,3)),super(r,new Xe({color:e,toneMapped:!1})),this.object=t,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&th.setFromObject(this.object),th.isEmpty())return;let t=th.min,e=th.max,n=this.geometry.attributes.position,i=n.array;i[0]=e.x,i[1]=e.y,i[2]=e.z,i[3]=t.x,i[4]=e.y,i[5]=e.z,i[6]=t.x,i[7]=t.y,i[8]=e.z,i[9]=e.x,i[10]=t.y,i[11]=e.z,i[12]=e.x,i[13]=e.y,i[14]=t.z,i[15]=t.x,i[16]=e.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=e.x,i[22]=t.y,i[23]=t.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(t){return this.object=t,this.update(),this}copy(t,e){return super.copy(t,e),this.object=t.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},jh=class extends yn{constructor(t,e=16776960){let n=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]),i=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],r=new Vt;r.setIndex(new kt(n,1)),r.setAttribute("position",new Lt(i,3)),super(r,new Xe({color:e,toneMapped:!1})),this.box=t,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(t){let e=this.box;e.isEmpty()||(e.getCenter(this.position),e.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(t))}dispose(){this.geometry.dispose(),this.material.dispose()}},Qh=class extends Vn{constructor(t,e=1,n=16776960){let i=n,r=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new Vt;o.setAttribute("position",new Lt(r,3)),o.computeBoundingSphere(),super(o,new Xe({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=t,this.size=e;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new Vt;c.setAttribute("position",new Lt(a,3)),c.computeBoundingSphere(),this.add(new ce(c,new sn({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(t){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(t)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},V_=new I,eh,lp,tf=class extends re{constructor(t=new I(0,0,1),e=new I(0,0,0),n=1,i=16776960,r=n*.2,o=r*.2){super(),this.type="ArrowHelper",eh===void 0&&(eh=new Vt,eh.setAttribute("position",new Lt([0,0,0,0,1,0],3)),lp=new Co(.5,1,5,1),lp.translate(0,-.5,0)),this.position.copy(e),this.line=new Vn(eh,new Xe({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ce(lp,new sn({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(n,r,o)}setDirection(t){if(t.y>.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{V_.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(V_,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},ef=class extends yn{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Vt;i.setAttribute("position",new Lt(e,3)),i.setAttribute("color",new Lt(n,3));let r=new Xe({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new yt,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},nf=class{constructor(){this.type="ShapePath",this.color=new yt,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new xs,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,o){return this.currentPath.bezierCurveTo(t,e,n,i,r,o),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(_){let S=[];for(let g=0,d=_.length;g<d;g++){let M=_[g],m=new Pi;m.curves=M.curves,S.push(m)}return S}function n(_,S){let g=S.length,d=!1;for(let M=g-1,m=0;m<g;M=m++){let R=S[M],E=S[m],T=E.x-R.x,b=E.y-R.y;if(Math.abs(b)>Number.EPSILON){if(b<0&&(R=S[m],T=-T,E=S[M],b=-b),_.y<R.y||_.y>E.y)continue;if(_.y===R.y){if(_.x===R.x)return!0}else{let w=b*(_.x-R.x)-T*(_.y-R.y);if(w===0)return!0;if(w<0)continue;d=!d}}else{if(_.y!==R.y)continue;if(E.x<=_.x&&_.x<=R.x||R.x<=_.x&&_.x<=E.x)return!0}}return d}let i=Qn.isClockWise,r=this.subPaths;if(r.length===0)return[];let o,a,c,l=[];if(r.length===1)return a=r[0],c=new Pi,c.curves=a.curves,l.push(c),l;let u=!i(r[0].getPoints());u=t?!u:u;let h=[],f=[],p=[],x=0,v;f[x]=void 0,p[x]=[];for(let _=0,S=r.length;_<S;_++)a=r[_],v=a.getPoints(),o=i(v),o=t?!o:o,o?(!u&&f[x]&&x++,f[x]={s:new Pi,p:v},f[x].s.curves=a.curves,u&&x++,p[x]=[]):p[x].push({h:a,p:v[0]});if(!f[0])return e(r);if(f.length>1){let _=!1,S=0;for(let g=0,d=f.length;g<d;g++)h[g]=[];for(let g=0,d=f.length;g<d;g++){let M=p[g];for(let m=0;m<M.length;m++){let R=M[m],E=!0;for(let T=0;T<f.length;T++)n(R.p,f[T].p)&&(g!==T&&S++,E?(E=!1,h[T].push(R)):_=!0);E&&h[g].push(R)}}S>0&&_===!1&&(p=h)}let y;for(let _=0,S=f.length;_<S;_++){c=f[_].s,l.push(c),y=p[_];for(let g=0,d=y.length;g<d;g++)c.holes.push(y[g].h)}return l}},rf=class extends kn{constructor(t,e=null){super(),this.object=t,this.domElement=e,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(t){if(t===void 0){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=t}disconnect(){}dispose(){}update(){}};function Sb(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function bb(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function Tb(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function Sf(s,t,e,n){let i=Eb(n);switch(e){case mf:return s*t;case al:return s*t/i.components*i.byteLength;case Ko:return s*t/i.components*i.byteLength;case xf:return s*t*2/i.components*i.byteLength;case cl:return s*t*2/i.components*i.byteLength;case gf:return s*t*3/i.components*i.byteLength;case Qe:return s*t*4/i.components*i.byteLength;case ll:return s*t*4/i.components*i.byteLength;case Zo:case Jo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case jo:case Qo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case hl:case dl:return Math.max(s,16)*Math.max(t,8)/4;case ul:case fl:return Math.max(s,8)*Math.max(t,8)/2;case pl:case ml:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case gl:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case xl:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case _l:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case yl:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case vl:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case Ml:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case Sl:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case bl:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case Tl:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case El:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case wl:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case Al:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case Rl:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case Cl:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case Il:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case Pl:case Ll:case Nl:return Math.ceil(s/4)*Math.ceil(t/4)*16;case Dl:case Ul:return Math.ceil(s/4)*Math.ceil(t/4)*8;case Fl:case Ol:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Eb(s){switch(s){case ri:case hf:return{byteLength:1,components:1};case Es:case ff:case ws:return{byteLength:2,components:1};case sl:case ol:return{byteLength:2,components:4};case qi:case rl:case xn:return{byteLength:4,components:1};case df:case pf:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}var sf=class{static contain(t,e){return Sb(t,e)}static cover(t,e){return bb(t,e)}static fill(t){return Tb(t)}static getByteLength(t,e,n,i){return Sf(t,e,n,i)}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Hi}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Hi);function sy(){let s=null,t=!1,e=null,n=null;function i(r,o){e(r,o),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function wb(s){let t=new WeakMap;function e(a,c){let l=a.array,u=a.usage,h=l.byteLength,f=s.createBuffer();s.bindBuffer(c,f),s.bufferData(c,l,u),a.onUploadCallback();let p;if(l instanceof Float32Array)p=s.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)p=s.HALF_FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?p=s.HALF_FLOAT:p=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)p=s.SHORT;else if(l instanceof Uint32Array)p=s.UNSIGNED_INT;else if(l instanceof Int32Array)p=s.INT;else if(l instanceof Int8Array)p=s.BYTE;else if(l instanceof Uint8Array)p=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)p=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:f,type:p,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){let u=c.array,h=c.updateRanges;if(s.bindBuffer(l,a),h.length===0)s.bufferSubData(l,0,u);else{h.sort((p,x)=>p.start-x.start);let f=0;for(let p=1;p<h.length;p++){let x=h[f],v=h[p];v.start<=x.start+x.count+1?x.count=Math.max(x.count,v.start+v.count-x.start):(++f,h[f]=v)}h.length=f+1;for(let p=0,x=h.length;p<x;p++){let v=h[p];s.bufferSubData(l,v.start*u.BYTES_PER_ELEMENT,u,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(a){return a.isInterleavedBufferAttribute&&(a=a.data),t.get(a)}function r(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=t.get(a);c&&(s.deleteBuffer(c.buffer),t.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let u=t.get(a);(!u||u.version<a.version)&&t.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=t.get(a);if(l===void 0)t.set(a,e(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:i,remove:r,update:o}}var Ab=`#ifdef USE_ALPHAHASH
|
|
41
41
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
42
42
|
#endif`,Rb=`#ifdef USE_ALPHAHASH
|
|
43
43
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
@@ -3576,7 +3576,7 @@ void main() {
|
|
|
3576
3576
|
#include <tonemapping_fragment>
|
|
3577
3577
|
#include <colorspace_fragment>
|
|
3578
3578
|
#include <fog_fragment>
|
|
3579
|
-
}`,te={alphahash_fragment:Ab,alphahash_pars_fragment:Rb,alphamap_fragment:Cb,alphamap_pars_fragment:Ib,alphatest_fragment:Pb,alphatest_pars_fragment:Lb,aomap_fragment:Nb,aomap_pars_fragment:Db,batching_pars_vertex:Ub,batching_vertex:Fb,begin_vertex:Ob,beginnormal_vertex:Bb,bsdfs:zb,iridescence_fragment:kb,bumpmap_pars_fragment:Hb,clipping_planes_fragment:Vb,clipping_planes_pars_fragment:Gb,clipping_planes_pars_vertex:Wb,clipping_planes_vertex:Xb,color_fragment:qb,color_pars_fragment:Yb,color_pars_vertex:$b,color_vertex:Kb,common:Zb,cube_uv_reflection_fragment:Jb,defaultnormal_vertex:jb,displacementmap_pars_vertex:Qb,displacementmap_vertex:tT,emissivemap_fragment:eT,emissivemap_pars_fragment:nT,colorspace_fragment:iT,colorspace_pars_fragment:rT,envmap_fragment:sT,envmap_common_pars_fragment:oT,envmap_pars_fragment:aT,envmap_pars_vertex:cT,envmap_physical_pars_fragment:yT,envmap_vertex:lT,fog_vertex:uT,fog_pars_vertex:hT,fog_fragment:fT,fog_pars_fragment:dT,gradientmap_pars_fragment:pT,lightmap_pars_fragment:mT,lights_lambert_fragment:gT,lights_lambert_pars_fragment:xT,lights_pars_begin:_T,lights_toon_fragment:vT,lights_toon_pars_fragment:MT,lights_phong_fragment:ST,lights_phong_pars_fragment:bT,lights_physical_fragment:TT,lights_physical_pars_fragment:ET,lights_fragment_begin:wT,lights_fragment_maps:AT,lights_fragment_end:RT,logdepthbuf_fragment:CT,logdepthbuf_pars_fragment:IT,logdepthbuf_pars_vertex:PT,logdepthbuf_vertex:LT,map_fragment:NT,map_pars_fragment:DT,map_particle_fragment:UT,map_particle_pars_fragment:FT,metalnessmap_fragment:OT,metalnessmap_pars_fragment:BT,morphinstance_vertex:zT,morphcolor_vertex:kT,morphnormal_vertex:HT,morphtarget_pars_vertex:VT,morphtarget_vertex:GT,normal_fragment_begin:WT,normal_fragment_maps:XT,normal_pars_fragment:qT,normal_pars_vertex:YT,normal_vertex:$T,normalmap_pars_fragment:KT,clearcoat_normal_fragment_begin:ZT,clearcoat_normal_fragment_maps:JT,clearcoat_pars_fragment:jT,iridescence_pars_fragment:QT,opaque_fragment:tE,packing:eE,premultiplied_alpha_fragment:nE,project_vertex:iE,dithering_fragment:rE,dithering_pars_fragment:sE,roughnessmap_fragment:oE,roughnessmap_pars_fragment:aE,shadowmap_pars_fragment:cE,shadowmap_pars_vertex:lE,shadowmap_vertex:uE,shadowmask_pars_fragment:hE,skinbase_vertex:fE,skinning_pars_vertex:dE,skinning_vertex:pE,skinnormal_vertex:mE,specularmap_fragment:gE,specularmap_pars_fragment:xE,tonemapping_fragment:_E,tonemapping_pars_fragment:yE,transmission_fragment:vE,transmission_pars_fragment:ME,uv_pars_fragment:SE,uv_pars_vertex:bE,uv_vertex:TE,worldpos_vertex:EE,background_vert:wE,background_frag:AE,backgroundCube_vert:RE,backgroundCube_frag:CE,cube_vert:IE,cube_frag:PE,depth_vert:LE,depth_frag:NE,distanceRGBA_vert:DE,distanceRGBA_frag:UE,equirect_vert:FE,equirect_frag:OE,linedashed_vert:BE,linedashed_frag:zE,meshbasic_vert:kE,meshbasic_frag:HE,meshlambert_vert:VE,meshlambert_frag:GE,meshmatcap_vert:WE,meshmatcap_frag:XE,meshnormal_vert:qE,meshnormal_frag:YE,meshphong_vert:$E,meshphong_frag:KE,meshphysical_vert:ZE,meshphysical_frag:JE,meshtoon_vert:jE,meshtoon_frag:QE,points_vert:tw,points_frag:ew,shadow_vert:nw,shadow_frag:iw,sprite_vert:rw,sprite_frag:sw},Tt={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $t}},envmap:{envMap:{value:null},envMapRotation:{value:new $t},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $t}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $t}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $t},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $t},normalScale:{value:new nt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $t},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $t}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $t}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $t}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0},uvTransform:{value:new $t}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}}},Si={basic:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.fog]),vertexShader:te.meshbasic_vert,fragmentShader:te.meshbasic_frag},lambert:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)}}]),vertexShader:te.meshlambert_vert,fragmentShader:te.meshlambert_frag},phong:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:te.meshphong_vert,fragmentShader:te.meshphong_frag},standard:{uniforms:hn([Tt.common,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.roughnessmap,Tt.metalnessmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag},toon:{uniforms:hn([Tt.common,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.gradientmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)}}]),vertexShader:te.meshtoon_vert,fragmentShader:te.meshtoon_frag},matcap:{uniforms:hn([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,{matcap:{value:null}}]),vertexShader:te.meshmatcap_vert,fragmentShader:te.meshmatcap_frag},points:{uniforms:hn([Tt.points,Tt.fog]),vertexShader:te.points_vert,fragmentShader:te.points_frag},dashed:{uniforms:hn([Tt.common,Tt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:te.linedashed_vert,fragmentShader:te.linedashed_frag},depth:{uniforms:hn([Tt.common,Tt.displacementmap]),vertexShader:te.depth_vert,fragmentShader:te.depth_frag},normal:{uniforms:hn([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,{opacity:{value:1}}]),vertexShader:te.meshnormal_vert,fragmentShader:te.meshnormal_frag},sprite:{uniforms:hn([Tt.sprite,Tt.fog]),vertexShader:te.sprite_vert,fragmentShader:te.sprite_frag},background:{uniforms:{uvTransform:{value:new $t},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:te.background_vert,fragmentShader:te.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $t}},vertexShader:te.backgroundCube_vert,fragmentShader:te.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:te.cube_vert,fragmentShader:te.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:te.equirect_vert,fragmentShader:te.equirect_frag},distanceRGBA:{uniforms:hn([Tt.common,Tt.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:te.distanceRGBA_vert,fragmentShader:te.distanceRGBA_frag},shadow:{uniforms:hn([Tt.lights,Tt.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:te.shadow_vert,fragmentShader:te.shadow_frag}};Si.physical={uniforms:hn([Si.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $t},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $t},clearcoatNormalScale:{value:new nt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $t},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $t},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $t},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $t},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $t},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $t},transmissionSamplerSize:{value:new nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $t},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $t},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $t},anisotropyVector:{value:new nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $t}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag};var bf={r:0,b:0,g:0},Ps=new Rn,ow=new vt;function aw(s,t,e,n,i,r,o){let a=new yt(0),c=r===!0?0:1,l,u,h=null,f=0,p=null;function x(g){let d=g.isScene===!0?g.background:null;return d&&d.isTexture&&(d=(g.backgroundBlurriness>0?e:t).get(d)),d}function v(g){let d=!1,M=x(g);M===null?_(a,c):M&&M.isColor&&(_(M,1),d=!0);let m=s.xr.getEnvironmentBlendMode();m==="additive"?n.buffers.color.setClear(0,0,0,1,o):m==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||d)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function y(g,d){let M=x(d);M&&(M.isCubeTexture||M.mapping===Ts)?(u===void 0&&(u=new ce(new Ui(1,1,1),new Cn({name:"BackgroundCubeMaterial",uniforms:Is(Si.backgroundCube.uniforms),vertexShader:Si.backgroundCube.vertexShader,fragmentShader:Si.backgroundCube.fragmentShader,side:qe,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(m,R,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Ps.copy(d.backgroundRotation),Ps.x*=-1,Ps.y*=-1,Ps.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Ps.y*=-1,Ps.z*=-1),u.material.uniforms.envMap.value=M,u.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(ow.makeRotationFromEuler(Ps)),u.material.toneMapped=ie.getTransfer(M.colorSpace)!==ge,(h!==M||f!==M.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,h=M,f=M.version,p=s.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new ce(new ys(2,2),new Cn({name:"BackgroundMaterial",uniforms:Is(Si.background.uniforms),vertexShader:Si.background.vertexShader,fragmentShader:Si.background.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,l.material.toneMapped=ie.getTransfer(M.colorSpace)!==ge,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||f!==M.version||p!==s.toneMapping)&&(l.material.needsUpdate=!0,h=M,f=M.version,p=s.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function _(g,d){g.getRGB(bf,pm(s)),n.buffers.color.setClear(bf.r,bf.g,bf.b,d,o)}function S(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(g,d=1){a.set(g),c=d,_(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,_(a,c)},render:v,addToRenderList:y,dispose:S}}function cw(s,t){let e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=f(null),r=i,o=!1;function a(b,w,A,C,D){let F=!1,O=h(C,A,w);r!==O&&(r=O,l(r.object)),F=p(b,C,A,D),F&&x(b,C,A,D),D!==null&&t.update(D,s.ELEMENT_ARRAY_BUFFER),(F||o)&&(o=!1,d(b,w,A,C),D!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(D).buffer))}function c(){return s.createVertexArray()}function l(b){return s.bindVertexArray(b)}function u(b){return s.deleteVertexArray(b)}function h(b,w,A){let C=A.wireframe===!0,D=n[b.id];D===void 0&&(D={},n[b.id]=D);let F=D[w.id];F===void 0&&(F={},D[w.id]=F);let O=F[C];return O===void 0&&(O=f(c()),F[C]=O),O}function f(b){let w=[],A=[],C=[];for(let D=0;D<e;D++)w[D]=0,A[D]=0,C[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:A,attributeDivisors:C,object:b,attributes:{},index:null}}function p(b,w,A,C){let D=r.attributes,F=w.attributes,O=0,H=A.getAttributes();for(let B in H)if(H[B].location>=0){let at=D[B],rt=F[B];if(rt===void 0&&(B==="instanceMatrix"&&b.instanceMatrix&&(rt=b.instanceMatrix),B==="instanceColor"&&b.instanceColor&&(rt=b.instanceColor)),at===void 0||at.attribute!==rt||rt&&at.data!==rt.data)return!0;O++}return r.attributesNum!==O||r.index!==C}function x(b,w,A,C){let D={},F=w.attributes,O=0,H=A.getAttributes();for(let B in H)if(H[B].location>=0){let at=F[B];at===void 0&&(B==="instanceMatrix"&&b.instanceMatrix&&(at=b.instanceMatrix),B==="instanceColor"&&b.instanceColor&&(at=b.instanceColor));let rt={};rt.attribute=at,at&&at.data&&(rt.data=at.data),D[B]=rt,O++}r.attributes=D,r.attributesNum=O,r.index=C}function v(){let b=r.newAttributes;for(let w=0,A=b.length;w<A;w++)b[w]=0}function y(b){_(b,0)}function _(b,w){let A=r.newAttributes,C=r.enabledAttributes,D=r.attributeDivisors;A[b]=1,C[b]===0&&(s.enableVertexAttribArray(b),C[b]=1),D[b]!==w&&(s.vertexAttribDivisor(b,w),D[b]=w)}function S(){let b=r.newAttributes,w=r.enabledAttributes;for(let A=0,C=w.length;A<C;A++)w[A]!==b[A]&&(s.disableVertexAttribArray(A),w[A]=0)}function g(b,w,A,C,D,F,O){O===!0?s.vertexAttribIPointer(b,w,A,D,F):s.vertexAttribPointer(b,w,A,C,D,F)}function d(b,w,A,C){v();let D=C.attributes,F=A.getAttributes(),O=w.defaultAttributeValues;for(let H in F){let B=F[H];if(B.location>=0){let $=D[H];if($===void 0&&(H==="instanceMatrix"&&b.instanceMatrix&&($=b.instanceMatrix),H==="instanceColor"&&b.instanceColor&&($=b.instanceColor)),$!==void 0){let at=$.normalized,rt=$.itemSize,ht=t.get($);if(ht===void 0)continue;let bt=ht.buffer,Et=ht.type,Mt=ht.bytesPerElement,K=Et===s.INT||Et===s.UNSIGNED_INT||$.gpuType===rl;if($.isInterleavedBufferAttribute){let Q=$.data,ct=Q.stride,lt=$.offset;if(Q.isInstancedInterleavedBuffer){for(let ut=0;ut<B.locationSize;ut++)_(B.location+ut,Q.meshPerAttribute);b.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ut=0;ut<B.locationSize;ut++)y(B.location+ut);s.bindBuffer(s.ARRAY_BUFFER,bt);for(let ut=0;ut<B.locationSize;ut++)g(B.location+ut,rt/B.locationSize,Et,at,ct*Mt,(lt+rt/B.locationSize*ut)*Mt,K)}else{if($.isInstancedBufferAttribute){for(let Q=0;Q<B.locationSize;Q++)_(B.location+Q,$.meshPerAttribute);b.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let Q=0;Q<B.locationSize;Q++)y(B.location+Q);s.bindBuffer(s.ARRAY_BUFFER,bt);for(let Q=0;Q<B.locationSize;Q++)g(B.location+Q,rt/B.locationSize,Et,at,rt*Mt,rt/B.locationSize*Q*Mt,K)}}else if(O!==void 0){let at=O[H];if(at!==void 0)switch(at.length){case 2:s.vertexAttrib2fv(B.location,at);break;case 3:s.vertexAttrib3fv(B.location,at);break;case 4:s.vertexAttrib4fv(B.location,at);break;default:s.vertexAttrib1fv(B.location,at)}}}}S()}function M(){E();for(let b in n){let w=n[b];for(let A in w){let C=w[A];for(let D in C)u(C[D].object),delete C[D];delete w[A]}delete n[b]}}function m(b){if(n[b.id]===void 0)return;let w=n[b.id];for(let A in w){let C=w[A];for(let D in C)u(C[D].object),delete C[D];delete w[A]}delete n[b.id]}function R(b){for(let w in n){let A=n[w];if(A[b.id]===void 0)continue;let C=A[b.id];for(let D in C)u(C[D].object),delete C[D];delete A[b.id]}}function E(){T(),o=!0,r!==i&&(r=i,l(r.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:E,resetDefaultState:T,dispose:M,releaseStatesOfGeometry:m,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:y,disableUnusedAttributes:S}}function lw(s,t,e){let n;function i(l){n=l}function r(l,u){s.drawArrays(n,l,u),e.update(u,n,1)}function o(l,u,h){h!==0&&(s.drawArraysInstanced(n,l,u,h),e.update(u,n,h))}function a(l,u,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let p=0;for(let x=0;x<h;x++)p+=u[x];e.update(p,n,1)}function c(l,u,h,f){if(h===0)return;let p=t.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<l.length;x++)o(l[x],u[x],f[x]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,h);let x=0;for(let v=0;v<h;v++)x+=u[v]*f[v];e.update(x,n,1)}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function uw(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(R){return!(R!==Qe&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(R){let E=R===ws&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==ri&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==xn&&!E)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=e.logarithmicDepthBuffer===!0,f=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),y=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),_=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),g=s.getParameter(s.MAX_VARYING_VECTORS),d=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=x>0,m=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:_,maxVertexUniforms:S,maxVaryings:g,maxFragmentUniforms:d,vertexTextures:M,maxSamples:m}}function hw(s){let t=this,e=null,n=0,i=!1,r=!1,o=new $e,a=new $t,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let p=h.length!==0||f||n!==0||i;return i=f,n=h.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,f){e=u(h,f,0)},this.setState=function(h,f,p){let x=h.clippingPlanes,v=h.clipIntersection,y=h.clipShadows,_=s.get(h);if(!i||x===null||x.length===0||r&&!y)r?u(null):l();else{let S=r?0:n,g=S*4,d=_.clippingState||null;c.value=d,d=u(x,f,g,p);for(let M=0;M!==g;++M)d[M]=e[M];_.clippingState=d,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(h,f,p,x){let v=h!==null?h.length:0,y=null;if(v!==0){if(y=c.value,x!==!0||y===null){let _=p+v*4,S=f.matrixWorldInverse;a.getNormalMatrix(S),(y===null||y.length<_)&&(y=new Float32Array(_));for(let g=0,d=p;g!==v;++g,d+=4)o.copy(h[g]).applyMatrix4(S,a),o.normal.toArray(y,d),y[d+3]=o.constant}c.value=y,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,y}}function fw(s){let t=new WeakMap;function e(o,a){return a===Yo?o.mapping=Wi:a===$o&&(o.mapping=ur),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Yo||a===$o)if(t.has(o)){let c=t.get(o).texture;return e(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Ja(c.height);return l.fromEquirectangularTexture(s,o),t.set(o,l),o.addEventListener("dispose",i),e(l.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var na=4,F0=[.125,.215,.35,.446,.526,.582],Ds=20,Mm=new cr,O0=new yt,Sm=null,bm=0,Tm=0,Em=!1,Ns=(1+Math.sqrt(5))/2,ea=1/Ns,B0=[new I(-Ns,ea,0),new I(Ns,ea,0),new I(-ea,0,Ns),new I(ea,0,Ns),new I(0,Ns,-ea),new I(0,Ns,ea),new I(-1,1,-1),new I(1,1,-1),new I(-1,1,1),new I(1,1,1)],dw=new I,kl=class{constructor(t){this._renderer=t,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(t,e=0,n=.1,i=100,r={}){let{size:o=256,position:a=dw}=r;Sm=this._renderer.getRenderTarget(),bm=this._renderer.getActiveCubeFace(),Tm=this._renderer.getActiveMipmapLevel(),Em=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,a),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=H0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(Sm,bm,Tm),this._renderer.xr.enabled=Em,t.scissorTest=!1,Tf(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Wi||t.mapping===ur?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Sm=this._renderer.getRenderTarget(),bm=this._renderer.getActiveCubeFace(),Tm=this._renderer.getActiveMipmapLevel(),Em=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ee,minFilter:Ee,generateMipmaps:!1,type:ws,format:Qe,colorSpace:tn,depthBuffer:!1},i=z0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=z0(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=pw(r)),this._blurMaterial=mw(r,t,e)}return i}_compileMaterial(t){let e=new ce(this._lodPlanes[0],t);this._renderer.compile(e,Mm)}_sceneToCubeUV(t,e,n,i,r){let c=new Re(90,1,e,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(O0),h.toneMapping=Gi,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null));let v=new sn({name:"PMREM.Background",side:qe,depthWrite:!1,depthTest:!1}),y=new ce(new Ui,v),_=!1,S=t.background;S?S.isColor&&(v.color.copy(S),t.background=null,_=!0):(v.color.copy(O0),_=!0);for(let g=0;g<6;g++){let d=g%3;d===0?(c.up.set(0,l[g],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+u[g],r.y,r.z)):d===1?(c.up.set(0,0,l[g]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+u[g],r.z)):(c.up.set(0,l[g],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+u[g]));let M=this._cubeSize;Tf(i,d*M,g>2?M:0,M,M),h.setRenderTarget(i),_&&h.render(y,c),h.render(t,c)}y.geometry.dispose(),y.material.dispose(),h.toneMapping=p,h.autoClear=f,t.background=S}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===Wi||t.mapping===ur;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=H0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k0());let r=i?this._cubemapMaterial:this._equirectMaterial,o=new ce(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=t;let c=this._cubeSize;Tf(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,Mm)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodPlanes.length;for(let r=1;r<i;r++){let o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=B0[(i-r-1)%B0.length];this._blur(t,r-1,r,o,a)}e.autoClear=n}_blur(t,e,n,i,r){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",r),this._halfBlur(o,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ce(this._lodPlanes[i],l),f=l.uniforms,p=this._sizeLods[n]-1,x=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Ds-1),v=r/x,y=isFinite(r)?1+Math.floor(u*v):Ds;y>Ds&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Ds}`);let _=[],S=0;for(let R=0;R<Ds;++R){let E=R/v,T=Math.exp(-E*E/2);_.push(T),R===0?S+=T:R<y&&(S+=2*T)}for(let R=0;R<_.length;R++)_[R]=_[R]/S;f.envMap.value=t.texture,f.samples.value=y,f.weights.value=_,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:g}=this;f.dTheta.value=x,f.mipInt.value=g-n;let d=this._sizeLods[i],M=3*d*(i>g-na?i-g+na:0),m=4*(this._cubeSize-d);Tf(e,M,m,3*d,2*d),c.setRenderTarget(e),c.render(h,Mm)}};function pw(s){let t=[],e=[],n=[],i=s,r=s-na+1+F0.length;for(let o=0;o<r;o++){let a=Math.pow(2,i);e.push(a);let c=1/a;o>s-na?c=F0[o-s+na-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,x=6,v=3,y=2,_=1,S=new Float32Array(v*x*p),g=new Float32Array(y*x*p),d=new Float32Array(_*x*p);for(let m=0;m<p;m++){let R=m%3*2/3-1,E=m>2?0:-1,T=[R,E,0,R+2/3,E,0,R+2/3,E+1,0,R,E,0,R+2/3,E+1,0,R,E+1,0];S.set(T,v*x*m),g.set(f,y*x*m);let b=[m,m,m,m,m,m];d.set(b,_*x*m)}let M=new Vt;M.setAttribute("position",new kt(S,v)),M.setAttribute("uv",new kt(g,y)),M.setAttribute("faceIndex",new kt(d,_)),t.push(M),i>na&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function z0(s,t,e){let n=new Hn(s,t,e);return n.texture.mapping=Ts,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Tf(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function mw(s,t,e){let n=new Float32Array(Ds),i=new I(0,1,0);return new Cn({name:"SphericalGaussianBlur",defines:{n:Ds,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Um(),fragmentShader:`
|
|
3579
|
+
}`,te={alphahash_fragment:Ab,alphahash_pars_fragment:Rb,alphamap_fragment:Cb,alphamap_pars_fragment:Ib,alphatest_fragment:Pb,alphatest_pars_fragment:Lb,aomap_fragment:Nb,aomap_pars_fragment:Db,batching_pars_vertex:Ub,batching_vertex:Fb,begin_vertex:Ob,beginnormal_vertex:Bb,bsdfs:zb,iridescence_fragment:kb,bumpmap_pars_fragment:Hb,clipping_planes_fragment:Vb,clipping_planes_pars_fragment:Gb,clipping_planes_pars_vertex:Wb,clipping_planes_vertex:Xb,color_fragment:qb,color_pars_fragment:Yb,color_pars_vertex:$b,color_vertex:Kb,common:Zb,cube_uv_reflection_fragment:Jb,defaultnormal_vertex:jb,displacementmap_pars_vertex:Qb,displacementmap_vertex:tT,emissivemap_fragment:eT,emissivemap_pars_fragment:nT,colorspace_fragment:iT,colorspace_pars_fragment:rT,envmap_fragment:sT,envmap_common_pars_fragment:oT,envmap_pars_fragment:aT,envmap_pars_vertex:cT,envmap_physical_pars_fragment:yT,envmap_vertex:lT,fog_vertex:uT,fog_pars_vertex:hT,fog_fragment:fT,fog_pars_fragment:dT,gradientmap_pars_fragment:pT,lightmap_pars_fragment:mT,lights_lambert_fragment:gT,lights_lambert_pars_fragment:xT,lights_pars_begin:_T,lights_toon_fragment:vT,lights_toon_pars_fragment:MT,lights_phong_fragment:ST,lights_phong_pars_fragment:bT,lights_physical_fragment:TT,lights_physical_pars_fragment:ET,lights_fragment_begin:wT,lights_fragment_maps:AT,lights_fragment_end:RT,logdepthbuf_fragment:CT,logdepthbuf_pars_fragment:IT,logdepthbuf_pars_vertex:PT,logdepthbuf_vertex:LT,map_fragment:NT,map_pars_fragment:DT,map_particle_fragment:UT,map_particle_pars_fragment:FT,metalnessmap_fragment:OT,metalnessmap_pars_fragment:BT,morphinstance_vertex:zT,morphcolor_vertex:kT,morphnormal_vertex:HT,morphtarget_pars_vertex:VT,morphtarget_vertex:GT,normal_fragment_begin:WT,normal_fragment_maps:XT,normal_pars_fragment:qT,normal_pars_vertex:YT,normal_vertex:$T,normalmap_pars_fragment:KT,clearcoat_normal_fragment_begin:ZT,clearcoat_normal_fragment_maps:JT,clearcoat_pars_fragment:jT,iridescence_pars_fragment:QT,opaque_fragment:tE,packing:eE,premultiplied_alpha_fragment:nE,project_vertex:iE,dithering_fragment:rE,dithering_pars_fragment:sE,roughnessmap_fragment:oE,roughnessmap_pars_fragment:aE,shadowmap_pars_fragment:cE,shadowmap_pars_vertex:lE,shadowmap_vertex:uE,shadowmask_pars_fragment:hE,skinbase_vertex:fE,skinning_pars_vertex:dE,skinning_vertex:pE,skinnormal_vertex:mE,specularmap_fragment:gE,specularmap_pars_fragment:xE,tonemapping_fragment:_E,tonemapping_pars_fragment:yE,transmission_fragment:vE,transmission_pars_fragment:ME,uv_pars_fragment:SE,uv_pars_vertex:bE,uv_vertex:TE,worldpos_vertex:EE,background_vert:wE,background_frag:AE,backgroundCube_vert:RE,backgroundCube_frag:CE,cube_vert:IE,cube_frag:PE,depth_vert:LE,depth_frag:NE,distanceRGBA_vert:DE,distanceRGBA_frag:UE,equirect_vert:FE,equirect_frag:OE,linedashed_vert:BE,linedashed_frag:zE,meshbasic_vert:kE,meshbasic_frag:HE,meshlambert_vert:VE,meshlambert_frag:GE,meshmatcap_vert:WE,meshmatcap_frag:XE,meshnormal_vert:qE,meshnormal_frag:YE,meshphong_vert:$E,meshphong_frag:KE,meshphysical_vert:ZE,meshphysical_frag:JE,meshtoon_vert:jE,meshtoon_frag:QE,points_vert:tw,points_frag:ew,shadow_vert:nw,shadow_frag:iw,sprite_vert:rw,sprite_frag:sw},Tt={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new $t}},envmap:{envMap:{value:null},envMapRotation:{value:new $t},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new $t}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new $t}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new $t},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new $t},normalScale:{value:new nt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new $t},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new $t}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new $t}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new $t}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0},uvTransform:{value:new $t}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new $t},alphaMap:{value:null},alphaMapTransform:{value:new $t},alphaTest:{value:0}}},Si={basic:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.fog]),vertexShader:te.meshbasic_vert,fragmentShader:te.meshbasic_frag},lambert:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)}}]),vertexShader:te.meshlambert_vert,fragmentShader:te.meshlambert_frag},phong:{uniforms:hn([Tt.common,Tt.specularmap,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:te.meshphong_vert,fragmentShader:te.meshphong_frag},standard:{uniforms:hn([Tt.common,Tt.envmap,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.roughnessmap,Tt.metalnessmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag},toon:{uniforms:hn([Tt.common,Tt.aomap,Tt.lightmap,Tt.emissivemap,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.gradientmap,Tt.fog,Tt.lights,{emissive:{value:new yt(0)}}]),vertexShader:te.meshtoon_vert,fragmentShader:te.meshtoon_frag},matcap:{uniforms:hn([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,Tt.fog,{matcap:{value:null}}]),vertexShader:te.meshmatcap_vert,fragmentShader:te.meshmatcap_frag},points:{uniforms:hn([Tt.points,Tt.fog]),vertexShader:te.points_vert,fragmentShader:te.points_frag},dashed:{uniforms:hn([Tt.common,Tt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:te.linedashed_vert,fragmentShader:te.linedashed_frag},depth:{uniforms:hn([Tt.common,Tt.displacementmap]),vertexShader:te.depth_vert,fragmentShader:te.depth_frag},normal:{uniforms:hn([Tt.common,Tt.bumpmap,Tt.normalmap,Tt.displacementmap,{opacity:{value:1}}]),vertexShader:te.meshnormal_vert,fragmentShader:te.meshnormal_frag},sprite:{uniforms:hn([Tt.sprite,Tt.fog]),vertexShader:te.sprite_vert,fragmentShader:te.sprite_frag},background:{uniforms:{uvTransform:{value:new $t},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:te.background_vert,fragmentShader:te.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new $t}},vertexShader:te.backgroundCube_vert,fragmentShader:te.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:te.cube_vert,fragmentShader:te.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:te.equirect_vert,fragmentShader:te.equirect_frag},distanceRGBA:{uniforms:hn([Tt.common,Tt.displacementmap,{referencePosition:{value:new I},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:te.distanceRGBA_vert,fragmentShader:te.distanceRGBA_frag},shadow:{uniforms:hn([Tt.lights,Tt.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:te.shadow_vert,fragmentShader:te.shadow_frag}};Si.physical={uniforms:hn([Si.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new $t},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new $t},clearcoatNormalScale:{value:new nt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new $t},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new $t},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new $t},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new $t},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new $t},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new $t},transmissionSamplerSize:{value:new nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new $t},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new $t},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new $t},anisotropyVector:{value:new nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new $t}}]),vertexShader:te.meshphysical_vert,fragmentShader:te.meshphysical_frag};var bf={r:0,b:0,g:0},Ps=new Rn,ow=new vt;function aw(s,t,e,n,i,r,o){let a=new yt(0),c=r===!0?0:1,l,u,h=null,f=0,p=null;function x(g){let d=g.isScene===!0?g.background:null;return d&&d.isTexture&&(d=(g.backgroundBlurriness>0?e:t).get(d)),d}function v(g){let d=!1,M=x(g);M===null?_(a,c):M&&M.isColor&&(_(M,1),d=!0);let m=s.xr.getEnvironmentBlendMode();m==="additive"?n.buffers.color.setClear(0,0,0,1,o):m==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(s.autoClear||d)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function y(g,d){let M=x(d);M&&(M.isCubeTexture||M.mapping===Ts)?(u===void 0&&(u=new ce(new Ui(1,1,1),new Cn({name:"BackgroundCubeMaterial",uniforms:Is(Si.backgroundCube.uniforms),vertexShader:Si.backgroundCube.vertexShader,fragmentShader:Si.backgroundCube.fragmentShader,side:qe,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(m,R,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),Ps.copy(d.backgroundRotation),Ps.x*=-1,Ps.y*=-1,Ps.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(Ps.y*=-1,Ps.z*=-1),u.material.uniforms.envMap.value=M,u.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=d.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(ow.makeRotationFromEuler(Ps)),u.material.toneMapped=ie.getTransfer(M.colorSpace)!==ge,(h!==M||f!==M.version||p!==s.toneMapping)&&(u.material.needsUpdate=!0,h=M,f=M.version,p=s.toneMapping),u.layers.enableAll(),g.unshift(u,u.geometry,u.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new ce(new ys(2,2),new Cn({name:"BackgroundMaterial",uniforms:Is(Si.background.uniforms),vertexShader:Si.background.vertexShader,fragmentShader:Si.background.fragmentShader,side:rn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=d.backgroundIntensity,l.material.toneMapped=ie.getTransfer(M.colorSpace)!==ge,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||f!==M.version||p!==s.toneMapping)&&(l.material.needsUpdate=!0,h=M,f=M.version,p=s.toneMapping),l.layers.enableAll(),g.unshift(l,l.geometry,l.material,0,0,null))}function _(g,d){g.getRGB(bf,mm(s)),n.buffers.color.setClear(bf.r,bf.g,bf.b,d,o)}function S(){u!==void 0&&(u.geometry.dispose(),u.material.dispose(),u=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(g,d=1){a.set(g),c=d,_(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(g){c=g,_(a,c)},render:v,addToRenderList:y,dispose:S}}function cw(s,t){let e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=f(null),r=i,o=!1;function a(b,w,A,C,D){let F=!1,O=h(C,A,w);r!==O&&(r=O,l(r.object)),F=p(b,C,A,D),F&&x(b,C,A,D),D!==null&&t.update(D,s.ELEMENT_ARRAY_BUFFER),(F||o)&&(o=!1,d(b,w,A,C),D!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(D).buffer))}function c(){return s.createVertexArray()}function l(b){return s.bindVertexArray(b)}function u(b){return s.deleteVertexArray(b)}function h(b,w,A){let C=A.wireframe===!0,D=n[b.id];D===void 0&&(D={},n[b.id]=D);let F=D[w.id];F===void 0&&(F={},D[w.id]=F);let O=F[C];return O===void 0&&(O=f(c()),F[C]=O),O}function f(b){let w=[],A=[],C=[];for(let D=0;D<e;D++)w[D]=0,A[D]=0,C[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:w,enabledAttributes:A,attributeDivisors:C,object:b,attributes:{},index:null}}function p(b,w,A,C){let D=r.attributes,F=w.attributes,O=0,H=A.getAttributes();for(let B in H)if(H[B].location>=0){let at=D[B],rt=F[B];if(rt===void 0&&(B==="instanceMatrix"&&b.instanceMatrix&&(rt=b.instanceMatrix),B==="instanceColor"&&b.instanceColor&&(rt=b.instanceColor)),at===void 0||at.attribute!==rt||rt&&at.data!==rt.data)return!0;O++}return r.attributesNum!==O||r.index!==C}function x(b,w,A,C){let D={},F=w.attributes,O=0,H=A.getAttributes();for(let B in H)if(H[B].location>=0){let at=F[B];at===void 0&&(B==="instanceMatrix"&&b.instanceMatrix&&(at=b.instanceMatrix),B==="instanceColor"&&b.instanceColor&&(at=b.instanceColor));let rt={};rt.attribute=at,at&&at.data&&(rt.data=at.data),D[B]=rt,O++}r.attributes=D,r.attributesNum=O,r.index=C}function v(){let b=r.newAttributes;for(let w=0,A=b.length;w<A;w++)b[w]=0}function y(b){_(b,0)}function _(b,w){let A=r.newAttributes,C=r.enabledAttributes,D=r.attributeDivisors;A[b]=1,C[b]===0&&(s.enableVertexAttribArray(b),C[b]=1),D[b]!==w&&(s.vertexAttribDivisor(b,w),D[b]=w)}function S(){let b=r.newAttributes,w=r.enabledAttributes;for(let A=0,C=w.length;A<C;A++)w[A]!==b[A]&&(s.disableVertexAttribArray(A),w[A]=0)}function g(b,w,A,C,D,F,O){O===!0?s.vertexAttribIPointer(b,w,A,D,F):s.vertexAttribPointer(b,w,A,C,D,F)}function d(b,w,A,C){v();let D=C.attributes,F=A.getAttributes(),O=w.defaultAttributeValues;for(let H in F){let B=F[H];if(B.location>=0){let $=D[H];if($===void 0&&(H==="instanceMatrix"&&b.instanceMatrix&&($=b.instanceMatrix),H==="instanceColor"&&b.instanceColor&&($=b.instanceColor)),$!==void 0){let at=$.normalized,rt=$.itemSize,ht=t.get($);if(ht===void 0)continue;let bt=ht.buffer,Et=ht.type,Mt=ht.bytesPerElement,K=Et===s.INT||Et===s.UNSIGNED_INT||$.gpuType===rl;if($.isInterleavedBufferAttribute){let Q=$.data,ct=Q.stride,lt=$.offset;if(Q.isInstancedInterleavedBuffer){for(let ut=0;ut<B.locationSize;ut++)_(B.location+ut,Q.meshPerAttribute);b.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=Q.meshPerAttribute*Q.count)}else for(let ut=0;ut<B.locationSize;ut++)y(B.location+ut);s.bindBuffer(s.ARRAY_BUFFER,bt);for(let ut=0;ut<B.locationSize;ut++)g(B.location+ut,rt/B.locationSize,Et,at,ct*Mt,(lt+rt/B.locationSize*ut)*Mt,K)}else{if($.isInstancedBufferAttribute){for(let Q=0;Q<B.locationSize;Q++)_(B.location+Q,$.meshPerAttribute);b.isInstancedMesh!==!0&&C._maxInstanceCount===void 0&&(C._maxInstanceCount=$.meshPerAttribute*$.count)}else for(let Q=0;Q<B.locationSize;Q++)y(B.location+Q);s.bindBuffer(s.ARRAY_BUFFER,bt);for(let Q=0;Q<B.locationSize;Q++)g(B.location+Q,rt/B.locationSize,Et,at,rt*Mt,rt/B.locationSize*Q*Mt,K)}}else if(O!==void 0){let at=O[H];if(at!==void 0)switch(at.length){case 2:s.vertexAttrib2fv(B.location,at);break;case 3:s.vertexAttrib3fv(B.location,at);break;case 4:s.vertexAttrib4fv(B.location,at);break;default:s.vertexAttrib1fv(B.location,at)}}}}S()}function M(){E();for(let b in n){let w=n[b];for(let A in w){let C=w[A];for(let D in C)u(C[D].object),delete C[D];delete w[A]}delete n[b]}}function m(b){if(n[b.id]===void 0)return;let w=n[b.id];for(let A in w){let C=w[A];for(let D in C)u(C[D].object),delete C[D];delete w[A]}delete n[b.id]}function R(b){for(let w in n){let A=n[w];if(A[b.id]===void 0)continue;let C=A[b.id];for(let D in C)u(C[D].object),delete C[D];delete A[b.id]}}function E(){T(),o=!0,r!==i&&(r=i,l(r.object))}function T(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:a,reset:E,resetDefaultState:T,dispose:M,releaseStatesOfGeometry:m,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:y,disableUnusedAttributes:S}}function lw(s,t,e){let n;function i(l){n=l}function r(l,u){s.drawArrays(n,l,u),e.update(u,n,1)}function o(l,u,h){h!==0&&(s.drawArraysInstanced(n,l,u,h),e.update(u,n,h))}function a(l,u,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let p=0;for(let x=0;x<h;x++)p+=u[x];e.update(p,n,1)}function c(l,u,h,f){if(h===0)return;let p=t.get("WEBGL_multi_draw");if(p===null)for(let x=0;x<l.length;x++)o(l[x],u[x],f[x]);else{p.multiDrawArraysInstancedWEBGL(n,l,0,u,0,f,0,h);let x=0;for(let v=0;v<h;v++)x+=u[v]*f[v];e.update(x,n,1)}}this.setMode=i,this.render=r,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function uw(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){let R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(R){return!(R!==Qe&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(R){let E=R===ws&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==ri&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==xn&&!E)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=e.logarithmicDepthBuffer===!0,f=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control"),p=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),x=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),y=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),_=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),g=s.getParameter(s.MAX_VARYING_VECTORS),d=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),M=x>0,m=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reversedDepthBuffer:f,maxTextures:p,maxVertexTextures:x,maxTextureSize:v,maxCubemapSize:y,maxAttributes:_,maxVertexUniforms:S,maxVaryings:g,maxFragmentUniforms:d,vertexTextures:M,maxSamples:m}}function hw(s){let t=this,e=null,n=0,i=!1,r=!1,o=new $e,a=new $t,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let p=h.length!==0||f||n!==0||i;return i=f,n=h.length,p},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(h,f){e=u(h,f,0)},this.setState=function(h,f,p){let x=h.clippingPlanes,v=h.clipIntersection,y=h.clipShadows,_=s.get(h);if(!i||x===null||x.length===0||r&&!y)r?u(null):l();else{let S=r?0:n,g=S*4,d=_.clippingState||null;c.value=d,d=u(x,f,g,p);for(let M=0;M!==g;++M)d[M]=e[M];_.clippingState=d,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function u(h,f,p,x){let v=h!==null?h.length:0,y=null;if(v!==0){if(y=c.value,x!==!0||y===null){let _=p+v*4,S=f.matrixWorldInverse;a.getNormalMatrix(S),(y===null||y.length<_)&&(y=new Float32Array(_));for(let g=0,d=p;g!==v;++g,d+=4)o.copy(h[g]).applyMatrix4(S,a),o.normal.toArray(y,d),y[d+3]=o.constant}c.value=y,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,y}}function fw(s){let t=new WeakMap;function e(o,a){return a===Yo?o.mapping=Wi:a===$o&&(o.mapping=ur),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===Yo||a===$o)if(t.has(o)){let c=t.get(o).texture;return e(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Ja(c.height);return l.fromEquirectangularTexture(s,o),t.set(o,l),o.addEventListener("dispose",i),e(l.texture,o.mapping)}else return null}}return o}function i(o){let a=o.target;a.removeEventListener("dispose",i);let c=t.get(a);c!==void 0&&(t.delete(a),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var na=4,F0=[.125,.215,.35,.446,.526,.582],Ds=20,Sm=new cr,O0=new yt,bm=null,Tm=0,Em=0,wm=!1,Ns=(1+Math.sqrt(5))/2,ea=1/Ns,B0=[new I(-Ns,ea,0),new I(Ns,ea,0),new I(-ea,0,Ns),new I(ea,0,Ns),new I(0,Ns,-ea),new I(0,Ns,ea),new I(-1,1,-1),new I(1,1,-1),new I(-1,1,1),new I(1,1,1)],dw=new I,kl=class{constructor(t){this._renderer=t,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(t,e=0,n=.1,i=100,r={}){let{size:o=256,position:a=dw}=r;bm=this._renderer.getRenderTarget(),Tm=this._renderer.getActiveCubeFace(),Em=this._renderer.getActiveMipmapLevel(),wm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(o);let c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,a),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=H0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=k0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(bm,Tm,Em),this._renderer.xr.enabled=wm,t.scissorTest=!1,Tf(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Wi||t.mapping===ur?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),bm=this._renderer.getRenderTarget(),Tm=this._renderer.getActiveCubeFace(),Em=this._renderer.getActiveMipmapLevel(),wm=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:Ee,minFilter:Ee,generateMipmaps:!1,type:ws,format:Qe,colorSpace:tn,depthBuffer:!1},i=z0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=z0(t,e,n);let{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=pw(r)),this._blurMaterial=mw(r,t,e)}return i}_compileMaterial(t){let e=new ce(this._lodPlanes[0],t);this._renderer.compile(e,Sm)}_sceneToCubeUV(t,e,n,i,r){let c=new Re(90,1,e,n),l=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],h=this._renderer,f=h.autoClear,p=h.toneMapping;h.getClearColor(O0),h.toneMapping=Gi,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null));let v=new sn({name:"PMREM.Background",side:qe,depthWrite:!1,depthTest:!1}),y=new ce(new Ui,v),_=!1,S=t.background;S?S.isColor&&(v.color.copy(S),t.background=null,_=!0):(v.color.copy(O0),_=!0);for(let g=0;g<6;g++){let d=g%3;d===0?(c.up.set(0,l[g],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+u[g],r.y,r.z)):d===1?(c.up.set(0,0,l[g]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+u[g],r.z)):(c.up.set(0,l[g],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+u[g]));let M=this._cubeSize;Tf(i,d*M,g>2?M:0,M,M),h.setRenderTarget(i),_&&h.render(y,c),h.render(t,c)}y.geometry.dispose(),y.material.dispose(),h.toneMapping=p,h.autoClear=f,t.background=S}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===Wi||t.mapping===ur;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=H0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=k0());let r=i?this._cubemapMaterial:this._equirectMaterial,o=new ce(this._lodPlanes[0],r),a=r.uniforms;a.envMap.value=t;let c=this._cubeSize;Tf(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(o,Sm)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodPlanes.length;for(let r=1;r<i;r++){let o=Math.sqrt(this._sigmas[r]*this._sigmas[r]-this._sigmas[r-1]*this._sigmas[r-1]),a=B0[(i-r-1)%B0.length];this._blur(t,r-1,r,o,a)}e.autoClear=n}_blur(t,e,n,i,r){let o=this._pingPongRenderTarget;this._halfBlur(t,o,e,n,i,"latitudinal",r),this._halfBlur(o,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ce(this._lodPlanes[i],l),f=l.uniforms,p=this._sizeLods[n]-1,x=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Ds-1),v=r/x,y=isFinite(r)?1+Math.floor(u*v):Ds;y>Ds&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${y} samples when the maximum is set to ${Ds}`);let _=[],S=0;for(let R=0;R<Ds;++R){let E=R/v,T=Math.exp(-E*E/2);_.push(T),R===0?S+=T:R<y&&(S+=2*T)}for(let R=0;R<_.length;R++)_[R]=_[R]/S;f.envMap.value=t.texture,f.samples.value=y,f.weights.value=_,f.latitudinal.value=o==="latitudinal",a&&(f.poleAxis.value=a);let{_lodMax:g}=this;f.dTheta.value=x,f.mipInt.value=g-n;let d=this._sizeLods[i],M=3*d*(i>g-na?i-g+na:0),m=4*(this._cubeSize-d);Tf(e,M,m,3*d,2*d),c.setRenderTarget(e),c.render(h,Sm)}};function pw(s){let t=[],e=[],n=[],i=s,r=s-na+1+F0.length;for(let o=0;o<r;o++){let a=Math.pow(2,i);e.push(a);let c=1/a;o>s-na?c=F0[o-s+na-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),u=-l,h=1+l,f=[u,u,h,u,h,h,u,u,h,h,u,h],p=6,x=6,v=3,y=2,_=1,S=new Float32Array(v*x*p),g=new Float32Array(y*x*p),d=new Float32Array(_*x*p);for(let m=0;m<p;m++){let R=m%3*2/3-1,E=m>2?0:-1,T=[R,E,0,R+2/3,E,0,R+2/3,E+1,0,R,E,0,R+2/3,E+1,0,R,E+1,0];S.set(T,v*x*m),g.set(f,y*x*m);let b=[m,m,m,m,m,m];d.set(b,_*x*m)}let M=new Vt;M.setAttribute("position",new kt(S,v)),M.setAttribute("uv",new kt(g,y)),M.setAttribute("faceIndex",new kt(d,_)),t.push(M),i>na&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function z0(s,t,e){let n=new Hn(s,t,e);return n.texture.mapping=Ts,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Tf(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function mw(s,t,e){let n=new Float32Array(Ds),i=new I(0,1,0);return new Cn({name:"SphericalGaussianBlur",defines:{n:Ds,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Fm(),fragmentShader:`
|
|
3580
3580
|
|
|
3581
3581
|
precision mediump float;
|
|
3582
3582
|
precision mediump int;
|
|
@@ -3636,7 +3636,7 @@ void main() {
|
|
|
3636
3636
|
}
|
|
3637
3637
|
|
|
3638
3638
|
}
|
|
3639
|
-
`,blending:Vi,depthTest:!1,depthWrite:!1})}function k0(){return new Cn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:
|
|
3639
|
+
`,blending:Vi,depthTest:!1,depthWrite:!1})}function k0(){return new Cn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Fm(),fragmentShader:`
|
|
3640
3640
|
|
|
3641
3641
|
precision mediump float;
|
|
3642
3642
|
precision mediump int;
|
|
@@ -3655,7 +3655,7 @@ void main() {
|
|
|
3655
3655
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
3656
3656
|
|
|
3657
3657
|
}
|
|
3658
|
-
`,blending:Vi,depthTest:!1,depthWrite:!1})}function H0(){return new Cn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:
|
|
3658
|
+
`,blending:Vi,depthTest:!1,depthWrite:!1})}function H0(){return new Cn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Fm(),fragmentShader:`
|
|
3659
3659
|
|
|
3660
3660
|
precision mediump float;
|
|
3661
3661
|
precision mediump int;
|
|
@@ -3671,7 +3671,7 @@ void main() {
|
|
|
3671
3671
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
3672
3672
|
|
|
3673
3673
|
}
|
|
3674
|
-
`,blending:Vi,depthTest:!1,depthWrite:!1})}function
|
|
3674
|
+
`,blending:Vi,depthTest:!1,depthWrite:!1})}function Fm(){return`
|
|
3675
3675
|
|
|
3676
3676
|
precision mediump float;
|
|
3677
3677
|
precision mediump int;
|
|
@@ -3726,17 +3726,17 @@ void main() {
|
|
|
3726
3726
|
gl_Position = vec4( position, 1.0 );
|
|
3727
3727
|
|
|
3728
3728
|
}
|
|
3729
|
-
`}function gw(s){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===Yo||c===$o,u=c===Wi||c===ur;if(l||u){let h=t.get(a),f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return e===null&&(e=new kl(s)),h=l?e.fromEquirectangular(a,h):e.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),h.texture;if(h!==void 0)return h.texture;{let p=a.image;return l&&p&&p.height>0||u&&p&&i(p)?(e===null&&(e=new kl(s)),h=l?e.fromEquirectangular(a):e.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function i(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function r(a){let c=a.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function xw(s){let t={};function e(n){if(t[n]!==void 0)return t[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let i=e(n);return i===null&&vo("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function _w(s,t,e,n){let i={},r=new WeakMap;function o(h){let f=h.target;f.index!==null&&t.remove(f.index);for(let x in f.attributes)t.remove(f.attributes[x]);f.removeEventListener("dispose",o),delete i[f.id];let p=r.get(f);p&&(t.remove(p),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function a(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,e.memory.geometries++),f}function c(h){let f=h.attributes;for(let p in f)t.update(f[p],s.ARRAY_BUFFER)}function l(h){let f=[],p=h.index,x=h.attributes.position,v=0;if(p!==null){let S=p.array;v=p.version;for(let g=0,d=S.length;g<d;g+=3){let M=S[g+0],m=S[g+1],R=S[g+2];f.push(M,m,m,R,R,M)}}else if(x!==void 0){let S=x.array;v=x.version;for(let g=0,d=S.length/3-1;g<d;g+=3){let M=g+0,m=g+1,R=g+2;f.push(M,m,m,R,R,M)}}else return;let y=new(fm(f)?bo:So)(f,1);y.version=v;let _=r.get(h);_&&t.remove(_),r.set(h,y)}function u(h){let f=r.get(h);if(f){let p=h.index;p!==null&&f.version<p.version&&l(h)}else l(h);return r.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function yw(s,t,e){let n;function i(f){n=f}let r,o;function a(f){r=f.type,o=f.bytesPerElement}function c(f,p){s.drawElements(n,p,r,f*o),e.update(p,n,1)}function l(f,p,x){x!==0&&(s.drawElementsInstanced(n,p,r,f*o,x),e.update(p,n,x))}function u(f,p,x){if(x===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,f,0,x);let y=0;for(let _=0;_<x;_++)y+=p[_];e.update(y,n,1)}function h(f,p,x,v){if(x===0)return;let y=t.get("WEBGL_multi_draw");if(y===null)for(let _=0;_<f.length;_++)l(f[_]/o,p[_],v[_]);else{y.multiDrawElementsInstancedWEBGL(n,p,0,r,f,0,v,0,x);let _=0;for(let S=0;S<x;S++)_+=p[S]*v[S];e.update(_,n,1)}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function vw(s){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(e.calls++,o){case s.TRIANGLES:e.triangles+=a*(r/3);break;case s.LINES:e.lines+=a*(r/2);break;case s.LINE_STRIP:e.lines+=a*(r-1);break;case s.LINE_LOOP:e.lines+=a*r;break;case s.POINTS:e.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function Mw(s,t,e){let n=new WeakMap,i=new Qt;function r(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,f=n.get(a);if(f===void 0||f.count!==h){let T=function(){R.dispose(),n.delete(a),a.removeEventListener("dispose",T)};f!==void 0&&f.texture.dispose();let p=a.morphAttributes.position!==void 0,x=a.morphAttributes.normal!==void 0,v=a.morphAttributes.color!==void 0,y=a.morphAttributes.position||[],_=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],g=0;p===!0&&(g=1),x===!0&&(g=2),v===!0&&(g=3);let d=a.attributes.position.count*g,M=1;d>t.maxTextureSize&&(M=Math.ceil(d/t.maxTextureSize),d=t.maxTextureSize);let m=new Float32Array(d*M*4*h),R=new cs(m,d,M,h);R.type=xn,R.needsUpdate=!0;let E=g*4;for(let b=0;b<h;b++){let w=y[b],A=_[b],C=S[b],D=d*M*4*b;for(let F=0;F<w.count;F++){let O=F*E;p===!0&&(i.fromBufferAttribute(w,F),m[D+O+0]=i.x,m[D+O+1]=i.y,m[D+O+2]=i.z,m[D+O+3]=0),x===!0&&(i.fromBufferAttribute(A,F),m[D+O+4]=i.x,m[D+O+5]=i.y,m[D+O+6]=i.z,m[D+O+7]=0),v===!0&&(i.fromBufferAttribute(C,F),m[D+O+8]=i.x,m[D+O+9]=i.y,m[D+O+10]=i.z,m[D+O+11]=C.itemSize===4?i.w:1)}}f={count:h,texture:R,size:new nt(d,M)},n.set(a,f),a.addEventListener("dispose",T)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,e);else{let p=0;for(let v=0;v<l.length;v++)p+=l[v];let x=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(s,"morphTargetBaseInfluence",x),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(s,"morphTargetsTextureSize",f.size)}return{update:r}}function Sw(s,t,e,n){let i=new WeakMap;function r(c){let l=n.render.frame,u=c.geometry,h=t.get(c,u);if(i.get(h)!==l&&(t.update(h),i.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(e.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){let f=c.skeleton;i.get(f)!==l&&(f.update(),i.set(f,l))}return h}function o(){i=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:r,dispose:o}}var oy=new Ie,V0=new wo(1,1),ay=new cs,cy=new ls,ly=new Rr,G0=[],W0=[],X0=new Float32Array(16),q0=new Float32Array(9),Y0=new Float32Array(4);function ra(s,t,e){let n=s[0];if(n<=0||n>0)return s;let i=t*e,r=G0[i];if(r===void 0&&(r=new Float32Array(i),G0[i]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,s[o].toArray(r,a)}return r}function Ze(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function Je(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function wf(s,t){let e=W0[t];e===void 0&&(e=new Int32Array(t),W0[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function bw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function Tw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2fv(this.addr,t),Je(e,t)}}function Ew(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Ze(e,t))return;s.uniform3fv(this.addr,t),Je(e,t)}}function ww(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4fv(this.addr,t),Je(e,t)}}function Aw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;Y0.set(n),s.uniformMatrix2fv(this.addr,!1,Y0),Je(e,n)}}function Rw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;q0.set(n),s.uniformMatrix3fv(this.addr,!1,q0),Je(e,n)}}function Cw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;X0.set(n),s.uniformMatrix4fv(this.addr,!1,X0),Je(e,n)}}function Iw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function Pw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2iv(this.addr,t),Je(e,t)}}function Lw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ze(e,t))return;s.uniform3iv(this.addr,t),Je(e,t)}}function Nw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4iv(this.addr,t),Je(e,t)}}function Dw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function Uw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2uiv(this.addr,t),Je(e,t)}}function Fw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ze(e,t))return;s.uniform3uiv(this.addr,t),Je(e,t)}}function Ow(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4uiv(this.addr,t),Je(e,t)}}function Bw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(V0.compareFunction=vf,r=V0):r=oy,e.setTexture2D(t||r,i)}function zw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||cy,i)}function kw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||ly,i)}function Hw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||ay,i)}function Vw(s){switch(s){case 5126:return bw;case 35664:return Tw;case 35665:return Ew;case 35666:return ww;case 35674:return Aw;case 35675:return Rw;case 35676:return Cw;case 5124:case 35670:return Iw;case 35667:case 35671:return Pw;case 35668:case 35672:return Lw;case 35669:case 35673:return Nw;case 5125:return Dw;case 36294:return Uw;case 36295:return Fw;case 36296:return Ow;case 35678:case 36198:case 36298:case 36306:case 35682:return Bw;case 35679:case 36299:case 36307:return zw;case 35680:case 36300:case 36308:case 36293:return kw;case 36289:case 36303:case 36311:case 36292:return Hw}}function Gw(s,t){s.uniform1fv(this.addr,t)}function Ww(s,t){let e=ra(t,this.size,2);s.uniform2fv(this.addr,e)}function Xw(s,t){let e=ra(t,this.size,3);s.uniform3fv(this.addr,e)}function qw(s,t){let e=ra(t,this.size,4);s.uniform4fv(this.addr,e)}function Yw(s,t){let e=ra(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function $w(s,t){let e=ra(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function Kw(s,t){let e=ra(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function Zw(s,t){s.uniform1iv(this.addr,t)}function Jw(s,t){s.uniform2iv(this.addr,t)}function jw(s,t){s.uniform3iv(this.addr,t)}function Qw(s,t){s.uniform4iv(this.addr,t)}function tA(s,t){s.uniform1uiv(this.addr,t)}function eA(s,t){s.uniform2uiv(this.addr,t)}function nA(s,t){s.uniform3uiv(this.addr,t)}function iA(s,t){s.uniform4uiv(this.addr,t)}function rA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture2D(t[o]||oy,r[o])}function sA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture3D(t[o]||cy,r[o])}function oA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTextureCube(t[o]||ly,r[o])}function aA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture2DArray(t[o]||ay,r[o])}function cA(s){switch(s){case 5126:return Gw;case 35664:return Ww;case 35665:return Xw;case 35666:return qw;case 35674:return Yw;case 35675:return $w;case 35676:return Kw;case 5124:case 35670:return Zw;case 35667:case 35671:return Jw;case 35668:case 35672:return jw;case 35669:case 35673:return Qw;case 5125:return tA;case 36294:return eA;case 36295:return nA;case 36296:return iA;case 35678:case 36198:case 36298:case 36306:case 35682:return rA;case 35679:case 36299:case 36307:return sA;case 35680:case 36300:case 36308:case 36293:return oA;case 36289:case 36303:case 36311:case 36292:return aA}}var Am=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Vw(e.type)}},Rm=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=cA(e.type)}},Cm=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let r=0,o=i.length;r!==o;++r){let a=i[r];a.setValue(t,e[a.id],n)}}},wm=/(\w+)(\])?(\[|\.)?/g;function $0(s,t){s.seq.push(t),s.map[t.id]=t}function lA(s,t,e){let n=s.name,i=n.length;for(wm.lastIndex=0;;){let r=wm.exec(n),o=wm.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){$0(e,l===void 0?new Am(a,s,t):new Rm(a,s,t));break}else{let h=e.map[a];h===void 0&&(h=new Cm(a),$0(e,h)),e=h}}}var ia=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let r=t.getActiveUniform(e,i),o=t.getUniformLocation(e,r.name);lA(r,o,this)}}setValue(t,e,n,i){let r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,o=e.length;r!==o;++r){let a=e[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,r=t.length;i!==r;++i){let o=t[i];o.id in e&&n.push(o)}return n}};function K0(s,t,e){let n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}var uA=37297,hA=0;function fA(s,t){let e=s.split(`
|
|
3729
|
+
`}function gw(s){let t=new WeakMap,e=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===Yo||c===$o,u=c===Wi||c===ur;if(l||u){let h=t.get(a),f=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==f)return e===null&&(e=new kl(s)),h=l?e.fromEquirectangular(a,h):e.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),h.texture;if(h!==void 0)return h.texture;{let p=a.image;return l&&p&&p.height>0||u&&p&&i(p)?(e===null&&(e=new kl(s)),h=l?e.fromEquirectangular(a):e.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,t.set(a,h),a.addEventListener("dispose",r),h.texture):null}}}return a}function i(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function r(a){let c=a.target;c.removeEventListener("dispose",r);let l=t.get(c);l!==void 0&&(t.delete(c),l.dispose())}function o(){t=new WeakMap,e!==null&&(e.dispose(),e=null)}return{get:n,dispose:o}}function xw(s){let t={};function e(n){if(t[n]!==void 0)return t[n];let i;switch(n){case"WEBGL_depth_texture":i=s.getExtension("WEBGL_depth_texture")||s.getExtension("MOZ_WEBGL_depth_texture")||s.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=s.getExtension("WEBGL_compressed_texture_s3tc")||s.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=s.getExtension("WEBGL_compressed_texture_pvrtc")||s.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=s.getExtension(n)}return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){let i=e(n);return i===null&&vo("THREE.WebGLRenderer: "+n+" extension not supported."),i}}}function _w(s,t,e,n){let i={},r=new WeakMap;function o(h){let f=h.target;f.index!==null&&t.remove(f.index);for(let x in f.attributes)t.remove(f.attributes[x]);f.removeEventListener("dispose",o),delete i[f.id];let p=r.get(f);p&&(t.remove(p),r.delete(f)),n.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,e.memory.geometries--}function a(h,f){return i[f.id]===!0||(f.addEventListener("dispose",o),i[f.id]=!0,e.memory.geometries++),f}function c(h){let f=h.attributes;for(let p in f)t.update(f[p],s.ARRAY_BUFFER)}function l(h){let f=[],p=h.index,x=h.attributes.position,v=0;if(p!==null){let S=p.array;v=p.version;for(let g=0,d=S.length;g<d;g+=3){let M=S[g+0],m=S[g+1],R=S[g+2];f.push(M,m,m,R,R,M)}}else if(x!==void 0){let S=x.array;v=x.version;for(let g=0,d=S.length/3-1;g<d;g+=3){let M=g+0,m=g+1,R=g+2;f.push(M,m,m,R,R,M)}}else return;let y=new(dm(f)?bo:So)(f,1);y.version=v;let _=r.get(h);_&&t.remove(_),r.set(h,y)}function u(h){let f=r.get(h);if(f){let p=h.index;p!==null&&f.version<p.version&&l(h)}else l(h);return r.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function yw(s,t,e){let n;function i(f){n=f}let r,o;function a(f){r=f.type,o=f.bytesPerElement}function c(f,p){s.drawElements(n,p,r,f*o),e.update(p,n,1)}function l(f,p,x){x!==0&&(s.drawElementsInstanced(n,p,r,f*o,x),e.update(p,n,x))}function u(f,p,x){if(x===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,p,0,r,f,0,x);let y=0;for(let _=0;_<x;_++)y+=p[_];e.update(y,n,1)}function h(f,p,x,v){if(x===0)return;let y=t.get("WEBGL_multi_draw");if(y===null)for(let _=0;_<f.length;_++)l(f[_]/o,p[_],v[_]);else{y.multiDrawElementsInstancedWEBGL(n,p,0,r,f,0,v,0,x);let _=0;for(let S=0;S<x;S++)_+=p[S]*v[S];e.update(_,n,1)}}this.setMode=i,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function vw(s){let t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,o,a){switch(e.calls++,o){case s.TRIANGLES:e.triangles+=a*(r/3);break;case s.LINES:e.lines+=a*(r/2);break;case s.LINE_STRIP:e.lines+=a*(r-1);break;case s.LINE_LOOP:e.lines+=a*r;break;case s.POINTS:e.points+=a*r;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function Mw(s,t,e){let n=new WeakMap,i=new Qt;function r(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,f=n.get(a);if(f===void 0||f.count!==h){let T=function(){R.dispose(),n.delete(a),a.removeEventListener("dispose",T)};f!==void 0&&f.texture.dispose();let p=a.morphAttributes.position!==void 0,x=a.morphAttributes.normal!==void 0,v=a.morphAttributes.color!==void 0,y=a.morphAttributes.position||[],_=a.morphAttributes.normal||[],S=a.morphAttributes.color||[],g=0;p===!0&&(g=1),x===!0&&(g=2),v===!0&&(g=3);let d=a.attributes.position.count*g,M=1;d>t.maxTextureSize&&(M=Math.ceil(d/t.maxTextureSize),d=t.maxTextureSize);let m=new Float32Array(d*M*4*h),R=new cs(m,d,M,h);R.type=xn,R.needsUpdate=!0;let E=g*4;for(let b=0;b<h;b++){let w=y[b],A=_[b],C=S[b],D=d*M*4*b;for(let F=0;F<w.count;F++){let O=F*E;p===!0&&(i.fromBufferAttribute(w,F),m[D+O+0]=i.x,m[D+O+1]=i.y,m[D+O+2]=i.z,m[D+O+3]=0),x===!0&&(i.fromBufferAttribute(A,F),m[D+O+4]=i.x,m[D+O+5]=i.y,m[D+O+6]=i.z,m[D+O+7]=0),v===!0&&(i.fromBufferAttribute(C,F),m[D+O+8]=i.x,m[D+O+9]=i.y,m[D+O+10]=i.z,m[D+O+11]=C.itemSize===4?i.w:1)}}f={count:h,texture:R,size:new nt(d,M)},n.set(a,f),a.addEventListener("dispose",T)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",o.morphTexture,e);else{let p=0;for(let v=0;v<l.length;v++)p+=l[v];let x=a.morphTargetsRelative?1:1-p;c.getUniforms().setValue(s,"morphTargetBaseInfluence",x),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",f.texture,e),c.getUniforms().setValue(s,"morphTargetsTextureSize",f.size)}return{update:r}}function Sw(s,t,e,n){let i=new WeakMap;function r(c){let l=n.render.frame,u=c.geometry,h=t.get(c,u);if(i.get(h)!==l&&(t.update(h),i.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),i.get(c)!==l&&(e.update(c.instanceMatrix,s.ARRAY_BUFFER),c.instanceColor!==null&&e.update(c.instanceColor,s.ARRAY_BUFFER),i.set(c,l))),c.isSkinnedMesh){let f=c.skeleton;i.get(f)!==l&&(f.update(),i.set(f,l))}return h}function o(){i=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),e.remove(l.instanceMatrix),l.instanceColor!==null&&e.remove(l.instanceColor)}return{update:r,dispose:o}}var oy=new Ie,V0=new wo(1,1),ay=new cs,cy=new ls,ly=new Rr,G0=[],W0=[],X0=new Float32Array(16),q0=new Float32Array(9),Y0=new Float32Array(4);function ra(s,t,e){let n=s[0];if(n<=0||n>0)return s;let i=t*e,r=G0[i];if(r===void 0&&(r=new Float32Array(i),G0[i]=r),t!==0){n.toArray(r,0);for(let o=1,a=0;o!==t;++o)a+=e,s[o].toArray(r,a)}return r}function Ze(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function Je(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function wf(s,t){let e=W0[t];e===void 0&&(e=new Int32Array(t),W0[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function bw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function Tw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2fv(this.addr,t),Je(e,t)}}function Ew(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Ze(e,t))return;s.uniform3fv(this.addr,t),Je(e,t)}}function ww(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4fv(this.addr,t),Je(e,t)}}function Aw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;Y0.set(n),s.uniformMatrix2fv(this.addr,!1,Y0),Je(e,n)}}function Rw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;q0.set(n),s.uniformMatrix3fv(this.addr,!1,q0),Je(e,n)}}function Cw(s,t){let e=this.cache,n=t.elements;if(n===void 0){if(Ze(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),Je(e,t)}else{if(Ze(e,n))return;X0.set(n),s.uniformMatrix4fv(this.addr,!1,X0),Je(e,n)}}function Iw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function Pw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2iv(this.addr,t),Je(e,t)}}function Lw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ze(e,t))return;s.uniform3iv(this.addr,t),Je(e,t)}}function Nw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4iv(this.addr,t),Je(e,t)}}function Dw(s,t){let e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function Uw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Ze(e,t))return;s.uniform2uiv(this.addr,t),Je(e,t)}}function Fw(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Ze(e,t))return;s.uniform3uiv(this.addr,t),Je(e,t)}}function Ow(s,t){let e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Ze(e,t))return;s.uniform4uiv(this.addr,t),Je(e,t)}}function Bw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(V0.compareFunction=vf,r=V0):r=oy,e.setTexture2D(t||r,i)}function zw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||cy,i)}function kw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||ly,i)}function Hw(s,t,e){let n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||ay,i)}function Vw(s){switch(s){case 5126:return bw;case 35664:return Tw;case 35665:return Ew;case 35666:return ww;case 35674:return Aw;case 35675:return Rw;case 35676:return Cw;case 5124:case 35670:return Iw;case 35667:case 35671:return Pw;case 35668:case 35672:return Lw;case 35669:case 35673:return Nw;case 5125:return Dw;case 36294:return Uw;case 36295:return Fw;case 36296:return Ow;case 35678:case 36198:case 36298:case 36306:case 35682:return Bw;case 35679:case 36299:case 36307:return zw;case 35680:case 36300:case 36308:case 36293:return kw;case 36289:case 36303:case 36311:case 36292:return Hw}}function Gw(s,t){s.uniform1fv(this.addr,t)}function Ww(s,t){let e=ra(t,this.size,2);s.uniform2fv(this.addr,e)}function Xw(s,t){let e=ra(t,this.size,3);s.uniform3fv(this.addr,e)}function qw(s,t){let e=ra(t,this.size,4);s.uniform4fv(this.addr,e)}function Yw(s,t){let e=ra(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function $w(s,t){let e=ra(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function Kw(s,t){let e=ra(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function Zw(s,t){s.uniform1iv(this.addr,t)}function Jw(s,t){s.uniform2iv(this.addr,t)}function jw(s,t){s.uniform3iv(this.addr,t)}function Qw(s,t){s.uniform4iv(this.addr,t)}function tA(s,t){s.uniform1uiv(this.addr,t)}function eA(s,t){s.uniform2uiv(this.addr,t)}function nA(s,t){s.uniform3uiv(this.addr,t)}function iA(s,t){s.uniform4uiv(this.addr,t)}function rA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture2D(t[o]||oy,r[o])}function sA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture3D(t[o]||cy,r[o])}function oA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTextureCube(t[o]||ly,r[o])}function aA(s,t,e){let n=this.cache,i=t.length,r=wf(e,i);Ze(n,r)||(s.uniform1iv(this.addr,r),Je(n,r));for(let o=0;o!==i;++o)e.setTexture2DArray(t[o]||ay,r[o])}function cA(s){switch(s){case 5126:return Gw;case 35664:return Ww;case 35665:return Xw;case 35666:return qw;case 35674:return Yw;case 35675:return $w;case 35676:return Kw;case 5124:case 35670:return Zw;case 35667:case 35671:return Jw;case 35668:case 35672:return jw;case 35669:case 35673:return Qw;case 5125:return tA;case 36294:return eA;case 36295:return nA;case 36296:return iA;case 35678:case 36198:case 36298:case 36306:case 35682:return rA;case 35679:case 36299:case 36307:return sA;case 35680:case 36300:case 36308:case 36293:return oA;case 36289:case 36303:case 36311:case 36292:return aA}}var Rm=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=Vw(e.type)}},Cm=class{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=cA(e.type)}},Im=class{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){let i=this.seq;for(let r=0,o=i.length;r!==o;++r){let a=i[r];a.setValue(t,e[a.id],n)}}},Am=/(\w+)(\])?(\[|\.)?/g;function $0(s,t){s.seq.push(t),s.map[t.id]=t}function lA(s,t,e){let n=s.name,i=n.length;for(Am.lastIndex=0;;){let r=Am.exec(n),o=Am.lastIndex,a=r[1],c=r[2]==="]",l=r[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===i){$0(e,l===void 0?new Rm(a,s,t):new Cm(a,s,t));break}else{let h=e.map[a];h===void 0&&(h=new Im(a),$0(e,h)),e=h}}}var ia=class{constructor(t,e){this.seq=[],this.map={};let n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<n;++i){let r=t.getActiveUniform(e,i),o=t.getUniformLocation(e,r.name);lA(r,o,this)}}setValue(t,e,n,i){let r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){let i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,o=e.length;r!==o;++r){let a=e[r],c=n[a.id];c.needsUpdate!==!1&&a.setValue(t,c.value,i)}}static seqWithValue(t,e){let n=[];for(let i=0,r=t.length;i!==r;++i){let o=t[i];o.id in e&&n.push(o)}return n}};function K0(s,t,e){let n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}var uA=37297,hA=0;function fA(s,t){let e=s.split(`
|
|
3730
3730
|
`),n=[],i=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let o=i;o<r;o++){let a=o+1;n.push(`${a===t?">":" "} ${a}: ${e[o]}`)}return n.join(`
|
|
3731
3731
|
`)}var Z0=new $t;function dA(s){ie._getMatrix(Z0,ie.workingColorSpace,s);let t=`mat3( ${Z0.elements.map(e=>e.toFixed(4))} )`;switch(ie.getTransfer(s)){case xo:return[t,"LinearTransferOETF"];case ge:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[t,"LinearTransferOETF"]}}function J0(s,t,e){let n=s.getShaderParameter(t,s.COMPILE_STATUS),r=(s.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";let o=/ERROR: 0:(\d+)/.exec(r);if(o){let a=parseInt(o[1]);return e.toUpperCase()+`
|
|
3732
3732
|
|
|
3733
3733
|
`+r+`
|
|
3734
3734
|
|
|
3735
3735
|
`+fA(s.getShaderSource(t),a)}else return r}function pA(s,t){let e=dA(t);return[`vec4 ${s}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
3736
|
-
`)}function mA(s,t){let e;switch(t){case
|
|
3736
|
+
`)}function mA(s,t){let e;switch(t){case Xp:e="Linear";break;case qp:e="Reinhard";break;case Yp:e="Cineon";break;case $p:e="ACESFilmic";break;case Zp:e="AgX";break;case Jp:e="Neutral";break;case Kp:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var Ef=new I;function gA(){ie.getLuminanceCoefficients(Ef);let s=Ef.x.toFixed(4),t=Ef.y.toFixed(4),e=Ef.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
3737
3737
|
`)}function xA(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(zl).join(`
|
|
3738
3738
|
`)}function _A(s){let t=[];for(let e in s){let n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
3739
|
-
`)}function yA(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let r=s.getActiveAttrib(t,i),o=r.name,a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),e[o]={type:r.type,location:s.getAttribLocation(t,o),locationSize:a}}return e}function zl(s){return s!==""}function j0(s,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return s.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,e).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 Q0(s,t){return s.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var vA=/^[ \t]*#include +<([\w\d./]+)>/gm;function
|
|
3739
|
+
`)}function yA(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){let r=s.getActiveAttrib(t,i),o=r.name,a=1;r.type===s.FLOAT_MAT2&&(a=2),r.type===s.FLOAT_MAT3&&(a=3),r.type===s.FLOAT_MAT4&&(a=4),e[o]={type:r.type,location:s.getAttribLocation(t,o),locationSize:a}}return e}function zl(s){return s!==""}function j0(s,t){let e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return s.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,e).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 Q0(s,t){return s.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var vA=/^[ \t]*#include +<([\w\d./]+)>/gm;function Pm(s){return s.replace(vA,SA)}var MA=new Map;function SA(s,t){let e=te[t];if(e===void 0){let n=MA.get(t);if(n!==void 0)e=te[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Pm(e)}var bA=/#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 ty(s){return s.replace(bA,TA)}function TA(s,t,e,n){let i="";for(let r=parseInt(t);r<parseInt(e);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function ey(s){let t=`precision ${s.precision} float;
|
|
3740
3740
|
precision ${s.precision} int;
|
|
3741
3741
|
precision ${s.precision} sampler2D;
|
|
3742
3742
|
precision ${s.precision} samplerCube;
|
|
@@ -3756,7 +3756,7 @@ void main() {
|
|
|
3756
3756
|
`;return s.precision==="highp"?t+=`
|
|
3757
3757
|
#define HIGH_PRECISION`:s.precision==="mediump"?t+=`
|
|
3758
3758
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(t+=`
|
|
3759
|
-
#define LOW_PRECISION`),t}function EA(s){let t="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===af?t="SHADOWMAP_TYPE_PCF":s.shadowMapType===
|
|
3759
|
+
#define LOW_PRECISION`),t}function EA(s){let t="SHADOWMAP_TYPE_BASIC";return s.shadowMapType===af?t="SHADOWMAP_TYPE_PCF":s.shadowMapType===Tp?t="SHADOWMAP_TYPE_PCF_SOFT":s.shadowMapType===vi&&(t="SHADOWMAP_TYPE_VSM"),t}function wA(s){let t="ENVMAP_TYPE_CUBE";if(s.envMap)switch(s.envMapMode){case Wi:case ur:t="ENVMAP_TYPE_CUBE";break;case Ts:t="ENVMAP_TYPE_CUBE_UV";break}return t}function AA(s){let t="ENVMAP_MODE_REFLECTION";if(s.envMap)switch(s.envMapMode){case ur:t="ENVMAP_MODE_REFRACTION";break}return t}function RA(s){let t="ENVMAP_BLENDING_NONE";if(s.envMap)switch(s.combine){case qo:t="ENVMAP_BLENDING_MULTIPLY";break;case Gp:t="ENVMAP_BLENDING_MIX";break;case Wp:t="ENVMAP_BLENDING_ADD";break}return t}function CA(s){let t=s.envMapCubeUVHeight;if(t===null)return null;let e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:n,maxMip:e}}function IA(s,t,e,n){let i=s.getContext(),r=e.defines,o=e.vertexShader,a=e.fragmentShader,c=EA(e),l=wA(e),u=AA(e),h=RA(e),f=CA(e),p=xA(e),x=_A(r),v=i.createProgram(),y,_,S=e.glslVersion?"#version "+e.glslVersion+`
|
|
3760
3760
|
`:"";e.isRawShaderMaterial?(y=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x].filter(zl).join(`
|
|
3761
3761
|
`),y.length>0&&(y+=`
|
|
3762
3762
|
`),_=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x].filter(zl).join(`
|
|
@@ -3765,7 +3765,7 @@ void main() {
|
|
|
3765
3765
|
`].filter(zl).join(`
|
|
3766
3766
|
`),_=[ey(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,x,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+u:"",e.envMap?"#define "+h:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Gi?"#define TONE_MAPPING":"",e.toneMapping!==Gi?te.tonemapping_pars_fragment:"",e.toneMapping!==Gi?mA("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",te.colorspace_pars_fragment,pA("linearToOutputTexel",e.outputColorSpace),gA(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
3767
3767
|
`].filter(zl).join(`
|
|
3768
|
-
`)),o=
|
|
3768
|
+
`)),o=Pm(o),o=j0(o,e),o=Q0(o,e),a=Pm(a),a=j0(a,e),a=Q0(a,e),o=ty(o),a=ty(a),e.isRawShaderMaterial!==!0&&(S=`#version 300 es
|
|
3769
3769
|
`,y=[p,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
3770
3770
|
`)+`
|
|
3771
3771
|
`+y,_=["#define varying in",e.glslVersion===Mf?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Mf?"":"#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(`
|
|
@@ -3777,7 +3777,7 @@ Material Type: `+w.type+`
|
|
|
3777
3777
|
|
|
3778
3778
|
Program Info Log: `+F+`
|
|
3779
3779
|
`+at+`
|
|
3780
|
-
`+rt)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(O===""||H==="")&&($=!1);$&&(w.diagnostics={runnable:B,programLog:F,vertexShader:{log:O,prefix:y},fragmentShader:{log:H,prefix:_}})}i.deleteShader(M),i.deleteShader(m),E=new ia(i,v),T=yA(i,v)}let E;this.getUniforms=function(){return E===void 0&&R(this),E};let T;this.getAttributes=function(){return T===void 0&&R(this),T};let b=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=i.getProgramParameter(v,uA)),b},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=hA++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=m,this}var PA=0,Pm=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Lm(t),e.set(t,n)),n}},Lm=class{constructor(t){this.id=PA++,this.code=t,this.usedTimes=0}};function LA(s,t,e,n,i,r,o){let a=new us,c=new Pm,l=new Set,u=[],h=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,x={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(T){return l.add(T),T===0?"uv":`uv${T}`}function y(T,b,w,A,C){let D=A.fog,F=C.geometry,O=T.isMeshStandardMaterial?A.environment:null,H=(T.isMeshStandardMaterial?e:t).get(T.envMap||O),B=H&&H.mapping===Ts?H.image.height:null,$=x[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));let at=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,rt=at!==void 0?at.length:0,ht=0;F.morphAttributes.position!==void 0&&(ht=1),F.morphAttributes.normal!==void 0&&(ht=2),F.morphAttributes.color!==void 0&&(ht=3);let bt,Et,Mt,K;if($){let pe=Si[$];bt=pe.vertexShader,Et=pe.fragmentShader}else bt=T.vertexShader,Et=T.fragmentShader,c.update(T),Mt=c.getVertexShaderID(T),K=c.getFragmentShaderID(T);let Q=s.getRenderTarget(),ct=s.state.buffers.depth.getReversed(),lt=C.isInstancedMesh===!0,ut=C.isBatchedMesh===!0,Ct=!!T.map,Kt=!!T.matcap,U=!!H,tt=!!T.aoMap,Z=!!T.lightMap,Y=!!T.bumpMap,q=!!T.normalMap,mt=!!T.displacementMap,it=!!T.emissiveMap,st=!!T.metalnessMap,Pt=!!T.roughnessMap,It=T.anisotropy>0,N=T.clearcoat>0,P=T.dispersion>0,k=T.iridescence>0,W=T.sheen>0,et=T.transmission>0,X=It&&!!T.anisotropyMap,_t=N&&!!T.clearcoatMap,xt=N&&!!T.clearcoatNormalMap,Ft=N&&!!T.clearcoatRoughnessMap,Dt=k&&!!T.iridescenceMap,ft=k&&!!T.iridescenceThicknessMap,Rt=W&&!!T.sheenColorMap,qt=W&&!!T.sheenRoughnessMap,zt=!!T.specularMap,wt=!!T.specularColorMap,jt=!!T.specularIntensityMap,z=et&&!!T.transmissionMap,gt=et&&!!T.thicknessMap,St=!!T.gradientMap,Ut=!!T.alphaMap,dt=T.alphaTest>0,ot=!!T.alphaHash,Bt=!!T.extensions,Zt=Gi;T.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(Zt=s.toneMapping);let Te={shaderID:$,shaderType:T.type,shaderName:T.name,vertexShader:bt,fragmentShader:Et,defines:T.defines,customVertexShaderID:Mt,customFragmentShaderID:K,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:ut,batchingColor:ut&&C._colorsTexture!==null,instancing:lt,instancingColor:lt&&C.instanceColor!==null,instancingMorph:lt&&C.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:Q===null?s.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:tn,alphaToCoverage:!!T.alphaToCoverage,map:Ct,matcap:Kt,envMap:U,envMapMode:U&&H.mapping,envMapCubeUVHeight:B,aoMap:tt,lightMap:Z,bumpMap:Y,normalMap:q,displacementMap:f&&mt,emissiveMap:it,normalMapObjectSpace:q&&T.normalMapType===im,normalMapTangentSpace:q&&T.normalMapType===hr,metalnessMap:st,roughnessMap:Pt,anisotropy:It,anisotropyMap:X,clearcoat:N,clearcoatMap:_t,clearcoatNormalMap:xt,clearcoatRoughnessMap:Ft,dispersion:P,iridescence:k,iridescenceMap:Dt,iridescenceThicknessMap:ft,sheen:W,sheenColorMap:Rt,sheenRoughnessMap:qt,specularMap:zt,specularColorMap:wt,specularIntensityMap:jt,transmission:et,transmissionMap:z,thicknessMap:gt,gradientMap:St,opaque:T.transparent===!1&&T.blending===wr&&T.alphaToCoverage===!1,alphaMap:Ut,alphaTest:dt,alphaHash:ot,combine:T.combine,mapUv:Ct&&v(T.map.channel),aoMapUv:tt&&v(T.aoMap.channel),lightMapUv:Z&&v(T.lightMap.channel),bumpMapUv:Y&&v(T.bumpMap.channel),normalMapUv:q&&v(T.normalMap.channel),displacementMapUv:mt&&v(T.displacementMap.channel),emissiveMapUv:it&&v(T.emissiveMap.channel),metalnessMapUv:st&&v(T.metalnessMap.channel),roughnessMapUv:Pt&&v(T.roughnessMap.channel),anisotropyMapUv:X&&v(T.anisotropyMap.channel),clearcoatMapUv:_t&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:xt&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ft&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Dt&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:ft&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:Rt&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:qt&&v(T.sheenRoughnessMap.channel),specularMapUv:zt&&v(T.specularMap.channel),specularColorMapUv:wt&&v(T.specularColorMap.channel),specularIntensityMapUv:jt&&v(T.specularIntensityMap.channel),transmissionMapUv:z&&v(T.transmissionMap.channel),thicknessMapUv:gt&&v(T.thicknessMap.channel),alphaMapUv:Ut&&v(T.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(q||It),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:C.isPoints===!0&&!!F.attributes.uv&&(Ct||Ut),fog:!!D,useFog:T.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:ct,skinning:C.isSkinnedMesh===!0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:rt,morphTextureStride:ht,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:s.shadowMap.enabled&&w.length>0,shadowMapType:s.shadowMap.type,toneMapping:Zt,decodeVideoTexture:Ct&&T.map.isVideoTexture===!0&&ie.getTransfer(T.map.colorSpace)===ge,decodeVideoTextureEmissive:it&&T.emissiveMap.isVideoTexture===!0&&ie.getTransfer(T.emissiveMap.colorSpace)===ge,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Ve,flipSided:T.side===qe,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Bt&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Bt&&T.extensions.multiDraw===!0||ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function _(T){let b=[];if(T.shaderID?b.push(T.shaderID):(b.push(T.customVertexShaderID),b.push(T.customFragmentShaderID)),T.defines!==void 0)for(let w in T.defines)b.push(w),b.push(T.defines[w]);return T.isRawShaderMaterial===!1&&(S(b,T),g(b,T),b.push(s.outputColorSpace)),b.push(T.customProgramCacheKey),b.join()}function S(T,b){T.push(b.precision),T.push(b.outputColorSpace),T.push(b.envMapMode),T.push(b.envMapCubeUVHeight),T.push(b.mapUv),T.push(b.alphaMapUv),T.push(b.lightMapUv),T.push(b.aoMapUv),T.push(b.bumpMapUv),T.push(b.normalMapUv),T.push(b.displacementMapUv),T.push(b.emissiveMapUv),T.push(b.metalnessMapUv),T.push(b.roughnessMapUv),T.push(b.anisotropyMapUv),T.push(b.clearcoatMapUv),T.push(b.clearcoatNormalMapUv),T.push(b.clearcoatRoughnessMapUv),T.push(b.iridescenceMapUv),T.push(b.iridescenceThicknessMapUv),T.push(b.sheenColorMapUv),T.push(b.sheenRoughnessMapUv),T.push(b.specularMapUv),T.push(b.specularColorMapUv),T.push(b.specularIntensityMapUv),T.push(b.transmissionMapUv),T.push(b.thicknessMapUv),T.push(b.combine),T.push(b.fogExp2),T.push(b.sizeAttenuation),T.push(b.morphTargetsCount),T.push(b.morphAttributeCount),T.push(b.numDirLights),T.push(b.numPointLights),T.push(b.numSpotLights),T.push(b.numSpotLightMaps),T.push(b.numHemiLights),T.push(b.numRectAreaLights),T.push(b.numDirLightShadows),T.push(b.numPointLightShadows),T.push(b.numSpotLightShadows),T.push(b.numSpotLightShadowsWithMaps),T.push(b.numLightProbes),T.push(b.shadowMapType),T.push(b.toneMapping),T.push(b.numClippingPlanes),T.push(b.numClipIntersection),T.push(b.depthPacking)}function g(T,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),b.batchingColor&&a.enable(21),b.gradientMap&&a.enable(22),T.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),T.push(a.mask)}function d(T){let b=x[T.type],w;if(b){let A=Si[b];w=mm.clone(A.uniforms)}else w=T.uniforms;return w}function M(T,b){let w;for(let A=0,C=u.length;A<C;A++){let D=u[A];if(D.cacheKey===b){w=D,++w.usedTimes;break}}return w===void 0&&(w=new IA(s,b,T,r),u.push(w)),w}function m(T){if(--T.usedTimes===0){let b=u.indexOf(T);u[b]=u[u.length-1],u.pop(),T.destroy()}}function R(T){c.remove(T)}function E(){c.dispose()}return{getParameters:y,getProgramCacheKey:_,getUniforms:d,acquireProgram:M,releaseProgram:m,releaseShaderCache:R,programs:u,dispose:E}}function NA(){let s=new WeakMap;function t(o){return s.has(o)}function e(o){let a=s.get(o);return a===void 0&&(a={},s.set(o,a)),a}function n(o){s.delete(o)}function i(o,a,c){s.get(o)[a]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function DA(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.z!==t.z?s.z-t.z:s.id-t.id}function ny(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function iy(){let s=[],t=0,e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function o(h,f,p,x,v,y){let _=s[t];return _===void 0?(_={id:h.id,object:h,geometry:f,material:p,groupOrder:x,renderOrder:h.renderOrder,z:v,group:y},s[t]=_):(_.id=h.id,_.object=h,_.geometry=f,_.material=p,_.groupOrder=x,_.renderOrder=h.renderOrder,_.z=v,_.group=y),t++,_}function a(h,f,p,x,v,y){let _=o(h,f,p,x,v,y);p.transmission>0?n.push(_):p.transparent===!0?i.push(_):e.push(_)}function c(h,f,p,x,v,y){let _=o(h,f,p,x,v,y);p.transmission>0?n.unshift(_):p.transparent===!0?i.unshift(_):e.unshift(_)}function l(h,f){e.length>1&&e.sort(h||DA),n.length>1&&n.sort(f||ny),i.length>1&&i.sort(f||ny)}function u(){for(let h=t,f=s.length;h<f;h++){let p=s[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:u,sort:l}}function UA(){let s=new WeakMap;function t(n,i){let r=s.get(n),o;return r===void 0?(o=new iy,s.set(n,[o])):i>=r.length?(o=new iy,r.push(o)):o=r[i],o}function e(){s=new WeakMap}return{get:t,dispose:e}}function FA(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new I,color:new yt};break;case"SpotLight":e={position:new I,direction:new I,color:new yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new I,color:new yt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new I,skyColor:new yt,groundColor:new yt};break;case"RectAreaLight":e={color:new yt,position:new I,halfWidth:new I,halfHeight:new I};break}return s[t.id]=e,e}}}function OA(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var BA=0;function zA(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function kA(s){let t=new FA,e=OA(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new I);let i=new I,r=new vt,o=new vt;function a(l){let u=0,h=0,f=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let p=0,x=0,v=0,y=0,_=0,S=0,g=0,d=0,M=0,m=0,R=0;l.sort(zA);for(let T=0,b=l.length;T<b;T++){let w=l[T],A=w.color,C=w.intensity,D=w.distance,F=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)u+=A.r*C,h+=A.g*C,f+=A.b*C;else if(w.isLightProbe){for(let O=0;O<9;O++)n.probe[O].addScaledVector(w.sh.coefficients[O],C);R++}else if(w.isDirectionalLight){let O=t.get(w);if(O.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){let H=w.shadow,B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,n.directionalShadow[p]=B,n.directionalShadowMap[p]=F,n.directionalShadowMatrix[p]=w.shadow.matrix,S++}n.directional[p]=O,p++}else if(w.isSpotLight){let O=t.get(w);O.position.setFromMatrixPosition(w.matrixWorld),O.color.copy(A).multiplyScalar(C),O.distance=D,O.coneCos=Math.cos(w.angle),O.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),O.decay=w.decay,n.spot[v]=O;let H=w.shadow;if(w.map&&(n.spotLightMap[M]=w.map,M++,H.updateMatrices(w),w.castShadow&&m++),n.spotLightMatrix[v]=H.matrix,w.castShadow){let B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,n.spotShadow[v]=B,n.spotShadowMap[v]=F,d++}v++}else if(w.isRectAreaLight){let O=t.get(w);O.color.copy(A).multiplyScalar(C),O.halfWidth.set(w.width*.5,0,0),O.halfHeight.set(0,w.height*.5,0),n.rectArea[y]=O,y++}else if(w.isPointLight){let O=t.get(w);if(O.color.copy(w.color).multiplyScalar(w.intensity),O.distance=w.distance,O.decay=w.decay,w.castShadow){let H=w.shadow,B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,B.shadowCameraNear=H.camera.near,B.shadowCameraFar=H.camera.far,n.pointShadow[x]=B,n.pointShadowMap[x]=F,n.pointShadowMatrix[x]=w.shadow.matrix,g++}n.point[x]=O,x++}else if(w.isHemisphereLight){let O=t.get(w);O.skyColor.copy(w.color).multiplyScalar(C),O.groundColor.copy(w.groundColor).multiplyScalar(C),n.hemi[_]=O,_++}}y>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Tt.LTC_FLOAT_1,n.rectAreaLTC2=Tt.LTC_FLOAT_2):(n.rectAreaLTC1=Tt.LTC_HALF_1,n.rectAreaLTC2=Tt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;let E=n.hash;(E.directionalLength!==p||E.pointLength!==x||E.spotLength!==v||E.rectAreaLength!==y||E.hemiLength!==_||E.numDirectionalShadows!==S||E.numPointShadows!==g||E.numSpotShadows!==d||E.numSpotMaps!==M||E.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=v,n.rectArea.length=y,n.point.length=x,n.hemi.length=_,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=g,n.pointShadowMap.length=g,n.spotShadow.length=d,n.spotShadowMap.length=d,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=g,n.spotLightMatrix.length=d+M-m,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=m,n.numLightProbes=R,E.directionalLength=p,E.pointLength=x,E.spotLength=v,E.rectAreaLength=y,E.hemiLength=_,E.numDirectionalShadows=S,E.numPointShadows=g,E.numSpotShadows=d,E.numSpotMaps=M,E.numLightProbes=R,n.version=BA++)}function c(l,u){let h=0,f=0,p=0,x=0,v=0,y=u.matrixWorldInverse;for(let _=0,S=l.length;_<S;_++){let g=l[_];if(g.isDirectionalLight){let d=n.directional[h];d.direction.setFromMatrixPosition(g.matrixWorld),i.setFromMatrixPosition(g.target.matrixWorld),d.direction.sub(i),d.direction.transformDirection(y),h++}else if(g.isSpotLight){let d=n.spot[p];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),d.direction.setFromMatrixPosition(g.matrixWorld),i.setFromMatrixPosition(g.target.matrixWorld),d.direction.sub(i),d.direction.transformDirection(y),p++}else if(g.isRectAreaLight){let d=n.rectArea[x];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),o.identity(),r.copy(g.matrixWorld),r.premultiply(y),o.extractRotation(r),d.halfWidth.set(g.width*.5,0,0),d.halfHeight.set(0,g.height*.5,0),d.halfWidth.applyMatrix4(o),d.halfHeight.applyMatrix4(o),x++}else if(g.isPointLight){let d=n.point[f];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),f++}else if(g.isHemisphereLight){let d=n.hemi[v];d.direction.setFromMatrixPosition(g.matrixWorld),d.direction.transformDirection(y),v++}}}return{setup:a,setupView:c,state:n}}function ry(s){let t=new kA(s),e=[],n=[];function i(u){l.camera=u,e.length=0,n.length=0}function r(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function c(u){t.setupView(e,u)}let l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:l,setupLights:a,setupLightsView:c,pushLight:r,pushShadow:o}}function HA(s){let t=new WeakMap;function e(i,r=0){let o=t.get(i),a;return o===void 0?(a=new ry(s),t.set(i,[a])):r>=o.length?(a=new ry(s),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var VA=`void main() {
|
|
3780
|
+
`+rt)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(O===""||H==="")&&($=!1);$&&(w.diagnostics={runnable:B,programLog:F,vertexShader:{log:O,prefix:y},fragmentShader:{log:H,prefix:_}})}i.deleteShader(M),i.deleteShader(m),E=new ia(i,v),T=yA(i,v)}let E;this.getUniforms=function(){return E===void 0&&R(this),E};let T;this.getAttributes=function(){return T===void 0&&R(this),T};let b=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return b===!1&&(b=i.getProgramParameter(v,uA)),b},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=hA++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=M,this.fragmentShader=m,this}var PA=0,Lm=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),o=this._getShaderCacheForMaterial(t);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(r)===!1&&(o.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Nm(t),e.set(t,n)),n}},Nm=class{constructor(t){this.id=PA++,this.code=t,this.usedTimes=0}};function LA(s,t,e,n,i,r,o){let a=new us,c=new Lm,l=new Set,u=[],h=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,x={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(T){return l.add(T),T===0?"uv":`uv${T}`}function y(T,b,w,A,C){let D=A.fog,F=C.geometry,O=T.isMeshStandardMaterial?A.environment:null,H=(T.isMeshStandardMaterial?e:t).get(T.envMap||O),B=H&&H.mapping===Ts?H.image.height:null,$=x[T.type];T.precision!==null&&(p=i.getMaxPrecision(T.precision),p!==T.precision&&console.warn("THREE.WebGLProgram.getParameters:",T.precision,"not supported, using",p,"instead."));let at=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,rt=at!==void 0?at.length:0,ht=0;F.morphAttributes.position!==void 0&&(ht=1),F.morphAttributes.normal!==void 0&&(ht=2),F.morphAttributes.color!==void 0&&(ht=3);let bt,Et,Mt,K;if($){let pe=Si[$];bt=pe.vertexShader,Et=pe.fragmentShader}else bt=T.vertexShader,Et=T.fragmentShader,c.update(T),Mt=c.getVertexShaderID(T),K=c.getFragmentShaderID(T);let Q=s.getRenderTarget(),ct=s.state.buffers.depth.getReversed(),lt=C.isInstancedMesh===!0,ut=C.isBatchedMesh===!0,Ct=!!T.map,Kt=!!T.matcap,U=!!H,tt=!!T.aoMap,Z=!!T.lightMap,Y=!!T.bumpMap,q=!!T.normalMap,mt=!!T.displacementMap,it=!!T.emissiveMap,st=!!T.metalnessMap,Pt=!!T.roughnessMap,It=T.anisotropy>0,N=T.clearcoat>0,P=T.dispersion>0,k=T.iridescence>0,W=T.sheen>0,et=T.transmission>0,X=It&&!!T.anisotropyMap,_t=N&&!!T.clearcoatMap,xt=N&&!!T.clearcoatNormalMap,Ft=N&&!!T.clearcoatRoughnessMap,Dt=k&&!!T.iridescenceMap,ft=k&&!!T.iridescenceThicknessMap,Rt=W&&!!T.sheenColorMap,qt=W&&!!T.sheenRoughnessMap,zt=!!T.specularMap,wt=!!T.specularColorMap,jt=!!T.specularIntensityMap,z=et&&!!T.transmissionMap,gt=et&&!!T.thicknessMap,St=!!T.gradientMap,Ut=!!T.alphaMap,dt=T.alphaTest>0,ot=!!T.alphaHash,Bt=!!T.extensions,Zt=Gi;T.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(Zt=s.toneMapping);let Te={shaderID:$,shaderType:T.type,shaderName:T.name,vertexShader:bt,fragmentShader:Et,defines:T.defines,customVertexShaderID:Mt,customFragmentShaderID:K,isRawShaderMaterial:T.isRawShaderMaterial===!0,glslVersion:T.glslVersion,precision:p,batching:ut,batchingColor:ut&&C._colorsTexture!==null,instancing:lt,instancingColor:lt&&C.instanceColor!==null,instancingMorph:lt&&C.morphTexture!==null,supportsVertexTextures:f,outputColorSpace:Q===null?s.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:tn,alphaToCoverage:!!T.alphaToCoverage,map:Ct,matcap:Kt,envMap:U,envMapMode:U&&H.mapping,envMapCubeUVHeight:B,aoMap:tt,lightMap:Z,bumpMap:Y,normalMap:q,displacementMap:f&&mt,emissiveMap:it,normalMapObjectSpace:q&&T.normalMapType===rm,normalMapTangentSpace:q&&T.normalMapType===hr,metalnessMap:st,roughnessMap:Pt,anisotropy:It,anisotropyMap:X,clearcoat:N,clearcoatMap:_t,clearcoatNormalMap:xt,clearcoatRoughnessMap:Ft,dispersion:P,iridescence:k,iridescenceMap:Dt,iridescenceThicknessMap:ft,sheen:W,sheenColorMap:Rt,sheenRoughnessMap:qt,specularMap:zt,specularColorMap:wt,specularIntensityMap:jt,transmission:et,transmissionMap:z,thicknessMap:gt,gradientMap:St,opaque:T.transparent===!1&&T.blending===wr&&T.alphaToCoverage===!1,alphaMap:Ut,alphaTest:dt,alphaHash:ot,combine:T.combine,mapUv:Ct&&v(T.map.channel),aoMapUv:tt&&v(T.aoMap.channel),lightMapUv:Z&&v(T.lightMap.channel),bumpMapUv:Y&&v(T.bumpMap.channel),normalMapUv:q&&v(T.normalMap.channel),displacementMapUv:mt&&v(T.displacementMap.channel),emissiveMapUv:it&&v(T.emissiveMap.channel),metalnessMapUv:st&&v(T.metalnessMap.channel),roughnessMapUv:Pt&&v(T.roughnessMap.channel),anisotropyMapUv:X&&v(T.anisotropyMap.channel),clearcoatMapUv:_t&&v(T.clearcoatMap.channel),clearcoatNormalMapUv:xt&&v(T.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Ft&&v(T.clearcoatRoughnessMap.channel),iridescenceMapUv:Dt&&v(T.iridescenceMap.channel),iridescenceThicknessMapUv:ft&&v(T.iridescenceThicknessMap.channel),sheenColorMapUv:Rt&&v(T.sheenColorMap.channel),sheenRoughnessMapUv:qt&&v(T.sheenRoughnessMap.channel),specularMapUv:zt&&v(T.specularMap.channel),specularColorMapUv:wt&&v(T.specularColorMap.channel),specularIntensityMapUv:jt&&v(T.specularIntensityMap.channel),transmissionMapUv:z&&v(T.transmissionMap.channel),thicknessMapUv:gt&&v(T.thicknessMap.channel),alphaMapUv:Ut&&v(T.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(q||It),vertexColors:T.vertexColors,vertexAlphas:T.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:C.isPoints===!0&&!!F.attributes.uv&&(Ct||Ut),fog:!!D,useFog:T.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:T.flatShading===!0&&T.wireframe===!1,sizeAttenuation:T.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:ct,skinning:C.isSkinnedMesh===!0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:rt,morphTextureStride:ht,numDirLights:b.directional.length,numPointLights:b.point.length,numSpotLights:b.spot.length,numSpotLightMaps:b.spotLightMap.length,numRectAreaLights:b.rectArea.length,numHemiLights:b.hemi.length,numDirLightShadows:b.directionalShadowMap.length,numPointLightShadows:b.pointShadowMap.length,numSpotLightShadows:b.spotShadowMap.length,numSpotLightShadowsWithMaps:b.numSpotLightShadowsWithMaps,numLightProbes:b.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:T.dithering,shadowMapEnabled:s.shadowMap.enabled&&w.length>0,shadowMapType:s.shadowMap.type,toneMapping:Zt,decodeVideoTexture:Ct&&T.map.isVideoTexture===!0&&ie.getTransfer(T.map.colorSpace)===ge,decodeVideoTextureEmissive:it&&T.emissiveMap.isVideoTexture===!0&&ie.getTransfer(T.emissiveMap.colorSpace)===ge,premultipliedAlpha:T.premultipliedAlpha,doubleSided:T.side===Ve,flipSided:T.side===qe,useDepthPacking:T.depthPacking>=0,depthPacking:T.depthPacking||0,index0AttributeName:T.index0AttributeName,extensionClipCullDistance:Bt&&T.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Bt&&T.extensions.multiDraw===!0||ut)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:T.customProgramCacheKey()};return Te.vertexUv1s=l.has(1),Te.vertexUv2s=l.has(2),Te.vertexUv3s=l.has(3),l.clear(),Te}function _(T){let b=[];if(T.shaderID?b.push(T.shaderID):(b.push(T.customVertexShaderID),b.push(T.customFragmentShaderID)),T.defines!==void 0)for(let w in T.defines)b.push(w),b.push(T.defines[w]);return T.isRawShaderMaterial===!1&&(S(b,T),g(b,T),b.push(s.outputColorSpace)),b.push(T.customProgramCacheKey),b.join()}function S(T,b){T.push(b.precision),T.push(b.outputColorSpace),T.push(b.envMapMode),T.push(b.envMapCubeUVHeight),T.push(b.mapUv),T.push(b.alphaMapUv),T.push(b.lightMapUv),T.push(b.aoMapUv),T.push(b.bumpMapUv),T.push(b.normalMapUv),T.push(b.displacementMapUv),T.push(b.emissiveMapUv),T.push(b.metalnessMapUv),T.push(b.roughnessMapUv),T.push(b.anisotropyMapUv),T.push(b.clearcoatMapUv),T.push(b.clearcoatNormalMapUv),T.push(b.clearcoatRoughnessMapUv),T.push(b.iridescenceMapUv),T.push(b.iridescenceThicknessMapUv),T.push(b.sheenColorMapUv),T.push(b.sheenRoughnessMapUv),T.push(b.specularMapUv),T.push(b.specularColorMapUv),T.push(b.specularIntensityMapUv),T.push(b.transmissionMapUv),T.push(b.thicknessMapUv),T.push(b.combine),T.push(b.fogExp2),T.push(b.sizeAttenuation),T.push(b.morphTargetsCount),T.push(b.morphAttributeCount),T.push(b.numDirLights),T.push(b.numPointLights),T.push(b.numSpotLights),T.push(b.numSpotLightMaps),T.push(b.numHemiLights),T.push(b.numRectAreaLights),T.push(b.numDirLightShadows),T.push(b.numPointLightShadows),T.push(b.numSpotLightShadows),T.push(b.numSpotLightShadowsWithMaps),T.push(b.numLightProbes),T.push(b.shadowMapType),T.push(b.toneMapping),T.push(b.numClippingPlanes),T.push(b.numClipIntersection),T.push(b.depthPacking)}function g(T,b){a.disableAll(),b.supportsVertexTextures&&a.enable(0),b.instancing&&a.enable(1),b.instancingColor&&a.enable(2),b.instancingMorph&&a.enable(3),b.matcap&&a.enable(4),b.envMap&&a.enable(5),b.normalMapObjectSpace&&a.enable(6),b.normalMapTangentSpace&&a.enable(7),b.clearcoat&&a.enable(8),b.iridescence&&a.enable(9),b.alphaTest&&a.enable(10),b.vertexColors&&a.enable(11),b.vertexAlphas&&a.enable(12),b.vertexUv1s&&a.enable(13),b.vertexUv2s&&a.enable(14),b.vertexUv3s&&a.enable(15),b.vertexTangents&&a.enable(16),b.anisotropy&&a.enable(17),b.alphaHash&&a.enable(18),b.batching&&a.enable(19),b.dispersion&&a.enable(20),b.batchingColor&&a.enable(21),b.gradientMap&&a.enable(22),T.push(a.mask),a.disableAll(),b.fog&&a.enable(0),b.useFog&&a.enable(1),b.flatShading&&a.enable(2),b.logarithmicDepthBuffer&&a.enable(3),b.reversedDepthBuffer&&a.enable(4),b.skinning&&a.enable(5),b.morphTargets&&a.enable(6),b.morphNormals&&a.enable(7),b.morphColors&&a.enable(8),b.premultipliedAlpha&&a.enable(9),b.shadowMapEnabled&&a.enable(10),b.doubleSided&&a.enable(11),b.flipSided&&a.enable(12),b.useDepthPacking&&a.enable(13),b.dithering&&a.enable(14),b.transmission&&a.enable(15),b.sheen&&a.enable(16),b.opaque&&a.enable(17),b.pointsUvs&&a.enable(18),b.decodeVideoTexture&&a.enable(19),b.decodeVideoTextureEmissive&&a.enable(20),b.alphaToCoverage&&a.enable(21),T.push(a.mask)}function d(T){let b=x[T.type],w;if(b){let A=Si[b];w=gm.clone(A.uniforms)}else w=T.uniforms;return w}function M(T,b){let w;for(let A=0,C=u.length;A<C;A++){let D=u[A];if(D.cacheKey===b){w=D,++w.usedTimes;break}}return w===void 0&&(w=new IA(s,b,T,r),u.push(w)),w}function m(T){if(--T.usedTimes===0){let b=u.indexOf(T);u[b]=u[u.length-1],u.pop(),T.destroy()}}function R(T){c.remove(T)}function E(){c.dispose()}return{getParameters:y,getProgramCacheKey:_,getUniforms:d,acquireProgram:M,releaseProgram:m,releaseShaderCache:R,programs:u,dispose:E}}function NA(){let s=new WeakMap;function t(o){return s.has(o)}function e(o){let a=s.get(o);return a===void 0&&(a={},s.set(o,a)),a}function n(o){s.delete(o)}function i(o,a,c){s.get(o)[a]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function DA(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.z!==t.z?s.z-t.z:s.id-t.id}function ny(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function iy(){let s=[],t=0,e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function o(h,f,p,x,v,y){let _=s[t];return _===void 0?(_={id:h.id,object:h,geometry:f,material:p,groupOrder:x,renderOrder:h.renderOrder,z:v,group:y},s[t]=_):(_.id=h.id,_.object=h,_.geometry=f,_.material=p,_.groupOrder=x,_.renderOrder=h.renderOrder,_.z=v,_.group=y),t++,_}function a(h,f,p,x,v,y){let _=o(h,f,p,x,v,y);p.transmission>0?n.push(_):p.transparent===!0?i.push(_):e.push(_)}function c(h,f,p,x,v,y){let _=o(h,f,p,x,v,y);p.transmission>0?n.unshift(_):p.transparent===!0?i.unshift(_):e.unshift(_)}function l(h,f){e.length>1&&e.sort(h||DA),n.length>1&&n.sort(f||ny),i.length>1&&i.sort(f||ny)}function u(){for(let h=t,f=s.length;h<f;h++){let p=s[h];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:n,transparent:i,init:r,push:a,unshift:c,finish:u,sort:l}}function UA(){let s=new WeakMap;function t(n,i){let r=s.get(n),o;return r===void 0?(o=new iy,s.set(n,[o])):i>=r.length?(o=new iy,r.push(o)):o=r[i],o}function e(){s=new WeakMap}return{get:t,dispose:e}}function FA(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new I,color:new yt};break;case"SpotLight":e={position:new I,direction:new I,color:new yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new I,color:new yt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new I,skyColor:new yt,groundColor:new yt};break;case"RectAreaLight":e={color:new yt,position:new I,halfWidth:new I,halfHeight:new I};break}return s[t.id]=e,e}}}function OA(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var BA=0;function zA(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function kA(s){let t=new FA,e=OA(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new I);let i=new I,r=new vt,o=new vt;function a(l){let u=0,h=0,f=0;for(let T=0;T<9;T++)n.probe[T].set(0,0,0);let p=0,x=0,v=0,y=0,_=0,S=0,g=0,d=0,M=0,m=0,R=0;l.sort(zA);for(let T=0,b=l.length;T<b;T++){let w=l[T],A=w.color,C=w.intensity,D=w.distance,F=w.shadow&&w.shadow.map?w.shadow.map.texture:null;if(w.isAmbientLight)u+=A.r*C,h+=A.g*C,f+=A.b*C;else if(w.isLightProbe){for(let O=0;O<9;O++)n.probe[O].addScaledVector(w.sh.coefficients[O],C);R++}else if(w.isDirectionalLight){let O=t.get(w);if(O.color.copy(w.color).multiplyScalar(w.intensity),w.castShadow){let H=w.shadow,B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,n.directionalShadow[p]=B,n.directionalShadowMap[p]=F,n.directionalShadowMatrix[p]=w.shadow.matrix,S++}n.directional[p]=O,p++}else if(w.isSpotLight){let O=t.get(w);O.position.setFromMatrixPosition(w.matrixWorld),O.color.copy(A).multiplyScalar(C),O.distance=D,O.coneCos=Math.cos(w.angle),O.penumbraCos=Math.cos(w.angle*(1-w.penumbra)),O.decay=w.decay,n.spot[v]=O;let H=w.shadow;if(w.map&&(n.spotLightMap[M]=w.map,M++,H.updateMatrices(w),w.castShadow&&m++),n.spotLightMatrix[v]=H.matrix,w.castShadow){let B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,n.spotShadow[v]=B,n.spotShadowMap[v]=F,d++}v++}else if(w.isRectAreaLight){let O=t.get(w);O.color.copy(A).multiplyScalar(C),O.halfWidth.set(w.width*.5,0,0),O.halfHeight.set(0,w.height*.5,0),n.rectArea[y]=O,y++}else if(w.isPointLight){let O=t.get(w);if(O.color.copy(w.color).multiplyScalar(w.intensity),O.distance=w.distance,O.decay=w.decay,w.castShadow){let H=w.shadow,B=e.get(w);B.shadowIntensity=H.intensity,B.shadowBias=H.bias,B.shadowNormalBias=H.normalBias,B.shadowRadius=H.radius,B.shadowMapSize=H.mapSize,B.shadowCameraNear=H.camera.near,B.shadowCameraFar=H.camera.far,n.pointShadow[x]=B,n.pointShadowMap[x]=F,n.pointShadowMatrix[x]=w.shadow.matrix,g++}n.point[x]=O,x++}else if(w.isHemisphereLight){let O=t.get(w);O.skyColor.copy(w.color).multiplyScalar(C),O.groundColor.copy(w.groundColor).multiplyScalar(C),n.hemi[_]=O,_++}}y>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Tt.LTC_FLOAT_1,n.rectAreaLTC2=Tt.LTC_FLOAT_2):(n.rectAreaLTC1=Tt.LTC_HALF_1,n.rectAreaLTC2=Tt.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;let E=n.hash;(E.directionalLength!==p||E.pointLength!==x||E.spotLength!==v||E.rectAreaLength!==y||E.hemiLength!==_||E.numDirectionalShadows!==S||E.numPointShadows!==g||E.numSpotShadows!==d||E.numSpotMaps!==M||E.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=v,n.rectArea.length=y,n.point.length=x,n.hemi.length=_,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=g,n.pointShadowMap.length=g,n.spotShadow.length=d,n.spotShadowMap.length=d,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=g,n.spotLightMatrix.length=d+M-m,n.spotLightMap.length=M,n.numSpotLightShadowsWithMaps=m,n.numLightProbes=R,E.directionalLength=p,E.pointLength=x,E.spotLength=v,E.rectAreaLength=y,E.hemiLength=_,E.numDirectionalShadows=S,E.numPointShadows=g,E.numSpotShadows=d,E.numSpotMaps=M,E.numLightProbes=R,n.version=BA++)}function c(l,u){let h=0,f=0,p=0,x=0,v=0,y=u.matrixWorldInverse;for(let _=0,S=l.length;_<S;_++){let g=l[_];if(g.isDirectionalLight){let d=n.directional[h];d.direction.setFromMatrixPosition(g.matrixWorld),i.setFromMatrixPosition(g.target.matrixWorld),d.direction.sub(i),d.direction.transformDirection(y),h++}else if(g.isSpotLight){let d=n.spot[p];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),d.direction.setFromMatrixPosition(g.matrixWorld),i.setFromMatrixPosition(g.target.matrixWorld),d.direction.sub(i),d.direction.transformDirection(y),p++}else if(g.isRectAreaLight){let d=n.rectArea[x];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),o.identity(),r.copy(g.matrixWorld),r.premultiply(y),o.extractRotation(r),d.halfWidth.set(g.width*.5,0,0),d.halfHeight.set(0,g.height*.5,0),d.halfWidth.applyMatrix4(o),d.halfHeight.applyMatrix4(o),x++}else if(g.isPointLight){let d=n.point[f];d.position.setFromMatrixPosition(g.matrixWorld),d.position.applyMatrix4(y),f++}else if(g.isHemisphereLight){let d=n.hemi[v];d.direction.setFromMatrixPosition(g.matrixWorld),d.direction.transformDirection(y),v++}}}return{setup:a,setupView:c,state:n}}function ry(s){let t=new kA(s),e=[],n=[];function i(u){l.camera=u,e.length=0,n.length=0}function r(u){e.push(u)}function o(u){n.push(u)}function a(){t.setup(e)}function c(u){t.setupView(e,u)}let l={lightsArray:e,shadowsArray:n,camera:null,lights:t,transmissionRenderTarget:{}};return{init:i,state:l,setupLights:a,setupLightsView:c,pushLight:r,pushShadow:o}}function HA(s){let t=new WeakMap;function e(i,r=0){let o=t.get(i),a;return o===void 0?(a=new ry(s),t.set(i,[a])):r>=o.length?(a=new ry(s),o.push(a)):a=o[r],a}function n(){t=new WeakMap}return{get:e,dispose:n}}var VA=`void main() {
|
|
3781
3781
|
gl_Position = vec4( position, 1.0 );
|
|
3782
3782
|
}`,GA=`uniform sampler2D shadow_pass;
|
|
3783
3783
|
uniform vec2 resolution;
|
|
@@ -3805,7 +3805,7 @@ void main() {
|
|
|
3805
3805
|
squared_mean = squared_mean / samples;
|
|
3806
3806
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3807
3807
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3808
|
-
}`;function WA(s,t,e){let n=new or,i=new nt,r=new nt,o=new Qt,a=new Bo({depthPacking:nm}),c=new zo,l={},u=e.maxTextureSize,h={[rn]:qe,[qe]:rn,[Ve]:Ve},f=new Cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new nt},radius:{value:4}},vertexShader:VA,fragmentShader:GA}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let x=new Vt;x.setAttribute("position",new kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new ce(x,f),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=af;let _=this.type;this.render=function(m,R,E){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||m.length===0)return;let T=s.getRenderTarget(),b=s.getActiveCubeFace(),w=s.getActiveMipmapLevel(),A=s.state;A.setBlending(Vi),A.buffers.depth.getReversed()===!0?A.buffers.color.setClear(0,0,0,0):A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);let C=_!==vi&&this.type===vi,D=_===vi&&this.type!==vi;for(let F=0,O=m.length;F<O;F++){let H=m[F],B=H.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",H,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;i.copy(B.mapSize);let $=B.getFrameExtents();if(i.multiply($),r.copy(B.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/$.x),i.x=r.x*$.x,B.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/$.y),i.y=r.y*$.y,B.mapSize.y=r.y)),B.map===null||C===!0||D===!0){let rt=this.type!==vi?{minFilter:De,magFilter:De}:{};B.map!==null&&B.map.dispose(),B.map=new Hn(i.x,i.y,rt),B.map.texture.name=H.name+".shadowMap",B.camera.updateProjectionMatrix()}s.setRenderTarget(B.map),s.clear();let at=B.getViewportCount();for(let rt=0;rt<at;rt++){let ht=B.getViewport(rt);o.set(r.x*ht.x,r.y*ht.y,r.x*ht.z,r.y*ht.w),A.viewport(o),B.updateMatrices(H,rt),n=B.getFrustum(),d(R,E,B.camera,H,this.type)}B.isPointLightShadow!==!0&&this.type===vi&&S(B,E),B.needsUpdate=!1}_=this.type,y.needsUpdate=!1,s.setRenderTarget(T,b,w)};function S(m,R){let E=t.update(v);f.defines.VSM_SAMPLES!==m.blurSamples&&(f.defines.VSM_SAMPLES=m.blurSamples,p.defines.VSM_SAMPLES=m.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),m.mapPass===null&&(m.mapPass=new Hn(i.x,i.y)),f.uniforms.shadow_pass.value=m.map.texture,f.uniforms.resolution.value=m.mapSize,f.uniforms.radius.value=m.radius,s.setRenderTarget(m.mapPass),s.clear(),s.renderBufferDirect(R,null,E,f,v,null),p.uniforms.shadow_pass.value=m.mapPass.texture,p.uniforms.resolution.value=m.mapSize,p.uniforms.radius.value=m.radius,s.setRenderTarget(m.map),s.clear(),s.renderBufferDirect(R,null,E,p,v,null)}function g(m,R,E,T){let b=null,w=E.isPointLight===!0?m.customDistanceMaterial:m.customDepthMaterial;if(w!==void 0)b=w;else if(b=E.isPointLight===!0?c:a,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let A=b.uuid,C=R.uuid,D=l[A];D===void 0&&(D={},l[A]=D);let F=D[C];F===void 0&&(F=b.clone(),D[C]=F,R.addEventListener("dispose",M)),b=F}if(b.visible=R.visible,b.wireframe=R.wireframe,T===vi?b.side=R.shadowSide!==null?R.shadowSide:R.side:b.side=R.shadowSide!==null?R.shadowSide:h[R.side],b.alphaMap=R.alphaMap,b.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,b.map=R.map,b.clipShadows=R.clipShadows,b.clippingPlanes=R.clippingPlanes,b.clipIntersection=R.clipIntersection,b.displacementMap=R.displacementMap,b.displacementScale=R.displacementScale,b.displacementBias=R.displacementBias,b.wireframeLinewidth=R.wireframeLinewidth,b.linewidth=R.linewidth,E.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let A=s.properties.get(b);A.light=E}return b}function d(m,R,E,T,b){if(m.visible===!1)return;if(m.layers.test(R.layers)&&(m.isMesh||m.isLine||m.isPoints)&&(m.castShadow||m.receiveShadow&&b===vi)&&(!m.frustumCulled||n.intersectsObject(m))){m.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,m.matrixWorld);let C=t.update(m),D=m.material;if(Array.isArray(D)){let F=C.groups;for(let O=0,H=F.length;O<H;O++){let B=F[O],$=D[B.materialIndex];if($&&$.visible){let at=g(m,$,T,b);m.onBeforeShadow(s,m,R,E,C,at,B),s.renderBufferDirect(E,null,C,at,m,B),m.onAfterShadow(s,m,R,E,C,at,B)}}}else if(D.visible){let F=g(m,D,T,b);m.onBeforeShadow(s,m,R,E,C,F,null),s.renderBufferDirect(E,null,C,F,m,null),m.onAfterShadow(s,m,R,E,C,F,null)}}let A=m.children;for(let C=0,D=A.length;C<D;C++)d(A[C],R,E,T,b)}function M(m){m.target.removeEventListener("dispose",M);for(let E in l){let T=l[E],b=m.target.uuid;b in T&&(T[b].dispose(),delete T[b])}}}var XA={[Zc]:Jc,[jc]:el,[Qc]:nl,[Ar]:tl,[Jc]:Zc,[el]:jc,[nl]:Qc,[tl]:Ar};function qA(s,t){function e(){let z=!1,gt=new Qt,St=null,Ut=new Qt(0,0,0,0);return{setMask:function(dt){St!==dt&&!z&&(s.colorMask(dt,dt,dt,dt),St=dt)},setLocked:function(dt){z=dt},setClear:function(dt,ot,Bt,Zt,Te){Te===!0&&(dt*=Zt,ot*=Zt,Bt*=Zt),gt.set(dt,ot,Bt,Zt),Ut.equals(gt)===!1&&(s.clearColor(dt,ot,Bt,Zt),Ut.copy(gt))},reset:function(){z=!1,St=null,Ut.set(-1,0,0,0)}}}function n(){let z=!1,gt=!1,St=null,Ut=null,dt=null;return{setReversed:function(ot){if(gt!==ot){let Bt=t.get("EXT_clip_control");ot?Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.ZERO_TO_ONE_EXT):Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.NEGATIVE_ONE_TO_ONE_EXT),gt=ot;let Zt=dt;dt=null,this.setClear(Zt)}},getReversed:function(){return gt},setTest:function(ot){ot?Q(s.DEPTH_TEST):ct(s.DEPTH_TEST)},setMask:function(ot){St!==ot&&!z&&(s.depthMask(ot),St=ot)},setFunc:function(ot){if(gt&&(ot=XA[ot]),Ut!==ot){switch(ot){case Zc:s.depthFunc(s.NEVER);break;case Jc:s.depthFunc(s.ALWAYS);break;case jc:s.depthFunc(s.LESS);break;case Ar:s.depthFunc(s.LEQUAL);break;case Qc:s.depthFunc(s.EQUAL);break;case tl:s.depthFunc(s.GEQUAL);break;case el:s.depthFunc(s.GREATER);break;case nl:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Ut=ot}},setLocked:function(ot){z=ot},setClear:function(ot){dt!==ot&&(gt&&(ot=1-ot),s.clearDepth(ot),dt=ot)},reset:function(){z=!1,St=null,Ut=null,dt=null,gt=!1}}}function i(){let z=!1,gt=null,St=null,Ut=null,dt=null,ot=null,Bt=null,Zt=null,Te=null;return{setTest:function(pe){z||(pe?Q(s.STENCIL_TEST):ct(s.STENCIL_TEST))},setMask:function(pe){gt!==pe&&!z&&(s.stencilMask(pe),gt=pe)},setFunc:function(pe,Zi,Ri){(St!==pe||Ut!==Zi||dt!==Ri)&&(s.stencilFunc(pe,Zi,Ri),St=pe,Ut=Zi,dt=Ri)},setOp:function(pe,Zi,Ri){(ot!==pe||Bt!==Zi||Zt!==Ri)&&(s.stencilOp(pe,Zi,Ri),ot=pe,Bt=Zi,Zt=Ri)},setLocked:function(pe){z=pe},setClear:function(pe){Te!==pe&&(s.clearStencil(pe),Te=pe)},reset:function(){z=!1,gt=null,St=null,Ut=null,dt=null,ot=null,Bt=null,Zt=null,Te=null}}}let r=new e,o=new n,a=new i,c=new WeakMap,l=new WeakMap,u={},h={},f=new WeakMap,p=[],x=null,v=!1,y=null,_=null,S=null,g=null,d=null,M=null,m=null,R=new yt(0,0,0),E=0,T=!1,b=null,w=null,A=null,C=null,D=null,F=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,H=0,B=s.getParameter(s.VERSION);B.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=H>=1):B.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=H>=2);let $=null,at={},rt=s.getParameter(s.SCISSOR_BOX),ht=s.getParameter(s.VIEWPORT),bt=new Qt().fromArray(rt),Et=new Qt().fromArray(ht);function Mt(z,gt,St,Ut){let dt=new Uint8Array(4),ot=s.createTexture();s.bindTexture(z,ot),s.texParameteri(z,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(z,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Bt=0;Bt<St;Bt++)z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?s.texImage3D(gt,0,s.RGBA,1,1,Ut,0,s.RGBA,s.UNSIGNED_BYTE,dt):s.texImage2D(gt+Bt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,dt);return ot}let K={};K[s.TEXTURE_2D]=Mt(s.TEXTURE_2D,s.TEXTURE_2D,1),K[s.TEXTURE_CUBE_MAP]=Mt(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[s.TEXTURE_2D_ARRAY]=Mt(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),K[s.TEXTURE_3D]=Mt(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Q(s.DEPTH_TEST),o.setFunc(Ar),Y(!1),q(of),Q(s.CULL_FACE),tt(Vi);function Q(z){u[z]!==!0&&(s.enable(z),u[z]=!0)}function ct(z){u[z]!==!1&&(s.disable(z),u[z]=!1)}function lt(z,gt){return h[z]!==gt?(s.bindFramebuffer(z,gt),h[z]=gt,z===s.DRAW_FRAMEBUFFER&&(h[s.FRAMEBUFFER]=gt),z===s.FRAMEBUFFER&&(h[s.DRAW_FRAMEBUFFER]=gt),!0):!1}function ut(z,gt){let St=p,Ut=!1;if(z){St=f.get(gt),St===void 0&&(St=[],f.set(gt,St));let dt=z.textures;if(St.length!==dt.length||St[0]!==s.COLOR_ATTACHMENT0){for(let ot=0,Bt=dt.length;ot<Bt;ot++)St[ot]=s.COLOR_ATTACHMENT0+ot;St.length=dt.length,Ut=!0}}else St[0]!==s.BACK&&(St[0]=s.BACK,Ut=!0);Ut&&s.drawBuffers(St)}function Ct(z){return x!==z?(s.useProgram(z),x=z,!0):!1}let Kt={[sr]:s.FUNC_ADD,[Ep]:s.FUNC_SUBTRACT,[wp]:s.FUNC_REVERSE_SUBTRACT};Kt[Ap]=s.MIN,Kt[Rp]=s.MAX;let U={[Cp]:s.ZERO,[Ip]:s.ONE,[Pp]:s.SRC_COLOR,[$a]:s.SRC_ALPHA,[Op]:s.SRC_ALPHA_SATURATE,[Up]:s.DST_COLOR,[Np]:s.DST_ALPHA,[Lp]:s.ONE_MINUS_SRC_COLOR,[Ka]:s.ONE_MINUS_SRC_ALPHA,[Fp]:s.ONE_MINUS_DST_COLOR,[Dp]:s.ONE_MINUS_DST_ALPHA,[Bp]:s.CONSTANT_COLOR,[zp]:s.ONE_MINUS_CONSTANT_COLOR,[kp]:s.CONSTANT_ALPHA,[Hp]:s.ONE_MINUS_CONSTANT_ALPHA};function tt(z,gt,St,Ut,dt,ot,Bt,Zt,Te,pe){if(z===Vi){v===!0&&(ct(s.BLEND),v=!1);return}if(v===!1&&(Q(s.BLEND),v=!0),z!==Tp){if(z!==y||pe!==T){if((_!==sr||d!==sr)&&(s.blendEquation(s.FUNC_ADD),_=sr,d=sr),pe)switch(z){case wr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cf:s.blendFunc(s.ONE,s.ONE);break;case lf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case uf:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case wr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cf:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case lf:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case uf:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}S=null,g=null,M=null,m=null,R.set(0,0,0),E=0,y=z,T=pe}return}dt=dt||gt,ot=ot||St,Bt=Bt||Ut,(gt!==_||dt!==d)&&(s.blendEquationSeparate(Kt[gt],Kt[dt]),_=gt,d=dt),(St!==S||Ut!==g||ot!==M||Bt!==m)&&(s.blendFuncSeparate(U[St],U[Ut],U[ot],U[Bt]),S=St,g=Ut,M=ot,m=Bt),(Zt.equals(R)===!1||Te!==E)&&(s.blendColor(Zt.r,Zt.g,Zt.b,Te),R.copy(Zt),E=Te),y=z,T=!1}function Z(z,gt){z.side===Ve?ct(s.CULL_FACE):Q(s.CULL_FACE);let St=z.side===qe;gt&&(St=!St),Y(St),z.blending===wr&&z.transparent===!1?tt(Vi):tt(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),o.setFunc(z.depthFunc),o.setTest(z.depthTest),o.setMask(z.depthWrite),r.setMask(z.colorWrite);let Ut=z.stencilWrite;a.setTest(Ut),Ut&&(a.setMask(z.stencilWriteMask),a.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),a.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),it(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?Q(s.SAMPLE_ALPHA_TO_COVERAGE):ct(s.SAMPLE_ALPHA_TO_COVERAGE)}function Y(z){b!==z&&(z?s.frontFace(s.CW):s.frontFace(s.CCW),b=z)}function q(z){z!==Mp?(Q(s.CULL_FACE),z!==w&&(z===of?s.cullFace(s.BACK):z===Sp?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):ct(s.CULL_FACE),w=z}function mt(z){z!==A&&(O&&s.lineWidth(z),A=z)}function it(z,gt,St){z?(Q(s.POLYGON_OFFSET_FILL),(C!==gt||D!==St)&&(s.polygonOffset(gt,St),C=gt,D=St)):ct(s.POLYGON_OFFSET_FILL)}function st(z){z?Q(s.SCISSOR_TEST):ct(s.SCISSOR_TEST)}function Pt(z){z===void 0&&(z=s.TEXTURE0+F-1),$!==z&&(s.activeTexture(z),$=z)}function It(z,gt,St){St===void 0&&($===null?St=s.TEXTURE0+F-1:St=$);let Ut=at[St];Ut===void 0&&(Ut={type:void 0,texture:void 0},at[St]=Ut),(Ut.type!==z||Ut.texture!==gt)&&($!==St&&(s.activeTexture(St),$=St),s.bindTexture(z,gt||K[z]),Ut.type=z,Ut.texture=gt)}function N(){let z=at[$];z!==void 0&&z.type!==void 0&&(s.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function P(){try{s.compressedTexImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function k(){try{s.compressedTexImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function W(){try{s.texSubImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function et(){try{s.texSubImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function _t(){try{s.compressedTexSubImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function xt(){try{s.texStorage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ft(){try{s.texStorage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Dt(){try{s.texImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ft(){try{s.texImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Rt(z){bt.equals(z)===!1&&(s.scissor(z.x,z.y,z.z,z.w),bt.copy(z))}function qt(z){Et.equals(z)===!1&&(s.viewport(z.x,z.y,z.z,z.w),Et.copy(z))}function zt(z,gt){let St=l.get(gt);St===void 0&&(St=new WeakMap,l.set(gt,St));let Ut=St.get(z);Ut===void 0&&(Ut=s.getUniformBlockIndex(gt,z.name),St.set(z,Ut))}function wt(z,gt){let Ut=l.get(gt).get(z);c.get(gt)!==Ut&&(s.uniformBlockBinding(gt,Ut,z.__bindingPointIndex),c.set(gt,Ut))}function jt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),o.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),u={},$=null,at={},h={},f=new WeakMap,p=[],x=null,v=!1,y=null,_=null,S=null,g=null,d=null,M=null,m=null,R=new yt(0,0,0),E=0,T=!1,b=null,w=null,A=null,C=null,D=null,bt.set(0,0,s.canvas.width,s.canvas.height),Et.set(0,0,s.canvas.width,s.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:Q,disable:ct,bindFramebuffer:lt,drawBuffers:ut,useProgram:Ct,setBlending:tt,setMaterial:Z,setFlipSided:Y,setCullFace:q,setLineWidth:mt,setPolygonOffset:it,setScissorTest:st,activeTexture:Pt,bindTexture:It,unbindTexture:N,compressedTexImage2D:P,compressedTexImage3D:k,texImage2D:Dt,texImage3D:ft,updateUBOMapping:zt,uniformBlockBinding:wt,texStorage2D:xt,texStorage3D:Ft,texSubImage2D:W,texSubImage3D:et,compressedTexSubImage2D:X,compressedTexSubImage3D:_t,scissor:Rt,viewport:qt,reset:jt}}function YA(s,t,e,n,i,r,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new nt,u=new WeakMap,h,f=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(N,P){return p?new OffscreenCanvas(N,P):yo("canvas")}function v(N,P,k){let W=1,et=It(N);if((et.width>k||et.height>k)&&(W=k/Math.max(et.width,et.height)),W<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){let X=Math.floor(W*et.width),_t=Math.floor(W*et.height);h===void 0&&(h=x(X,_t));let xt=P?x(X,_t):h;return xt.width=X,xt.height=_t,xt.getContext("2d").drawImage(N,0,0,X,_t),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+et.width+"x"+et.height+") to ("+X+"x"+_t+")."),xt}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+et.width+"x"+et.height+")."),N;return N}function y(N){return N.generateMipmaps}function _(N){s.generateMipmap(N)}function S(N){return N.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?s.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function g(N,P,k,W,et=!1){if(N!==null){if(s[N]!==void 0)return s[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let X=P;if(P===s.RED&&(k===s.FLOAT&&(X=s.R32F),k===s.HALF_FLOAT&&(X=s.R16F),k===s.UNSIGNED_BYTE&&(X=s.R8)),P===s.RED_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.R8UI),k===s.UNSIGNED_SHORT&&(X=s.R16UI),k===s.UNSIGNED_INT&&(X=s.R32UI),k===s.BYTE&&(X=s.R8I),k===s.SHORT&&(X=s.R16I),k===s.INT&&(X=s.R32I)),P===s.RG&&(k===s.FLOAT&&(X=s.RG32F),k===s.HALF_FLOAT&&(X=s.RG16F),k===s.UNSIGNED_BYTE&&(X=s.RG8)),P===s.RG_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RG8UI),k===s.UNSIGNED_SHORT&&(X=s.RG16UI),k===s.UNSIGNED_INT&&(X=s.RG32UI),k===s.BYTE&&(X=s.RG8I),k===s.SHORT&&(X=s.RG16I),k===s.INT&&(X=s.RG32I)),P===s.RGB_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RGB8UI),k===s.UNSIGNED_SHORT&&(X=s.RGB16UI),k===s.UNSIGNED_INT&&(X=s.RGB32UI),k===s.BYTE&&(X=s.RGB8I),k===s.SHORT&&(X=s.RGB16I),k===s.INT&&(X=s.RGB32I)),P===s.RGBA_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RGBA8UI),k===s.UNSIGNED_SHORT&&(X=s.RGBA16UI),k===s.UNSIGNED_INT&&(X=s.RGBA32UI),k===s.BYTE&&(X=s.RGBA8I),k===s.SHORT&&(X=s.RGBA16I),k===s.INT&&(X=s.RGBA32I)),P===s.RGB&&(k===s.UNSIGNED_INT_5_9_9_9_REV&&(X=s.RGB9_E5),k===s.UNSIGNED_INT_10F_11F_11F_REV&&(X=s.R11F_G11F_B10F)),P===s.RGBA){let _t=et?xo:ie.getTransfer(W);k===s.FLOAT&&(X=s.RGBA32F),k===s.HALF_FLOAT&&(X=s.RGBA16F),k===s.UNSIGNED_BYTE&&(X=_t===ge?s.SRGB8_ALPHA8:s.RGBA8),k===s.UNSIGNED_SHORT_4_4_4_4&&(X=s.RGBA4),k===s.UNSIGNED_SHORT_5_5_5_1&&(X=s.RGB5_A1)}return(X===s.R16F||X===s.R32F||X===s.RG16F||X===s.RG32F||X===s.RGBA16F||X===s.RGBA32F)&&t.get("EXT_color_buffer_float"),X}function d(N,P){let k;return N?P===null||P===qi||P===As?k=s.DEPTH24_STENCIL8:P===xn?k=s.DEPTH32F_STENCIL8:P===Es&&(k=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===qi||P===As?k=s.DEPTH_COMPONENT24:P===xn?k=s.DEPTH_COMPONENT32F:P===Es&&(k=s.DEPTH_COMPONENT16),k}function M(N,P){return y(N)===!0||N.isFramebufferTexture&&N.minFilter!==De&&N.minFilter!==Ee?Math.log2(Math.max(P.width,P.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?P.mipmaps.length:1}function m(N){let P=N.target;P.removeEventListener("dispose",m),E(P),P.isVideoTexture&&u.delete(P)}function R(N){let P=N.target;P.removeEventListener("dispose",R),b(P)}function E(N){let P=n.get(N);if(P.__webglInit===void 0)return;let k=N.source,W=f.get(k);if(W){let et=W[P.__cacheKey];et.usedTimes--,et.usedTimes===0&&T(N),Object.keys(W).length===0&&f.delete(k)}n.remove(N)}function T(N){let P=n.get(N);s.deleteTexture(P.__webglTexture);let k=N.source,W=f.get(k);delete W[P.__cacheKey],o.memory.textures--}function b(N){let P=n.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),n.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(P.__webglFramebuffer[W]))for(let et=0;et<P.__webglFramebuffer[W].length;et++)s.deleteFramebuffer(P.__webglFramebuffer[W][et]);else s.deleteFramebuffer(P.__webglFramebuffer[W]);P.__webglDepthbuffer&&s.deleteRenderbuffer(P.__webglDepthbuffer[W])}else{if(Array.isArray(P.__webglFramebuffer))for(let W=0;W<P.__webglFramebuffer.length;W++)s.deleteFramebuffer(P.__webglFramebuffer[W]);else s.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&s.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&s.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let W=0;W<P.__webglColorRenderbuffer.length;W++)P.__webglColorRenderbuffer[W]&&s.deleteRenderbuffer(P.__webglColorRenderbuffer[W]);P.__webglDepthRenderbuffer&&s.deleteRenderbuffer(P.__webglDepthRenderbuffer)}let k=N.textures;for(let W=0,et=k.length;W<et;W++){let X=n.get(k[W]);X.__webglTexture&&(s.deleteTexture(X.__webglTexture),o.memory.textures--),n.remove(k[W])}n.remove(N)}let w=0;function A(){w=0}function C(){let N=w;return N>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+i.maxTextures),w+=1,N}function D(N){let P=[];return P.push(N.wrapS),P.push(N.wrapT),P.push(N.wrapR||0),P.push(N.magFilter),P.push(N.minFilter),P.push(N.anisotropy),P.push(N.internalFormat),P.push(N.format),P.push(N.type),P.push(N.generateMipmaps),P.push(N.premultiplyAlpha),P.push(N.flipY),P.push(N.unpackAlignment),P.push(N.colorSpace),P.join()}function F(N,P){let k=n.get(N);if(N.isVideoTexture&&st(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&k.__version!==N.version){let W=N.image;if(W===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(k,N,P);return}}else N.isExternalTexture&&(k.__webglTexture=N.sourceTexture?N.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,k.__webglTexture,s.TEXTURE0+P)}function O(N,P){let k=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&k.__version!==N.version){K(k,N,P);return}e.bindTexture(s.TEXTURE_2D_ARRAY,k.__webglTexture,s.TEXTURE0+P)}function H(N,P){let k=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&k.__version!==N.version){K(k,N,P);return}e.bindTexture(s.TEXTURE_3D,k.__webglTexture,s.TEXTURE0+P)}function B(N,P){let k=n.get(N);if(N.version>0&&k.__version!==N.version){Q(k,N,P);return}e.bindTexture(s.TEXTURE_CUBE_MAP,k.__webglTexture,s.TEXTURE0+P)}let $={[An]:s.REPEAT,[en]:s.CLAMP_TO_EDGE,[Li]:s.MIRRORED_REPEAT},at={[De]:s.NEAREST,[Nr]:s.NEAREST_MIPMAP_NEAREST,[Mi]:s.NEAREST_MIPMAP_LINEAR,[Ee]:s.LINEAR,[Xi]:s.LINEAR_MIPMAP_NEAREST,[un]:s.LINEAR_MIPMAP_LINEAR},rt={[rm]:s.NEVER,[um]:s.ALWAYS,[sm]:s.LESS,[vf]:s.LEQUAL,[om]:s.EQUAL,[lm]:s.GEQUAL,[am]:s.GREATER,[cm]:s.NOTEQUAL};function ht(N,P){if(P.type===xn&&t.has("OES_texture_float_linear")===!1&&(P.magFilter===Ee||P.magFilter===Xi||P.magFilter===Mi||P.magFilter===un||P.minFilter===Ee||P.minFilter===Xi||P.minFilter===Mi||P.minFilter===un)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(N,s.TEXTURE_WRAP_S,$[P.wrapS]),s.texParameteri(N,s.TEXTURE_WRAP_T,$[P.wrapT]),(N===s.TEXTURE_3D||N===s.TEXTURE_2D_ARRAY)&&s.texParameteri(N,s.TEXTURE_WRAP_R,$[P.wrapR]),s.texParameteri(N,s.TEXTURE_MAG_FILTER,at[P.magFilter]),s.texParameteri(N,s.TEXTURE_MIN_FILTER,at[P.minFilter]),P.compareFunction&&(s.texParameteri(N,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(N,s.TEXTURE_COMPARE_FUNC,rt[P.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===De||P.minFilter!==Mi&&P.minFilter!==un||P.type===xn&&t.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||n.get(P).__currentAnisotropy){let k=t.get("EXT_texture_filter_anisotropic");s.texParameterf(N,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,i.getMaxAnisotropy())),n.get(P).__currentAnisotropy=P.anisotropy}}}function bt(N,P){let k=!1;N.__webglInit===void 0&&(N.__webglInit=!0,P.addEventListener("dispose",m));let W=P.source,et=f.get(W);et===void 0&&(et={},f.set(W,et));let X=D(P);if(X!==N.__cacheKey){et[X]===void 0&&(et[X]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,k=!0),et[X].usedTimes++;let _t=et[N.__cacheKey];_t!==void 0&&(et[N.__cacheKey].usedTimes--,_t.usedTimes===0&&T(P)),N.__cacheKey=X,N.__webglTexture=et[X].texture}return k}function Et(N,P,k){return Math.floor(Math.floor(N/k)/P)}function Mt(N,P,k,W){let X=N.updateRanges;if(X.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,P.width,P.height,k,W,P.data);else{X.sort((ft,Rt)=>ft.start-Rt.start);let _t=0;for(let ft=1;ft<X.length;ft++){let Rt=X[_t],qt=X[ft],zt=Rt.start+Rt.count,wt=Et(qt.start,P.width,4),jt=Et(Rt.start,P.width,4);qt.start<=zt+1&&wt===jt&&Et(qt.start+qt.count-1,P.width,4)===wt?Rt.count=Math.max(Rt.count,qt.start+qt.count-Rt.start):(++_t,X[_t]=qt)}X.length=_t+1;let xt=s.getParameter(s.UNPACK_ROW_LENGTH),Ft=s.getParameter(s.UNPACK_SKIP_PIXELS),Dt=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,P.width);for(let ft=0,Rt=X.length;ft<Rt;ft++){let qt=X[ft],zt=Math.floor(qt.start/4),wt=Math.ceil(qt.count/4),jt=zt%P.width,z=Math.floor(zt/P.width),gt=wt,St=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,jt),s.pixelStorei(s.UNPACK_SKIP_ROWS,z),e.texSubImage2D(s.TEXTURE_2D,0,jt,z,gt,St,k,W,P.data)}N.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,xt),s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ft),s.pixelStorei(s.UNPACK_SKIP_ROWS,Dt)}}function K(N,P,k){let W=s.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(W=s.TEXTURE_2D_ARRAY),P.isData3DTexture&&(W=s.TEXTURE_3D);let et=bt(N,P),X=P.source;e.bindTexture(W,N.__webglTexture,s.TEXTURE0+k);let _t=n.get(X);if(X.version!==_t.__version||et===!0){e.activeTexture(s.TEXTURE0+k);let xt=ie.getPrimaries(ie.workingColorSpace),Ft=P.colorSpace===si?null:ie.getPrimaries(P.colorSpace),Dt=P.colorSpace===si||xt===Ft?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,P.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,P.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Dt);let ft=v(P.image,!1,i.maxTextureSize);ft=Pt(P,ft);let Rt=r.convert(P.format,P.colorSpace),qt=r.convert(P.type),zt=g(P.internalFormat,Rt,qt,P.colorSpace,P.isVideoTexture);ht(W,P);let wt,jt=P.mipmaps,z=P.isVideoTexture!==!0,gt=_t.__version===void 0||et===!0,St=X.dataReady,Ut=M(P,ft);if(P.isDepthTexture)zt=d(P.format===Rs,P.type),gt&&(z?e.texStorage2D(s.TEXTURE_2D,1,zt,ft.width,ft.height):e.texImage2D(s.TEXTURE_2D,0,zt,ft.width,ft.height,0,Rt,qt,null));else if(P.isDataTexture)if(jt.length>0){z&>&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,jt[0].width,jt[0].height);for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,qt,wt.data):e.texImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,Rt,qt,wt.data);P.generateMipmaps=!1}else z?(gt&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,ft.width,ft.height),St&&Mt(P,ft,Rt,qt)):e.texImage2D(s.TEXTURE_2D,0,zt,ft.width,ft.height,0,Rt,qt,ft.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){z&>&&e.texStorage3D(s.TEXTURE_2D_ARRAY,Ut,zt,jt[0].width,jt[0].height,ft.depth);for(let dt=0,ot=jt.length;dt<ot;dt++)if(wt=jt[dt],P.format!==Qe)if(Rt!==null)if(z){if(St)if(P.layerUpdates.size>0){let Bt=Sf(wt.width,wt.height,P.format,P.type);for(let Zt of P.layerUpdates){let Te=wt.data.subarray(Zt*Bt/wt.data.BYTES_PER_ELEMENT,(Zt+1)*Bt/wt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,Zt,wt.width,wt.height,1,Rt,Te)}P.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,0,wt.width,wt.height,ft.depth,Rt,wt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,dt,zt,wt.width,wt.height,ft.depth,0,wt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?St&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,0,wt.width,wt.height,ft.depth,Rt,qt,wt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,dt,zt,wt.width,wt.height,ft.depth,0,Rt,qt,wt.data)}else{z&>&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,jt[0].width,jt[0].height);for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],P.format!==Qe?Rt!==null?z?St&&e.compressedTexSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,wt.data):e.compressedTexImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,wt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,qt,wt.data):e.texImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,Rt,qt,wt.data)}else if(P.isDataArrayTexture)if(z){if(gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,Ut,zt,ft.width,ft.height,ft.depth),St)if(P.layerUpdates.size>0){let dt=Sf(ft.width,ft.height,P.format,P.type);for(let ot of P.layerUpdates){let Bt=ft.data.subarray(ot*dt/ft.data.BYTES_PER_ELEMENT,(ot+1)*dt/ft.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ot,ft.width,ft.height,1,Rt,qt,Bt)}P.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,ft.width,ft.height,ft.depth,Rt,qt,ft.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,zt,ft.width,ft.height,ft.depth,0,Rt,qt,ft.data);else if(P.isData3DTexture)z?(gt&&e.texStorage3D(s.TEXTURE_3D,Ut,zt,ft.width,ft.height,ft.depth),St&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,ft.width,ft.height,ft.depth,Rt,qt,ft.data)):e.texImage3D(s.TEXTURE_3D,0,zt,ft.width,ft.height,ft.depth,0,Rt,qt,ft.data);else if(P.isFramebufferTexture){if(gt)if(z)e.texStorage2D(s.TEXTURE_2D,Ut,zt,ft.width,ft.height);else{let dt=ft.width,ot=ft.height;for(let Bt=0;Bt<Ut;Bt++)e.texImage2D(s.TEXTURE_2D,Bt,zt,dt,ot,0,Rt,qt,null),dt>>=1,ot>>=1}}else if(jt.length>0){if(z&>){let dt=It(jt[0]);e.texStorage2D(s.TEXTURE_2D,Ut,zt,dt.width,dt.height)}for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,Rt,qt,wt):e.texImage2D(s.TEXTURE_2D,dt,zt,Rt,qt,wt);P.generateMipmaps=!1}else if(z){if(gt){let dt=It(ft);e.texStorage2D(s.TEXTURE_2D,Ut,zt,dt.width,dt.height)}St&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,Rt,qt,ft)}else e.texImage2D(s.TEXTURE_2D,0,zt,Rt,qt,ft);y(P)&&_(W),_t.__version=X.version,P.onUpdate&&P.onUpdate(P)}N.__version=P.version}function Q(N,P,k){if(P.image.length!==6)return;let W=bt(N,P),et=P.source;e.bindTexture(s.TEXTURE_CUBE_MAP,N.__webglTexture,s.TEXTURE0+k);let X=n.get(et);if(et.version!==X.__version||W===!0){e.activeTexture(s.TEXTURE0+k);let _t=ie.getPrimaries(ie.workingColorSpace),xt=P.colorSpace===si?null:ie.getPrimaries(P.colorSpace),Ft=P.colorSpace===si||_t===xt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,P.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,P.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ft);let Dt=P.isCompressedTexture||P.image[0].isCompressedTexture,ft=P.image[0]&&P.image[0].isDataTexture,Rt=[];for(let ot=0;ot<6;ot++)!Dt&&!ft?Rt[ot]=v(P.image[ot],!0,i.maxCubemapSize):Rt[ot]=ft?P.image[ot].image:P.image[ot],Rt[ot]=Pt(P,Rt[ot]);let qt=Rt[0],zt=r.convert(P.format,P.colorSpace),wt=r.convert(P.type),jt=g(P.internalFormat,zt,wt,P.colorSpace),z=P.isVideoTexture!==!0,gt=X.__version===void 0||W===!0,St=et.dataReady,Ut=M(P,qt);ht(s.TEXTURE_CUBE_MAP,P);let dt;if(Dt){z&>&&e.texStorage2D(s.TEXTURE_CUBE_MAP,Ut,jt,qt.width,qt.height);for(let ot=0;ot<6;ot++){dt=Rt[ot].mipmaps;for(let Bt=0;Bt<dt.length;Bt++){let Zt=dt[Bt];P.format!==Qe?zt!==null?z?St&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,0,0,Zt.width,Zt.height,zt,Zt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,jt,Zt.width,Zt.height,0,Zt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,0,0,Zt.width,Zt.height,zt,wt,Zt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,jt,Zt.width,Zt.height,0,zt,wt,Zt.data)}}}else{if(dt=P.mipmaps,z&>){dt.length>0&&Ut++;let ot=It(Rt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,Ut,jt,ot.width,ot.height)}for(let ot=0;ot<6;ot++)if(ft){z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,Rt[ot].width,Rt[ot].height,zt,wt,Rt[ot].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jt,Rt[ot].width,Rt[ot].height,0,zt,wt,Rt[ot].data);for(let Bt=0;Bt<dt.length;Bt++){let Te=dt[Bt].image[ot].image;z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,0,0,Te.width,Te.height,zt,wt,Te.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,jt,Te.width,Te.height,0,zt,wt,Te.data)}}else{z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,zt,wt,Rt[ot]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jt,zt,wt,Rt[ot]);for(let Bt=0;Bt<dt.length;Bt++){let Zt=dt[Bt];z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,0,0,zt,wt,Zt.image[ot]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,jt,zt,wt,Zt.image[ot])}}}y(P)&&_(s.TEXTURE_CUBE_MAP),X.__version=et.version,P.onUpdate&&P.onUpdate(P)}N.__version=P.version}function ct(N,P,k,W,et,X){let _t=r.convert(k.format,k.colorSpace),xt=r.convert(k.type),Ft=g(k.internalFormat,_t,xt,k.colorSpace),Dt=n.get(P),ft=n.get(k);if(ft.__renderTarget=P,!Dt.__hasExternalTextures){let Rt=Math.max(1,P.width>>X),qt=Math.max(1,P.height>>X);et===s.TEXTURE_3D||et===s.TEXTURE_2D_ARRAY?e.texImage3D(et,X,Ft,Rt,qt,P.depth,0,_t,xt,null):e.texImage2D(et,X,Ft,Rt,qt,0,_t,xt,null)}e.bindFramebuffer(s.FRAMEBUFFER,N),it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,W,et,ft.__webglTexture,0,mt(P)):(et===s.TEXTURE_2D||et>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&et<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,W,et,ft.__webglTexture,X),e.bindFramebuffer(s.FRAMEBUFFER,null)}function lt(N,P,k){if(s.bindRenderbuffer(s.RENDERBUFFER,N),P.depthBuffer){let W=P.depthTexture,et=W&&W.isDepthTexture?W.type:null,X=d(P.stencilBuffer,et),_t=P.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,xt=mt(P);it(P)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,xt,X,P.width,P.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,xt,X,P.width,P.height):s.renderbufferStorage(s.RENDERBUFFER,X,P.width,P.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,_t,s.RENDERBUFFER,N)}else{let W=P.textures;for(let et=0;et<W.length;et++){let X=W[et],_t=r.convert(X.format,X.colorSpace),xt=r.convert(X.type),Ft=g(X.internalFormat,_t,xt,X.colorSpace),Dt=mt(P);k&&it(P)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Dt,Ft,P.width,P.height):it(P)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Dt,Ft,P.width,P.height):s.renderbufferStorage(s.RENDERBUFFER,Ft,P.width,P.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function ut(N,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(s.FRAMEBUFFER,N),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let W=n.get(P.depthTexture);W.__renderTarget=P,(!W.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),F(P.depthTexture,0);let et=W.__webglTexture,X=mt(P);if(P.depthTexture.format===rs)it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,et,0,X):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,et,0);else if(P.depthTexture.format===Rs)it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,et,0,X):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,et,0);else throw new Error("Unknown depthTexture format")}function Ct(N){let P=n.get(N),k=N.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==N.depthTexture){let W=N.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),W){let et=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,W.removeEventListener("dispose",et)};W.addEventListener("dispose",et),P.__depthDisposeCallback=et}P.__boundDepthTexture=W}if(N.depthTexture&&!P.__autoAllocateDepthBuffer){if(k)throw new Error("target.depthTexture not supported in Cube render targets");let W=N.texture.mipmaps;W&&W.length>0?ut(P.__webglFramebuffer[0],N):ut(P.__webglFramebuffer,N)}else if(k){P.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer[W]),P.__webglDepthbuffer[W]===void 0)P.__webglDepthbuffer[W]=s.createRenderbuffer(),lt(P.__webglDepthbuffer[W],N,!1);else{let et=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,X=P.__webglDepthbuffer[W];s.bindRenderbuffer(s.RENDERBUFFER,X),s.framebufferRenderbuffer(s.FRAMEBUFFER,et,s.RENDERBUFFER,X)}}else{let W=N.texture.mipmaps;if(W&&W.length>0?e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=s.createRenderbuffer(),lt(P.__webglDepthbuffer,N,!1);else{let et=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,X=P.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,X),s.framebufferRenderbuffer(s.FRAMEBUFFER,et,s.RENDERBUFFER,X)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Kt(N,P,k){let W=n.get(N);P!==void 0&&ct(W.__webglFramebuffer,N,N.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),k!==void 0&&Ct(N)}function U(N){let P=N.texture,k=n.get(N),W=n.get(P);N.addEventListener("dispose",R);let et=N.textures,X=N.isWebGLCubeRenderTarget===!0,_t=et.length>1;if(_t||(W.__webglTexture===void 0&&(W.__webglTexture=s.createTexture()),W.__version=P.version,o.memory.textures++),X){k.__webglFramebuffer=[];for(let xt=0;xt<6;xt++)if(P.mipmaps&&P.mipmaps.length>0){k.__webglFramebuffer[xt]=[];for(let Ft=0;Ft<P.mipmaps.length;Ft++)k.__webglFramebuffer[xt][Ft]=s.createFramebuffer()}else k.__webglFramebuffer[xt]=s.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){k.__webglFramebuffer=[];for(let xt=0;xt<P.mipmaps.length;xt++)k.__webglFramebuffer[xt]=s.createFramebuffer()}else k.__webglFramebuffer=s.createFramebuffer();if(_t)for(let xt=0,Ft=et.length;xt<Ft;xt++){let Dt=n.get(et[xt]);Dt.__webglTexture===void 0&&(Dt.__webglTexture=s.createTexture(),o.memory.textures++)}if(N.samples>0&&it(N)===!1){k.__webglMultisampledFramebuffer=s.createFramebuffer(),k.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let xt=0;xt<et.length;xt++){let Ft=et[xt];k.__webglColorRenderbuffer[xt]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,k.__webglColorRenderbuffer[xt]);let Dt=r.convert(Ft.format,Ft.colorSpace),ft=r.convert(Ft.type),Rt=g(Ft.internalFormat,Dt,ft,Ft.colorSpace,N.isXRRenderTarget===!0),qt=mt(N);s.renderbufferStorageMultisample(s.RENDERBUFFER,qt,Rt,N.width,N.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+xt,s.RENDERBUFFER,k.__webglColorRenderbuffer[xt])}s.bindRenderbuffer(s.RENDERBUFFER,null),N.depthBuffer&&(k.__webglDepthRenderbuffer=s.createRenderbuffer(),lt(k.__webglDepthRenderbuffer,N,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(X){e.bindTexture(s.TEXTURE_CUBE_MAP,W.__webglTexture),ht(s.TEXTURE_CUBE_MAP,P);for(let xt=0;xt<6;xt++)if(P.mipmaps&&P.mipmaps.length>0)for(let Ft=0;Ft<P.mipmaps.length;Ft++)ct(k.__webglFramebuffer[xt][Ft],N,P,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+xt,Ft);else ct(k.__webglFramebuffer[xt],N,P,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+xt,0);y(P)&&_(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(_t){for(let xt=0,Ft=et.length;xt<Ft;xt++){let Dt=et[xt],ft=n.get(Dt),Rt=s.TEXTURE_2D;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(Rt=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(Rt,ft.__webglTexture),ht(Rt,Dt),ct(k.__webglFramebuffer,N,Dt,s.COLOR_ATTACHMENT0+xt,Rt,0),y(Dt)&&_(Rt)}e.unbindTexture()}else{let xt=s.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(xt=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(xt,W.__webglTexture),ht(xt,P),P.mipmaps&&P.mipmaps.length>0)for(let Ft=0;Ft<P.mipmaps.length;Ft++)ct(k.__webglFramebuffer[Ft],N,P,s.COLOR_ATTACHMENT0,xt,Ft);else ct(k.__webglFramebuffer,N,P,s.COLOR_ATTACHMENT0,xt,0);y(P)&&_(xt),e.unbindTexture()}N.depthBuffer&&Ct(N)}function tt(N){let P=N.textures;for(let k=0,W=P.length;k<W;k++){let et=P[k];if(y(et)){let X=S(N),_t=n.get(et).__webglTexture;e.bindTexture(X,_t),_(X),e.unbindTexture()}}}let Z=[],Y=[];function q(N){if(N.samples>0){if(it(N)===!1){let P=N.textures,k=N.width,W=N.height,et=s.COLOR_BUFFER_BIT,X=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,_t=n.get(N),xt=P.length>1;if(xt)for(let Dt=0;Dt<P.length;Dt++)e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,_t.__webglMultisampledFramebuffer);let Ft=N.texture.mipmaps;Ft&&Ft.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglFramebuffer);for(let Dt=0;Dt<P.length;Dt++){if(N.resolveDepthBuffer&&(N.depthBuffer&&(et|=s.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&(et|=s.STENCIL_BUFFER_BIT)),xt){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,_t.__webglColorRenderbuffer[Dt]);let ft=n.get(P[Dt]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,ft,0)}s.blitFramebuffer(0,0,k,W,0,0,k,W,et,s.NEAREST),c===!0&&(Z.length=0,Y.length=0,Z.push(s.COLOR_ATTACHMENT0+Dt),N.depthBuffer&&N.resolveDepthBuffer===!1&&(Z.push(X),Y.push(X),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Y)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,Z))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),xt)for(let Dt=0;Dt<P.length;Dt++){e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.RENDERBUFFER,_t.__webglColorRenderbuffer[Dt]);let ft=n.get(P[Dt]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.TEXTURE_2D,ft,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&c){let P=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[P])}}}function mt(N){return Math.min(i.maxSamples,N.samples)}function it(N){let P=n.get(N);return N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function st(N){let P=o.render.frame;u.get(N)!==P&&(u.set(N,P),N.update())}function Pt(N,P){let k=N.colorSpace,W=N.format,et=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||k!==tn&&k!==si&&(ie.getTransfer(k)===ge?(W!==Qe||et!==ri)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),P}function It(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(l.width=N.naturalWidth||N.width,l.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(l.width=N.displayWidth,l.height=N.displayHeight):(l.width=N.width,l.height=N.height),l}this.allocateTextureUnit=C,this.resetTextureUnits=A,this.setTexture2D=F,this.setTexture2DArray=O,this.setTexture3D=H,this.setTextureCube=B,this.rebindTextures=Kt,this.setupRenderTarget=U,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Ct,this.setupFrameBufferTexture=ct,this.useMultisampledRTT=it}function uy(s,t){function e(n,i=si){let r,o=ie.getTransfer(i);if(n===ri)return s.UNSIGNED_BYTE;if(n===sl)return s.UNSIGNED_SHORT_4_4_4_4;if(n===ol)return s.UNSIGNED_SHORT_5_5_5_1;if(n===df)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===pf)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===hf)return s.BYTE;if(n===ff)return s.SHORT;if(n===Es)return s.UNSIGNED_SHORT;if(n===rl)return s.INT;if(n===qi)return s.UNSIGNED_INT;if(n===xn)return s.FLOAT;if(n===ws)return s.HALF_FLOAT;if(n===mf)return s.ALPHA;if(n===gf)return s.RGB;if(n===Qe)return s.RGBA;if(n===rs)return s.DEPTH_COMPONENT;if(n===Rs)return s.DEPTH_STENCIL;if(n===al)return s.RED;if(n===Ko)return s.RED_INTEGER;if(n===xf)return s.RG;if(n===cl)return s.RG_INTEGER;if(n===ll)return s.RGBA_INTEGER;if(n===Zo||n===Jo||n===jo||n===Qo)if(o===ge)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Zo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Qo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Zo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Jo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===jo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Qo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ul||n===hl||n===fl||n===dl)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ul)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===hl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===dl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===pl||n===ml||n===gl)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===pl||n===ml)return o===ge?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===gl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xl||n===_l||n===yl||n===vl||n===Ml||n===Sl||n===bl||n===Tl||n===El||n===wl||n===Al||n===Rl||n===Cl||n===Il)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===xl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===_l)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===yl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ml)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Sl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===bl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Tl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===El)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===wl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Al)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Rl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Cl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Il)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Pl||n===Ll||n===Nl)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Pl)return o===ge?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ll)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Nl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Dl||n===Ul||n===Fl||n===Ol)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Dl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ul)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fl)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ol)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===As?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}var $A=`
|
|
3808
|
+
}`;function WA(s,t,e){let n=new or,i=new nt,r=new nt,o=new Qt,a=new Bo({depthPacking:im}),c=new zo,l={},u=e.maxTextureSize,h={[rn]:qe,[qe]:rn,[Ve]:Ve},f=new Cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new nt},radius:{value:4}},vertexShader:VA,fragmentShader:GA}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let x=new Vt;x.setAttribute("position",new kt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new ce(x,f),y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=af;let _=this.type;this.render=function(m,R,E){if(y.enabled===!1||y.autoUpdate===!1&&y.needsUpdate===!1||m.length===0)return;let T=s.getRenderTarget(),b=s.getActiveCubeFace(),w=s.getActiveMipmapLevel(),A=s.state;A.setBlending(Vi),A.buffers.depth.getReversed()===!0?A.buffers.color.setClear(0,0,0,0):A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);let C=_!==vi&&this.type===vi,D=_===vi&&this.type!==vi;for(let F=0,O=m.length;F<O;F++){let H=m[F],B=H.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",H,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;i.copy(B.mapSize);let $=B.getFrameExtents();if(i.multiply($),r.copy(B.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(r.x=Math.floor(u/$.x),i.x=r.x*$.x,B.mapSize.x=r.x),i.y>u&&(r.y=Math.floor(u/$.y),i.y=r.y*$.y,B.mapSize.y=r.y)),B.map===null||C===!0||D===!0){let rt=this.type!==vi?{minFilter:De,magFilter:De}:{};B.map!==null&&B.map.dispose(),B.map=new Hn(i.x,i.y,rt),B.map.texture.name=H.name+".shadowMap",B.camera.updateProjectionMatrix()}s.setRenderTarget(B.map),s.clear();let at=B.getViewportCount();for(let rt=0;rt<at;rt++){let ht=B.getViewport(rt);o.set(r.x*ht.x,r.y*ht.y,r.x*ht.z,r.y*ht.w),A.viewport(o),B.updateMatrices(H,rt),n=B.getFrustum(),d(R,E,B.camera,H,this.type)}B.isPointLightShadow!==!0&&this.type===vi&&S(B,E),B.needsUpdate=!1}_=this.type,y.needsUpdate=!1,s.setRenderTarget(T,b,w)};function S(m,R){let E=t.update(v);f.defines.VSM_SAMPLES!==m.blurSamples&&(f.defines.VSM_SAMPLES=m.blurSamples,p.defines.VSM_SAMPLES=m.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),m.mapPass===null&&(m.mapPass=new Hn(i.x,i.y)),f.uniforms.shadow_pass.value=m.map.texture,f.uniforms.resolution.value=m.mapSize,f.uniforms.radius.value=m.radius,s.setRenderTarget(m.mapPass),s.clear(),s.renderBufferDirect(R,null,E,f,v,null),p.uniforms.shadow_pass.value=m.mapPass.texture,p.uniforms.resolution.value=m.mapSize,p.uniforms.radius.value=m.radius,s.setRenderTarget(m.map),s.clear(),s.renderBufferDirect(R,null,E,p,v,null)}function g(m,R,E,T){let b=null,w=E.isPointLight===!0?m.customDistanceMaterial:m.customDepthMaterial;if(w!==void 0)b=w;else if(b=E.isPointLight===!0?c:a,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){let A=b.uuid,C=R.uuid,D=l[A];D===void 0&&(D={},l[A]=D);let F=D[C];F===void 0&&(F=b.clone(),D[C]=F,R.addEventListener("dispose",M)),b=F}if(b.visible=R.visible,b.wireframe=R.wireframe,T===vi?b.side=R.shadowSide!==null?R.shadowSide:R.side:b.side=R.shadowSide!==null?R.shadowSide:h[R.side],b.alphaMap=R.alphaMap,b.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,b.map=R.map,b.clipShadows=R.clipShadows,b.clippingPlanes=R.clippingPlanes,b.clipIntersection=R.clipIntersection,b.displacementMap=R.displacementMap,b.displacementScale=R.displacementScale,b.displacementBias=R.displacementBias,b.wireframeLinewidth=R.wireframeLinewidth,b.linewidth=R.linewidth,E.isPointLight===!0&&b.isMeshDistanceMaterial===!0){let A=s.properties.get(b);A.light=E}return b}function d(m,R,E,T,b){if(m.visible===!1)return;if(m.layers.test(R.layers)&&(m.isMesh||m.isLine||m.isPoints)&&(m.castShadow||m.receiveShadow&&b===vi)&&(!m.frustumCulled||n.intersectsObject(m))){m.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,m.matrixWorld);let C=t.update(m),D=m.material;if(Array.isArray(D)){let F=C.groups;for(let O=0,H=F.length;O<H;O++){let B=F[O],$=D[B.materialIndex];if($&&$.visible){let at=g(m,$,T,b);m.onBeforeShadow(s,m,R,E,C,at,B),s.renderBufferDirect(E,null,C,at,m,B),m.onAfterShadow(s,m,R,E,C,at,B)}}}else if(D.visible){let F=g(m,D,T,b);m.onBeforeShadow(s,m,R,E,C,F,null),s.renderBufferDirect(E,null,C,F,m,null),m.onAfterShadow(s,m,R,E,C,F,null)}}let A=m.children;for(let C=0,D=A.length;C<D;C++)d(A[C],R,E,T,b)}function M(m){m.target.removeEventListener("dispose",M);for(let E in l){let T=l[E],b=m.target.uuid;b in T&&(T[b].dispose(),delete T[b])}}}var XA={[Zc]:Jc,[jc]:el,[Qc]:nl,[Ar]:tl,[Jc]:Zc,[el]:jc,[nl]:Qc,[tl]:Ar};function qA(s,t){function e(){let z=!1,gt=new Qt,St=null,Ut=new Qt(0,0,0,0);return{setMask:function(dt){St!==dt&&!z&&(s.colorMask(dt,dt,dt,dt),St=dt)},setLocked:function(dt){z=dt},setClear:function(dt,ot,Bt,Zt,Te){Te===!0&&(dt*=Zt,ot*=Zt,Bt*=Zt),gt.set(dt,ot,Bt,Zt),Ut.equals(gt)===!1&&(s.clearColor(dt,ot,Bt,Zt),Ut.copy(gt))},reset:function(){z=!1,St=null,Ut.set(-1,0,0,0)}}}function n(){let z=!1,gt=!1,St=null,Ut=null,dt=null;return{setReversed:function(ot){if(gt!==ot){let Bt=t.get("EXT_clip_control");ot?Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.ZERO_TO_ONE_EXT):Bt.clipControlEXT(Bt.LOWER_LEFT_EXT,Bt.NEGATIVE_ONE_TO_ONE_EXT),gt=ot;let Zt=dt;dt=null,this.setClear(Zt)}},getReversed:function(){return gt},setTest:function(ot){ot?Q(s.DEPTH_TEST):ct(s.DEPTH_TEST)},setMask:function(ot){St!==ot&&!z&&(s.depthMask(ot),St=ot)},setFunc:function(ot){if(gt&&(ot=XA[ot]),Ut!==ot){switch(ot){case Zc:s.depthFunc(s.NEVER);break;case Jc:s.depthFunc(s.ALWAYS);break;case jc:s.depthFunc(s.LESS);break;case Ar:s.depthFunc(s.LEQUAL);break;case Qc:s.depthFunc(s.EQUAL);break;case tl:s.depthFunc(s.GEQUAL);break;case el:s.depthFunc(s.GREATER);break;case nl:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}Ut=ot}},setLocked:function(ot){z=ot},setClear:function(ot){dt!==ot&&(gt&&(ot=1-ot),s.clearDepth(ot),dt=ot)},reset:function(){z=!1,St=null,Ut=null,dt=null,gt=!1}}}function i(){let z=!1,gt=null,St=null,Ut=null,dt=null,ot=null,Bt=null,Zt=null,Te=null;return{setTest:function(pe){z||(pe?Q(s.STENCIL_TEST):ct(s.STENCIL_TEST))},setMask:function(pe){gt!==pe&&!z&&(s.stencilMask(pe),gt=pe)},setFunc:function(pe,Zi,Ri){(St!==pe||Ut!==Zi||dt!==Ri)&&(s.stencilFunc(pe,Zi,Ri),St=pe,Ut=Zi,dt=Ri)},setOp:function(pe,Zi,Ri){(ot!==pe||Bt!==Zi||Zt!==Ri)&&(s.stencilOp(pe,Zi,Ri),ot=pe,Bt=Zi,Zt=Ri)},setLocked:function(pe){z=pe},setClear:function(pe){Te!==pe&&(s.clearStencil(pe),Te=pe)},reset:function(){z=!1,gt=null,St=null,Ut=null,dt=null,ot=null,Bt=null,Zt=null,Te=null}}}let r=new e,o=new n,a=new i,c=new WeakMap,l=new WeakMap,u={},h={},f=new WeakMap,p=[],x=null,v=!1,y=null,_=null,S=null,g=null,d=null,M=null,m=null,R=new yt(0,0,0),E=0,T=!1,b=null,w=null,A=null,C=null,D=null,F=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),O=!1,H=0,B=s.getParameter(s.VERSION);B.indexOf("WebGL")!==-1?(H=parseFloat(/^WebGL (\d)/.exec(B)[1]),O=H>=1):B.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(B)[1]),O=H>=2);let $=null,at={},rt=s.getParameter(s.SCISSOR_BOX),ht=s.getParameter(s.VIEWPORT),bt=new Qt().fromArray(rt),Et=new Qt().fromArray(ht);function Mt(z,gt,St,Ut){let dt=new Uint8Array(4),ot=s.createTexture();s.bindTexture(z,ot),s.texParameteri(z,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(z,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Bt=0;Bt<St;Bt++)z===s.TEXTURE_3D||z===s.TEXTURE_2D_ARRAY?s.texImage3D(gt,0,s.RGBA,1,1,Ut,0,s.RGBA,s.UNSIGNED_BYTE,dt):s.texImage2D(gt+Bt,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,dt);return ot}let K={};K[s.TEXTURE_2D]=Mt(s.TEXTURE_2D,s.TEXTURE_2D,1),K[s.TEXTURE_CUBE_MAP]=Mt(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),K[s.TEXTURE_2D_ARRAY]=Mt(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),K[s.TEXTURE_3D]=Mt(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),o.setClear(1),a.setClear(0),Q(s.DEPTH_TEST),o.setFunc(Ar),Y(!1),q(of),Q(s.CULL_FACE),tt(Vi);function Q(z){u[z]!==!0&&(s.enable(z),u[z]=!0)}function ct(z){u[z]!==!1&&(s.disable(z),u[z]=!1)}function lt(z,gt){return h[z]!==gt?(s.bindFramebuffer(z,gt),h[z]=gt,z===s.DRAW_FRAMEBUFFER&&(h[s.FRAMEBUFFER]=gt),z===s.FRAMEBUFFER&&(h[s.DRAW_FRAMEBUFFER]=gt),!0):!1}function ut(z,gt){let St=p,Ut=!1;if(z){St=f.get(gt),St===void 0&&(St=[],f.set(gt,St));let dt=z.textures;if(St.length!==dt.length||St[0]!==s.COLOR_ATTACHMENT0){for(let ot=0,Bt=dt.length;ot<Bt;ot++)St[ot]=s.COLOR_ATTACHMENT0+ot;St.length=dt.length,Ut=!0}}else St[0]!==s.BACK&&(St[0]=s.BACK,Ut=!0);Ut&&s.drawBuffers(St)}function Ct(z){return x!==z?(s.useProgram(z),x=z,!0):!1}let Kt={[sr]:s.FUNC_ADD,[wp]:s.FUNC_SUBTRACT,[Ap]:s.FUNC_REVERSE_SUBTRACT};Kt[Rp]=s.MIN,Kt[Cp]=s.MAX;let U={[Ip]:s.ZERO,[Pp]:s.ONE,[Lp]:s.SRC_COLOR,[$a]:s.SRC_ALPHA,[Bp]:s.SRC_ALPHA_SATURATE,[Fp]:s.DST_COLOR,[Dp]:s.DST_ALPHA,[Np]:s.ONE_MINUS_SRC_COLOR,[Ka]:s.ONE_MINUS_SRC_ALPHA,[Op]:s.ONE_MINUS_DST_COLOR,[Up]:s.ONE_MINUS_DST_ALPHA,[zp]:s.CONSTANT_COLOR,[kp]:s.ONE_MINUS_CONSTANT_COLOR,[Hp]:s.CONSTANT_ALPHA,[Vp]:s.ONE_MINUS_CONSTANT_ALPHA};function tt(z,gt,St,Ut,dt,ot,Bt,Zt,Te,pe){if(z===Vi){v===!0&&(ct(s.BLEND),v=!1);return}if(v===!1&&(Q(s.BLEND),v=!0),z!==Ep){if(z!==y||pe!==T){if((_!==sr||d!==sr)&&(s.blendEquation(s.FUNC_ADD),_=sr,d=sr),pe)switch(z){case wr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cf:s.blendFunc(s.ONE,s.ONE);break;case lf:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case uf:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}else switch(z){case wr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case cf:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case lf:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case uf:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",z);break}S=null,g=null,M=null,m=null,R.set(0,0,0),E=0,y=z,T=pe}return}dt=dt||gt,ot=ot||St,Bt=Bt||Ut,(gt!==_||dt!==d)&&(s.blendEquationSeparate(Kt[gt],Kt[dt]),_=gt,d=dt),(St!==S||Ut!==g||ot!==M||Bt!==m)&&(s.blendFuncSeparate(U[St],U[Ut],U[ot],U[Bt]),S=St,g=Ut,M=ot,m=Bt),(Zt.equals(R)===!1||Te!==E)&&(s.blendColor(Zt.r,Zt.g,Zt.b,Te),R.copy(Zt),E=Te),y=z,T=!1}function Z(z,gt){z.side===Ve?ct(s.CULL_FACE):Q(s.CULL_FACE);let St=z.side===qe;gt&&(St=!St),Y(St),z.blending===wr&&z.transparent===!1?tt(Vi):tt(z.blending,z.blendEquation,z.blendSrc,z.blendDst,z.blendEquationAlpha,z.blendSrcAlpha,z.blendDstAlpha,z.blendColor,z.blendAlpha,z.premultipliedAlpha),o.setFunc(z.depthFunc),o.setTest(z.depthTest),o.setMask(z.depthWrite),r.setMask(z.colorWrite);let Ut=z.stencilWrite;a.setTest(Ut),Ut&&(a.setMask(z.stencilWriteMask),a.setFunc(z.stencilFunc,z.stencilRef,z.stencilFuncMask),a.setOp(z.stencilFail,z.stencilZFail,z.stencilZPass)),it(z.polygonOffset,z.polygonOffsetFactor,z.polygonOffsetUnits),z.alphaToCoverage===!0?Q(s.SAMPLE_ALPHA_TO_COVERAGE):ct(s.SAMPLE_ALPHA_TO_COVERAGE)}function Y(z){b!==z&&(z?s.frontFace(s.CW):s.frontFace(s.CCW),b=z)}function q(z){z!==Sp?(Q(s.CULL_FACE),z!==w&&(z===of?s.cullFace(s.BACK):z===bp?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):ct(s.CULL_FACE),w=z}function mt(z){z!==A&&(O&&s.lineWidth(z),A=z)}function it(z,gt,St){z?(Q(s.POLYGON_OFFSET_FILL),(C!==gt||D!==St)&&(s.polygonOffset(gt,St),C=gt,D=St)):ct(s.POLYGON_OFFSET_FILL)}function st(z){z?Q(s.SCISSOR_TEST):ct(s.SCISSOR_TEST)}function Pt(z){z===void 0&&(z=s.TEXTURE0+F-1),$!==z&&(s.activeTexture(z),$=z)}function It(z,gt,St){St===void 0&&($===null?St=s.TEXTURE0+F-1:St=$);let Ut=at[St];Ut===void 0&&(Ut={type:void 0,texture:void 0},at[St]=Ut),(Ut.type!==z||Ut.texture!==gt)&&($!==St&&(s.activeTexture(St),$=St),s.bindTexture(z,gt||K[z]),Ut.type=z,Ut.texture=gt)}function N(){let z=at[$];z!==void 0&&z.type!==void 0&&(s.bindTexture(z.type,null),z.type=void 0,z.texture=void 0)}function P(){try{s.compressedTexImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function k(){try{s.compressedTexImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function W(){try{s.texSubImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function et(){try{s.texSubImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function _t(){try{s.compressedTexSubImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function xt(){try{s.texStorage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Ft(){try{s.texStorage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Dt(){try{s.texImage2D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function ft(){try{s.texImage3D(...arguments)}catch(z){console.error("THREE.WebGLState:",z)}}function Rt(z){bt.equals(z)===!1&&(s.scissor(z.x,z.y,z.z,z.w),bt.copy(z))}function qt(z){Et.equals(z)===!1&&(s.viewport(z.x,z.y,z.z,z.w),Et.copy(z))}function zt(z,gt){let St=l.get(gt);St===void 0&&(St=new WeakMap,l.set(gt,St));let Ut=St.get(z);Ut===void 0&&(Ut=s.getUniformBlockIndex(gt,z.name),St.set(z,Ut))}function wt(z,gt){let Ut=l.get(gt).get(z);c.get(gt)!==Ut&&(s.uniformBlockBinding(gt,Ut,z.__bindingPointIndex),c.set(gt,Ut))}function jt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),o.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),u={},$=null,at={},h={},f=new WeakMap,p=[],x=null,v=!1,y=null,_=null,S=null,g=null,d=null,M=null,m=null,R=new yt(0,0,0),E=0,T=!1,b=null,w=null,A=null,C=null,D=null,bt.set(0,0,s.canvas.width,s.canvas.height),Et.set(0,0,s.canvas.width,s.canvas.height),r.reset(),o.reset(),a.reset()}return{buffers:{color:r,depth:o,stencil:a},enable:Q,disable:ct,bindFramebuffer:lt,drawBuffers:ut,useProgram:Ct,setBlending:tt,setMaterial:Z,setFlipSided:Y,setCullFace:q,setLineWidth:mt,setPolygonOffset:it,setScissorTest:st,activeTexture:Pt,bindTexture:It,unbindTexture:N,compressedTexImage2D:P,compressedTexImage3D:k,texImage2D:Dt,texImage3D:ft,updateUBOMapping:zt,uniformBlockBinding:wt,texStorage2D:xt,texStorage3D:Ft,texSubImage2D:W,texSubImage3D:et,compressedTexSubImage2D:X,compressedTexSubImage3D:_t,scissor:Rt,viewport:qt,reset:jt}}function YA(s,t,e,n,i,r,o){let a=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new nt,u=new WeakMap,h,f=new WeakMap,p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(N,P){return p?new OffscreenCanvas(N,P):yo("canvas")}function v(N,P,k){let W=1,et=It(N);if((et.width>k||et.height>k)&&(W=k/Math.max(et.width,et.height)),W<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){let X=Math.floor(W*et.width),_t=Math.floor(W*et.height);h===void 0&&(h=x(X,_t));let xt=P?x(X,_t):h;return xt.width=X,xt.height=_t,xt.getContext("2d").drawImage(N,0,0,X,_t),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+et.width+"x"+et.height+") to ("+X+"x"+_t+")."),xt}else return"data"in N&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+et.width+"x"+et.height+")."),N;return N}function y(N){return N.generateMipmaps}function _(N){s.generateMipmap(N)}function S(N){return N.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?s.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function g(N,P,k,W,et=!1){if(N!==null){if(s[N]!==void 0)return s[N];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let X=P;if(P===s.RED&&(k===s.FLOAT&&(X=s.R32F),k===s.HALF_FLOAT&&(X=s.R16F),k===s.UNSIGNED_BYTE&&(X=s.R8)),P===s.RED_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.R8UI),k===s.UNSIGNED_SHORT&&(X=s.R16UI),k===s.UNSIGNED_INT&&(X=s.R32UI),k===s.BYTE&&(X=s.R8I),k===s.SHORT&&(X=s.R16I),k===s.INT&&(X=s.R32I)),P===s.RG&&(k===s.FLOAT&&(X=s.RG32F),k===s.HALF_FLOAT&&(X=s.RG16F),k===s.UNSIGNED_BYTE&&(X=s.RG8)),P===s.RG_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RG8UI),k===s.UNSIGNED_SHORT&&(X=s.RG16UI),k===s.UNSIGNED_INT&&(X=s.RG32UI),k===s.BYTE&&(X=s.RG8I),k===s.SHORT&&(X=s.RG16I),k===s.INT&&(X=s.RG32I)),P===s.RGB_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RGB8UI),k===s.UNSIGNED_SHORT&&(X=s.RGB16UI),k===s.UNSIGNED_INT&&(X=s.RGB32UI),k===s.BYTE&&(X=s.RGB8I),k===s.SHORT&&(X=s.RGB16I),k===s.INT&&(X=s.RGB32I)),P===s.RGBA_INTEGER&&(k===s.UNSIGNED_BYTE&&(X=s.RGBA8UI),k===s.UNSIGNED_SHORT&&(X=s.RGBA16UI),k===s.UNSIGNED_INT&&(X=s.RGBA32UI),k===s.BYTE&&(X=s.RGBA8I),k===s.SHORT&&(X=s.RGBA16I),k===s.INT&&(X=s.RGBA32I)),P===s.RGB&&(k===s.UNSIGNED_INT_5_9_9_9_REV&&(X=s.RGB9_E5),k===s.UNSIGNED_INT_10F_11F_11F_REV&&(X=s.R11F_G11F_B10F)),P===s.RGBA){let _t=et?xo:ie.getTransfer(W);k===s.FLOAT&&(X=s.RGBA32F),k===s.HALF_FLOAT&&(X=s.RGBA16F),k===s.UNSIGNED_BYTE&&(X=_t===ge?s.SRGB8_ALPHA8:s.RGBA8),k===s.UNSIGNED_SHORT_4_4_4_4&&(X=s.RGBA4),k===s.UNSIGNED_SHORT_5_5_5_1&&(X=s.RGB5_A1)}return(X===s.R16F||X===s.R32F||X===s.RG16F||X===s.RG32F||X===s.RGBA16F||X===s.RGBA32F)&&t.get("EXT_color_buffer_float"),X}function d(N,P){let k;return N?P===null||P===qi||P===As?k=s.DEPTH24_STENCIL8:P===xn?k=s.DEPTH32F_STENCIL8:P===Es&&(k=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):P===null||P===qi||P===As?k=s.DEPTH_COMPONENT24:P===xn?k=s.DEPTH_COMPONENT32F:P===Es&&(k=s.DEPTH_COMPONENT16),k}function M(N,P){return y(N)===!0||N.isFramebufferTexture&&N.minFilter!==De&&N.minFilter!==Ee?Math.log2(Math.max(P.width,P.height))+1:N.mipmaps!==void 0&&N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?P.mipmaps.length:1}function m(N){let P=N.target;P.removeEventListener("dispose",m),E(P),P.isVideoTexture&&u.delete(P)}function R(N){let P=N.target;P.removeEventListener("dispose",R),b(P)}function E(N){let P=n.get(N);if(P.__webglInit===void 0)return;let k=N.source,W=f.get(k);if(W){let et=W[P.__cacheKey];et.usedTimes--,et.usedTimes===0&&T(N),Object.keys(W).length===0&&f.delete(k)}n.remove(N)}function T(N){let P=n.get(N);s.deleteTexture(P.__webglTexture);let k=N.source,W=f.get(k);delete W[P.__cacheKey],o.memory.textures--}function b(N){let P=n.get(N);if(N.depthTexture&&(N.depthTexture.dispose(),n.remove(N.depthTexture)),N.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(P.__webglFramebuffer[W]))for(let et=0;et<P.__webglFramebuffer[W].length;et++)s.deleteFramebuffer(P.__webglFramebuffer[W][et]);else s.deleteFramebuffer(P.__webglFramebuffer[W]);P.__webglDepthbuffer&&s.deleteRenderbuffer(P.__webglDepthbuffer[W])}else{if(Array.isArray(P.__webglFramebuffer))for(let W=0;W<P.__webglFramebuffer.length;W++)s.deleteFramebuffer(P.__webglFramebuffer[W]);else s.deleteFramebuffer(P.__webglFramebuffer);if(P.__webglDepthbuffer&&s.deleteRenderbuffer(P.__webglDepthbuffer),P.__webglMultisampledFramebuffer&&s.deleteFramebuffer(P.__webglMultisampledFramebuffer),P.__webglColorRenderbuffer)for(let W=0;W<P.__webglColorRenderbuffer.length;W++)P.__webglColorRenderbuffer[W]&&s.deleteRenderbuffer(P.__webglColorRenderbuffer[W]);P.__webglDepthRenderbuffer&&s.deleteRenderbuffer(P.__webglDepthRenderbuffer)}let k=N.textures;for(let W=0,et=k.length;W<et;W++){let X=n.get(k[W]);X.__webglTexture&&(s.deleteTexture(X.__webglTexture),o.memory.textures--),n.remove(k[W])}n.remove(N)}let w=0;function A(){w=0}function C(){let N=w;return N>=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+N+" texture units while this GPU supports only "+i.maxTextures),w+=1,N}function D(N){let P=[];return P.push(N.wrapS),P.push(N.wrapT),P.push(N.wrapR||0),P.push(N.magFilter),P.push(N.minFilter),P.push(N.anisotropy),P.push(N.internalFormat),P.push(N.format),P.push(N.type),P.push(N.generateMipmaps),P.push(N.premultiplyAlpha),P.push(N.flipY),P.push(N.unpackAlignment),P.push(N.colorSpace),P.join()}function F(N,P){let k=n.get(N);if(N.isVideoTexture&&st(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&k.__version!==N.version){let W=N.image;if(W===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{K(k,N,P);return}}else N.isExternalTexture&&(k.__webglTexture=N.sourceTexture?N.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,k.__webglTexture,s.TEXTURE0+P)}function O(N,P){let k=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&k.__version!==N.version){K(k,N,P);return}e.bindTexture(s.TEXTURE_2D_ARRAY,k.__webglTexture,s.TEXTURE0+P)}function H(N,P){let k=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&k.__version!==N.version){K(k,N,P);return}e.bindTexture(s.TEXTURE_3D,k.__webglTexture,s.TEXTURE0+P)}function B(N,P){let k=n.get(N);if(N.version>0&&k.__version!==N.version){Q(k,N,P);return}e.bindTexture(s.TEXTURE_CUBE_MAP,k.__webglTexture,s.TEXTURE0+P)}let $={[An]:s.REPEAT,[en]:s.CLAMP_TO_EDGE,[Li]:s.MIRRORED_REPEAT},at={[De]:s.NEAREST,[Nr]:s.NEAREST_MIPMAP_NEAREST,[Mi]:s.NEAREST_MIPMAP_LINEAR,[Ee]:s.LINEAR,[Xi]:s.LINEAR_MIPMAP_NEAREST,[un]:s.LINEAR_MIPMAP_LINEAR},rt={[sm]:s.NEVER,[hm]:s.ALWAYS,[om]:s.LESS,[vf]:s.LEQUAL,[am]:s.EQUAL,[um]:s.GEQUAL,[cm]:s.GREATER,[lm]:s.NOTEQUAL};function ht(N,P){if(P.type===xn&&t.has("OES_texture_float_linear")===!1&&(P.magFilter===Ee||P.magFilter===Xi||P.magFilter===Mi||P.magFilter===un||P.minFilter===Ee||P.minFilter===Xi||P.minFilter===Mi||P.minFilter===un)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(N,s.TEXTURE_WRAP_S,$[P.wrapS]),s.texParameteri(N,s.TEXTURE_WRAP_T,$[P.wrapT]),(N===s.TEXTURE_3D||N===s.TEXTURE_2D_ARRAY)&&s.texParameteri(N,s.TEXTURE_WRAP_R,$[P.wrapR]),s.texParameteri(N,s.TEXTURE_MAG_FILTER,at[P.magFilter]),s.texParameteri(N,s.TEXTURE_MIN_FILTER,at[P.minFilter]),P.compareFunction&&(s.texParameteri(N,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(N,s.TEXTURE_COMPARE_FUNC,rt[P.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(P.magFilter===De||P.minFilter!==Mi&&P.minFilter!==un||P.type===xn&&t.has("OES_texture_float_linear")===!1)return;if(P.anisotropy>1||n.get(P).__currentAnisotropy){let k=t.get("EXT_texture_filter_anisotropic");s.texParameterf(N,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(P.anisotropy,i.getMaxAnisotropy())),n.get(P).__currentAnisotropy=P.anisotropy}}}function bt(N,P){let k=!1;N.__webglInit===void 0&&(N.__webglInit=!0,P.addEventListener("dispose",m));let W=P.source,et=f.get(W);et===void 0&&(et={},f.set(W,et));let X=D(P);if(X!==N.__cacheKey){et[X]===void 0&&(et[X]={texture:s.createTexture(),usedTimes:0},o.memory.textures++,k=!0),et[X].usedTimes++;let _t=et[N.__cacheKey];_t!==void 0&&(et[N.__cacheKey].usedTimes--,_t.usedTimes===0&&T(P)),N.__cacheKey=X,N.__webglTexture=et[X].texture}return k}function Et(N,P,k){return Math.floor(Math.floor(N/k)/P)}function Mt(N,P,k,W){let X=N.updateRanges;if(X.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,P.width,P.height,k,W,P.data);else{X.sort((ft,Rt)=>ft.start-Rt.start);let _t=0;for(let ft=1;ft<X.length;ft++){let Rt=X[_t],qt=X[ft],zt=Rt.start+Rt.count,wt=Et(qt.start,P.width,4),jt=Et(Rt.start,P.width,4);qt.start<=zt+1&&wt===jt&&Et(qt.start+qt.count-1,P.width,4)===wt?Rt.count=Math.max(Rt.count,qt.start+qt.count-Rt.start):(++_t,X[_t]=qt)}X.length=_t+1;let xt=s.getParameter(s.UNPACK_ROW_LENGTH),Ft=s.getParameter(s.UNPACK_SKIP_PIXELS),Dt=s.getParameter(s.UNPACK_SKIP_ROWS);s.pixelStorei(s.UNPACK_ROW_LENGTH,P.width);for(let ft=0,Rt=X.length;ft<Rt;ft++){let qt=X[ft],zt=Math.floor(qt.start/4),wt=Math.ceil(qt.count/4),jt=zt%P.width,z=Math.floor(zt/P.width),gt=wt,St=1;s.pixelStorei(s.UNPACK_SKIP_PIXELS,jt),s.pixelStorei(s.UNPACK_SKIP_ROWS,z),e.texSubImage2D(s.TEXTURE_2D,0,jt,z,gt,St,k,W,P.data)}N.clearUpdateRanges(),s.pixelStorei(s.UNPACK_ROW_LENGTH,xt),s.pixelStorei(s.UNPACK_SKIP_PIXELS,Ft),s.pixelStorei(s.UNPACK_SKIP_ROWS,Dt)}}function K(N,P,k){let W=s.TEXTURE_2D;(P.isDataArrayTexture||P.isCompressedArrayTexture)&&(W=s.TEXTURE_2D_ARRAY),P.isData3DTexture&&(W=s.TEXTURE_3D);let et=bt(N,P),X=P.source;e.bindTexture(W,N.__webglTexture,s.TEXTURE0+k);let _t=n.get(X);if(X.version!==_t.__version||et===!0){e.activeTexture(s.TEXTURE0+k);let xt=ie.getPrimaries(ie.workingColorSpace),Ft=P.colorSpace===si?null:ie.getPrimaries(P.colorSpace),Dt=P.colorSpace===si||xt===Ft?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,P.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,P.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Dt);let ft=v(P.image,!1,i.maxTextureSize);ft=Pt(P,ft);let Rt=r.convert(P.format,P.colorSpace),qt=r.convert(P.type),zt=g(P.internalFormat,Rt,qt,P.colorSpace,P.isVideoTexture);ht(W,P);let wt,jt=P.mipmaps,z=P.isVideoTexture!==!0,gt=_t.__version===void 0||et===!0,St=X.dataReady,Ut=M(P,ft);if(P.isDepthTexture)zt=d(P.format===Rs,P.type),gt&&(z?e.texStorage2D(s.TEXTURE_2D,1,zt,ft.width,ft.height):e.texImage2D(s.TEXTURE_2D,0,zt,ft.width,ft.height,0,Rt,qt,null));else if(P.isDataTexture)if(jt.length>0){z&>&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,jt[0].width,jt[0].height);for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,qt,wt.data):e.texImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,Rt,qt,wt.data);P.generateMipmaps=!1}else z?(gt&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,ft.width,ft.height),St&&Mt(P,ft,Rt,qt)):e.texImage2D(s.TEXTURE_2D,0,zt,ft.width,ft.height,0,Rt,qt,ft.data);else if(P.isCompressedTexture)if(P.isCompressedArrayTexture){z&>&&e.texStorage3D(s.TEXTURE_2D_ARRAY,Ut,zt,jt[0].width,jt[0].height,ft.depth);for(let dt=0,ot=jt.length;dt<ot;dt++)if(wt=jt[dt],P.format!==Qe)if(Rt!==null)if(z){if(St)if(P.layerUpdates.size>0){let Bt=Sf(wt.width,wt.height,P.format,P.type);for(let Zt of P.layerUpdates){let Te=wt.data.subarray(Zt*Bt/wt.data.BYTES_PER_ELEMENT,(Zt+1)*Bt/wt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,Zt,wt.width,wt.height,1,Rt,Te)}P.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,0,wt.width,wt.height,ft.depth,Rt,wt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,dt,zt,wt.width,wt.height,ft.depth,0,wt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else z?St&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,dt,0,0,0,wt.width,wt.height,ft.depth,Rt,qt,wt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,dt,zt,wt.width,wt.height,ft.depth,0,Rt,qt,wt.data)}else{z&>&&e.texStorage2D(s.TEXTURE_2D,Ut,zt,jt[0].width,jt[0].height);for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],P.format!==Qe?Rt!==null?z?St&&e.compressedTexSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,wt.data):e.compressedTexImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,wt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,wt.width,wt.height,Rt,qt,wt.data):e.texImage2D(s.TEXTURE_2D,dt,zt,wt.width,wt.height,0,Rt,qt,wt.data)}else if(P.isDataArrayTexture)if(z){if(gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,Ut,zt,ft.width,ft.height,ft.depth),St)if(P.layerUpdates.size>0){let dt=Sf(ft.width,ft.height,P.format,P.type);for(let ot of P.layerUpdates){let Bt=ft.data.subarray(ot*dt/ft.data.BYTES_PER_ELEMENT,(ot+1)*dt/ft.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ot,ft.width,ft.height,1,Rt,qt,Bt)}P.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,ft.width,ft.height,ft.depth,Rt,qt,ft.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,zt,ft.width,ft.height,ft.depth,0,Rt,qt,ft.data);else if(P.isData3DTexture)z?(gt&&e.texStorage3D(s.TEXTURE_3D,Ut,zt,ft.width,ft.height,ft.depth),St&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,ft.width,ft.height,ft.depth,Rt,qt,ft.data)):e.texImage3D(s.TEXTURE_3D,0,zt,ft.width,ft.height,ft.depth,0,Rt,qt,ft.data);else if(P.isFramebufferTexture){if(gt)if(z)e.texStorage2D(s.TEXTURE_2D,Ut,zt,ft.width,ft.height);else{let dt=ft.width,ot=ft.height;for(let Bt=0;Bt<Ut;Bt++)e.texImage2D(s.TEXTURE_2D,Bt,zt,dt,ot,0,Rt,qt,null),dt>>=1,ot>>=1}}else if(jt.length>0){if(z&>){let dt=It(jt[0]);e.texStorage2D(s.TEXTURE_2D,Ut,zt,dt.width,dt.height)}for(let dt=0,ot=jt.length;dt<ot;dt++)wt=jt[dt],z?St&&e.texSubImage2D(s.TEXTURE_2D,dt,0,0,Rt,qt,wt):e.texImage2D(s.TEXTURE_2D,dt,zt,Rt,qt,wt);P.generateMipmaps=!1}else if(z){if(gt){let dt=It(ft);e.texStorage2D(s.TEXTURE_2D,Ut,zt,dt.width,dt.height)}St&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,Rt,qt,ft)}else e.texImage2D(s.TEXTURE_2D,0,zt,Rt,qt,ft);y(P)&&_(W),_t.__version=X.version,P.onUpdate&&P.onUpdate(P)}N.__version=P.version}function Q(N,P,k){if(P.image.length!==6)return;let W=bt(N,P),et=P.source;e.bindTexture(s.TEXTURE_CUBE_MAP,N.__webglTexture,s.TEXTURE0+k);let X=n.get(et);if(et.version!==X.__version||W===!0){e.activeTexture(s.TEXTURE0+k);let _t=ie.getPrimaries(ie.workingColorSpace),xt=P.colorSpace===si?null:ie.getPrimaries(P.colorSpace),Ft=P.colorSpace===si||_t===xt?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,P.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,P.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,P.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ft);let Dt=P.isCompressedTexture||P.image[0].isCompressedTexture,ft=P.image[0]&&P.image[0].isDataTexture,Rt=[];for(let ot=0;ot<6;ot++)!Dt&&!ft?Rt[ot]=v(P.image[ot],!0,i.maxCubemapSize):Rt[ot]=ft?P.image[ot].image:P.image[ot],Rt[ot]=Pt(P,Rt[ot]);let qt=Rt[0],zt=r.convert(P.format,P.colorSpace),wt=r.convert(P.type),jt=g(P.internalFormat,zt,wt,P.colorSpace),z=P.isVideoTexture!==!0,gt=X.__version===void 0||W===!0,St=et.dataReady,Ut=M(P,qt);ht(s.TEXTURE_CUBE_MAP,P);let dt;if(Dt){z&>&&e.texStorage2D(s.TEXTURE_CUBE_MAP,Ut,jt,qt.width,qt.height);for(let ot=0;ot<6;ot++){dt=Rt[ot].mipmaps;for(let Bt=0;Bt<dt.length;Bt++){let Zt=dt[Bt];P.format!==Qe?zt!==null?z?St&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,0,0,Zt.width,Zt.height,zt,Zt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,jt,Zt.width,Zt.height,0,Zt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,0,0,Zt.width,Zt.height,zt,wt,Zt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt,jt,Zt.width,Zt.height,0,zt,wt,Zt.data)}}}else{if(dt=P.mipmaps,z&>){dt.length>0&&Ut++;let ot=It(Rt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,Ut,jt,ot.width,ot.height)}for(let ot=0;ot<6;ot++)if(ft){z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,Rt[ot].width,Rt[ot].height,zt,wt,Rt[ot].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jt,Rt[ot].width,Rt[ot].height,0,zt,wt,Rt[ot].data);for(let Bt=0;Bt<dt.length;Bt++){let Te=dt[Bt].image[ot].image;z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,0,0,Te.width,Te.height,zt,wt,Te.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,jt,Te.width,Te.height,0,zt,wt,Te.data)}}else{z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,zt,wt,Rt[ot]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jt,zt,wt,Rt[ot]);for(let Bt=0;Bt<dt.length;Bt++){let Zt=dt[Bt];z?St&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,0,0,zt,wt,Zt.image[ot]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ot,Bt+1,jt,zt,wt,Zt.image[ot])}}}y(P)&&_(s.TEXTURE_CUBE_MAP),X.__version=et.version,P.onUpdate&&P.onUpdate(P)}N.__version=P.version}function ct(N,P,k,W,et,X){let _t=r.convert(k.format,k.colorSpace),xt=r.convert(k.type),Ft=g(k.internalFormat,_t,xt,k.colorSpace),Dt=n.get(P),ft=n.get(k);if(ft.__renderTarget=P,!Dt.__hasExternalTextures){let Rt=Math.max(1,P.width>>X),qt=Math.max(1,P.height>>X);et===s.TEXTURE_3D||et===s.TEXTURE_2D_ARRAY?e.texImage3D(et,X,Ft,Rt,qt,P.depth,0,_t,xt,null):e.texImage2D(et,X,Ft,Rt,qt,0,_t,xt,null)}e.bindFramebuffer(s.FRAMEBUFFER,N),it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,W,et,ft.__webglTexture,0,mt(P)):(et===s.TEXTURE_2D||et>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&et<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,W,et,ft.__webglTexture,X),e.bindFramebuffer(s.FRAMEBUFFER,null)}function lt(N,P,k){if(s.bindRenderbuffer(s.RENDERBUFFER,N),P.depthBuffer){let W=P.depthTexture,et=W&&W.isDepthTexture?W.type:null,X=d(P.stencilBuffer,et),_t=P.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,xt=mt(P);it(P)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,xt,X,P.width,P.height):k?s.renderbufferStorageMultisample(s.RENDERBUFFER,xt,X,P.width,P.height):s.renderbufferStorage(s.RENDERBUFFER,X,P.width,P.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,_t,s.RENDERBUFFER,N)}else{let W=P.textures;for(let et=0;et<W.length;et++){let X=W[et],_t=r.convert(X.format,X.colorSpace),xt=r.convert(X.type),Ft=g(X.internalFormat,_t,xt,X.colorSpace),Dt=mt(P);k&&it(P)===!1?s.renderbufferStorageMultisample(s.RENDERBUFFER,Dt,Ft,P.width,P.height):it(P)?a.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Dt,Ft,P.width,P.height):s.renderbufferStorage(s.RENDERBUFFER,Ft,P.width,P.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function ut(N,P){if(P&&P.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(s.FRAMEBUFFER,N),!(P.depthTexture&&P.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let W=n.get(P.depthTexture);W.__renderTarget=P,(!W.__webglTexture||P.depthTexture.image.width!==P.width||P.depthTexture.image.height!==P.height)&&(P.depthTexture.image.width=P.width,P.depthTexture.image.height=P.height,P.depthTexture.needsUpdate=!0),F(P.depthTexture,0);let et=W.__webglTexture,X=mt(P);if(P.depthTexture.format===rs)it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,et,0,X):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_2D,et,0);else if(P.depthTexture.format===Rs)it(P)?a.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,et,0,X):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_2D,et,0);else throw new Error("Unknown depthTexture format")}function Ct(N){let P=n.get(N),k=N.isWebGLCubeRenderTarget===!0;if(P.__boundDepthTexture!==N.depthTexture){let W=N.depthTexture;if(P.__depthDisposeCallback&&P.__depthDisposeCallback(),W){let et=()=>{delete P.__boundDepthTexture,delete P.__depthDisposeCallback,W.removeEventListener("dispose",et)};W.addEventListener("dispose",et),P.__depthDisposeCallback=et}P.__boundDepthTexture=W}if(N.depthTexture&&!P.__autoAllocateDepthBuffer){if(k)throw new Error("target.depthTexture not supported in Cube render targets");let W=N.texture.mipmaps;W&&W.length>0?ut(P.__webglFramebuffer[0],N):ut(P.__webglFramebuffer,N)}else if(k){P.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer[W]),P.__webglDepthbuffer[W]===void 0)P.__webglDepthbuffer[W]=s.createRenderbuffer(),lt(P.__webglDepthbuffer[W],N,!1);else{let et=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,X=P.__webglDepthbuffer[W];s.bindRenderbuffer(s.RENDERBUFFER,X),s.framebufferRenderbuffer(s.FRAMEBUFFER,et,s.RENDERBUFFER,X)}}else{let W=N.texture.mipmaps;if(W&&W.length>0?e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,P.__webglFramebuffer),P.__webglDepthbuffer===void 0)P.__webglDepthbuffer=s.createRenderbuffer(),lt(P.__webglDepthbuffer,N,!1);else{let et=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,X=P.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,X),s.framebufferRenderbuffer(s.FRAMEBUFFER,et,s.RENDERBUFFER,X)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Kt(N,P,k){let W=n.get(N);P!==void 0&&ct(W.__webglFramebuffer,N,N.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),k!==void 0&&Ct(N)}function U(N){let P=N.texture,k=n.get(N),W=n.get(P);N.addEventListener("dispose",R);let et=N.textures,X=N.isWebGLCubeRenderTarget===!0,_t=et.length>1;if(_t||(W.__webglTexture===void 0&&(W.__webglTexture=s.createTexture()),W.__version=P.version,o.memory.textures++),X){k.__webglFramebuffer=[];for(let xt=0;xt<6;xt++)if(P.mipmaps&&P.mipmaps.length>0){k.__webglFramebuffer[xt]=[];for(let Ft=0;Ft<P.mipmaps.length;Ft++)k.__webglFramebuffer[xt][Ft]=s.createFramebuffer()}else k.__webglFramebuffer[xt]=s.createFramebuffer()}else{if(P.mipmaps&&P.mipmaps.length>0){k.__webglFramebuffer=[];for(let xt=0;xt<P.mipmaps.length;xt++)k.__webglFramebuffer[xt]=s.createFramebuffer()}else k.__webglFramebuffer=s.createFramebuffer();if(_t)for(let xt=0,Ft=et.length;xt<Ft;xt++){let Dt=n.get(et[xt]);Dt.__webglTexture===void 0&&(Dt.__webglTexture=s.createTexture(),o.memory.textures++)}if(N.samples>0&&it(N)===!1){k.__webglMultisampledFramebuffer=s.createFramebuffer(),k.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let xt=0;xt<et.length;xt++){let Ft=et[xt];k.__webglColorRenderbuffer[xt]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,k.__webglColorRenderbuffer[xt]);let Dt=r.convert(Ft.format,Ft.colorSpace),ft=r.convert(Ft.type),Rt=g(Ft.internalFormat,Dt,ft,Ft.colorSpace,N.isXRRenderTarget===!0),qt=mt(N);s.renderbufferStorageMultisample(s.RENDERBUFFER,qt,Rt,N.width,N.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+xt,s.RENDERBUFFER,k.__webglColorRenderbuffer[xt])}s.bindRenderbuffer(s.RENDERBUFFER,null),N.depthBuffer&&(k.__webglDepthRenderbuffer=s.createRenderbuffer(),lt(k.__webglDepthRenderbuffer,N,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(X){e.bindTexture(s.TEXTURE_CUBE_MAP,W.__webglTexture),ht(s.TEXTURE_CUBE_MAP,P);for(let xt=0;xt<6;xt++)if(P.mipmaps&&P.mipmaps.length>0)for(let Ft=0;Ft<P.mipmaps.length;Ft++)ct(k.__webglFramebuffer[xt][Ft],N,P,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+xt,Ft);else ct(k.__webglFramebuffer[xt],N,P,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+xt,0);y(P)&&_(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(_t){for(let xt=0,Ft=et.length;xt<Ft;xt++){let Dt=et[xt],ft=n.get(Dt),Rt=s.TEXTURE_2D;(N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(Rt=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(Rt,ft.__webglTexture),ht(Rt,Dt),ct(k.__webglFramebuffer,N,Dt,s.COLOR_ATTACHMENT0+xt,Rt,0),y(Dt)&&_(Rt)}e.unbindTexture()}else{let xt=s.TEXTURE_2D;if((N.isWebGL3DRenderTarget||N.isWebGLArrayRenderTarget)&&(xt=N.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(xt,W.__webglTexture),ht(xt,P),P.mipmaps&&P.mipmaps.length>0)for(let Ft=0;Ft<P.mipmaps.length;Ft++)ct(k.__webglFramebuffer[Ft],N,P,s.COLOR_ATTACHMENT0,xt,Ft);else ct(k.__webglFramebuffer,N,P,s.COLOR_ATTACHMENT0,xt,0);y(P)&&_(xt),e.unbindTexture()}N.depthBuffer&&Ct(N)}function tt(N){let P=N.textures;for(let k=0,W=P.length;k<W;k++){let et=P[k];if(y(et)){let X=S(N),_t=n.get(et).__webglTexture;e.bindTexture(X,_t),_(X),e.unbindTexture()}}}let Z=[],Y=[];function q(N){if(N.samples>0){if(it(N)===!1){let P=N.textures,k=N.width,W=N.height,et=s.COLOR_BUFFER_BIT,X=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,_t=n.get(N),xt=P.length>1;if(xt)for(let Dt=0;Dt<P.length;Dt++)e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,_t.__webglMultisampledFramebuffer);let Ft=N.texture.mipmaps;Ft&&Ft.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglFramebuffer);for(let Dt=0;Dt<P.length;Dt++){if(N.resolveDepthBuffer&&(N.depthBuffer&&(et|=s.DEPTH_BUFFER_BIT),N.stencilBuffer&&N.resolveStencilBuffer&&(et|=s.STENCIL_BUFFER_BIT)),xt){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,_t.__webglColorRenderbuffer[Dt]);let ft=n.get(P[Dt]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,ft,0)}s.blitFramebuffer(0,0,k,W,0,0,k,W,et,s.NEAREST),c===!0&&(Z.length=0,Y.length=0,Z.push(s.COLOR_ATTACHMENT0+Dt),N.depthBuffer&&N.resolveDepthBuffer===!1&&(Z.push(X),Y.push(X),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Y)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,Z))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),xt)for(let Dt=0;Dt<P.length;Dt++){e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.RENDERBUFFER,_t.__webglColorRenderbuffer[Dt]);let ft=n.get(P[Dt]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,_t.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+Dt,s.TEXTURE_2D,ft,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,_t.__webglMultisampledFramebuffer)}else if(N.depthBuffer&&N.resolveDepthBuffer===!1&&c){let P=N.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[P])}}}function mt(N){return Math.min(i.maxSamples,N.samples)}function it(N){let P=n.get(N);return N.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&P.__useRenderToTexture!==!1}function st(N){let P=o.render.frame;u.get(N)!==P&&(u.set(N,P),N.update())}function Pt(N,P){let k=N.colorSpace,W=N.format,et=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||k!==tn&&k!==si&&(ie.getTransfer(k)===ge?(W!==Qe||et!==ri)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),P}function It(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(l.width=N.naturalWidth||N.width,l.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(l.width=N.displayWidth,l.height=N.displayHeight):(l.width=N.width,l.height=N.height),l}this.allocateTextureUnit=C,this.resetTextureUnits=A,this.setTexture2D=F,this.setTexture2DArray=O,this.setTexture3D=H,this.setTextureCube=B,this.rebindTextures=Kt,this.setupRenderTarget=U,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Ct,this.setupFrameBufferTexture=ct,this.useMultisampledRTT=it}function uy(s,t){function e(n,i=si){let r,o=ie.getTransfer(i);if(n===ri)return s.UNSIGNED_BYTE;if(n===sl)return s.UNSIGNED_SHORT_4_4_4_4;if(n===ol)return s.UNSIGNED_SHORT_5_5_5_1;if(n===df)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===pf)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===hf)return s.BYTE;if(n===ff)return s.SHORT;if(n===Es)return s.UNSIGNED_SHORT;if(n===rl)return s.INT;if(n===qi)return s.UNSIGNED_INT;if(n===xn)return s.FLOAT;if(n===ws)return s.HALF_FLOAT;if(n===mf)return s.ALPHA;if(n===gf)return s.RGB;if(n===Qe)return s.RGBA;if(n===rs)return s.DEPTH_COMPONENT;if(n===Rs)return s.DEPTH_STENCIL;if(n===al)return s.RED;if(n===Ko)return s.RED_INTEGER;if(n===xf)return s.RG;if(n===cl)return s.RG_INTEGER;if(n===ll)return s.RGBA_INTEGER;if(n===Zo||n===Jo||n===jo||n===Qo)if(o===ge)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Zo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===jo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Qo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Zo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Jo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===jo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Qo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ul||n===hl||n===fl||n===dl)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===ul)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===hl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===dl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===pl||n===ml||n===gl)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===pl||n===ml)return o===ge?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===gl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xl||n===_l||n===yl||n===vl||n===Ml||n===Sl||n===bl||n===Tl||n===El||n===wl||n===Al||n===Rl||n===Cl||n===Il)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===xl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===_l)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===yl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===vl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ml)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Sl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===bl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Tl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===El)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===wl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Al)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Rl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Cl)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Il)return o===ge?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Pl||n===Ll||n===Nl)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Pl)return o===ge?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ll)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Nl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Dl||n===Ul||n===Fl||n===Ol)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===Dl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Ul)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Fl)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Ol)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===As?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}var $A=`
|
|
3809
3809
|
void main() {
|
|
3810
3810
|
|
|
3811
3811
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -3829,4 +3829,4 @@ void main() {
|
|
|
3829
3829
|
|
|
3830
3830
|
}
|
|
3831
3831
|
|
|
3832
|
-
}`,Nm=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new Ao(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new Cn({vertexShader:$A,fragmentShader:KA,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ce(new ys(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Dm=class extends kn{constructor(t,e){super();let n=this,i=null,r=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,p=null,x=null,v=typeof XRWebGLBinding<"u",y=new Nm,_={},S=e.getContextAttributes(),g=null,d=null,M=[],m=[],R=new nt,E=null,T=new Re;T.viewport=new Qt;let b=new Re;b.viewport=new Qt;let w=[T,b],A=new qc,C=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getGripSpace()},this.getHand=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getHandSpace()};function F(K){let Q=m.indexOf(K.inputSource);if(Q===-1)return;let ct=M[Q];ct!==void 0&&(ct.update(K.inputSource,K.frame,l||o),ct.dispatchEvent({type:K.type,data:K.inputSource}))}function O(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",O),i.removeEventListener("inputsourceschange",H);for(let K=0;K<M.length;K++){let Q=m[K];Q!==null&&(m[K]=null,M[K].disconnect(Q))}C=null,D=null,y.reset();for(let K in _)delete _[K];t.setRenderTarget(g),p=null,f=null,h=null,i=null,d=null,Mt.stop(),n.isPresenting=!1,t.setPixelRatio(E),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){a=K,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(i,e)),h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",O),i.addEventListener("inputsourceschange",H),S.xrCompatible!==!0&&await e.makeXRCompatible(),E=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ct=null,lt=null,ut=null;S.depth&&(ut=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ct=S.stencil?Rs:rs,lt=S.stencil?As:qi);let Ct={colorFormat:e.RGBA8,depthFormat:ut,scaleFactor:r};h=this.getBinding(),f=h.createProjectionLayer(Ct),i.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),d=new Hn(f.textureWidth,f.textureHeight,{format:Qe,type:ri,depthTexture:new wo(f.textureWidth,f.textureHeight,lt,void 0,void 0,void 0,void 0,void 0,void 0,ct),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let ct={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,e,ct),i.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),d=new Hn(p.framebufferWidth,p.framebufferHeight,{format:Qe,type:ri,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}d.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),Mt.setContext(i),Mt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function H(K){for(let Q=0;Q<K.removed.length;Q++){let ct=K.removed[Q],lt=m.indexOf(ct);lt>=0&&(m[lt]=null,M[lt].disconnect(ct))}for(let Q=0;Q<K.added.length;Q++){let ct=K.added[Q],lt=m.indexOf(ct);if(lt===-1){for(let Ct=0;Ct<M.length;Ct++)if(Ct>=m.length){m.push(ct),lt=Ct;break}else if(m[Ct]===null){m[Ct]=ct,lt=Ct;break}if(lt===-1)break}let ut=M[lt];ut&&ut.connect(ct)}}let B=new I,$=new I;function at(K,Q,ct){B.setFromMatrixPosition(Q.matrixWorld),$.setFromMatrixPosition(ct.matrixWorld);let lt=B.distanceTo($),ut=Q.projectionMatrix.elements,Ct=ct.projectionMatrix.elements,Kt=ut[14]/(ut[10]-1),U=ut[14]/(ut[10]+1),tt=(ut[9]+1)/ut[5],Z=(ut[9]-1)/ut[5],Y=(ut[8]-1)/ut[0],q=(Ct[8]+1)/Ct[0],mt=Kt*Y,it=Kt*q,st=lt/(-Y+q),Pt=st*-Y;if(Q.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Pt),K.translateZ(st),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),ut[10]===-1)K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{let It=Kt+st,N=U+st,P=mt-Pt,k=it+(lt-Pt),W=tt*U/N*It,et=Z*U/N*It;K.projectionMatrix.makePerspective(P,k,W,et,It,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function rt(K,Q){Q===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(Q.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let Q=K.near,ct=K.far;y.texture!==null&&(y.depthNear>0&&(Q=y.depthNear),y.depthFar>0&&(ct=y.depthFar)),A.near=b.near=T.near=Q,A.far=b.far=T.far=ct,(C!==A.near||D!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,D=A.far),A.layers.mask=K.layers.mask|6,T.layers.mask=A.layers.mask&3,b.layers.mask=A.layers.mask&5;let lt=K.parent,ut=A.cameras;rt(A,lt);for(let Ct=0;Ct<ut.length;Ct++)rt(ut[Ct],lt);ut.length===2?at(A,T,b):A.projectionMatrix.copy(T.projectionMatrix),ht(K,A,lt)};function ht(K,Q,ct){ct===null?K.matrix.copy(Q.matrixWorld):(K.matrix.copy(ct.matrixWorld),K.matrix.invert(),K.matrix.multiply(Q.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=os*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(K){c=K,f!==null&&(f.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(A)},this.getCameraTexture=function(K){return _[K]};let bt=null;function Et(K,Q){if(u=Q.getViewerPose(l||o),x=Q,u!==null){let ct=u.views;p!==null&&(t.setRenderTargetFramebuffer(d,p.framebuffer),t.setRenderTarget(d));let lt=!1;ct.length!==A.cameras.length&&(A.cameras.length=0,lt=!0);for(let U=0;U<ct.length;U++){let tt=ct[U],Z=null;if(p!==null)Z=p.getViewport(tt);else{let q=h.getViewSubImage(f,tt);Z=q.viewport,U===0&&(t.setRenderTargetTextures(d,q.colorTexture,q.depthStencilTexture),t.setRenderTarget(d))}let Y=w[U];Y===void 0&&(Y=new Re,Y.layers.enable(U),Y.viewport=new Qt,w[U]=Y),Y.matrix.fromArray(tt.transform.matrix),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.projectionMatrix.fromArray(tt.projectionMatrix),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert(),Y.viewport.set(Z.x,Z.y,Z.width,Z.height),U===0&&(A.matrix.copy(Y.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),lt===!0&&A.cameras.push(Y)}let ut=i.enabledFeatures;if(ut&&ut.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=n.getBinding();let U=h.getDepthInformation(ct[0]);U&&U.isValid&&U.texture&&y.init(U,i.renderState)}if(ut&&ut.includes("camera-access")&&v){t.state.unbindTexture(),h=n.getBinding();for(let U=0;U<ct.length;U++){let tt=ct[U].camera;if(tt){let Z=_[tt];Z||(Z=new Ao,_[tt]=Z);let Y=h.getCameraImage(tt);Z.sourceTexture=Y}}}}for(let ct=0;ct<M.length;ct++){let lt=m[ct],ut=M[ct];lt!==null&&ut!==void 0&&ut.update(lt,Q,l||o)}bt&&bt(K,Q),Q.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Q}),x=null}let Mt=new sy;Mt.setAnimationLoop(Et),this.setAnimationLoop=function(K){bt=K},this.dispose=function(){}}},Ls=new Rn,ZA=new vt;function JA(s,t){function e(y,_){y.matrixAutoUpdate===!0&&y.updateMatrix(),_.value.copy(y.matrix)}function n(y,_){_.color.getRGB(y.fogColor.value,pm(s)),_.isFog?(y.fogNear.value=_.near,y.fogFar.value=_.far):_.isFogExp2&&(y.fogDensity.value=_.density)}function i(y,_,S,g,d){_.isMeshBasicMaterial||_.isMeshLambertMaterial?r(y,_):_.isMeshToonMaterial?(r(y,_),h(y,_)):_.isMeshPhongMaterial?(r(y,_),u(y,_)):_.isMeshStandardMaterial?(r(y,_),f(y,_),_.isMeshPhysicalMaterial&&p(y,_,d)):_.isMeshMatcapMaterial?(r(y,_),x(y,_)):_.isMeshDepthMaterial?r(y,_):_.isMeshDistanceMaterial?(r(y,_),v(y,_)):_.isMeshNormalMaterial?r(y,_):_.isLineBasicMaterial?(o(y,_),_.isLineDashedMaterial&&a(y,_)):_.isPointsMaterial?c(y,_,S,g):_.isSpriteMaterial?l(y,_):_.isShadowMaterial?(y.color.value.copy(_.color),y.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function r(y,_){y.opacity.value=_.opacity,_.color&&y.diffuse.value.copy(_.color),_.emissive&&y.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(y.map.value=_.map,e(_.map,y.mapTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.bumpMap&&(y.bumpMap.value=_.bumpMap,e(_.bumpMap,y.bumpMapTransform),y.bumpScale.value=_.bumpScale,_.side===qe&&(y.bumpScale.value*=-1)),_.normalMap&&(y.normalMap.value=_.normalMap,e(_.normalMap,y.normalMapTransform),y.normalScale.value.copy(_.normalScale),_.side===qe&&y.normalScale.value.negate()),_.displacementMap&&(y.displacementMap.value=_.displacementMap,e(_.displacementMap,y.displacementMapTransform),y.displacementScale.value=_.displacementScale,y.displacementBias.value=_.displacementBias),_.emissiveMap&&(y.emissiveMap.value=_.emissiveMap,e(_.emissiveMap,y.emissiveMapTransform)),_.specularMap&&(y.specularMap.value=_.specularMap,e(_.specularMap,y.specularMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest);let S=t.get(_),g=S.envMap,d=S.envMapRotation;g&&(y.envMap.value=g,Ls.copy(d),Ls.x*=-1,Ls.y*=-1,Ls.z*=-1,g.isCubeTexture&&g.isRenderTargetTexture===!1&&(Ls.y*=-1,Ls.z*=-1),y.envMapRotation.value.setFromMatrix4(ZA.makeRotationFromEuler(Ls)),y.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=_.reflectivity,y.ior.value=_.ior,y.refractionRatio.value=_.refractionRatio),_.lightMap&&(y.lightMap.value=_.lightMap,y.lightMapIntensity.value=_.lightMapIntensity,e(_.lightMap,y.lightMapTransform)),_.aoMap&&(y.aoMap.value=_.aoMap,y.aoMapIntensity.value=_.aoMapIntensity,e(_.aoMap,y.aoMapTransform))}function o(y,_){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,_.map&&(y.map.value=_.map,e(_.map,y.mapTransform))}function a(y,_){y.dashSize.value=_.dashSize,y.totalSize.value=_.dashSize+_.gapSize,y.scale.value=_.scale}function c(y,_,S,g){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,y.size.value=_.size*S,y.scale.value=g*.5,_.map&&(y.map.value=_.map,e(_.map,y.uvTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest)}function l(y,_){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,y.rotation.value=_.rotation,_.map&&(y.map.value=_.map,e(_.map,y.mapTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest)}function u(y,_){y.specular.value.copy(_.specular),y.shininess.value=Math.max(_.shininess,1e-4)}function h(y,_){_.gradientMap&&(y.gradientMap.value=_.gradientMap)}function f(y,_){y.metalness.value=_.metalness,_.metalnessMap&&(y.metalnessMap.value=_.metalnessMap,e(_.metalnessMap,y.metalnessMapTransform)),y.roughness.value=_.roughness,_.roughnessMap&&(y.roughnessMap.value=_.roughnessMap,e(_.roughnessMap,y.roughnessMapTransform)),_.envMap&&(y.envMapIntensity.value=_.envMapIntensity)}function p(y,_,S){y.ior.value=_.ior,_.sheen>0&&(y.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),y.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(y.sheenColorMap.value=_.sheenColorMap,e(_.sheenColorMap,y.sheenColorMapTransform)),_.sheenRoughnessMap&&(y.sheenRoughnessMap.value=_.sheenRoughnessMap,e(_.sheenRoughnessMap,y.sheenRoughnessMapTransform))),_.clearcoat>0&&(y.clearcoat.value=_.clearcoat,y.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(y.clearcoatMap.value=_.clearcoatMap,e(_.clearcoatMap,y.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,e(_.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(y.clearcoatNormalMap.value=_.clearcoatNormalMap,e(_.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===qe&&y.clearcoatNormalScale.value.negate())),_.dispersion>0&&(y.dispersion.value=_.dispersion),_.iridescence>0&&(y.iridescence.value=_.iridescence,y.iridescenceIOR.value=_.iridescenceIOR,y.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(y.iridescenceMap.value=_.iridescenceMap,e(_.iridescenceMap,y.iridescenceMapTransform)),_.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=_.iridescenceThicknessMap,e(_.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),_.transmission>0&&(y.transmission.value=_.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),_.transmissionMap&&(y.transmissionMap.value=_.transmissionMap,e(_.transmissionMap,y.transmissionMapTransform)),y.thickness.value=_.thickness,_.thicknessMap&&(y.thicknessMap.value=_.thicknessMap,e(_.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=_.attenuationDistance,y.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(y.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(y.anisotropyMap.value=_.anisotropyMap,e(_.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=_.specularIntensity,y.specularColor.value.copy(_.specularColor),_.specularColorMap&&(y.specularColorMap.value=_.specularColorMap,e(_.specularColorMap,y.specularColorMapTransform)),_.specularIntensityMap&&(y.specularIntensityMap.value=_.specularIntensityMap,e(_.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,_){_.matcap&&(y.matcap.value=_.matcap)}function v(y,_){let S=t.get(_).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function jA(s,t,e,n){let i={},r={},o=[],a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,g){let d=g.program;n.uniformBlockBinding(S,d)}function l(S,g){let d=i[S.id];d===void 0&&(x(S),d=u(S),i[S.id]=d,S.addEventListener("dispose",y));let M=g.program;n.updateUBOMapping(S,M);let m=t.render.frame;r[S.id]!==m&&(f(S),r[S.id]=m)}function u(S){let g=h();S.__bindingPointIndex=g;let d=s.createBuffer(),M=S.__size,m=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,d),s.bufferData(s.UNIFORM_BUFFER,M,m),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,g,d),d}function h(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(S){let g=i[S.id],d=S.uniforms,M=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,g);for(let m=0,R=d.length;m<R;m++){let E=Array.isArray(d[m])?d[m]:[d[m]];for(let T=0,b=E.length;T<b;T++){let w=E[T];if(p(w,m,T,M)===!0){let A=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],D=0;for(let F=0;F<C.length;F++){let O=C[F],H=v(O);typeof O=="number"||typeof O=="boolean"?(w.__data[0]=O,s.bufferSubData(s.UNIFORM_BUFFER,A+D,w.__data)):O.isMatrix3?(w.__data[0]=O.elements[0],w.__data[1]=O.elements[1],w.__data[2]=O.elements[2],w.__data[3]=0,w.__data[4]=O.elements[3],w.__data[5]=O.elements[4],w.__data[6]=O.elements[5],w.__data[7]=0,w.__data[8]=O.elements[6],w.__data[9]=O.elements[7],w.__data[10]=O.elements[8],w.__data[11]=0):(O.toArray(w.__data,D),D+=H.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,A,w.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(S,g,d,M){let m=S.value,R=g+"_"+d;if(M[R]===void 0)return typeof m=="number"||typeof m=="boolean"?M[R]=m:M[R]=m.clone(),!0;{let E=M[R];if(typeof m=="number"||typeof m=="boolean"){if(E!==m)return M[R]=m,!0}else if(E.equals(m)===!1)return E.copy(m),!0}return!1}function x(S){let g=S.uniforms,d=0,M=16;for(let R=0,E=g.length;R<E;R++){let T=Array.isArray(g[R])?g[R]:[g[R]];for(let b=0,w=T.length;b<w;b++){let A=T[b],C=Array.isArray(A.value)?A.value:[A.value];for(let D=0,F=C.length;D<F;D++){let O=C[D],H=v(O),B=d%M,$=B%H.boundary,at=B+$;d+=$,at!==0&&M-at<H.storage&&(d+=M-at),A.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=d,d+=H.storage}}}let m=d%M;return m>0&&(d+=M-m),S.__size=d,S.__cache={},this}function v(S){let g={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(g.boundary=4,g.storage=4):S.isVector2?(g.boundary=8,g.storage=8):S.isVector3||S.isColor?(g.boundary=16,g.storage=12):S.isVector4?(g.boundary=16,g.storage=16):S.isMatrix3?(g.boundary=48,g.storage=48):S.isMatrix4?(g.boundary=64,g.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),g}function y(S){let g=S.target;g.removeEventListener("dispose",y);let d=o.indexOf(g.__bindingPointIndex);o.splice(d,1),s.deleteBuffer(i[g.id]),delete i[g.id],delete r[g.id]}function _(){for(let S in i)s.deleteBuffer(i[S]);o=[],i={},r={}}return{bind:c,update:l,dispose:_}}var Hl=class{constructor(t={}){let{canvas:e=dm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;let x=new Uint32Array(4),v=new Int32Array(4),y=null,_=null,S=[],g=[];this.domElement=e,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.toneMapping=Gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let d=this,M=!1;this._outputColorSpace=Ae;let m=0,R=0,E=null,T=-1,b=null,w=new Qt,A=new Qt,C=null,D=new yt(0),F=0,O=e.width,H=e.height,B=1,$=null,at=null,rt=new Qt(0,0,O,H),ht=new Qt(0,0,O,H),bt=!1,Et=new or,Mt=!1,K=!1,Q=new vt,ct=new I,lt=new Qt,ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ct=!1;function Kt(){return E===null?B:1}let U=n;function tt(L,V){return e.getContext(L,V)}try{let L={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Hi}`),e.addEventListener("webglcontextlost",St,!1),e.addEventListener("webglcontextrestored",Ut,!1),e.addEventListener("webglcontextcreationerror",dt,!1),U===null){let V="webgl2";if(U=tt(V,L),U===null)throw tt(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Z,Y,q,mt,it,st,Pt,It,N,P,k,W,et,X,_t,xt,Ft,Dt,ft,Rt,qt,zt,wt,jt;function z(){Z=new xw(U),Z.init(),zt=new uy(U,Z),Y=new uw(U,Z,t,zt),q=new qA(U,Z),Y.reversedDepthBuffer&&f&&q.buffers.depth.setReversed(!0),mt=new vw(U),it=new NA,st=new YA(U,Z,q,it,Y,zt,mt),Pt=new fw(d),It=new gw(d),N=new wb(U),wt=new cw(U,N),P=new _w(U,N,mt,wt),k=new Sw(U,P,N,mt),ft=new Mw(U,Y,st),xt=new hw(it),W=new LA(d,Pt,It,Z,Y,wt,xt),et=new JA(d,it),X=new UA,_t=new HA(Z),Dt=new aw(d,Pt,It,q,k,p,c),Ft=new WA(d,k,Y),jt=new jA(U,mt,Y,q),Rt=new lw(U,Z,mt),qt=new yw(U,Z,mt),mt.programs=W.programs,d.capabilities=Y,d.extensions=Z,d.properties=it,d.renderLists=X,d.shadowMap=Ft,d.state=q,d.info=mt}z();let gt=new Dm(d,U);this.xr=gt,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let L=Z.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=Z.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(L){L!==void 0&&(B=L,this.setSize(O,H,!1))},this.getSize=function(L){return L.set(O,H)},this.setSize=function(L,V,J=!0){if(gt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}O=L,H=V,e.width=Math.floor(L*B),e.height=Math.floor(V*B),J===!0&&(e.style.width=L+"px",e.style.height=V+"px"),this.setViewport(0,0,L,V)},this.getDrawingBufferSize=function(L){return L.set(O*B,H*B).floor()},this.setDrawingBufferSize=function(L,V,J){O=L,H=V,B=J,e.width=Math.floor(L*J),e.height=Math.floor(V*J),this.setViewport(0,0,L,V)},this.getCurrentViewport=function(L){return L.copy(w)},this.getViewport=function(L){return L.copy(rt)},this.setViewport=function(L,V,J,j){L.isVector4?rt.set(L.x,L.y,L.z,L.w):rt.set(L,V,J,j),q.viewport(w.copy(rt).multiplyScalar(B).round())},this.getScissor=function(L){return L.copy(ht)},this.setScissor=function(L,V,J,j){L.isVector4?ht.set(L.x,L.y,L.z,L.w):ht.set(L,V,J,j),q.scissor(A.copy(ht).multiplyScalar(B).round())},this.getScissorTest=function(){return bt},this.setScissorTest=function(L){q.setScissorTest(bt=L)},this.setOpaqueSort=function(L){$=L},this.setTransparentSort=function(L){at=L},this.getClearColor=function(L){return L.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor(...arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha(...arguments)},this.clear=function(L=!0,V=!0,J=!0){let j=0;if(L){let G=!1;if(E!==null){let pt=E.texture.format;G=pt===ll||pt===cl||pt===Ko}if(G){let pt=E.texture.type,At=pt===ri||pt===qi||pt===Es||pt===As||pt===sl||pt===ol,Ot=Dt.getClearColor(),Nt=Dt.getClearAlpha(),Wt=Ot.r,Yt=Ot.g,Ht=Ot.b;At?(x[0]=Wt,x[1]=Yt,x[2]=Ht,x[3]=Nt,U.clearBufferuiv(U.COLOR,0,x)):(v[0]=Wt,v[1]=Yt,v[2]=Ht,v[3]=Nt,U.clearBufferiv(U.COLOR,0,v))}else j|=U.COLOR_BUFFER_BIT}V&&(j|=U.DEPTH_BUFFER_BIT),J&&(j|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U.clear(j)},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(){e.removeEventListener("webglcontextlost",St,!1),e.removeEventListener("webglcontextrestored",Ut,!1),e.removeEventListener("webglcontextcreationerror",dt,!1),Dt.dispose(),X.dispose(),_t.dispose(),it.dispose(),Pt.dispose(),It.dispose(),k.dispose(),wt.dispose(),jt.dispose(),W.dispose(),gt.dispose(),gt.removeEventListener("sessionstart",Ri),gt.removeEventListener("sessionend",Ix),Vr.stop()};function St(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ut(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;let L=mt.autoReset,V=Ft.enabled,J=Ft.autoUpdate,j=Ft.needsUpdate,G=Ft.type;z(),mt.autoReset=L,Ft.enabled=V,Ft.autoUpdate=J,Ft.needsUpdate=j,Ft.type=G}function dt(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function ot(L){let V=L.target;V.removeEventListener("dispose",ot),Bt(V)}function Bt(L){Zt(L),it.remove(L)}function Zt(L){let V=it.get(L).programs;V!==void 0&&(V.forEach(function(J){W.releaseProgram(J)}),L.isShaderMaterial&&W.releaseShaderCache(L))}this.renderBufferDirect=function(L,V,J,j,G,pt){V===null&&(V=ut);let At=G.isMesh&&G.matrixWorld.determinant()<0,Ot=wM(L,V,J,j,G);q.setMaterial(j,At);let Nt=J.index,Wt=1;if(j.wireframe===!0){if(Nt=P.getWireframeAttribute(J),Nt===void 0)return;Wt=2}let Yt=J.drawRange,Ht=J.attributes.position,ae=Yt.start*Wt,ye=(Yt.start+Yt.count)*Wt;pt!==null&&(ae=Math.max(ae,pt.start*Wt),ye=Math.min(ye,(pt.start+pt.count)*Wt)),Nt!==null?(ae=Math.max(ae,0),ye=Math.min(ye,Nt.count)):Ht!=null&&(ae=Math.max(ae,0),ye=Math.min(ye,Ht.count));let Fe=ye-ae;if(Fe<0||Fe===1/0)return;wt.setup(G,j,Ot,J,Nt);let we,Me=Rt;if(Nt!==null&&(we=N.get(Nt),Me=qt,Me.setIndex(we)),G.isMesh)j.wireframe===!0?(q.setLineWidth(j.wireframeLinewidth*Kt()),Me.setMode(U.LINES)):Me.setMode(U.TRIANGLES);else if(G.isLine){let Gt=j.linewidth;Gt===void 0&&(Gt=1),q.setLineWidth(Gt*Kt()),G.isLineSegments?Me.setMode(U.LINES):G.isLineLoop?Me.setMode(U.LINE_LOOP):Me.setMode(U.LINE_STRIP)}else G.isPoints?Me.setMode(U.POINTS):G.isSprite&&Me.setMode(U.TRIANGLES);if(G.isBatchedMesh)if(G._multiDrawInstances!==null)vo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Me.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))Me.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let Gt=G._multiDrawStarts,Pe=G._multiDrawCounts,he=G._multiDrawCount,Nn=Nt?N.get(Nt).bytesPerElement:1,qs=it.get(j).currentProgram.getUniforms();for(let Dn=0;Dn<he;Dn++)qs.setValue(U,"_gl_DrawID",Dn),Me.render(Gt[Dn]/Nn,Pe[Dn])}else if(G.isInstancedMesh)Me.renderInstances(ae,Fe,G.count);else if(J.isInstancedBufferGeometry){let Gt=J._maxInstanceCount!==void 0?J._maxInstanceCount:1/0,Pe=Math.min(J.instanceCount,Gt);Me.renderInstances(ae,Fe,Pe)}else Me.render(ae,Fe)};function Te(L,V,J){L.transparent===!0&&L.side===Ve&&L.forceSinglePass===!1?(L.side=qe,L.needsUpdate=!0,du(L,V,J),L.side=rn,L.needsUpdate=!0,du(L,V,J),L.side=Ve):du(L,V,J)}this.compile=function(L,V,J=null){J===null&&(J=L),_=_t.get(J),_.init(V),g.push(_),J.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(_.pushLight(G),G.castShadow&&_.pushShadow(G))}),L!==J&&L.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(_.pushLight(G),G.castShadow&&_.pushShadow(G))}),_.setupLights();let j=new Set;return L.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let pt=G.material;if(pt)if(Array.isArray(pt))for(let At=0;At<pt.length;At++){let Ot=pt[At];Te(Ot,J,G),j.add(Ot)}else Te(pt,J,G),j.add(pt)}),_=g.pop(),j},this.compileAsync=function(L,V,J=null){let j=this.compile(L,V,J);return new Promise(G=>{function pt(){if(j.forEach(function(At){it.get(At).currentProgram.isReady()&&j.delete(At)}),j.size===0){G(L);return}setTimeout(pt,10)}Z.get("KHR_parallel_shader_compile")!==null?pt():setTimeout(pt,10)})};let pe=null;function Zi(L){pe&&pe(L)}function Ri(){Vr.stop()}function Ix(){Vr.start()}let Vr=new sy;Vr.setAnimationLoop(Zi),typeof self<"u"&&Vr.setContext(self),this.setAnimationLoop=function(L){pe=L,gt.setAnimationLoop(L),L===null?Vr.stop():Vr.start()},gt.addEventListener("sessionstart",Ri),gt.addEventListener("sessionend",Ix),this.render=function(L,V){if(V!==void 0&&V.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),gt.enabled===!0&>.isPresenting===!0&&(gt.cameraAutoUpdate===!0&>.updateCamera(V),V=gt.getCamera()),L.isScene===!0&&L.onBeforeRender(d,L,V,E),_=_t.get(L,g.length),_.init(V),g.push(_),Q.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),Et.setFromProjectionMatrix(Q,wn,V.reversedDepth),K=this.localClippingEnabled,Mt=xt.init(this.clippingPlanes,K),y=X.get(L,S.length),y.init(),S.push(y),gt.enabled===!0&>.isPresenting===!0){let pt=d.xr.getDepthSensingMesh();pt!==null&&bd(pt,V,-1/0,d.sortObjects)}bd(L,V,0,d.sortObjects),y.finish(),d.sortObjects===!0&&y.sort($,at),Ct=gt.enabled===!1||gt.isPresenting===!1||gt.hasDepthSensing()===!1,Ct&&Dt.addToRenderList(y,L),this.info.render.frame++,Mt===!0&&xt.beginShadows();let J=_.state.shadowsArray;Ft.render(J,L,V),Mt===!0&&xt.endShadows(),this.info.autoReset===!0&&this.info.reset();let j=y.opaque,G=y.transmissive;if(_.setupLights(),V.isArrayCamera){let pt=V.cameras;if(G.length>0)for(let At=0,Ot=pt.length;At<Ot;At++){let Nt=pt[At];Lx(j,G,L,Nt)}Ct&&Dt.render(L);for(let At=0,Ot=pt.length;At<Ot;At++){let Nt=pt[At];Px(y,L,Nt,Nt.viewport)}}else G.length>0&&Lx(j,G,L,V),Ct&&Dt.render(L),Px(y,L,V);E!==null&&R===0&&(st.updateMultisampleRenderTarget(E),st.updateRenderTargetMipmap(E)),L.isScene===!0&&L.onAfterRender(d,L,V),wt.resetDefaultState(),T=-1,b=null,g.pop(),g.length>0?(_=g[g.length-1],Mt===!0&&xt.setGlobalState(d.clippingPlanes,_.state.camera)):_=null,S.pop(),S.length>0?y=S[S.length-1]:y=null};function bd(L,V,J,j){if(L.visible===!1)return;if(L.layers.test(V.layers)){if(L.isGroup)J=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(V);else if(L.isLight)_.pushLight(L),L.castShadow&&_.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Et.intersectsSprite(L)){j&<.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let At=k.update(L),Ot=L.material;Ot.visible&&y.push(L,At,Ot,J,lt.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||Et.intersectsObject(L))){let At=k.update(L),Ot=L.material;if(j&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),lt.copy(L.boundingSphere.center)):(At.boundingSphere===null&&At.computeBoundingSphere(),lt.copy(At.boundingSphere.center)),lt.applyMatrix4(L.matrixWorld).applyMatrix4(Q)),Array.isArray(Ot)){let Nt=At.groups;for(let Wt=0,Yt=Nt.length;Wt<Yt;Wt++){let Ht=Nt[Wt],ae=Ot[Ht.materialIndex];ae&&ae.visible&&y.push(L,At,ae,J,lt.z,Ht)}}else Ot.visible&&y.push(L,At,Ot,J,lt.z,null)}}let pt=L.children;for(let At=0,Ot=pt.length;At<Ot;At++)bd(pt[At],V,J,j)}function Px(L,V,J,j){let G=L.opaque,pt=L.transmissive,At=L.transparent;_.setupLightsView(J),Mt===!0&&xt.setGlobalState(d.clippingPlanes,J),j&&q.viewport(w.copy(j)),G.length>0&&fu(G,V,J),pt.length>0&&fu(pt,V,J),At.length>0&&fu(At,V,J),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1)}function Lx(L,V,J,j){if((J.isScene===!0?J.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[j.id]===void 0&&(_.state.transmissionRenderTarget[j.id]=new Hn(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?ws:ri,minFilter:un,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ie.workingColorSpace}));let pt=_.state.transmissionRenderTarget[j.id],At=j.viewport||w;pt.setSize(At.z*d.transmissionResolutionScale,At.w*d.transmissionResolutionScale);let Ot=d.getRenderTarget(),Nt=d.getActiveCubeFace(),Wt=d.getActiveMipmapLevel();d.setRenderTarget(pt),d.getClearColor(D),F=d.getClearAlpha(),F<1&&d.setClearColor(16777215,.5),d.clear(),Ct&&Dt.render(J);let Yt=d.toneMapping;d.toneMapping=Gi;let Ht=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),_.setupLightsView(j),Mt===!0&&xt.setGlobalState(d.clippingPlanes,j),fu(L,J,j),st.updateMultisampleRenderTarget(pt),st.updateRenderTargetMipmap(pt),Z.has("WEBGL_multisampled_render_to_texture")===!1){let ae=!1;for(let ye=0,Fe=V.length;ye<Fe;ye++){let we=V[ye],Me=we.object,Gt=we.geometry,Pe=we.material,he=we.group;if(Pe.side===Ve&&Me.layers.test(j.layers)){let Nn=Pe.side;Pe.side=qe,Pe.needsUpdate=!0,Nx(Me,J,j,Gt,Pe,he),Pe.side=Nn,Pe.needsUpdate=!0,ae=!0}}ae===!0&&(st.updateMultisampleRenderTarget(pt),st.updateRenderTargetMipmap(pt))}d.setRenderTarget(Ot,Nt,Wt),d.setClearColor(D,F),Ht!==void 0&&(j.viewport=Ht),d.toneMapping=Yt}function fu(L,V,J){let j=V.isScene===!0?V.overrideMaterial:null;for(let G=0,pt=L.length;G<pt;G++){let At=L[G],Ot=At.object,Nt=At.geometry,Wt=At.group,Yt=At.material;Yt.allowOverride===!0&&j!==null&&(Yt=j),Ot.layers.test(J.layers)&&Nx(Ot,V,J,Nt,Yt,Wt)}}function Nx(L,V,J,j,G,pt){L.onBeforeRender(d,V,J,j,G,pt),L.modelViewMatrix.multiplyMatrices(J.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),G.onBeforeRender(d,V,J,j,L,pt),G.transparent===!0&&G.side===Ve&&G.forceSinglePass===!1?(G.side=qe,G.needsUpdate=!0,d.renderBufferDirect(J,V,j,G,L,pt),G.side=rn,G.needsUpdate=!0,d.renderBufferDirect(J,V,j,G,L,pt),G.side=Ve):d.renderBufferDirect(J,V,j,G,L,pt),L.onAfterRender(d,V,J,j,G,pt)}function du(L,V,J){V.isScene!==!0&&(V=ut);let j=it.get(L),G=_.state.lights,pt=_.state.shadowsArray,At=G.state.version,Ot=W.getParameters(L,G.state,pt,V,J),Nt=W.getProgramCacheKey(Ot),Wt=j.programs;j.environment=L.isMeshStandardMaterial?V.environment:null,j.fog=V.fog,j.envMap=(L.isMeshStandardMaterial?It:Pt).get(L.envMap||j.environment),j.envMapRotation=j.environment!==null&&L.envMap===null?V.environmentRotation:L.envMapRotation,Wt===void 0&&(L.addEventListener("dispose",ot),Wt=new Map,j.programs=Wt);let Yt=Wt.get(Nt);if(Yt!==void 0){if(j.currentProgram===Yt&&j.lightsStateVersion===At)return Ux(L,Ot),Yt}else Ot.uniforms=W.getUniforms(L),L.onBeforeCompile(Ot,d),Yt=W.acquireProgram(Ot,Nt),Wt.set(Nt,Yt),j.uniforms=Ot.uniforms;let Ht=j.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Ht.clippingPlanes=xt.uniform),Ux(L,Ot),j.needsLights=RM(L),j.lightsStateVersion=At,j.needsLights&&(Ht.ambientLightColor.value=G.state.ambient,Ht.lightProbe.value=G.state.probe,Ht.directionalLights.value=G.state.directional,Ht.directionalLightShadows.value=G.state.directionalShadow,Ht.spotLights.value=G.state.spot,Ht.spotLightShadows.value=G.state.spotShadow,Ht.rectAreaLights.value=G.state.rectArea,Ht.ltc_1.value=G.state.rectAreaLTC1,Ht.ltc_2.value=G.state.rectAreaLTC2,Ht.pointLights.value=G.state.point,Ht.pointLightShadows.value=G.state.pointShadow,Ht.hemisphereLights.value=G.state.hemi,Ht.directionalShadowMap.value=G.state.directionalShadowMap,Ht.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ht.spotShadowMap.value=G.state.spotShadowMap,Ht.spotLightMatrix.value=G.state.spotLightMatrix,Ht.spotLightMap.value=G.state.spotLightMap,Ht.pointShadowMap.value=G.state.pointShadowMap,Ht.pointShadowMatrix.value=G.state.pointShadowMatrix),j.currentProgram=Yt,j.uniformsList=null,Yt}function Dx(L){if(L.uniformsList===null){let V=L.currentProgram.getUniforms();L.uniformsList=ia.seqWithValue(V.seq,L.uniforms)}return L.uniformsList}function Ux(L,V){let J=it.get(L);J.outputColorSpace=V.outputColorSpace,J.batching=V.batching,J.batchingColor=V.batchingColor,J.instancing=V.instancing,J.instancingColor=V.instancingColor,J.instancingMorph=V.instancingMorph,J.skinning=V.skinning,J.morphTargets=V.morphTargets,J.morphNormals=V.morphNormals,J.morphColors=V.morphColors,J.morphTargetsCount=V.morphTargetsCount,J.numClippingPlanes=V.numClippingPlanes,J.numIntersection=V.numClipIntersection,J.vertexAlphas=V.vertexAlphas,J.vertexTangents=V.vertexTangents,J.toneMapping=V.toneMapping}function wM(L,V,J,j,G){V.isScene!==!0&&(V=ut),st.resetTextureUnits();let pt=V.fog,At=j.isMeshStandardMaterial?V.environment:null,Ot=E===null?d.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:tn,Nt=(j.isMeshStandardMaterial?It:Pt).get(j.envMap||At),Wt=j.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,Yt=!!J.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),Ht=!!J.morphAttributes.position,ae=!!J.morphAttributes.normal,ye=!!J.morphAttributes.color,Fe=Gi;j.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Fe=d.toneMapping);let we=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Me=we!==void 0?we.length:0,Gt=it.get(j),Pe=_.state.lights;if(Mt===!0&&(K===!0||L!==b)){let pn=L===b&&j.id===T;xt.setState(j,L,pn)}let he=!1;j.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==Pe.state.version||Gt.outputColorSpace!==Ot||G.isBatchedMesh&&Gt.batching===!1||!G.isBatchedMesh&&Gt.batching===!0||G.isBatchedMesh&&Gt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Gt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Gt.instancing===!1||!G.isInstancedMesh&&Gt.instancing===!0||G.isSkinnedMesh&&Gt.skinning===!1||!G.isSkinnedMesh&&Gt.skinning===!0||G.isInstancedMesh&&Gt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Gt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Gt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Gt.instancingMorph===!1&&G.morphTexture!==null||Gt.envMap!==Nt||j.fog===!0&&Gt.fog!==pt||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==xt.numPlanes||Gt.numIntersection!==xt.numIntersection)||Gt.vertexAlphas!==Wt||Gt.vertexTangents!==Yt||Gt.morphTargets!==Ht||Gt.morphNormals!==ae||Gt.morphColors!==ye||Gt.toneMapping!==Fe||Gt.morphTargetsCount!==Me)&&(he=!0):(he=!0,Gt.__version=j.version);let Nn=Gt.currentProgram;he===!0&&(Nn=du(j,V,G));let qs=!1,Dn=!1,Ca=!1,Le=Nn.getUniforms(),Zn=Gt.uniforms;if(q.useProgram(Nn.program)&&(qs=!0,Dn=!0,Ca=!0),j.id!==T&&(T=j.id,Dn=!0),qs||b!==L){q.buffers.depth.getReversed()&&L.reversedDepth!==!0&&(L._reversedDepth=!0,L.updateProjectionMatrix()),Le.setValue(U,"projectionMatrix",L.projectionMatrix),Le.setValue(U,"viewMatrix",L.matrixWorldInverse);let bn=Le.map.cameraPosition;bn!==void 0&&bn.setValue(U,ct.setFromMatrixPosition(L.matrixWorld)),Y.logarithmicDepthBuffer&&Le.setValue(U,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&Le.setValue(U,"isOrthographic",L.isOrthographicCamera===!0),b!==L&&(b=L,Dn=!0,Ca=!0)}if(G.isSkinnedMesh){Le.setOptional(U,G,"bindMatrix"),Le.setOptional(U,G,"bindMatrixInverse");let pn=G.skeleton;pn&&(pn.boneTexture===null&&pn.computeBoneTexture(),Le.setValue(U,"boneTexture",pn.boneTexture,st))}G.isBatchedMesh&&(Le.setOptional(U,G,"batchingTexture"),Le.setValue(U,"batchingTexture",G._matricesTexture,st),Le.setOptional(U,G,"batchingIdTexture"),Le.setValue(U,"batchingIdTexture",G._indirectTexture,st),Le.setOptional(U,G,"batchingColorTexture"),G._colorsTexture!==null&&Le.setValue(U,"batchingColorTexture",G._colorsTexture,st));let Jn=J.morphAttributes;if((Jn.position!==void 0||Jn.normal!==void 0||Jn.color!==void 0)&&ft.update(G,J,Nn),(Dn||Gt.receiveShadow!==G.receiveShadow)&&(Gt.receiveShadow=G.receiveShadow,Le.setValue(U,"receiveShadow",G.receiveShadow)),j.isMeshGouraudMaterial&&j.envMap!==null&&(Zn.envMap.value=Nt,Zn.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),j.isMeshStandardMaterial&&j.envMap===null&&V.environment!==null&&(Zn.envMapIntensity.value=V.environmentIntensity),Dn&&(Le.setValue(U,"toneMappingExposure",d.toneMappingExposure),Gt.needsLights&&AM(Zn,Ca),pt&&j.fog===!0&&et.refreshFogUniforms(Zn,pt),et.refreshMaterialUniforms(Zn,j,B,H,_.state.transmissionRenderTarget[L.id]),ia.upload(U,Dx(Gt),Zn,st)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(ia.upload(U,Dx(Gt),Zn,st),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&Le.setValue(U,"center",G.center),Le.setValue(U,"modelViewMatrix",G.modelViewMatrix),Le.setValue(U,"normalMatrix",G.normalMatrix),Le.setValue(U,"modelMatrix",G.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){let pn=j.uniformsGroups;for(let bn=0,Td=pn.length;bn<Td;bn++){let Gr=pn[bn];jt.update(Gr,Nn),jt.bind(Gr,Nn)}}return Nn}function AM(L,V){L.ambientLightColor.needsUpdate=V,L.lightProbe.needsUpdate=V,L.directionalLights.needsUpdate=V,L.directionalLightShadows.needsUpdate=V,L.pointLights.needsUpdate=V,L.pointLightShadows.needsUpdate=V,L.spotLights.needsUpdate=V,L.spotLightShadows.needsUpdate=V,L.rectAreaLights.needsUpdate=V,L.hemisphereLights.needsUpdate=V}function RM(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return m},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(L,V,J){let j=it.get(L);j.__autoAllocateDepthBuffer=L.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),it.get(L.texture).__webglTexture=V,it.get(L.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:J,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(L,V){let J=it.get(L);J.__webglFramebuffer=V,J.__useDefaultFramebuffer=V===void 0};let CM=U.createFramebuffer();this.setRenderTarget=function(L,V=0,J=0){E=L,m=V,R=J;let j=!0,G=null,pt=!1,At=!1;if(L){let Nt=it.get(L);if(Nt.__useDefaultFramebuffer!==void 0)q.bindFramebuffer(U.FRAMEBUFFER,null),j=!1;else if(Nt.__webglFramebuffer===void 0)st.setupRenderTarget(L);else if(Nt.__hasExternalTextures)st.rebindTextures(L,it.get(L.texture).__webglTexture,it.get(L.depthTexture).__webglTexture);else if(L.depthBuffer){let Ht=L.depthTexture;if(Nt.__boundDepthTexture!==Ht){if(Ht!==null&&it.has(Ht)&&(L.width!==Ht.image.width||L.height!==Ht.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");st.setupDepthRenderbuffer(L)}}let Wt=L.texture;(Wt.isData3DTexture||Wt.isDataArrayTexture||Wt.isCompressedArrayTexture)&&(At=!0);let Yt=it.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(Yt[V])?G=Yt[V][J]:G=Yt[V],pt=!0):L.samples>0&&st.useMultisampledRTT(L)===!1?G=it.get(L).__webglMultisampledFramebuffer:Array.isArray(Yt)?G=Yt[J]:G=Yt,w.copy(L.viewport),A.copy(L.scissor),C=L.scissorTest}else w.copy(rt).multiplyScalar(B).floor(),A.copy(ht).multiplyScalar(B).floor(),C=bt;if(J!==0&&(G=CM),q.bindFramebuffer(U.FRAMEBUFFER,G)&&j&&q.drawBuffers(L,G),q.viewport(w),q.scissor(A),q.setScissorTest(C),pt){let Nt=it.get(L.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+V,Nt.__webglTexture,J)}else if(At){let Nt=V;for(let Wt=0;Wt<L.textures.length;Wt++){let Yt=it.get(L.textures[Wt]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Wt,Yt.__webglTexture,J,Nt)}}else if(L!==null&&J!==0){let Nt=it.get(L.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Nt.__webglTexture,J)}T=-1},this.readRenderTargetPixels=function(L,V,J,j,G,pt,At,Ot=0){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=it.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&At!==void 0&&(Nt=Nt[At]),Nt){q.bindFramebuffer(U.FRAMEBUFFER,Nt);try{let Wt=L.textures[Ot],Yt=Wt.format,Ht=Wt.type;if(!Y.textureFormatReadable(Yt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Y.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=L.width-j&&J>=0&&J<=L.height-G&&(L.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ot),U.readPixels(V,J,j,G,zt.convert(Yt),zt.convert(Ht),pt))}finally{let Wt=E!==null?it.get(E).__webglFramebuffer:null;q.bindFramebuffer(U.FRAMEBUFFER,Wt)}}},this.readRenderTargetPixelsAsync=async function(L,V,J,j,G,pt,At,Ot=0){if(!(L&&L.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=it.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&At!==void 0&&(Nt=Nt[At]),Nt)if(V>=0&&V<=L.width-j&&J>=0&&J<=L.height-G){q.bindFramebuffer(U.FRAMEBUFFER,Nt);let Wt=L.textures[Ot],Yt=Wt.format,Ht=Wt.type;if(!Y.textureFormatReadable(Yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Y.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ae=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,ae),U.bufferData(U.PIXEL_PACK_BUFFER,pt.byteLength,U.STREAM_READ),L.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ot),U.readPixels(V,J,j,G,zt.convert(Yt),zt.convert(Ht),0);let ye=E!==null?it.get(E).__webglFramebuffer:null;q.bindFramebuffer(U.FRAMEBUFFER,ye);let Fe=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await w0(U,Fe,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,ae),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,pt),U.deleteBuffer(ae),U.deleteSync(Fe),pt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(L,V=null,J=0){let j=Math.pow(2,-J),G=Math.floor(L.image.width*j),pt=Math.floor(L.image.height*j),At=V!==null?V.x:0,Ot=V!==null?V.y:0;st.setTexture2D(L,0),U.copyTexSubImage2D(U.TEXTURE_2D,J,0,0,At,Ot,G,pt),q.unbindTexture()};let IM=U.createFramebuffer(),PM=U.createFramebuffer();this.copyTextureToTexture=function(L,V,J=null,j=null,G=0,pt=null){pt===null&&(G!==0?(vo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),pt=G,G=0):pt=0);let At,Ot,Nt,Wt,Yt,Ht,ae,ye,Fe,we=L.isCompressedTexture?L.mipmaps[pt]:L.image;if(J!==null)At=J.max.x-J.min.x,Ot=J.max.y-J.min.y,Nt=J.isBox3?J.max.z-J.min.z:1,Wt=J.min.x,Yt=J.min.y,Ht=J.isBox3?J.min.z:0;else{let Jn=Math.pow(2,-G);At=Math.floor(we.width*Jn),Ot=Math.floor(we.height*Jn),L.isDataArrayTexture?Nt=we.depth:L.isData3DTexture?Nt=Math.floor(we.depth*Jn):Nt=1,Wt=0,Yt=0,Ht=0}j!==null?(ae=j.x,ye=j.y,Fe=j.z):(ae=0,ye=0,Fe=0);let Me=zt.convert(V.format),Gt=zt.convert(V.type),Pe;V.isData3DTexture?(st.setTexture3D(V,0),Pe=U.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(st.setTexture2DArray(V,0),Pe=U.TEXTURE_2D_ARRAY):(st.setTexture2D(V,0),Pe=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,V.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,V.unpackAlignment);let he=U.getParameter(U.UNPACK_ROW_LENGTH),Nn=U.getParameter(U.UNPACK_IMAGE_HEIGHT),qs=U.getParameter(U.UNPACK_SKIP_PIXELS),Dn=U.getParameter(U.UNPACK_SKIP_ROWS),Ca=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,we.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,we.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Wt),U.pixelStorei(U.UNPACK_SKIP_ROWS,Yt),U.pixelStorei(U.UNPACK_SKIP_IMAGES,Ht);let Le=L.isDataArrayTexture||L.isData3DTexture,Zn=V.isDataArrayTexture||V.isData3DTexture;if(L.isDepthTexture){let Jn=it.get(L),pn=it.get(V),bn=it.get(Jn.__renderTarget),Td=it.get(pn.__renderTarget);q.bindFramebuffer(U.READ_FRAMEBUFFER,bn.__webglFramebuffer),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,Td.__webglFramebuffer);for(let Gr=0;Gr<Nt;Gr++)Le&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,it.get(L).__webglTexture,G,Ht+Gr),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,it.get(V).__webglTexture,pt,Fe+Gr)),U.blitFramebuffer(Wt,Yt,At,Ot,ae,ye,At,Ot,U.DEPTH_BUFFER_BIT,U.NEAREST);q.bindFramebuffer(U.READ_FRAMEBUFFER,null),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(G!==0||L.isRenderTargetTexture||it.has(L)){let Jn=it.get(L),pn=it.get(V);q.bindFramebuffer(U.READ_FRAMEBUFFER,IM),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,PM);for(let bn=0;bn<Nt;bn++)Le?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Jn.__webglTexture,G,Ht+bn):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Jn.__webglTexture,G),Zn?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,pn.__webglTexture,pt,Fe+bn):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,pn.__webglTexture,pt),G!==0?U.blitFramebuffer(Wt,Yt,At,Ot,ae,ye,At,Ot,U.COLOR_BUFFER_BIT,U.NEAREST):Zn?U.copyTexSubImage3D(Pe,pt,ae,ye,Fe+bn,Wt,Yt,At,Ot):U.copyTexSubImage2D(Pe,pt,ae,ye,Wt,Yt,At,Ot);q.bindFramebuffer(U.READ_FRAMEBUFFER,null),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else Zn?L.isDataTexture||L.isData3DTexture?U.texSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,Gt,we.data):V.isCompressedArrayTexture?U.compressedTexSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,we.data):U.texSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,Gt,we):L.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,pt,ae,ye,At,Ot,Me,Gt,we.data):L.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,pt,ae,ye,we.width,we.height,Me,we.data):U.texSubImage2D(U.TEXTURE_2D,pt,ae,ye,At,Ot,Me,Gt,we);U.pixelStorei(U.UNPACK_ROW_LENGTH,he),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Nn),U.pixelStorei(U.UNPACK_SKIP_PIXELS,qs),U.pixelStorei(U.UNPACK_SKIP_ROWS,Dn),U.pixelStorei(U.UNPACK_SKIP_IMAGES,Ca),pt===0&&V.generateMipmaps&&U.generateMipmap(Pe),q.unbindTexture()},this.initRenderTarget=function(L){it.get(L).__webglFramebuffer===void 0&&st.setupRenderTarget(L)},this.initTexture=function(L){L.isCubeTexture?st.setTextureCube(L,0):L.isData3DTexture?st.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?st.setTexture2DArray(L,0):st.setTexture2D(L,0),q.unbindTexture()},this.resetState=function(){m=0,R=0,E=null,q.reset(),wt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return wn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=ie._getDrawingBufferColorSpace(t),e.unpackColorSpace=ie._getUnpackColorSpace()}};var hy={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},Us=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new zm(t)}),this.register(function(t){return new km(t)}),this.register(function(t){return new Wm(t)}),this.register(function(t){return new Xm(t)}),this.register(function(t){return new qm(t)}),this.register(function(t){return new Ym(t)}),this.register(function(t){return new Hm(t)}),this.register(function(t){return new Vm(t)}),this.register(function(t){return new Gm(t)}),this.register(function(t){return new $m(t)}),this.register(function(t){return new Km(t)}),this.register(function(t){return new Zm(t)}),this.register(function(t){return new Jm(t)}),this.register(function(t){return new jm(t)})}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}setTextureUtils(t){return this.textureUtils=t,this}parse(t,e,n,i){let r=new Bm,o=[];for(let a=0,c=this.pluginCallbacks.length;a<c;a++)o.push(this.pluginCallbacks[a](r));r.setPlugins(o),r.setTextureUtils(this.textureUtils),r.writeAsync(t,e,i).catch(n)}parseAsync(t,e){let n=this;return new Promise(function(i,r){n.parse(t,i,r,e)})}},se={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Fm="KHR_mesh_quantization",Xn={};Xn[De]=se.NEAREST;Xn[Nr]=se.NEAREST_MIPMAP_NEAREST;Xn[Mi]=se.NEAREST_MIPMAP_LINEAR;Xn[Ee]=se.LINEAR;Xn[Xi]=se.LINEAR_MIPMAP_NEAREST;Xn[un]=se.LINEAR_MIPMAP_LINEAR;Xn[en]=se.CLAMP_TO_EDGE;Xn[An]=se.REPEAT;Xn[Li]=se.MIRRORED_REPEAT;var fy={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},QA=new yt,dy=12,t1=1179937895,e1=2,py=8,n1=1313821514,i1=5130562;function Gl(s,t){return s.length===t.length&&s.every(function(e,n){return e===t[n]})}function r1(s){return new TextEncoder().encode(s).buffer}function s1(s){return Gl(s.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function o1(s,t,e){let n={min:new Array(s.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(s.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i<t+e;i++)for(let r=0;r<s.itemSize;r++){let o;s.itemSize>4?o=s.array[i*s.itemSize+r]:(r===0?o=s.getX(i):r===1?o=s.getY(i):r===2?o=s.getZ(i):r===3&&(o=s.getW(i)),s.normalized===!0&&(o=Yi.normalize(o,s.array))),n.min[r]=Math.min(n.min[r],o),n.max[r]=Math.max(n.max[r],o)}return n}function gy(s){return Math.ceil(s/4)*4}function Om(s,t=0){let e=gy(s.byteLength);if(e!==s.byteLength){let n=new Uint8Array(e);if(n.set(new Uint8Array(s)),t!==0)for(let i=s.byteLength;i<e;i++)n[i]=t;return n.buffer}return s}function my(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function a1(s,t){if(typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas){let e;return t==="image/jpeg"?e=.92:t==="image/webp"&&(e=.8),s.convertToBlob({type:t,quality:e})}else return new Promise(e=>s.toBlob(e,t))}var Bm=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+Hi}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);let i=this,r=i.buffers,o=i.json;n=i.options;let a=i.extensionsUsed,c=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),u=Object.keys(a),h=Object.keys(c);if(u.length>0&&(o.extensionsUsed=u),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=l.size),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(l),f.onloadend=function(){let p=Om(f.result),x=new DataView(new ArrayBuffer(py));x.setUint32(0,p.byteLength,!0),x.setUint32(4,i1,!0);let v=Om(r1(JSON.stringify(o)),32),y=new DataView(new ArrayBuffer(py));y.setUint32(0,v.byteLength,!0),y.setUint32(4,n1,!0);let _=new ArrayBuffer(dy),S=new DataView(_);S.setUint32(0,t1,!0),S.setUint32(4,e1,!0);let g=dy+y.byteLength+v.byteLength+x.byteLength+p.byteLength;S.setUint32(8,g,!0);let d=new Blob([_,y,v,x,p],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(d),M.onloadend=function(){e(M.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(l),f.onloadend=function(){let p=f.result;o.buffers[0].uri=p,e(o)}}else e(o)}serializeUserData(t,e){if(Object.keys(t.userData).length===0)return;let n=this.options,i=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){e.extensions===void 0&&(e.extensions={});for(let o in r.gltfExtensions)e.extensions[o]=r.gltfExtensions[o],i[o]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(t,e=!1){if(this.uids.has(t)===!1){let i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(t,i)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;let n=new I;for(let i=0,r=t.count;i<r;i++)if(Math.abs(n.fromBufferAttribute(t,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){let e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);let n=t.clone(),i=new I;for(let r=0,o=n.count;r<o;r++)i.fromBufferAttribute(n,r),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),n.setXYZ(r,i.x,i.y,i.z);return e.attributesNormalized.set(t,n),n}applyTextureTransform(t,e){let n=!1,i={};(e.offset.x!==0||e.offset.y!==0)&&(i.offset=e.offset.toArray(),n=!0),e.rotation!==0&&(i.rotation=e.rotation,n=!0),(e.repeat.x!==1||e.repeat.y!==1)&&(i.scale=e.repeat.toArray(),n=!0),n&&(t.extensions=t.extensions||{},t.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(t,e){if(t===e)return t;function n(p){return p.colorSpace===Ae?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}t instanceof gi&&(t=await this.decompressTextureAsync(t)),e instanceof gi&&(e=await this.decompressTextureAsync(e));let i=t?t.image:null,r=e?e.image:null,o=Math.max(i?i.width:0,r?r.width:0),a=Math.max(i?i.height:0,r?r.height:0),c=my();c.width=o,c.height=a;let l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,o,a);let u=l.getImageData(0,0,o,a);if(i){l.drawImage(i,0,0,o,a);let p=n(t),x=l.getImageData(0,0,o,a).data;for(let v=2;v<x.length;v+=4)u.data[v]=p(x[v]/256)*256}if(r){l.drawImage(r,0,0,o,a);let p=n(e),x=l.getImageData(0,0,o,a).data;for(let v=1;v<x.length;v+=4)u.data[v]=p(x[v]/256)*256}l.putImageData(u,0,0);let f=(t||e).clone();return f.source=new On(c),f.colorSpace=si,f.channel=(t||e).channel,t&&e&&t.channel!==e.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),f}async decompressTextureAsync(t,e=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(t,e)}processBuffer(t){let e=this.json,n=this.buffers;return e.buffers||(e.buffers=[{byteLength:0}]),n.push(t),0}processBufferView(t,e,n,i,r){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(e){case se.BYTE:case se.UNSIGNED_BYTE:a=1;break;case se.SHORT:case se.UNSIGNED_SHORT:a=2;break;default:a=4}let c=t.itemSize*a;r===se.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);let l=gy(i*c),u=new DataView(new ArrayBuffer(l)),h=0;for(let x=n;x<n+i;x++){for(let v=0;v<t.itemSize;v++){let y;t.itemSize>4?y=t.array[x*t.itemSize+v]:(v===0?y=t.getX(x):v===1?y=t.getY(x):v===2?y=t.getZ(x):v===3&&(y=t.getW(x)),t.normalized===!0&&(y=Yi.normalize(y,t.array))),e===se.FLOAT?u.setFloat32(h,y,!0):e===se.INT?u.setInt32(h,y,!0):e===se.UNSIGNED_INT?u.setUint32(h,y,!0):e===se.SHORT?u.setInt16(h,y,!0):e===se.UNSIGNED_SHORT?u.setUint16(h,y,!0):e===se.BYTE?u.setInt8(h,y):e===se.UNSIGNED_BYTE&&u.setUint8(h,y),h+=a}h%c!==0&&(h+=c-h%c)}let f={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:l};return r!==void 0&&(f.target=r),r===se.ARRAY_BUFFER&&(f.byteStride=c),this.byteOffset+=l,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){let e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(i){let r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){let o=Om(r.result),a={buffer:e.processBuffer(o),byteOffset:e.byteOffset,byteLength:o.byteLength};e.byteOffset+=o.byteLength,i(n.bufferViews.push(a)-1)}})}processAccessor(t,e,n,i){let r=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(t.array.constructor===Float32Array)a=se.FLOAT;else if(t.array.constructor===Int32Array)a=se.INT;else if(t.array.constructor===Uint32Array)a=se.UNSIGNED_INT;else if(t.array.constructor===Int16Array)a=se.SHORT;else if(t.array.constructor===Uint16Array)a=se.UNSIGNED_SHORT;else if(t.array.constructor===Int8Array)a=se.BYTE;else if(t.array.constructor===Uint8Array)a=se.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);if(n===void 0&&(n=0),(i===void 0||i===1/0)&&(i=t.count),i===0)return null;let c=o1(t,n,i),l;e!==void 0&&(l=t===e.index?se.ELEMENT_ARRAY_BUFFER:se.ARRAY_BUFFER);let u=this.processBufferView(t,a,n,i,l),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:a,count:i,max:c.max,min:c.min,type:o[t.itemSize]};return t.normalized===!0&&(h.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(h)-1}processImage(t,e,n,i="image/png"){if(t!==null){let r=this,o=r.cache,a=r.json,c=r.options,l=r.pending;o.images.has(t)||o.images.set(t,{});let u=o.images.get(t),h=i+":flipY/"+n.toString();if(u[h]!==void 0)return u[h];a.images||(a.images=[]);let f={mimeType:i},p=my();p.width=Math.min(t.width,c.maxTextureSize),p.height=Math.min(t.height,c.maxTextureSize);let x=p.getContext("2d",{willReadFrequently:!0});if(n===!0&&(x.translate(0,p.height),x.scale(1,-1)),t.data!==void 0){e!==Qe&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>c.maxTextureSize||t.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);let y=new Uint8ClampedArray(t.height*t.width*4);for(let _=0;_<y.length;_+=4)y[_+0]=t.data[_+0],y[_+1]=t.data[_+1],y[_+2]=t.data[_+2],y[_+3]=t.data[_+3];x.putImageData(new ImageData(y,t.width,t.height),0,0)}else if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)x.drawImage(t,0,0,p.width,p.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(a1(p,i).then(y=>r.processBufferViewImage(y)).then(y=>{f.bufferView=y})):f.uri=as.getDataURL(p,i);let v=a.images.push(f)-1;return u[h]=v,v}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){let e=this.json;e.samplers||(e.samplers=[]);let n={magFilter:Xn[t.magFilter],minFilter:Xn[t.minFilter],wrapS:Xn[t.wrapS],wrapT:Xn[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){let n=this.options,i=this.cache,r=this.json;if(i.textures.has(t))return i.textures.get(t);r.textures||(r.textures=[]),t instanceof gi&&(t=await this.decompressTextureAsync(t,n.maxTextureSize));let o=t.userData.mimeType;o==="image/webp"&&(o="image/png");let a={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,o)};t.name&&(a.name=t.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(t,a)});let c=r.textures.push(a)-1;return i.textures.set(t,c),c}async processMaterialAsync(t){let e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};t.isMeshStandardMaterial!==!0&&t.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=t.color.toArray().concat([t.opacity]);if(Gl(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){let a=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),c={index:await this.processTextureAsync(a),texCoord:a.channel};this.applyTextureTransform(c,a),i.pbrMetallicRoughness.metallicRoughnessTexture=c}if(t.map){let a={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(a,t.map),i.pbrMetallicRoughness.baseColorTexture=a}if(t.emissive){let a=t.emissive;if(Math.max(a.r,a.g,a.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){let l={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(l,t.emissiveMap),i.emissiveTexture=l}}if(t.normalMap){let a={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&t.normalScale.x!==1&&(a.scale=t.normalScale.x),this.applyTextureTransform(a,t.normalMap),i.normalTexture=a}if(t.aoMap){let a={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};t.aoMapIntensity!==1&&(a.strength=t.aoMapIntensity),this.applyTextureTransform(a,t.aoMap),i.occlusionTexture=a}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===Ve&&(i.doubleSided=!0),t.name!==""&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync(async function(a){a.writeMaterialAsync&&await a.writeMaterialAsync(t,i)});let o=n.materials.push(i)-1;return e.materials.set(t,o),o}async processMeshAsync(t){let e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let d=0,M=t.material.length;d<M;d++)i.push(t.material[d].uuid);else i.push(t.material.uuid);let r=i.join(":");if(e.meshes.has(r))return e.meshes.get(r);let o=t.geometry,a;t.isLineSegments?a=se.LINES:t.isLineLoop?a=se.LINE_LOOP:t.isLine?a=se.LINE_STRIP:t.isPoints?a=se.POINTS:a=t.material.wireframe?se.LINES:se.TRIANGLES;let c={},l={},u=[],h=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=o.getAttribute("normal");p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let x=null;for(let d in o.attributes){if(d.slice(0,5)==="morph")continue;let M=o.attributes[d];if(d=f[d]||d.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(d)||(d="_"+d),e.attributes.has(this.getUID(M))){l[d]=e.attributes.get(this.getUID(M));continue}x=null;let R=M.array;d==="JOINTS_0"&&!(R instanceof Uint16Array)&&!(R instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),x=new kt(new Uint16Array(R),M.itemSize,M.normalized)):(R instanceof Uint32Array||R instanceof Int32Array)&&!d.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${d}" converted to type FLOAT.`),x=Us.Utils.toFloat32BufferAttribute(M));let E=this.processAccessor(x||M,o);E!==null&&(d.startsWith("_")||this.detectMeshQuantization(d,M),l[d]=E,e.attributes.set(this.getUID(M),E))}if(p!==void 0&&o.setAttribute("normal",p),Object.keys(l).length===0)return null;if(t.morphTargetInfluences!==void 0&&t.morphTargetInfluences.length>0){let d=[],M=[],m={};if(t.morphTargetDictionary!==void 0)for(let R in t.morphTargetDictionary)m[t.morphTargetDictionary[R]]=R;for(let R=0;R<t.morphTargetInfluences.length;++R){let E={},T=!1;for(let b in o.morphAttributes){if(b!=="position"&&b!=="normal"){T||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),T=!0);continue}let w=o.morphAttributes[b][R],A=b.toUpperCase(),C=o.attributes[b];if(e.attributes.has(this.getUID(w,!0))){E[A]=e.attributes.get(this.getUID(w,!0));continue}let D=w.clone();if(!o.morphTargetsRelative)for(let F=0,O=w.count;F<O;F++)for(let H=0;H<w.itemSize;H++)H===0&&D.setX(F,w.getX(F)-C.getX(F)),H===1&&D.setY(F,w.getY(F)-C.getY(F)),H===2&&D.setZ(F,w.getZ(F)-C.getZ(F)),H===3&&D.setW(F,w.getW(F)-C.getW(F));E[A]=this.processAccessor(D,o),e.attributes.set(this.getUID(C,!0),E[A])}h.push(E),d.push(t.morphTargetInfluences[R]),t.morphTargetDictionary!==void 0&&M.push(m[R])}c.weights=d,M.length>0&&(c.extras={},c.extras.targetNames=M)}let v=Array.isArray(t.material);if(v&&o.groups.length===0)return null;let y=!1;if(v&&o.index===null){let d=[];for(let M=0,m=o.attributes.position.count;M<m;M++)d[M]=M;o.setIndex(d),y=!0}let _=v?t.material:[t.material],S=v?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let d=0,M=S.length;d<M;d++){let m={mode:a,attributes:l};if(this.serializeUserData(o,m),h.length>0&&(m.targets=h),o.index!==null){let E=this.getUID(o.index);(S[d].start!==void 0||S[d].count!==void 0)&&(E+=":"+S[d].start+":"+S[d].count),e.attributes.has(E)?m.indices=e.attributes.get(E):(m.indices=this.processAccessor(o.index,o,S[d].start,S[d].count),e.attributes.set(E,m.indices)),m.indices===null&&delete m.indices}let R=await this.processMaterialAsync(_[S[d].materialIndex]);R!==null&&(m.material=R),u.push(m)}y===!0&&o.setIndex(null),c.primitives=u,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(d){d.writeMesh&&d.writeMesh(t,c)});let g=n.meshes.push(c)-1;return e.meshes.set(r,g),g}detectMeshQuantization(t,e){if(this.extensionsUsed[Fm])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");let i=t.split("_",1)[0];hy[i]&&hy[i].includes(n)&&(this.extensionsUsed[Fm]=!0,this.extensionsRequired[Fm]=!0)}processCamera(t){let e=this.json;e.cameras||(e.cameras=[]);let n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:t.right*2,ymag:t.top*2,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:Yi.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},t.name!==""&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]),t=Us.Utils.mergeMorphTargetTracks(t.clone(),e);let r=t.tracks,o=[],a=[];for(let l=0;l<r.length;++l){let u=r[l],h=ee.parseTrackName(u.name),f=ee.findNode(e,h.nodeName),p=fy[h.propertyName];if(h.objectName==="bones"&&(f.isSkinnedMesh===!0?f=f.skeleton.getBoneByName(h.objectIndex):f=void 0),!f||!p){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name);continue}let x=1,v=u.values.length/u.times.length;p===fy.morphTargetInfluences&&(v/=f.morphTargetInfluences.length);let y;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",v/=3):u.getInterpolation()===Ni?y="STEP":y="LINEAR",a.push({input:this.processAccessor(new kt(u.times,x)),output:this.processAccessor(new kt(u.values,v)),interpolation:y}),o.push({sampler:a.length-1,target:{node:i.get(f),path:p}})}let c={name:t.name||"clip_"+n.animations.length,samplers:a,channels:o};return this.serializeUserData(t,c),n.animations.push(c),n.animations.length-1}processSkin(t){let e=this.json,n=this.nodeMap,i=e.nodes[n.get(t)],r=t.skeleton;if(r===void 0)return null;let o=t.skeleton.bones[0];if(o===void 0)return null;let a=[],c=new Float32Array(r.bones.length*16),l=new vt;for(let h=0;h<r.bones.length;++h)a.push(n.get(r.bones[h])),l.copy(r.boneInverses[h]),l.multiply(t.bindMatrix).toArray(c,h*16);return e.skins===void 0&&(e.skins=[]),e.skins.push({inverseBindMatrices:this.processAccessor(new kt(c,16)),joints:a,skeleton:n.get(o)}),i.skin=e.skins.length-1}async processNodeAsync(t){let e=this.json,n=this.options,i=this.nodeMap;e.nodes||(e.nodes=[]);let r={};if(n.trs){let a=t.quaternion.toArray(),c=t.position.toArray(),l=t.scale.toArray();Gl(a,[0,0,0,1])||(r.rotation=a),Gl(c,[0,0,0])||(r.translation=c),Gl(l,[1,1,1])||(r.scale=l)}else t.matrixAutoUpdate&&t.updateMatrix(),s1(t.matrix)===!1&&(r.matrix=t.matrix.elements);if(t.name!==""&&(r.name=String(t.name)),this.serializeUserData(t,r),t.isMesh||t.isLine||t.isPoints){let a=await this.processMeshAsync(t);a!==null&&(r.mesh=a)}else t.isCamera&&(r.camera=this.processCamera(t));t.isSkinnedMesh&&this.skins.push(t);let o=e.nodes.push(r)-1;if(i.set(t,o),t.children.length>0){let a=[];for(let c=0,l=t.children.length;c<l;c++){let u=t.children[c];if(u.visible||n.onlyVisible===!1){let h=await this.processNodeAsync(u);h!==null&&a.push(h)}}a.length>0&&(r.children=a)}return await this._invokeAllAsync(function(a){a.writeNode&&a.writeNode(t,r)}),o}async processSceneAsync(t){let e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);let i={};t.name!==""&&(i.name=t.name),e.scenes.push(i);let r=[];for(let o=0,a=t.children.length;o<a;o++){let c=t.children[o];if(c.visible||n.onlyVisible===!1){let l=await this.processNodeAsync(c);l!==null&&r.push(l)}}r.length>0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){let e=new Fi;e.name="AuxScene";for(let n=0;n<t.length;n++)e.children.push(t[n]);await this.processSceneAsync(e)}async processInputAsync(t){let e=this.options;t=t instanceof Array?t:[t],await this._invokeAllAsync(function(i){i.beforeParse&&i.beforeParse(t)});let n=[];for(let i=0;i<t.length;i++)t[i]instanceof Fi?await this.processSceneAsync(t[i]):n.push(t[i]);n.length>0&&await this.processObjectsAsync(n);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<e.animations.length;++i)this.processAnimation(e.animations[i],t[0]);await this._invokeAllAsync(function(i){i.afterParse&&i.afterParse(t)})}async _invokeAllAsync(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}},zm=class{constructor(t){this.writer=t,this.name="KHR_lights_punctual"}writeNode(t,e){if(!t.isLight)return;if(!t.isDirectionalLight&&!t.isPointLight&&!t.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",t);return}let n=this.writer,i=n.json,r=n.extensionsUsed,o={};t.name&&(o.name=t.name),o.color=t.color.toArray(),o.intensity=t.intensity,t.isDirectionalLight?o.type="directional":t.isPointLight?(o.type="point",t.distance>0&&(o.range=t.distance)):t.isSpotLight&&(o.type="spot",t.distance>0&&(o.range=t.distance),o.spot={},o.spot.innerConeAngle=(1-t.penumbra)*t.angle,o.spot.outerConeAngle=t.angle),t.decay!==void 0&&t.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),t.target&&(t.target.parent!==t||t.target.position.x!==0||t.target.position.y!==0||t.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);let a=i.extensions[this.name].lights;a.push(o),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}},km=class{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;let i=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},i[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}},Hm=class{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.clearcoat===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){let o={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(o,t.clearcoatMap),r.clearcoatTexture=o}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){let o={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=o}if(t.clearcoatNormalMap){let o={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};t.clearcoatNormalScale.x!==1&&(o.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(o,t.clearcoatNormalMap),r.clearcoatNormalTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Vm=class{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.dispersion===0)return;let i=this.writer.extensionsUsed,r={};r.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Gm=class{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.iridescence===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){let o={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(o,t.iridescenceMap),r.iridescenceTexture=o}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){let o={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(o,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Wm=class{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){let o={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(o,t.transmissionMap),r.transmissionTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Xm=class{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){let o={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(o,t.thicknessMap),r.thicknessTexture=o}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},qm=class{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.ior===1.5)return;let i=this.writer.extensionsUsed,r={};r.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Ym=class{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.specularIntensity===1&&t.specularColor.equals(QA)&&!t.specularIntensityMap&&!t.specularColorMap)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){let o={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(o,t.specularIntensityMap),r.specularTexture=o}if(t.specularColorMap){let o={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(o,t.specularColorMap),r.specularColorTexture=o}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},$m=class{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.sheen==0)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){let o={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(o,t.sheenRoughnessMap),r.sheenRoughnessTexture=o}if(t.sheenColorMap){let o={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(o,t.sheenColorMap),r.sheenColorTexture=o}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Km=class{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.anisotropy==0)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){let o={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(o,t.anisotropyMap),r.anisotropyTexture=o}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Zm=class{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||t.emissiveIntensity===1)return;let i=this.writer.extensionsUsed,r={};r.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Jm=class{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||t.bumpScale===1&&!t.bumpMap)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){let o={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(o,t.bumpMap),r.bumpTexture=o}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},jm=class{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;let n=this.writer,i=t,r=new Float32Array(i.count*3),o=new Float32Array(i.count*4),a=new Float32Array(i.count*3),c=new vt,l=new I,u=new Ce,h=new I;for(let p=0;p<i.count;p++)i.getMatrixAt(p,c),c.decompose(l,u,h),l.toArray(r,p*3),u.toArray(o,p*4),h.toArray(a,p*3);let f={TRANSLATION:n.processAccessor(new kt(r,3)),ROTATION:n.processAccessor(new kt(o,4)),SCALE:n.processAccessor(new kt(a,3))};i.instanceColor&&(f._COLOR_0=n.processAccessor(i.instanceColor)),e.extensions=e.extensions||{},e.extensions[this.name]={attributes:f},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};Us.Utils={insertKeyframe:function(s,t){let n=s.getValueSize(),i=new s.TimeBufferType(s.times.length+1),r=new s.ValueBufferType(s.values.length+n),o=s.createInterpolant(new s.ValueBufferType(n)),a;if(s.times.length===0){i[0]=t;for(let c=0;c<n;c++)r[c]=0;a=0}else if(t<s.times[0]){if(Math.abs(s.times[0]-t)<.001)return 0;i[0]=t,i.set(s.times,1),r.set(o.evaluate(t),0),r.set(s.values,n),a=0}else if(t>s.times[s.times.length-1]){if(Math.abs(s.times[s.times.length-1]-t)<.001)return s.times.length-1;i[i.length-1]=t,i.set(s.times,0),r.set(s.values,0),r.set(o.evaluate(t),s.values.length),a=i.length-1}else for(let c=0;c<s.times.length;c++){if(Math.abs(s.times[c]-t)<.001)return c;if(s.times[c]<t&&s.times[c+1]>t){i.set(s.times.slice(0,c+1),0),i[c+1]=t,i.set(s.times.slice(c+1),c+2),r.set(s.values.slice(0,(c+1)*n),0),r.set(o.evaluate(t),(c+1)*n),r.set(s.values.slice((c+1)*n),(c+2)*n),a=c+1;break}}return s.times=i,s.values=r,a},mergeMorphTargetTracks:function(s,t){let e=[],n={},i=s.tracks;for(let r=0;r<i.length;++r){let o=i[r],a=ee.parseTrackName(o.name),c=ee.findNode(t,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){e.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(Di)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[a.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let h;if(n[c.uuid]===void 0){h=o.clone();let p=new h.ValueBufferType(l*h.times.length);for(let x=0;x<h.times.length;x++)p[x*l+u]=h.values[x];h.name=(a.nodeName||"")+".morphTargetInfluences",h.values=p,n[c.uuid]=h,e.push(h);continue}let f=o.createInterpolant(new o.ValueBufferType(1));h=n[c.uuid];for(let p=0;p<h.times.length;p++)h.values[p*l+u]=f.evaluate(h.times[p]);for(let p=0;p<o.times.length;p++){let x=this.insertKeyframe(h,o.times[p]);h.values[x*l+u]=o.values[p]}}return s.tracks=e,s},toFloat32BufferAttribute:function(s){let t=new kt(new Float32Array(s.count*s.itemSize),s.itemSize,!1);if(!s.normalized&&!s.isInterleavedBufferAttribute)return t.array.set(s.array),t;for(let e=0,n=s.count;e<n;e++)for(let i=0;i<s.itemSize;i++)t.setComponent(e,i,s.getComponent(e,i));return t}};function Qm(s,t=!1){let e=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,c=new Vt,l=0;for(let u=0;u<s.length;++u){let h=s[u],f=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in h.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;r[p]===void 0&&(r[p]=[]),r[p].push(h.attributes[p]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in h.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(h.morphAttributes[p])}if(t){let p;if(e)p=h.index.count;else if(h.attributes.position!==void 0)p=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(e){let u=0,h=[];for(let f=0;f<s.length;++f){let p=s[f].index;for(let x=0;x<p.count;++x)h.push(p.getX(x)+u);u+=s[f].attributes.position.count}c.setIndex(h)}for(let u in r){let h=xy(r[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<h;++f){let p=[];for(let v=0;v<o[u].length;++v)p.push(o[u][v][f]);let x=xy(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(x)}}return c}function xy(s){let t,e,n,i=-1,r=0;for(let l=0;l<s.length;++l){let u=s[l];if(t===void 0&&(t=u.array.constructor),t!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=u.itemSize),e!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=u.normalized),n!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=u.count*e}let o=new t(r),a=new kt(o,e,n),c=0;for(let l=0;l<s.length;++l){let u=s[l];if(u.isInterleavedBufferAttribute){let h=c/e;for(let f=0,p=u.count;f<p;f++)for(let x=0;x<e;x++){let v=u.getComponent(f,x);a.setComponent(f+h,x,v)}}else o.set(u.array,c);c+=u.count*e}return i!==void 0&&(a.gpuType=i),a}function tg(s,t=1e-4){t=Math.max(t,Number.EPSILON);let e={},n=s.getIndex(),i=s.getAttribute("position"),r=n?n.count:i.count,o=0,a=Object.keys(s.attributes),c={},l={},u=[],h=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let S=0,g=a.length;S<g;S++){let d=a[S],M=s.attributes[d];c[d]=new M.constructor(new M.array.constructor(M.count*M.itemSize),M.itemSize,M.normalized);let m=s.morphAttributes[d];m&&(l[d]||(l[d]=[]),m.forEach((R,E)=>{let T=new R.array.constructor(R.count*R.itemSize);l[d][E]=new R.constructor(T,R.itemSize,R.normalized)}))}let p=t*.5,x=Math.log10(1/t),v=Math.pow(10,x),y=p*v;for(let S=0;S<r;S++){let g=n?n.getX(S):S,d="";for(let M=0,m=a.length;M<m;M++){let R=a[M],E=s.getAttribute(R),T=E.itemSize;for(let b=0;b<T;b++)d+=`${~~(E[h[b]](g)*v+y)},`}if(d in e)u.push(e[d]);else{for(let M=0,m=a.length;M<m;M++){let R=a[M],E=s.getAttribute(R),T=s.morphAttributes[R],b=E.itemSize,w=c[R],A=l[R];for(let C=0;C<b;C++){let D=h[C],F=f[C];if(w[F](o,E[D](g)),T)for(let O=0,H=T.length;O<H;O++)A[O][F](o,T[O][D](g))}}e[d]=o,u.push(o),o++}}let _=s.clone();for(let S in s.attributes){let g=c[S];if(_.setAttribute(S,new g.constructor(g.array.slice(0,o*g.itemSize),g.itemSize,g.normalized)),S in l)for(let d=0;d<l[S].length;d++){let M=l[S][d];_.morphAttributes[S][d]=new M.constructor(M.array.slice(0,o*M.itemSize),M.itemSize,M.normalized)}}return _.setIndex(u),_}function eg(s,t){if(t===yf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(t===Cs||t===ta){let e=s.getIndex();if(e===null){let o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),e=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}let n=e.count-2,i=[];if(t===Cs)for(let o=1;o<=n;o++)i.push(e.getX(0)),i.push(e.getX(o)),i.push(e.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(e.getX(o)),i.push(e.getX(o+1)),i.push(e.getX(o+2))):(i.push(e.getX(o+2)),i.push(e.getX(o+1)),i.push(e.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),s}var Af=class extends Ke{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new cg(e)}),this.register(function(e){return new lg(e)}),this.register(function(e){return new _g(e)}),this.register(function(e){return new yg(e)}),this.register(function(e){return new vg(e)}),this.register(function(e){return new hg(e)}),this.register(function(e){return new fg(e)}),this.register(function(e){return new dg(e)}),this.register(function(e){return new pg(e)}),this.register(function(e){return new ag(e)}),this.register(function(e){return new mg(e)}),this.register(function(e){return new ug(e)}),this.register(function(e){return new xg(e)}),this.register(function(e){return new gg(e)}),this.register(function(e){return new sg(e)}),this.register(function(e){return new Mg(e)}),this.register(function(e){return new Sg(e)})}load(t,e,n,i){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=ii.extractUrlBase(t);o=ii.resolveURL(l,this.path)}else o=ii.extractUrlBase(t);this.manager.itemStart(t);let a=function(l){i?i(l):console.error(l),r.manager.itemError(t),r.manager.itemEnd(t)},c=new Mn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,function(l){try{r.parse(l,o,function(u){e(u),r.manager.itemEnd(t)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r,o={},a={},c=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(c.decode(new Uint8Array(t,0,4))===Sy){try{o[oe.KHR_BINARY_GLTF]=new bg(t)}catch(h){i&&i(h);return}r=JSON.parse(o[oe.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new Ig(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){let h=r.extensionsUsed[u],f=r.extensionsRequired||[];switch(h){case oe.KHR_MATERIALS_UNLIT:o[h]=new og;break;case oe.KHR_DRACO_MESH_COMPRESSION:o[h]=new Tg(r,this.dracoLoader);break;case oe.KHR_TEXTURE_TRANSFORM:o[h]=new Eg;break;case oe.KHR_MESH_QUANTIZATION:o[h]=new wg;break;default:f.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){let n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}};function c1(){let s={};return{get:function(t){return s[t]},add:function(t,e){s[t]=e},remove:function(t){delete s[t]},removeAll:function(){s={}}}}var oe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},sg=class{constructor(t){this.parser=t,this.name=oe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){let r=e[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){let e=this.parser,n="light:"+t,i=e.cache.get(n);if(i)return i;let r=e.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t],l,u=new yt(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],tn);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new lr(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Ss(u),l.distance=h;break;case"spot":l=new Ms(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),$i(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=e.createUniqueName(c.name||"light_"+t),i=Promise.resolve(l),e.cache.add(n,i),i}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){let e=this,n=this.parser,r=n.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(e.cache,a,c)})}},og=class{constructor(){this.name=oe.KHR_MATERIALS_UNLIT}getMaterialType(){return sn}extendParams(t,e,n){let i=[];t.color=new yt(1,1,1),t.opacity=1;let r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;t.color.setRGB(o[0],o[1],o[2],tn),t.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(t,"map",r.baseColorTexture,Ae))}return Promise.all(i)}},ag=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(e.emissiveIntensity=r),Promise.resolve()}},cg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(e.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(e,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new nt(a,a)}return Promise.all(r)}},lg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_DISPERSION}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return e.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}},ug=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(e.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(e.iridescenceIOR=o.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},hg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_SHEEN}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[];e.sheenColor=new yt(0,0,0),e.sheenRoughness=0,e.sheen=1;let o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],tn)}return o.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(e,"sheenColorMap",o.sheenColorTexture,Ae)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},fg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(e.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},dg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_VOLUME}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];e.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return e.attenuationColor=new yt().setRGB(a[0],a[1],a[2],tn),Promise.all(r)}},pg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_IOR}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return e.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},mg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_SPECULAR}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];e.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(e,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return e.specularColor=new yt().setRGB(a[0],a[1],a[2],tn),o.specularColorTexture!==void 0&&r.push(n.assignTexture(e,"specularColorMap",o.specularColorTexture,Ae)),Promise.all(r)}},gg=class{constructor(t){this.parser=t,this.name=oe.EXT_MATERIALS_BUMP}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return e.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(e,"bumpMap",o.bumpTexture)),Promise.all(r)}},xg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(e.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(e.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(e,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},_g=class{constructor(t){this.parser=t,this.name=oe.KHR_TEXTURE_BASISU}loadTexture(t){let e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,o)}},yg=class{constructor(t){this.parser=t,this.name=oe.EXT_TEXTURE_WEBP}loadTexture(t){let e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;let o=r.extensions[e],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(t,o.source,c)}},vg=class{constructor(t){this.parser=t,this.name=oe.EXT_TEXTURE_AVIF}loadTexture(t){let e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;let o=r.extensions[e],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(t,o.source,c)}},Mg=class{constructor(t){this.name=oe.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){let e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){let p=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(p),u,h,f,i.mode,i.filter),p})})}else return null}},Sg=class{constructor(t){this.name=oe.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){let e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=e.meshes[n.mesh];for(let l of i.primitives)if(l.mode!==oi.TRIANGLES&&l.mode!==oi.TRIANGLE_STRIP&&l.mode!==oi.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],f=l[0].count,p=[];for(let x of h){let v=new vt,y=new I,_=new Ce,S=new I(1,1,1),g=new ei(x.geometry,x.material,f);for(let d=0;d<f;d++)c.TRANSLATION&&y.fromBufferAttribute(c.TRANSLATION,d),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,d),c.SCALE&&S.fromBufferAttribute(c.SCALE,d),g.setMatrixAt(d,v.compose(y,_,S));for(let d in c)if(d==="_COLOR_0"){let M=c[d];g.instanceColor=new ti(M.array,M.itemSize,M.normalized)}else d!=="TRANSLATION"&&d!=="ROTATION"&&d!=="SCALE"&&x.geometry.setAttribute(d,c[d]);re.prototype.copy.call(g,x),this.parser.assignFinalMaterial(g),p.push(g)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}},Sy="glTF",Wl=12,_y={JSON:1313821514,BIN:5130562},bg=class{constructor(t){this.name=oe.KHR_BINARY_GLTF,this.content=null,this.body=null;let e=new DataView(t,0,Wl),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Sy)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Wl,r=new DataView(t,Wl),o=0;for(;o<i;){let a=r.getUint32(o,!0);o+=4;let c=r.getUint32(o,!0);if(o+=4,c===_y.JSON){let l=new Uint8Array(t,Wl+o,a);this.content=n.decode(l)}else if(c===_y.BIN){let l=Wl+o;this.body=t.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Tg=class{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=oe.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){let n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=Rg[u]||u.toLowerCase();a[h]=o[u]}for(let u in t.attributes){let h=Rg[u]||u.toLowerCase();if(o[u]!==void 0){let f=n.accessors[t.attributes[u]],p=sa[f.componentType];l[h]=p.name,c[h]=f.normalized===!0}}return e.getDependency("bufferView",r).then(function(u){return new Promise(function(h,f){i.decodeDracoFile(u,function(p){for(let x in p.attributes){let v=p.attributes[x],y=c[x];y!==void 0&&(v.normalized=y)}h(p)},a,l,tn,f)})})}},Eg=class{constructor(){this.name=oe.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}},wg=class{constructor(){this.name=oe.KHR_MESH_QUANTIZATION}},Rf=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let o=0;o!==i;o++)e[o]=n[r+o];return e}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=i-e,h=(n-e)/u,f=h*h,p=f*h,x=t*l,v=x-l,y=-2*p+3*f,_=p-f,S=1-y,g=_-f+h;for(let d=0;d!==a;d++){let M=o[v+d+a],m=o[v+d+c]*u,R=o[x+d+a],E=o[x+d]*u;r[d]=S*M+g*m+y*R+_*E}return r}},l1=new Ce,Ag=class extends Rf{interpolate_(t,e,n,i){let r=super.interpolate_(t,e,n,i);return l1.fromArray(r).normalize().toArray(r),r}},oi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},sa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={9728:De,9729:Ee,9984:Nr,9985:Xi,9986:Mi,9987:un},vy={33071:en,33648:Li,10497:An},ng={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Rg={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Dr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},u1={CUBICSPLINE:void 0,LINEAR:Di,STEP:Ni},ig={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function h1(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new xi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),s.DefaultMaterial}function Fs(s,t,e){for(let n in e.extensions)s[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function $i(s,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(s.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function f1(s,t,e){let n=!1,i=!1,r=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(n){let f=h.POSITION!==void 0?e.getDependency("accessor",h.POSITION):s.attributes.position;o.push(f)}if(i){let f=h.NORMAL!==void 0?e.getDependency("accessor",h.NORMAL):s.attributes.normal;a.push(f)}if(r){let f=h.COLOR_0!==void 0?e.getDependency("accessor",h.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],f=l[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function d1(s,t){if(s.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)s.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){let e=t.extras.targetNames;if(s.morphTargetInfluences.length===e.length){s.morphTargetDictionary={};for(let n=0,i=e.length;n<i;n++)s.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function p1(s){let t,e=s.extensions&&s.extensions[oe.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+rg(e.attributes):t=s.indices+":"+rg(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)t+=":"+rg(s.targets[n]);return t}function rg(s){let t="",e=Object.keys(s).sort();for(let n=0,i=e.length;n<i;n++)t+=e[n]+":"+s[e[n]]+";";return t}function Cg(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function m1(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var g1=new vt,Ig=class{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new c1,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new Vo(this.options.manager):this.textureLoader=new Go(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Mn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return Fs(r,a,i),$i(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){let t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=e.length;i<r;i++){let o=e[i].joints;for(let a=0,c=o.length;a<c;a++)t[o[a]].isBone=!0}for(let i=0,r=t.length;i<r;i++){let o=t[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;let i=n.clone(),r=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())r(u,a.children[l])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){let e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){let i=t(e[n]);if(i)return i}return null}_invokeAll(t){let e=Object.values(this.plugins);e.unshift(this);let n=[];for(let i=0;i<e.length;i++){let r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){let n=t+":"+e,i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t);break}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){let n=this,i=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(i.map(function(r,o){return n.getDependency(t,o)})),this.cache.add(t,e)}return e}loadBuffer(t){let e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[oe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,o){n.load(ii.resolveURL(e.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){let e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){let i=e.byteLength||0,r=e.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(t){let e=this,n=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){let o=ng[i.type],a=sa[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new kt(l,o,c))}let r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],c=ng[i.type],l=sa[i.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,f=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,x=i.normalized===!0,v,y;if(p&&p!==h){let _=Math.floor(f/p),S="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+_+":"+i.count,g=e.cache.get(S);g||(v=new l(a,_*p,i.count*p/u),g=new Oi(v,p/u),e.cache.add(S,g)),y=new pi(g,c,f%p/u,x)}else a===null?v=new l(i.count*c):v=new l(a,f,i.count*c),y=new kt(v,c,x);if(i.sparse!==void 0){let _=ng.SCALAR,S=sa[i.sparse.indices.componentType],g=i.sparse.indices.byteOffset||0,d=i.sparse.values.byteOffset||0,M=new S(o[1],g,i.sparse.count*_),m=new l(o[2],d,i.sparse.count*c);a!==null&&(y=new kt(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let R=0,E=M.length;R<E;R++){let T=M[R];if(y.setX(T,m[R*c]),c>=2&&y.setY(T,m[R*c+1]),c>=3&&y.setZ(T,m[R*c+2]),c>=4&&y.setW(T,m[R*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=x}return y})}loadTexture(t){let e=this.json,n=this.options,r=e.textures[t].source,o=e.images[r],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,n){let i=this,r=this.json,o=r.textures[t],a=r.images[e],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(e,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(r.samplers||{})[o.sampler]||{};return u.magFilter=yy[f.magFilter]||Ee,u.minFilter=yy[f.minFilter]||un,u.wrapS=vy[f.wrapS]||An,u.wrapT=vy[f.wrapT]||An,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==De&&u.minFilter!==Ee,i.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(t,e){let n=this,i=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(h=>h.clone());let o=i.images[t],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let f=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(f,p){let x=f;e.isImageBitmapLoader===!0&&(x=function(v){let y=new Ie(v);y.needsUpdate=!0,f(y)}),e.load(ii.resolveURL(h,r.path),x,void 0,p)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),$i(h,o),h.userData.mimeType=o.mimeType||m1(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[t]=u,u}assignTexture(t,e,n,i){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[oe.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[oe.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=r.associations.get(o);o=r.extensions[oe.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),t[e]=o,o})}assignFinalMaterial(t){let e=t.geometry,n=t.material,i=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,o=e.attributes.normal===void 0;if(t.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Ir,Ue.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(t.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Xe,Ue.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}t.material=n}getMaterialType(){return xi}loadMaterial(t){let e=this,n=this.json,i=this.extensions,r=n.materials[t],o,a={},c=r.extensions||{},l=[];if(c[oe.KHR_MATERIALS_UNLIT]){let h=i[oe.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,r,e))}else{let h=r.pbrMetallicRoughness||{};if(a.color=new yt(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],tn),a.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(e.assignTexture(a,"map",h.baseColorTexture,Ae)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(e.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=Ve);let u=r.alphaMode||ig.OPAQUE;if(u===ig.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ig.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==sn&&(l.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new nt(1,1),r.normalTexture.scale!==void 0)){let h=r.normalTexture.scale;a.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&o!==sn&&(l.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==sn){let h=r.emissiveFactor;a.emissive=new yt().setRGB(h[0],h[1],h[2],tn)}return r.emissiveTexture!==void 0&&o!==sn&&l.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Ae)),Promise.all(l).then(function(){let h=new o(a);return r.name&&(h.name=r.name),$i(h,r),e.associations.set(h,{materials:t}),r.extensions&&Fs(i,h,r),h})}createUniqueName(t){let e=ee.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){let e=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[oe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(c){return My(c,a,e)})}let o=[];for(let a=0,c=t.length;a<c;a++){let l=t[a],u=p1(l),h=i[u];if(h)o.push(h.promise);else{let f;l.extensions&&l.extensions[oe.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=My(new Vt,l,e),i[u]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(t){let e=this,n=this.json,i=this.extensions,r=n.meshes[t],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?h1(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(e.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let p=0,x=u.length;p<x;p++){let v=u[p],y=o[p],_,S=l[p];if(y.mode===oi.TRIANGLES||y.mode===oi.TRIANGLE_STRIP||y.mode===oi.TRIANGLE_FAN||y.mode===void 0)_=r.isSkinnedMesh===!0?new mi(v,S):new ce(v,S),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),y.mode===oi.TRIANGLE_STRIP?_.geometry=eg(_.geometry,ta):y.mode===oi.TRIANGLE_FAN&&(_.geometry=eg(_.geometry,Cs));else if(y.mode===oi.LINES)_=new yn(v,S);else if(y.mode===oi.LINE_STRIP)_=new Vn(v,S);else if(y.mode===oi.LINE_LOOP)_=new ps(v,S);else if(y.mode===oi.POINTS)_=new ms(v,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(_.geometry.morphAttributes).length>0&&d1(_,r),_.name=e.createUniqueName(r.name||"mesh_"+t),$i(_,r),y.extensions&&Fs(i,_,y),e.assignFinalMaterial(_),h.push(_)}for(let p=0,x=h.length;p<x;p++)e.associations.set(h[p],{meshes:t,primitives:p});if(h.length===1)return r.extensions&&Fs(i,h[0],r),h[0];let f=new nn;r.extensions&&Fs(i,f,r),e.associations.set(f,{meshes:t});for(let p=0,x=h.length;p<x;p++)f.add(h[p]);return f})}loadCamera(t){let e,n=this.json.cameras[t],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new Re(Yi.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(e=new cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),$i(e,n),Promise.resolve(e)}loadSkin(t){let e=this.json.skins[t],n=[];for(let i=0,r=e.joints.length;i<r;i++)n.push(this._loadNodeShallow(e.joints[i]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){let r=i.pop(),o=i,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let f=new vt;r!==null&&f.fromArray(r.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new ds(a,c)})}loadAnimation(t){let e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,o=[],a=[],c=[],l=[],u=[];for(let h=0,f=i.channels.length;h<f;h++){let p=i.channels[h],x=i.samplers[p.sampler],v=p.target,y=v.node,_=i.parameters!==void 0?i.parameters[x.input]:x.input,S=i.parameters!==void 0?i.parameters[x.output]:x.output;v.node!==void 0&&(o.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",S)),l.push(x),u.push(v))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let f=h[0],p=h[1],x=h[2],v=h[3],y=h[4],_=[];for(let g=0,d=f.length;g<d;g++){let M=f[g],m=p[g],R=x[g],E=v[g],T=y[g];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();let b=n._createAnimationTracks(M,m,R,E,T);if(b)for(let w=0;w<b.length;w++)_.push(b[w])}let S=new ni(r,void 0,_);return $i(S,i),S})}createNodeMesh(t){let e=this.json,n=this,i=e.nodes[t];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(t){let e=this.json,n=this,i=e.nodes[t],r=n._loadNodeShallow(t),o=[],a=i.children||[];for(let l=0,u=a.length;l<u;l++)o.push(n.getDependency("node",a[l]));let c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],f=l[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,g1)});for(let p=0,x=h.length;p<x;p++)u.add(h[p]);return u})}_loadNodeShallow(t){let e=this.json,n=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];let r=e.nodes[t],o=r.name?i.createUniqueName(r.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(t)});return c&&a.push(c),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(l){return i._getNodeRef(i.cameraCache,r.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(t)}).forEach(function(l){a.push(l)}),this.nodeCache[t]=Promise.all(a).then(function(l){let u;if(r.isBone===!0?u=new Cr:l.length>1?u=new nn:l.length===1?u=l[0]:u=new re,u!==l[0])for(let h=0,f=l.length;h<f;h++)u.add(l[h]);if(r.name&&(u.userData.name=r.name,u.name=o),$i(u,r),r.extensions&&Fs(n,u,r),r.matrix!==void 0){let h=new vt;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){let e=this.extensions,n=this.json.scenes[t],i=this,r=new nn;n.name&&(r.name=i.createUniqueName(n.name)),$i(r,n),n.extensions&&Fs(e,r,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)r.add(c[u]);let l=u=>{let h=new Map;for(let[f,p]of i.associations)(f instanceof Ue||f instanceof Ie)&&h.set(f,p);return u.traverse(f=>{let p=i.associations.get(f);p!=null&&h.set(f,p)}),h};return i.associations=l(r),r})}_createAnimationTracks(t,e,n,i,r){let o=[],a=t.name?t.name:t.uuid,c=[];Dr[r.path]===Dr.weights?t.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Dr[r.path]){case Dr.weights:l=_i;break;case Dr.rotation:l=Gn;break;case Dr.translation:case Dr.scale:l=Wn;break;default:switch(n.itemSize){case 1:l=_i;break;case 2:case 3:default:l=Wn;break}break}let u=i.interpolation!==void 0?u1[i.interpolation]:Di,h=this._getArrayFromAccessor(n);for(let f=0,p=c.length;f<p;f++){let x=new l(c[f]+"."+Dr[r.path],e.array,h,u);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),o.push(x)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){let n=Cg(e.constructor),i=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r++)i[r]=e[r]*n;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){let i=this instanceof Gn?Ag:Rf;return new i(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function x1(s,t,e){let n=t.attributes,i=new ne;if(n.POSITION!==void 0){let a=e.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new I(c[0],c[1],c[2]),new I(l[0],l[1],l[2])),a.normalized){let u=Cg(sa[a.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=t.targets;if(r!==void 0){let a=new I,c=new I;for(let l=0,u=r.length;l<u;l++){let h=r[l];if(h.POSITION!==void 0){let f=e.json.accessors[h.POSITION],p=f.min,x=f.max;if(p!==void 0&&x!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(x[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(x[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(x[2]))),f.normalized){let v=Cg(sa[f.componentType]);c.multiplyScalar(v)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;let o=new Be;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function My(s,t,e){let n=t.attributes,i=[];function r(o,a){return e.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(let o in n){let a=Rg[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(t.indices!==void 0&&!s.index){let o=e.getDependency("accessor",t.indices).then(function(a){s.setIndex(a)});i.push(o)}return ie.workingColorSpace!==tn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ie.workingColorSpace}" not supported.`),$i(s,t),x1(s,t,e),Promise.all(i).then(function(){return t.targets!==void 0?f1(s,t.targets,e):s})}var Xl=new I;function ai(s,t,e,n,i,r){let o=2*Math.PI*i/4,a=Math.max(r-2*i,0),c=Math.PI/4;Xl.copy(t),Xl[n]=0,Xl.normalize();let l=.5*o/(o+a),u=1-Xl.angleTo(s)/c;return Math.sign(Xl[e])===1?u*l:a/(o+a)+l+l*(1-u)}var Cf=class s extends Ui{constructor(t=1,e=1,n=1,i=2,r=.1){let o=i*2+1;if(r=Math.min(t/2,e/2,n/2,r),super(1,1,1,o,o,o),this.type="RoundedBoxGeometry",this.parameters={width:t,height:e,depth:n,segments:i,radius:r},o===1)return;let a=this.toNonIndexed();this.index=null,this.attributes.position=a.attributes.position,this.attributes.normal=a.attributes.normal,this.attributes.uv=a.attributes.uv;let c=new I,l=new I,u=new I(t,e,n).divideScalar(2).subScalar(r),h=this.attributes.position.array,f=this.attributes.normal.array,p=this.attributes.uv.array,x=h.length/6,v=new I,y=.5/o;for(let _=0,S=0;_<h.length;_+=3,S+=2)switch(c.fromArray(h,_),l.copy(c),l.x-=Math.sign(l.x)*y,l.y-=Math.sign(l.y)*y,l.z-=Math.sign(l.z)*y,l.normalize(),h[_+0]=u.x*Math.sign(c.x)+l.x*r,h[_+1]=u.y*Math.sign(c.y)+l.y*r,h[_+2]=u.z*Math.sign(c.z)+l.z*r,f[_+0]=l.x,f[_+1]=l.y,f[_+2]=l.z,Math.floor(_/x)){case 0:v.set(1,0,0),p[S+0]=ai(v,l,"z","y",r,n),p[S+1]=1-ai(v,l,"y","z",r,e);break;case 1:v.set(-1,0,0),p[S+0]=1-ai(v,l,"z","y",r,n),p[S+1]=1-ai(v,l,"y","z",r,e);break;case 2:v.set(0,1,0),p[S+0]=1-ai(v,l,"x","z",r,t),p[S+1]=ai(v,l,"z","x",r,n);break;case 3:v.set(0,-1,0),p[S+0]=1-ai(v,l,"x","z",r,t),p[S+1]=1-ai(v,l,"z","x",r,n);break;case 4:v.set(0,0,1),p[S+0]=1-ai(v,l,"x","y",r,t),p[S+1]=1-ai(v,l,"y","x",r,e);break;case 5:v.set(0,0,-1),p[S+0]=ai(v,l,"x","y",r,t),p[S+1]=1-ai(v,l,"y","x",r,e);break}}static fromJSON(t){return new s(t.width,t.height,t.depth,t.segments,t.radius)}};var oa=Math.pow(2,-24),ql=Symbol("SKIP_GENERATION"),If={strategy:0,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[ql]:!1};function Se(s,t,e){return e.min.x=t[s],e.min.y=t[s+1],e.min.z=t[s+2],e.max.x=t[s+3],e.max.y=t[s+4],e.max.z=t[s+5],e}function Yl(s){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=s[n+3]-s[n];i>e&&(e=i,t=n)}return t}function Pg(s,t){t.set(s)}function Lg(s,t,e){let n,i;for(let r=0;r<3;r++){let o=r+3;n=s[r],i=t[r],e[r]=n<i?n:i,n=s[o],i=t[o],e[o]=n>i?n:i}}function $l(s,t,e){for(let n=0;n<3;n++){let i=t[s+2*n],r=t[s+2*n+1],o=i-r,a=i+r;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function aa(s){let t=s[3]-s[0],e=s[4]-s[1],n=s[5]-s[2];return 2*(t*e+e*n+n*t)}function le(s,t){return t[s+15]===65535}function xe(s,t){return t[s+6]}function ve(s,t){return t[s+14]}function fe(s){return s+8}function de(s,t){let e=t[s+6];return s+e*8}function ca(s,t){return t[s+7]}function Pf(s,t,e,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,p=1/0,x=-1/0,v=-1/0,y=-1/0,_=s.offset||0;for(let S=(t-_)*6,g=(t+e-_)*6;S<g;S+=6){let d=s[S+0],M=s[S+1],m=d-M,R=d+M;m<r&&(r=m),R>c&&(c=R),d<h&&(h=d),d>x&&(x=d);let E=s[S+2],T=s[S+3],b=E-T,w=E+T;b<o&&(o=b),w>l&&(l=w),E<f&&(f=E),E>v&&(v=E);let A=s[S+4],C=s[S+5],D=A-C,F=A+C;D<a&&(a=D),F>u&&(u=F),A<p&&(p=A),A>y&&(y=A)}n[0]=r,n[1]=o,n[2]=a,n[3]=c,n[4]=l,n[5]=u,i[0]=h,i[1]=f,i[2]=p,i[3]=x,i[4]=v,i[5]=y}var fr=32,v1=(s,t)=>s.candidate-t.candidate,Ur=new Array(fr).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Lf=new Float32Array(6);function Ty(s,t,e,n,i,r){let o=-1,a=0;if(r===0)o=Yl(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(r===1)o=Yl(s),o!==-1&&(a=M1(e,n,i,o));else if(r===2){let c=aa(s),l=1.25*i,u=e.offset||0,h=(n-u)*6,f=(n+i-u)*6;for(let p=0;p<3;p++){let x=t[p],_=(t[p+3]-x)/fr;if(i<fr/4){let S=[...Ur];S.length=i;let g=0;for(let M=h;M<f;M+=6,g++){let m=S[g];m.candidate=e[M+2*p],m.count=0;let{bounds:R,leftCacheBounds:E,rightCacheBounds:T}=m;for(let b=0;b<3;b++)T[b]=1/0,T[b+3]=-1/0,E[b]=1/0,E[b+3]=-1/0,R[b]=1/0,R[b+3]=-1/0;$l(M,e,R)}S.sort(v1);let d=i;for(let M=0;M<d;M++){let m=S[M];for(;M+1<d&&S[M+1].candidate===m.candidate;)S.splice(M+1,1),d--}for(let M=h;M<f;M+=6){let m=e[M+2*p];for(let R=0;R<d;R++){let E=S[R];m>=E.candidate?$l(M,e,E.rightCacheBounds):($l(M,e,E.leftCacheBounds),E.count++)}}for(let M=0;M<d;M++){let m=S[M],R=m.count,E=i-m.count,T=m.leftCacheBounds,b=m.rightCacheBounds,w=0;R!==0&&(w=aa(T)/c);let A=0;E!==0&&(A=aa(b)/c);let C=1+1.25*(w*R+A*E);C<l&&(o=p,l=C,a=m.candidate)}}else{for(let d=0;d<fr;d++){let M=Ur[d];M.count=0,M.candidate=x+_+d*_;let m=M.bounds;for(let R=0;R<3;R++)m[R]=1/0,m[R+3]=-1/0}for(let d=h;d<f;d+=6){let R=~~((e[d+2*p]-x)/_);R>=fr&&(R=fr-1);let E=Ur[R];E.count++,$l(d,e,E.bounds)}let S=Ur[fr-1];Pg(S.bounds,S.rightCacheBounds);for(let d=fr-2;d>=0;d--){let M=Ur[d],m=Ur[d+1];Lg(M.bounds,m.rightCacheBounds,M.rightCacheBounds)}let g=0;for(let d=0;d<fr-1;d++){let M=Ur[d],m=M.count,R=M.bounds,T=Ur[d+1].rightCacheBounds;m!==0&&(g===0?Pg(R,Lf):Lg(R,Lf,Lf)),g+=m;let b=0,w=0;g!==0&&(b=aa(Lf)/c);let A=i-g;A!==0&&(w=aa(T)/c);let C=1+1.25*(b*g+w*A);C<l&&(o=p,l=C,a=M.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}function M1(s,t,e,n){let i=0,r=s.offset;for(let o=t,a=t+e;o<a;o++)i+=s[(o-r)*6+n*2];return i/e}var la=class{constructor(){this.boundingData=new Float32Array(6)}};function Ey(s,t,e,n,i,r){let o=n,a=n+i-1,c=r.pos,l=r.axis*2,u=e.offset||0;for(;;){for(;o<=a&&e[(o-u)*6+l]<c;)o++;for(;o<=a&&e[(a-u)*6+l]>=c;)a--;if(o<a){for(let h=0;h<t;h++){let f=s[o*t+h];s[o*t+h]=s[a*t+h],s[a*t+h]=f}for(let h=0;h<6;h++){let f=o-u,p=a-u,x=e[f*6+h];e[f*6+h]=e[p*6+h],e[p*6+h]=x}o++,a--}else return o}}var wy,Nf,Ng,Ay,S1=Math.pow(2,32);function Df(s){return"count"in s?1:1+Df(s.left)+Df(s.right)}function Ry(s,t,e){return wy=new Float32Array(e),Nf=new Uint32Array(e),Ng=new Uint16Array(e),Ay=new Uint8Array(e),Dg(s,t)}function Dg(s,t){let e=s/4,n=s/2,i="count"in t,r=t.boundingData;for(let o=0;o<6;o++)wy[e+o]=r[o];if(i)return t.buffer?(Ay.set(new Uint8Array(t.buffer),s),s+t.buffer.byteLength):(Nf[e+6]=t.offset,Ng[n+14]=t.count,Ng[n+15]=65535,s+32);{let{left:o,right:a,splitAxis:c}=t,l=s+32,u=Dg(l,o),h=s/32,p=u/32-h;if(p>S1)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Nf[e+6]=p,Nf[e+7]=c,Dg(u,a)}}function b1(s,t,e,n,i,r){let{maxDepth:o,verbose:a,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:h}=i,f=s.primitiveBuffer,p=s.primitiveBufferStride,x=new Float32Array(6),v=!1,y=new la;return Pf(t,e,n,y.boundingData,x),S(y,e,n,x),y;function _(g){h&&h((g-r.offset)/r.count)}function S(g,d,M,m=null,R=0){!v&&R>=o&&(v=!0,a&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));let E=M>l;if(M<=c&&!E||R>=o)return _(d+M),g.offset=d,g.count=M,g;let T=Ty(g.boundingData,m,t,d,M,u),b=T.axis===-1?-1:Ey(f,p,t,d,M,T);if(T.axis===-1||b===d||b===d+M){if(!E)return _(d+M),g.offset=d,g.count=M,g;T.axis=Math.max(0,Yl(g.boundingData)),b=d+Math.max(1,Math.floor(M/2))}g.splitAxis=T.axis;let w=new la,A=d,C=b-d;g.left=w,Pf(t,A,C,w.boundingData,x),S(w,A,C,x,R+1);let D=new la,F=b,O=M-C;return g.right=D,Pf(t,F,O,D.boundingData,x),S(D,F,O,x,R+1),g}}function Cy(s,t){let e=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=s.getRootRanges(t.range),i=n[0],r=n[n.length-1],o={offset:i.offset,count:r.offset+r.count-i.offset},a=new Float32Array(6*o.count);a.offset=o.offset,s.computePrimitiveBounds(o.offset,o.count,a),s._roots=n.map(c=>{let l=b1(s,a,c.offset,c.count,t,o),u=Df(l),h=new e(32*u);return Ry(0,l,h),h})}var Fr=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};var Ug=class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let t=[],e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}},ue=new Ug;var Or,ha,ua=[],Uf=new Fr(()=>new ne);function Iy(s,t,e,n,i,r){Or=Uf.getPrimitive(),ha=Uf.getPrimitive(),ua.push(Or,ha),ue.setBuffer(s._roots[t]);let o=Fg(0,s.geometry,e,n,i,r);ue.clearBuffer(),Uf.releasePrimitive(Or),Uf.releasePrimitive(ha),ua.pop(),ua.pop();let a=ua.length;return a>0&&(ha=ua[a-1],Or=ua[a-2]),o}function Fg(s,t,e,n,i=null,r=0,o=0){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);return Se(s,a,Or),n(f,p,!1,o,r+s/8,Or)}else{let b=function(A){let{uint16Array:C,uint32Array:D}=ue,F=A*2;for(;!le(F,C);)A=fe(A),F=A*2;return xe(A,D)},w=function(A){let{uint16Array:C,uint32Array:D}=ue,F=A*2;for(;!le(F,C);)A=de(A,D),F=A*2;return xe(A,D)+ve(F,C)},f=fe(s),p=de(s,l),x=f,v=p,y,_,S,g;if(i&&(S=Or,g=ha,Se(x,a,S),Se(v,a,g),y=i(S),_=i(g),_<y)){x=p,v=f;let A=y;y=_,_=A,S=g}S||(S=Or,Se(x,a,S));let d=le(x*2,c),M=e(S,d,y,o+1,r+x/8),m;if(M===2){let A=b(x),D=w(x)-A;m=n(A,D,!0,o+1,r+x/8,S)}else m=M&&Fg(x,t,e,n,i,r,o+1);if(m)return!0;g=ha,Se(v,a,g);let R=le(v*2,c),E=e(g,R,_,o+1,r+v/8),T;if(E===2){let A=b(v),D=w(v)-A;T=n(A,D,!0,o+1,r+v/8,g)}else T=E&&Fg(v,t,e,n,i,r,o+1);return!!T}}var Kl=new ue.constructor,Ff=new ue.constructor,Br=new Fr(()=>new ne),fa=new ne,da=new ne,Bg=new ne,zg=new ne,kg=!1;function Py(s,t,e,n){if(kg)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");kg=!0;let i=s._roots,r=t._roots,o,a=0,c=0,l=new vt().copy(e).invert();for(let u=0,h=i.length;u<h;u++){Kl.setBuffer(i[u]),c=0;let f=Br.getPrimitive();Se(0,Kl.float32Array,f),f.applyMatrix4(l);for(let p=0,x=r.length;p<x&&(Ff.setBuffer(r[p]),o=bi(0,0,e,l,n,a,c,0,0,f),Ff.clearBuffer(),c+=r[p].byteLength/32,!o);p++);if(Br.releasePrimitive(f),Kl.clearBuffer(),a+=i[u].byteLength/32,o)break}return kg=!1,o}function bi(s,t,e,n,i,r=0,o=0,a=0,c=0,l=null,u=!1){let h,f;u?(h=Ff,f=Kl):(h=Kl,f=Ff);let p=h.float32Array,x=h.uint32Array,v=h.uint16Array,y=f.float32Array,_=f.uint32Array,S=f.uint16Array,g=s*2,d=t*2,M=le(g,v),m=le(d,S),R=!1;if(m&&M)u?R=i(xe(t,_),ve(t*2,S),xe(s,x),ve(s*2,v),c,o+t/8,a,r+s/8):R=i(xe(s,x),ve(s*2,v),xe(t,_),ve(t*2,S),a,r+s/8,c,o+t/8);else if(m){let E=Br.getPrimitive();Se(t,y,E),E.applyMatrix4(e);let T=fe(s),b=de(s,x);Se(T,p,fa),Se(b,p,da);let w=E.intersectsBox(fa),A=E.intersectsBox(da);R=w&&bi(t,T,n,e,i,o,r,c,a+1,E,!u)||A&&bi(t,b,n,e,i,o,r,c,a+1,E,!u),Br.releasePrimitive(E)}else{let E=fe(t),T=de(t,_);Se(E,y,Bg),Se(T,y,zg);let b=l.intersectsBox(Bg),w=l.intersectsBox(zg);if(b&&w)R=bi(s,E,e,n,i,r,o,a,c+1,l,u)||bi(s,T,e,n,i,r,o,a,c+1,l,u);else if(b)if(M)R=bi(s,E,e,n,i,r,o,a,c+1,l,u);else{let A=Br.getPrimitive();A.copy(Bg).applyMatrix4(e);let C=fe(s),D=de(s,x);Se(C,p,fa),Se(D,p,da);let F=A.intersectsBox(fa),O=A.intersectsBox(da);R=F&&bi(E,C,n,e,i,o,r,c,a+1,A,!u)||O&&bi(E,D,n,e,i,o,r,c,a+1,A,!u),Br.releasePrimitive(A)}else if(w)if(M)R=bi(s,T,e,n,i,r,o,a,c+1,l,u);else{let A=Br.getPrimitive();A.copy(zg).applyMatrix4(e);let C=fe(s),D=de(s,x);Se(C,p,fa),Se(D,p,da);let F=A.intersectsBox(fa),O=A.intersectsBox(da);R=F&&bi(T,C,n,e,i,o,r,c,a+1,A,!u)||O&&bi(T,D,n,e,i,o,r,c,a+1,A,!u),Br.releasePrimitive(A)}}return R}var Of=new class{constructor(){let s=null,t=null,e=null,n=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(r,o)=>{if(n)throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");this.root=o,this.buffer=s=r._roots[o],this.uint16Array=e=new Uint16Array(s),this.uint32Array=t=new Uint32Array(s)},this.reset=()=>{this.root=null,this.buffer=s=null,this.uint16Array=e=null,this.uint32Array=t=null},this.getRangeStart=r=>{let o=r*2;for(;!le(o,e);)r=fe(r),o=r*2;return xe(r,t)},this.getRangeEnd=r=>{let o=r*2;for(;!le(o,e);)r=de(r,t),o=r*2;return xe(r,t)+ve(o,e)};let i=(r,o,a)=>{let c=o*2,l=le(c,e);if(!r(a,l,o)&&!l){let h=fe(o),f=de(o,t);i(r,h,a+1),i(r,f,a+1)}};this.traverseBuffer=r=>{if(n)throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");n=!0;try{i(r,0,0)}finally{n=!1}},this.traverse=r=>{this.traverseBuffer((o,a,c)=>{if(a){let l=c*2,u=t[c+6],h=e[l+14];return r(o,a,new Float32Array(s,c*4,6),u,h)}else{let l=ca(c,t);return r(o,a,new Float32Array(s,c*4,6),l)}})}}};var Ly=new ne,pa=new Float32Array(6),Bf=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){t={...If,...t},"maxLeafSize"in t&&(console.warn('BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.'),t={...t,targetLeafSize:t.maxLeafSize}),Cy(this,t)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,u=-1/0;for(let h=t,f=t+e;h<f;h++){this.writePrimitiveBounds(h,pa,0);let[p,x,v,y,_,S]=pa;p<r&&(r=p),y>c&&(c=y),x<o&&(o=x),_>l&&(l=_),v<a&&(a=v),S>u&&(u=S)}return n[i+0]=r,n[i+1]=o,n[i+2]=a,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(t,e,n){let i=n.offset||0;for(let r=t,o=t+e;r<o;r++){this.writePrimitiveBounds(r,pa,0);let[a,c,l,u,h,f]=pa,p=(a+u)/2,x=(c+h)/2,v=(l+f)/2,y=(u-a)/2,_=(h-c)/2,S=(f-l)/2,g=(r-i)*6;n[g+0]=p,n[g+1]=y+(Math.abs(p)+y)*oa,n[g+2]=x,n[g+3]=_+(Math.abs(x)+_)*oa,n[g+4]=v,n[g+5]=S+(Math.abs(v)+S)*oa}return n}shiftPrimitiveOffsets(t){let e=this._indirectBuffer;if(e)for(let n=0,i=e.length;n<i;n++)e[n]+=t;else{let n=this._roots;for(let i=0;i<n.length;i++){let r=n[i],o=new Uint32Array(r),a=new Uint16Array(r),c=r.byteLength/32;for(let l=0;l<c;l++){let u=8*l,h=2*u;le(h,a)&&(o[u+6]+=t)}}}}traverse(t,e=0){Of.setBVH(this,e),Of.traverse(t),Of.reset()}refit(){let t=this._roots;for(let e=0,n=t.length;e<n;e++){let i=t[e],r=new Uint32Array(i),o=new Uint16Array(i),a=new Float32Array(i),c=i.byteLength/32;for(let l=c-1;l>=0;l--){let u=l*8,h=u*2;if(le(h,o)){let p=xe(u,r),x=ve(h,o);this.writePrimitiveRangeBounds(p,x,pa,0),a.set(pa,u)}else{let p=fe(u),x=de(u,r);for(let v=0;v<3;v++){let y=a[p+v],_=a[p+v+3],S=a[x+v],g=a[x+v+3];a[u+v]=y<S?y:S,a[u+v+3]=_>g?_:g}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),Ly),t.union(Ly)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:r,scratchPrimitive:o,iterate:a}=t;if(i&&r){let h=i;i=(f,p,x,v,y)=>h(f,p,x,v,y)?!0:a(f,p,this,r,x,v,o)}else i||(r?i=(h,f,p,x)=>a(h,f,this,r,p,x,o):i=(h,f,p)=>p);let c=!1,l=0,u=this._roots;for(let h=0,f=u.length;h<f;h++){let p=u[h];if(c=Iy(this,h,n,i,e,l),c)break;l+=p.byteLength/32}return c}bvhcast(t,e,n){let{intersectsRanges:i}=n;return Py(this,t,e,i)}};function Ny(){return typeof SharedArrayBuffer<"u"}function Hg(s){return s.index?s.index.count:s.attributes.position.count}function zr(s){return Hg(s)/3}function E1(s,t=ArrayBuffer){return s>65535?new Uint32Array(new t(4*s)):new Uint16Array(new t(2*s))}function Dy(s,t){if(!s.index){let e=s.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=E1(e,n);s.setIndex(new kt(i,1));for(let r=0;r<e;r++)i[r]=r}}function w1(s,t,e){let n=Hg(s)/e,i=t||s.drawRange,r=i.start/e,o=(i.start+i.count)/e,a=Math.max(0,r),c=Math.min(n,o)-a;return{offset:Math.floor(a),count:Math.floor(c)}}function A1(s,t){return s.groups.map(e=>({offset:e.start/t,count:e.count/t}))}function Vg(s,t,e){let n=w1(s,t,e),i=A1(s,e);if(!i.length)return[n];let r=[],o=n.offset,a=n.offset+n.count,c=Hg(s)/e,l=[];for(let f of i){let{offset:p,count:x}=f,v=p,y=isFinite(x)?x:c-p,_=p+y;v<a&&_>o&&(l.push({pos:Math.max(o,v),isStart:!0}),l.push({pos:Math.min(a,_),isStart:!1}))}l.sort((f,p)=>f.pos!==p.pos?f.pos-p.pos:f.type==="end"?-1:1);let u=0,h=null;for(let f of l){let p=f.pos;u!==0&&p!==h&&r.push({offset:h,count:p-h}),u+=f.isStart?1:-1,h=p}return r}function R1(s,t){let e=s[s.length-1],n=e.offset+e.count>2**16,i=s.reduce((l,u)=>l+u.count,0),r=n?4:2,o=t?new SharedArrayBuffer(i*r):new ArrayBuffer(i*r),a=n?new Uint32Array(o):new Uint16Array(o),c=0;for(let l=0;l<s.length;l++){let{offset:u,count:h}=s[l];for(let f=0;f<h;f++)a[c+f]=u+f;c+=h}return a}var zf=class extends Bf{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(e.useSharedArrayBuffer&&!Ny())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,e={...If,...e},e[ql]||this.init(e)}init(t){let{geometry:e,primitiveStride:n}=this;if(t.indirect){let i=Vg(e,t.range,n),r=R1(i,t.useSharedArrayBuffer);this._indirectBuffer=r}else Dy(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ne))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Vg(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}};var qn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let r=0,o=t.length;r<o;r++){let c=t[r][e];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,o=e.length;r<o;r++){let a=e[r],c=t.dot(a);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};qn.prototype.setFromBox=function(){let s=new I;return function(e,n){let i=n.min,r=n.max,o=1/0,a=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){s.x=i.x*c+r.x*(1-c),s.y=i.y*l+r.y*(1-l),s.z=i.z*u+r.z*(1-u);let h=e.dot(s);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var C1=function(){let s=new I,t=new I,e=new I;return function(i,r,o){let a=i.start,c=s,l=r.start,u=t;e.subVectors(a,l),s.subVectors(i.end,i.start),t.subVectors(r.end,r.start);let h=e.dot(u),f=u.dot(c),p=u.dot(u),x=e.dot(c),y=c.dot(c)*p-f*f,_,S;y!==0?_=(h*f-x*p)/y:_=0,S=(h+_*f)/p,o.x=_,o.y=S}}(),Zl=function(){let s=new nt,t=new I,e=new I;return function(i,r,o,a){C1(i,r,s);let c=s.x,l=s.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,o),r.at(l,a);return}else if(c>=0&&c<=1){l<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(l>=0&&l<=1){c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let u;c<0?u=i.start:u=i.end;let h;l<0?h=r.start:h=r.end;let f=t,p=e;if(i.closestPointToPoint(h,!0,t),r.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=p.distanceToSquared(u)){o.copy(f),a.copy(h);return}else{o.copy(u),a.copy(p);return}}}}(),Uy=function(){let s=new I,t=new I,e=new $e,n=new _e;return function(r,o){let{radius:a,center:c}=r,{a:l,b:u,c:h}=o;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a||(n.start=l,n.end=h,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a)||(n.start=u,n.end=h,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a))return!0;let v=o.getPlane(e);if(Math.abs(v.distanceToPoint(c))<=a){let _=v.projectPoint(c,t);if(o.containsPoint(_))return!0}return!1}}();var I1=["x","y","z"],dr=1e-15,Fy=dr*dr;function ci(s){return Math.abs(s)<dr}var ze=class extends me{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new qn),this.points=[this.a,this.b,this.c],this.plane=new $e,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new _e,this.needsUpdate=!0}intersectsSphere(t){return Uy(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,o=this.satBounds,a=r[0],c=o[0];this.getNormal(a),c.setFromPoints(a,i);let l=r[1],u=o[1];l.subVectors(t,e),u.setFromPoints(l,i);let h=r[2],f=o[2];h.subVectors(e,n),f.setFromPoints(h,i);let p=r[3],x=o[3];p.subVectors(n,t),x.setFromPoints(p,i);let v=l.length(),y=h.length(),_=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,v<dr?y<dr||_<dr?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(n)):y<dr?_<dr?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):_<dr&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};ze.prototype.closestPointToSegment=function(){let s=new I,t=new I,e=new _e;return function(i,r=null,o=null){let{start:a,end:c}=i,l=this.points,u,h=1/0;for(let f=0;f<3;f++){let p=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[p]),Zl(e,i,s,t),u=s.distanceToSquared(t),u<h&&(h=u,r&&r.copy(s),o&&o.copy(t))}return this.closestPointToPoint(a,s),u=a.distanceToSquared(s),u<h&&(h=u,r&&r.copy(s),o&&o.copy(a)),this.closestPointToPoint(c,s),u=c.distanceToSquared(s),u<h&&(h=u,r&&r.copy(s),o&&o.copy(c)),Math.sqrt(h)}}();ze.prototype.intersectsTriangle=function(){let s=new ze,t=new qn,e=new qn,n=new I,i=new I,r=new I,o=new I,a=new _e,c=new _e,l=new I,u=new nt,h=new nt;function f(g,d,M,m){let R=n;!g.isDegenerateIntoPoint&&!g.isDegenerateIntoSegment?R.copy(g.plane.normal):R.copy(d.plane.normal);let E=g.satBounds,T=g.satAxes;for(let A=1;A<4;A++){let C=E[A],D=T[A];if(t.setFromPoints(D,d.points),C.isSeparated(t)||(o.copy(R).cross(D),t.setFromPoints(o,g.points),e.setFromPoints(o,d.points),t.isSeparated(e)))return!1}let b=d.satBounds,w=d.satAxes;for(let A=1;A<4;A++){let C=b[A],D=w[A];if(t.setFromPoints(D,g.points),C.isSeparated(t)||(o.crossVectors(R,D),t.setFromPoints(o,g.points),e.setFromPoints(o,d.points),t.isSeparated(e)))return!1}return M&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function p(g,d,M,m,R,E,T,b,w,A,C){let D=T/(T-b);A.x=m+(R-m)*D,C.start.subVectors(d,g).multiplyScalar(D).add(g),D=T/(T-w),A.y=m+(E-m)*D,C.end.subVectors(M,g).multiplyScalar(D).add(g)}function x(g,d,M,m,R,E,T,b,w,A,C){if(R>0)p(g.c,g.a,g.b,m,d,M,w,T,b,A,C);else if(E>0)p(g.b,g.a,g.c,M,d,m,b,T,w,A,C);else if(b*w>0||T!=0)p(g.a,g.b,g.c,d,M,m,T,b,w,A,C);else if(b!=0)p(g.b,g.a,g.c,M,d,m,b,T,w,A,C);else if(w!=0)p(g.c,g.a,g.b,m,d,M,w,T,b,A,C);else return!0;return!1}function v(g,d,M,m){let R=d.degenerateSegment,E=g.plane.distanceToPoint(R.start),T=g.plane.distanceToPoint(R.end);return ci(E)?ci(T)?f(g,d,M,m):(M&&(M.start.copy(R.start),M.end.copy(R.start)),g.containsPoint(R.start)):ci(T)?(M&&(M.start.copy(R.end),M.end.copy(R.end)),g.containsPoint(R.end)):g.plane.intersectLine(R,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),g.containsPoint(n)):!1}function y(g,d,M){let m=d.a;return ci(g.plane.distanceToPoint(m))&&g.containsPoint(m)?(M&&(M.start.copy(m),M.end.copy(m)),!0):!1}function _(g,d,M){let m=g.degenerateSegment,R=d.a;return m.closestPointToPoint(R,!0,n),R.distanceToSquared(n)<Fy?(M&&(M.start.copy(R),M.end.copy(R)),!0):!1}function S(g,d,M,m){if(g.isDegenerateIntoSegment)if(d.isDegenerateIntoSegment){let R=g.degenerateSegment,E=d.degenerateSegment,T=i,b=r;R.delta(T),E.delta(b);let w=n.subVectors(E.start,R.start),A=T.x*b.y-T.y*b.x;if(ci(A))return!1;let C=(w.x*b.y-w.y*b.x)/A,D=-(T.x*w.y-T.y*w.x)/A;if(C<0||C>1||D<0||D>1)return!1;let F=R.start.z+T.z*C,O=E.start.z+b.z*D;return ci(F-O)?(M&&(M.start.copy(R.start).addScaledVector(T,C),M.end.copy(R.start).addScaledVector(T,C)),!0):!1}else return d.isDegenerateIntoPoint?_(g,d,M):v(d,g,M,m);else{if(g.isDegenerateIntoPoint)return d.isDegenerateIntoPoint?d.a.distanceToSquared(g.a)<Fy?(M&&(M.start.copy(g.a),M.end.copy(g.a)),!0):!1:d.isDegenerateIntoSegment?_(d,g,M):y(d,g,M);if(d.isDegenerateIntoPoint)return y(g,d,M);if(d.isDegenerateIntoSegment)return v(g,d,M,m)}}return function(d,M=null,m=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(s.copy(d),s.update(),d=s);let R=S(this,d,M,m);if(R!==void 0)return R;let E=this.plane,T=d.plane,b=T.distanceToPoint(this.a),w=T.distanceToPoint(this.b),A=T.distanceToPoint(this.c);ci(b)&&(b=0),ci(w)&&(w=0),ci(A)&&(A=0);let C=b*w,D=b*A;if(C>0&&D>0)return!1;let F=E.distanceToPoint(d.a),O=E.distanceToPoint(d.b),H=E.distanceToPoint(d.c);ci(F)&&(F=0),ci(O)&&(O=0),ci(H)&&(H=0);let B=F*O,$=F*H;if(B>0&&$>0)return!1;i.copy(E.normal),r.copy(T.normal);let at=i.cross(r),rt=0,ht=Math.abs(at.x),bt=Math.abs(at.y);bt>ht&&(ht=bt,rt=1),Math.abs(at.z)>ht&&(rt=2);let Mt=I1[rt],K=this.a[Mt],Q=this.b[Mt],ct=this.c[Mt],lt=d.a[Mt],ut=d.b[Mt],Ct=d.c[Mt];if(x(this,K,Q,ct,C,D,b,w,A,u,a))return f(this,d,M,m);if(x(d,lt,ut,Ct,B,$,F,O,H,h,c))return f(this,d,M,m);if(u.y<u.x){let Kt=u.y;u.y=u.x,u.x=Kt,l.copy(a.start),a.start.copy(a.end),a.end.copy(l)}if(h.y<h.x){let Kt=h.y;h.y=h.x,h.x=Kt,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<h.x||h.y<u.x?!1:(M&&(h.x>u.x?M.start.copy(c.start):M.start.copy(a.start),h.y<u.y?M.end.copy(c.end):M.end.copy(a.end)),!0)}}();ze.prototype.distanceToPoint=function(){let s=new I;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();ze.prototype.distanceToTriangle=function(){let s=new I,t=new I,e=["a","b","c"],n=new _e,i=new _e;return function(o,a=null,c=null){let l=a||c?n:null;if(this.intersectsTriangle(o,l,!0))return(a||c)&&(a&&l.getCenter(a),c&&l.getCenter(c)),0;let u=1/0;for(let h=0;h<3;h++){let f,p=e[h],x=o[p];this.closestPointToPoint(x,s),f=x.distanceToSquared(s),f<u&&(u=f,a&&a.copy(s),c&&c.copy(x));let v=this[p];o.closestPointToPoint(v,s),f=v.distanceToSquared(s),f<u&&(u=f,a&&a.copy(v),c&&c.copy(s))}for(let h=0;h<3;h++){let f=e[h],p=e[(h+1)%3];n.set(this[f],this[p]);for(let x=0;x<3;x++){let v=e[x],y=e[(x+1)%3];i.set(o[v],o[y]),Zl(n,i,s,t);let _=s.distanceToSquared(t);_<u&&(u=_,a&&a.copy(s),c&&c.copy(t))}}return Math.sqrt(u)}}();var ke=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new vt,this.invMatrix=new vt,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new qn),this.alignedSatBounds=new Array(3).fill().map(()=>new qn),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ke.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let f=1*l|2*u|4*h,p=i[f];p.x=l?n.x:e.x,p.y=u?n.y:e.y,p.z=h?n.z:e.z,p.applyMatrix4(t)}let r=this.satBounds,o=this.satAxes,a=i[0];for(let l=0;l<3;l++){let u=o[l],h=r[l],f=1<<l,p=i[f];u.subVectors(a,p),h.setFromPoints(u,i)}let c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ke.prototype.intersectsBox=function(){let s=new qn;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,r=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(s.min=n.x,s.max=i.x,a[0].isSeparated(s)||(s.min=n.y,s.max=i.y,a[1].isSeparated(s))||(s.min=n.z,s.max=i.z,a[2].isSeparated(s)))return!1;for(let c=0;c<3;c++){let l=o[c],u=r[c];if(s.setFromBox(l,e),u.isSeparated(s))return!1}return!0}}();ke.prototype.intersectsTriangle=function(){let s=new ze,t=new Array(3),e=new qn,n=new qn,i=new I;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(s.copy(o),s.update(),o=s);let a=this.satBounds,c=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let f=0;f<3;f++){let p=a[f],x=c[f];if(e.setFromPoints(x,t),p.isSeparated(e))return!1}let l=o.satBounds,u=o.satAxes,h=this.points;for(let f=0;f<3;f++){let p=l[f],x=u[f];if(e.setFromPoints(x,h),p.isSeparated(e))return!1}for(let f=0;f<3;f++){let p=c[f];for(let x=0;x<4;x++){let v=u[x];if(i.crossVectors(p,v),e.setFromPoints(i,t),n.setFromPoints(i,h),e.isSeparated(n))return!1}}return!0}}();ke.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();ke.prototype.distanceToPoint=function(){let s=new I;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();ke.prototype.distanceToBox=function(){let s=["x","y","z"],t=new Array(12).fill().map(()=>new _e),e=new Array(12).fill().map(()=>new _e),n=new I,i=new I;return function(o,a=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(c||l)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;let u=a*a,h=o.min,f=o.max,p=this.points,x=1/0;for(let y=0;y<8;y++){let _=p[y];i.copy(_).clamp(h,f);let S=_.distanceToSquared(i);if(S<x&&(x=S,c&&c.copy(_),l&&l.copy(i),S<u))return Math.sqrt(S)}let v=0;for(let y=0;y<3;y++)for(let _=0;_<=1;_++)for(let S=0;S<=1;S++){let g=(y+1)%3,d=(y+2)%3,M=_<<g|S<<d,m=1<<y|_<<g|S<<d,R=p[M],E=p[m];t[v].set(R,E);let b=s[y],w=s[g],A=s[d],C=e[v],D=C.start,F=C.end;D[b]=h[b],D[w]=_?h[w]:f[w],D[A]=S?h[A]:f[w],F[b]=f[b],F[w]=_?h[w]:f[w],F[A]=S?h[A]:f[w],v++}for(let y=0;y<=1;y++)for(let _=0;_<=1;_++)for(let S=0;S<=1;S++){i.x=y?f.x:h.x,i.y=_?f.y:h.y,i.z=S?f.z:h.z,this.closestPointToPoint(i,n);let g=i.distanceToSquared(n);if(g<x&&(x=g,c&&c.copy(n),l&&l.copy(i),g<u))return Math.sqrt(g)}for(let y=0;y<12;y++){let _=t[y];for(let S=0;S<12;S++){let g=e[S];Zl(_,g,n,i);let d=n.distanceToSquared(i);if(d<x&&(x=d,c&&c.copy(n),l&&l.copy(i),d<u))return Math.sqrt(d)}}return Math.sqrt(x)}}();var Gg=class extends Fr{constructor(){super(()=>new ze)}},Sn=new Gg;var Jl=new I,Wg=new I;function Oy(s,t,e={},n=0,i=1/0){let r=n*n,o=i*i,a=1/0,c=null;if(s.shapecast({boundsTraverseOrder:u=>(Jl.copy(t).clamp(u.min,u.max),Jl.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<a&&f<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Jl);let f=t.distanceToSquared(Jl);return f<a&&(Wg.copy(Jl),a=f,c=h),f<r}}),a===1/0)return null;let l=Math.sqrt(a);return e.point?e.point.copy(Wg):e.point=Wg.clone(),e.distance=l,e.faceIndex=c,e}var kf=parseInt(Hi)>=169,P1=parseInt(Hi)<=161,Os=new I,Bs=new I,zs=new I,Hf=new nt,Vf=new nt,Gf=new nt,By=new I,zy=new I,ky=new I,jl=new I;function L1(s,t,e,n,i,r,o,a){let c;if(r===qe?c=s.intersectTriangle(n,e,t,!0,i):c=s.intersectTriangle(t,e,n,r!==Ve,i),c===null)return null;let l=s.origin.distanceTo(i);return l<o||l>a?null:{distance:l,point:i.clone()}}function Hy(s,t,e,n,i,r,o,a,c,l,u){Os.fromBufferAttribute(t,r),Bs.fromBufferAttribute(t,o),zs.fromBufferAttribute(t,a);let h=L1(s,Os,Bs,zs,jl,c,l,u);if(h){if(n){Hf.fromBufferAttribute(n,r),Vf.fromBufferAttribute(n,o),Gf.fromBufferAttribute(n,a),h.uv=new nt;let p=me.getInterpolation(jl,Os,Bs,zs,Hf,Vf,Gf,h.uv);kf||(h.uv=p)}if(i){Hf.fromBufferAttribute(i,r),Vf.fromBufferAttribute(i,o),Gf.fromBufferAttribute(i,a),h.uv1=new nt;let p=me.getInterpolation(jl,Os,Bs,zs,Hf,Vf,Gf,h.uv1);kf||(h.uv1=p),P1&&(h.uv2=h.uv1)}if(e){By.fromBufferAttribute(e,r),zy.fromBufferAttribute(e,o),ky.fromBufferAttribute(e,a),h.normal=new I;let p=me.getInterpolation(jl,Os,Bs,zs,By,zy,ky,h.normal);h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1),kf||(h.normal=p)}let f={a:r,b:o,c:a,normal:new I,materialIndex:0};if(me.getNormal(Os,Bs,zs,f.normal),h.face=f,h.faceIndex=r,kf){let p=new I;me.getBarycoord(jl,Os,Bs,zs,p),h.barycoord=p}}return h}function Vy(s){return s&&s.isMaterial?s.side:s}function ma(s,t,e,n,i,r,o){let a=n*3,c=a+0,l=a+1,u=a+2,{index:h,groups:f}=s;s.index&&(c=h.getX(c),l=h.getX(l),u=h.getX(u));let{position:p,normal:x,uv:v,uv1:y}=s.attributes;if(Array.isArray(t)){let _=n*3;for(let S=0,g=f.length;S<g;S++){let{start:d,count:M,materialIndex:m}=f[S];if(_>=d&&_<d+M){let R=Vy(t[m]),E=Hy(e,p,x,v,y,c,l,u,R,r,o);if(E)if(E.faceIndex=n,E.face.materialIndex=m,i)i.push(E);else return E}}}else{let _=Vy(t),S=Hy(e,p,x,v,y,c,l,u,_,r,o);if(S)if(S.faceIndex=n,S.face.materialIndex=0,i)i.push(S);else return S}return null}function be(s,t,e,n){let i=s.a,r=s.b,o=s.c,a=t,c=t+1,l=t+2;e&&(a=e.getX(a),c=e.getX(c),l=e.getX(l)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c),o.x=n.getX(l),o.y=n.getY(l),o.z=n.getZ(l)}function Gy(s,t,e,n,i,r,o,a){let{geometry:c,_indirectBuffer:l}=s;for(let u=n,h=n+i;u<h;u++)ma(c,t,e,u,r,o,a)}function Wy(s,t,e,n,i,r,o){let{geometry:a,_indirectBuffer:c}=s,l=1/0,u=null;for(let h=n,f=n+i;h<f;h++){let p;p=ma(a,t,e,h,null,r,o),p&&p.distance<l&&(u=p,l=p.distance)}return u}function Xy(s,t,e,n,i,r,o){let{geometry:a}=e,{index:c}=a,l=a.attributes.position;for(let u=s,h=t+s;u<h;u++){let f;if(f=u,be(o,f*3,c,l),o.needsUpdate=!0,n(o,f,i,r))return!0}return!1}function qy(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=s.geometry,n=e.index?e.index.array:null,i=e.attributes.position,r,o,a,c,l=0,u=s._roots;for(let f=0,p=u.length;f<p;f++)r=u[f],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),h(0,l),l+=r.byteLength;function h(f,p,x=!1){let v=f*2;if(le(v,a)){let y=xe(f,o),_=ve(v,a),S=1/0,g=1/0,d=1/0,M=-1/0,m=-1/0,R=-1/0;for(let E=3*y,T=3*(y+_);E<T;E++){let b=n[E],w=i.getX(b),A=i.getY(b),C=i.getZ(b);w<S&&(S=w),w>M&&(M=w),A<g&&(g=A),A>m&&(m=A),C<d&&(d=C),C>R&&(R=C)}return c[f+0]!==S||c[f+1]!==g||c[f+2]!==d||c[f+3]!==M||c[f+4]!==m||c[f+5]!==R?(c[f+0]=S,c[f+1]=g,c[f+2]=d,c[f+3]=M,c[f+4]=m,c[f+5]=R,!0):!1}else{let y=fe(f),_=de(f,o),S=x,g=!1,d=!1;if(t){if(!S){let b=y/8+p/32,w=_/8+p/32;g=t.has(b),d=t.has(w),S=!g&&!d}}else g=!0,d=!0;let M=S||g,m=S||d,R=!1;M&&(R=h(y,p,S));let E=!1;m&&(E=h(_,p,S));let T=R||E;if(T)for(let b=0;b<3;b++){let w=y+b,A=_+b,C=c[w],D=c[w+3],F=c[A],O=c[A+3];c[f+b]=C<F?C:F,c[f+b+3]=D>O?D:O}return T}}}function li(s,t,e,n,i){let r,o,a,c,l,u,h=1/e.direction.x,f=1/e.direction.y,p=1/e.direction.z,x=e.origin.x,v=e.origin.y,y=e.origin.z,_=t[s],S=t[s+3],g=t[s+1],d=t[s+3+1],M=t[s+2],m=t[s+3+2];return h>=0?(r=(_-x)*h,o=(S-x)*h):(r=(S-x)*h,o=(_-x)*h),f>=0?(a=(g-v)*f,c=(d-v)*f):(a=(d-v)*f,c=(g-v)*f),r>c||a>o||((a>r||isNaN(r))&&(r=a),(c<o||isNaN(o))&&(o=c),p>=0?(l=(M-y)*p,u=(m-y)*p):(l=(m-y)*p,u=(M-y)*p),r>u||l>o)?!1:((l>r||r!==r)&&(r=l),(u<o||o!==o)&&(o=u),r<=i&&o>=n)}function Yy(s,t,e,n,i,r,o,a){let{geometry:c,_indirectBuffer:l}=s;for(let u=n,h=n+i;u<h;u++){let f=l?l[u]:u;ma(c,t,e,f,r,o,a)}}function $y(s,t,e,n,i,r,o){let{geometry:a,_indirectBuffer:c}=s,l=1/0,u=null;for(let h=n,f=n+i;h<f;h++){let p;p=ma(a,t,e,c?c[h]:h,null,r,o),p&&p.distance<l&&(u=p,l=p.distance)}return u}function Ky(s,t,e,n,i,r,o){let{geometry:a}=e,{index:c}=a,l=a.attributes.position;for(let u=s,h=t+s;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),be(o,f*3,c,l),o.needsUpdate=!0,n(o,f,i,r))return!0}return!1}function Zy(s,t,e,n,i,r,o){ue.setBuffer(s._roots[t]),Xg(0,s,e,n,i,r,o),ue.clearBuffer()}function Xg(s,t,e,n,i,r,o){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);Gy(t,e,n,f,p,i,r,o)}else{let f=fe(s);li(f,a,n,r,o)&&Xg(f,t,e,n,i,r,o);let p=de(s,l);li(p,a,n,r,o)&&Xg(p,t,e,n,i,r,o)}}var N1=["x","y","z"];function Jy(s,t,e,n,i,r){ue.setBuffer(s._roots[t]);let o=qg(0,s,e,n,i,r);return ue.clearBuffer(),o}function qg(s,t,e,n,i,r){let{float32Array:o,uint16Array:a,uint32Array:c}=ue,l=s*2;if(le(l,a)){let h=xe(s,c),f=ve(l,a);return Wy(t,e,n,h,f,i,r)}else{let h=ca(s,c),f=N1[h],x=n.direction[f]>=0,v,y;x?(v=fe(s),y=de(s,c)):(v=de(s,c),y=fe(s));let S=li(v,o,n,i,r)?qg(v,t,e,n,i,r):null;if(S){let M=S.point[f];if(x?M<=o[y+h]:M>=o[y+h+3])return S}let d=li(y,o,n,i,r)?qg(y,t,e,n,i,r):null;return S&&d?S.distance<=d.distance?S:d:S||d||null}}var Wf=new ne,ga=new ze,xa=new ze,Ql=new vt,jy=new ke,Xf=new ke;function Qy(s,t,e,n){ue.setBuffer(s._roots[t]);let i=Yg(0,s,e,n);return ue.clearBuffer(),i}function Yg(s,t,e,n,i=null){let{float32Array:r,uint16Array:o,uint32Array:a}=ue,c=s*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),jy.set(e.boundingBox.min,e.boundingBox.max,n),i=jy),le(c,o)){let u=t.geometry,h=u.index,f=u.attributes.position,p=e.index,x=e.attributes.position,v=xe(s,a),y=ve(c,o);if(Ql.copy(n).invert(),e.boundsTree)return Se(s,r,Xf),Xf.matrix.copy(Ql),Xf.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:S=>Xf.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(n),S.b.applyMatrix4(n),S.c.applyMatrix4(n),S.needsUpdate=!0;for(let g=v*3,d=(y+v)*3;g<d;g+=3)if(be(xa,g,h,f),xa.needsUpdate=!0,S.intersectsTriangle(xa))return!0;return!1}});{let _=zr(e);for(let S=v*3,g=(y+v)*3;S<g;S+=3){be(ga,S,h,f),ga.a.applyMatrix4(Ql),ga.b.applyMatrix4(Ql),ga.c.applyMatrix4(Ql),ga.needsUpdate=!0;for(let d=0,M=_*3;d<M;d+=3)if(be(xa,d,p,x),xa.needsUpdate=!0,ga.intersectsTriangle(xa))return!0}}}else{let u=fe(s),h=de(s,a);return Se(u,r,Wf),!!(i.intersectsBox(Wf)&&Yg(u,t,e,n,i)||(Se(h,r,Wf),i.intersectsBox(Wf)&&Yg(h,t,e,n,i)))}}var qf=new vt,$g=new ke,tu=new ke,D1=new I,U1=new I,F1=new I,O1=new I;function tv(s,t,e,n={},i={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$g.set(t.boundingBox.min,t.boundingBox.max,e),$g.needsUpdate=!0;let a=s.geometry,c=a.attributes.position,l=a.index,u=t.attributes.position,h=t.index,f=Sn.getPrimitive(),p=Sn.getPrimitive(),x=D1,v=U1,y=null,_=null;i&&(y=F1,_=O1);let S=1/0,g=null,d=null;return qf.copy(e).invert(),tu.matrix.copy(qf),s.shapecast({boundsTraverseOrder:M=>$g.distanceToBox(M),intersectsBounds:(M,m,R)=>R<S&&R<o?(m&&(tu.min.copy(M.min),tu.max.copy(M.max),tu.needsUpdate=!0),!0):!1,intersectsRange:(M,m)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>tu.distanceToBox(E),intersectsBounds:(E,T,b)=>b<S&&b<o,intersectsRange:(E,T)=>{for(let b=E,w=E+T;b<w;b++){be(p,3*b,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let A=M,C=M+m;A<C;A++){be(f,3*A,l,c),f.needsUpdate=!0;let D=f.distanceToTriangle(p,x,y);if(D<S&&(v.copy(x),_&&_.copy(y),S=D,g=A,d=b),D<r)return!0}}}});{let R=zr(t);for(let E=0,T=R;E<T;E++){be(p,3*E,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let b=M,w=M+m;b<w;b++){be(f,3*b,l,c),f.needsUpdate=!0;let A=f.distanceToTriangle(p,x,y);if(A<S&&(v.copy(x),_&&_.copy(y),S=A,g=b,d=E),A<r)return!0}}}}}),Sn.releasePrimitive(f),Sn.releasePrimitive(p),S===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=S,n.faceIndex=g,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(qf),v.applyMatrix4(qf),i.distance=v.sub(i.point).length(),i.faceIndex=d),n)}function ev(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=s.geometry,n=e.index?e.index.array:null,i=e.attributes.position,r,o,a,c,l=0,u=s._roots;for(let f=0,p=u.length;f<p;f++)r=u[f],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),h(0,l),l+=r.byteLength;function h(f,p,x=!1){let v=f*2;if(le(v,a)){let y=xe(f,o),_=ve(v,a),S=1/0,g=1/0,d=1/0,M=-1/0,m=-1/0,R=-1/0;for(let E=y,T=y+_;E<T;E++){let b=3*s.resolveTriangleIndex(E);for(let w=0;w<3;w++){let A=b+w;A=n?n[A]:A;let C=i.getX(A),D=i.getY(A),F=i.getZ(A);C<S&&(S=C),C>M&&(M=C),D<g&&(g=D),D>m&&(m=D),F<d&&(d=F),F>R&&(R=F)}}return c[f+0]!==S||c[f+1]!==g||c[f+2]!==d||c[f+3]!==M||c[f+4]!==m||c[f+5]!==R?(c[f+0]=S,c[f+1]=g,c[f+2]=d,c[f+3]=M,c[f+4]=m,c[f+5]=R,!0):!1}else{let y=fe(f),_=de(f,o),S=x,g=!1,d=!1;if(t){if(!S){let b=y/8+p/32,w=_/8+p/32;g=t.has(b),d=t.has(w),S=!g&&!d}}else g=!0,d=!0;let M=S||g,m=S||d,R=!1;M&&(R=h(y,p,S));let E=!1;m&&(E=h(_,p,S));let T=R||E;if(T)for(let b=0;b<3;b++){let w=y+b,A=_+b,C=c[w],D=c[w+3],F=c[A],O=c[A+3];c[f+b]=C<F?C:F,c[f+b+3]=D>O?D:O}return T}}}function nv(s,t,e,n,i,r,o){ue.setBuffer(s._roots[t]),Kg(0,s,e,n,i,r,o),ue.clearBuffer()}function Kg(s,t,e,n,i,r,o){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);Yy(t,e,n,f,p,i,r,o)}else{let f=fe(s);li(f,a,n,r,o)&&Kg(f,t,e,n,i,r,o);let p=de(s,l);li(p,a,n,r,o)&&Kg(p,t,e,n,i,r,o)}}var B1=["x","y","z"];function iv(s,t,e,n,i,r){ue.setBuffer(s._roots[t]);let o=Zg(0,s,e,n,i,r);return ue.clearBuffer(),o}function Zg(s,t,e,n,i,r){let{float32Array:o,uint16Array:a,uint32Array:c}=ue,l=s*2;if(le(l,a)){let h=xe(s,c),f=ve(l,a);return $y(t,e,n,h,f,i,r)}else{let h=ca(s,c),f=B1[h],x=n.direction[f]>=0,v,y;x?(v=fe(s),y=de(s,c)):(v=de(s,c),y=fe(s));let S=li(v,o,n,i,r)?Zg(v,t,e,n,i,r):null;if(S){let M=S.point[f];if(x?M<=o[y+h]:M>=o[y+h+3])return S}let d=li(y,o,n,i,r)?Zg(y,t,e,n,i,r):null;return S&&d?S.distance<=d.distance?S:d:S||d||null}}var Yf=new ne,_a=new ze,ya=new ze,eu=new vt,rv=new ke,$f=new ke;function sv(s,t,e,n){ue.setBuffer(s._roots[t]);let i=Jg(0,s,e,n);return ue.clearBuffer(),i}function Jg(s,t,e,n,i=null){let{float32Array:r,uint16Array:o,uint32Array:a}=ue,c=s*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),rv.set(e.boundingBox.min,e.boundingBox.max,n),i=rv),le(c,o)){let u=t.geometry,h=u.index,f=u.attributes.position,p=e.index,x=e.attributes.position,v=xe(s,a),y=ve(c,o);if(eu.copy(n).invert(),e.boundsTree)return Se(s,r,$f),$f.matrix.copy(eu),$f.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:S=>$f.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(n),S.b.applyMatrix4(n),S.c.applyMatrix4(n),S.needsUpdate=!0;for(let g=v,d=y+v;g<d;g++)if(be(ya,3*t.resolveTriangleIndex(g),h,f),ya.needsUpdate=!0,S.intersectsTriangle(ya))return!0;return!1}});{let _=zr(e);for(let S=v,g=y+v;S<g;S++){let d=t.resolveTriangleIndex(S);be(_a,3*d,h,f),_a.a.applyMatrix4(eu),_a.b.applyMatrix4(eu),_a.c.applyMatrix4(eu),_a.needsUpdate=!0;for(let M=0,m=_*3;M<m;M+=3)if(be(ya,M,p,x),ya.needsUpdate=!0,_a.intersectsTriangle(ya))return!0}}}else{let u=fe(s),h=de(s,a);return Se(u,r,Yf),!!(i.intersectsBox(Yf)&&Jg(u,t,e,n,i)||(Se(h,r,Yf),i.intersectsBox(Yf)&&Jg(h,t,e,n,i)))}}var Kf=new vt,jg=new ke,nu=new ke,z1=new I,k1=new I,H1=new I,V1=new I;function ov(s,t,e,n={},i={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),jg.set(t.boundingBox.min,t.boundingBox.max,e),jg.needsUpdate=!0;let a=s.geometry,c=a.attributes.position,l=a.index,u=t.attributes.position,h=t.index,f=Sn.getPrimitive(),p=Sn.getPrimitive(),x=z1,v=k1,y=null,_=null;i&&(y=H1,_=V1);let S=1/0,g=null,d=null;return Kf.copy(e).invert(),nu.matrix.copy(Kf),s.shapecast({boundsTraverseOrder:M=>jg.distanceToBox(M),intersectsBounds:(M,m,R)=>R<S&&R<o?(m&&(nu.min.copy(M.min),nu.max.copy(M.max),nu.needsUpdate=!0),!0):!1,intersectsRange:(M,m)=>{if(t.boundsTree){let R=t.boundsTree;return R.shapecast({boundsTraverseOrder:E=>nu.distanceToBox(E),intersectsBounds:(E,T,b)=>b<S&&b<o,intersectsRange:(E,T)=>{for(let b=E,w=E+T;b<w;b++){let A=R.resolveTriangleIndex(b);be(p,3*A,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let C=M,D=M+m;C<D;C++){let F=s.resolveTriangleIndex(C);be(f,3*F,l,c),f.needsUpdate=!0;let O=f.distanceToTriangle(p,x,y);if(O<S&&(v.copy(x),_&&_.copy(y),S=O,g=C,d=b),O<r)return!0}}}})}else{let R=zr(t);for(let E=0,T=R;E<T;E++){be(p,3*E,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let b=M,w=M+m;b<w;b++){let A=s.resolveTriangleIndex(b);be(f,3*A,l,c),f.needsUpdate=!0;let C=f.distanceToTriangle(p,x,y);if(C<S&&(v.copy(x),_&&_.copy(y),S=C,g=b,d=E),C<r)return!0}}}}}),Sn.releasePrimitive(f),Sn.releasePrimitive(p),S===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=S,n.faceIndex=g,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(Kf),v.applyMatrix4(Kf),i.distance=v.sub(i.point).length(),i.faceIndex=d),n)}function Qg(s,t,e){return s===null?null:(s.point.applyMatrix4(t.matrixWorld),s.distance=s.point.distanceTo(e.ray.origin),s.object=t,s)}var Zf=new ke,Jf=new _n,av=new I,cv=new vt,lv=new I,tx=["getX","getY","getZ"],jf=class s extends zf{static serialize(t,e={}){e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,r=t._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=i.map(c=>c.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=r),a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:!!t.indirectBuffer,...n};let{index:i,roots:r,indirectBuffer:o}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(r));let a=new s(e,{...n,[ql]:!0});if(a._roots=r,a._indirectBuffer=o||null,n.setIndex){let l=e.getIndex();if(l===null){let u=new kt(t.index,1,!1);e.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a;function c(l){for(let u=0;u<l.length;u++){let h=l[u],f=new Uint32Array(h),p=new Uint16Array(h);for(let x=0,v=h.byteLength/32;x<v;x++){let y=8*x,_=2*y;le(_,p)||(f[y+6]=f[y+6]/8-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.'),e={...e,targetLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,n){let i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,l=(r?r[t]:t)*3,u=l+0,h=l+1,f=l+2;a&&(u=a[u],h=a[h],f=a[f]);for(let p=0;p<3;p++){let x=o[tx[p]](u),v=o[tx[p]](h),y=o[tx[p]](f),_=x;v<_&&(_=v),y<_&&(_=y);let S=x;v>S&&(S=v),y>S&&(S=y),e[n+p]=_,e[n+p+3]=S}return e}computePrimitiveBounds(t,e,n){let i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,c=o.normalized;if(t<0||e+t-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");let l=o.array,u=o.offset||0,h=3;o.isInterleavedBufferAttribute&&(h=o.data.stride);let f=["getX","getY","getZ"],p=n.offset;for(let x=t,v=t+e;x<v;x++){let _=(r?r[x]:x)*3,S=(x-p)*6,g=_+0,d=_+1,M=_+2;a&&(g=a[g],d=a[d],M=a[M]),c||(g=g*h+u,d=d*h+u,M=M*h+u);for(let m=0;m<3;m++){let R,E,T;c?(R=o[f[m]](g),E=o[f[m]](d),T=o[f[m]](M)):(R=l[g+m],E=l[d+m],T=l[M+m]);let b=R;E<b&&(b=E),T<b&&(b=T);let w=R;E>w&&(w=E),T>w&&(w=T);let A=(w-b)/2,C=m*2;n[S+C+0]=b+A,n[S+C+1]=A+(Math.abs(b)+A)*oa}}return n}raycastObject3D(t,e,n=[]){let{material:i}=t;if(i===void 0)return;cv.copy(t.matrixWorld).invert(),Jf.copy(e.ray).applyMatrix4(cv),lv.setFromMatrixScale(t.matrixWorld),av.copy(Jf.direction).multiply(lv);let r=av.length(),o=e.near/r,a=e.far/r;if(e.firstHitOnly===!0){let c=this.raycastFirst(Jf,i,o,a);c=Qg(c,t,e),c&&n.push(c)}else{let c=this.raycast(Jf,i,o,a);for(let l=0,u=c.length;l<u;l++){let h=Qg(c[l],t,e);h&&n.push(h)}}return n}refit(t=null){return(this.indirect?ev:qy)(this,t)}raycast(t,e=rn,n=0,i=1/0){let r=this._roots,o=[],a=this.indirect?nv:Zy;for(let c=0,l=r.length;c<l;c++)a(this,c,e,t,o,n,i);return o}raycastFirst(t,e=rn,n=0,i=1/0){let r=this._roots,o=null,a=this.indirect?iv:Jy;for(let c=0,l=r.length;c<l;c++){let u=a(this,c,e,t,n,i);u!=null&&(o==null||u.distance<o.distance)&&(o=u)}return o}intersectsGeometry(t,e){let n=!1,i=this._roots,r=this.indirect?sv:Qy;for(let o=0,a=i.length;o<a&&(n=r(this,o,t,e),!n);o++);return n}shapecast(t){let e=Sn.getPrimitive(),n=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?Ky:Xy});return Sn.releasePrimitive(e),n}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:r}=n,o=Sn.getPrimitive(),a=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{let v=this.resolveTriangleIndex(x);be(o,v*3,a,c)}:x=>{be(o,x*3,a,c)},u=Sn.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,p=t.indirect?x=>{let v=t.resolveTriangleIndex(x);be(u,v*3,h,f)}:x=>{be(u,x*3,h,f)};if(r){if(!(t instanceof s))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');let x=(v,y,_,S,g,d,M,m)=>{for(let R=_,E=_+S;R<E;R++){p(R),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let T=v,b=v+y;T<b;T++)if(l(T),o.needsUpdate=!0,r(o,u,T,R,g,d,M,m))return!0}return!1};if(i){let v=i;i=function(y,_,S,g,d,M,m,R){return v(y,_,S,g,d,M,m,R)?!0:x(y,_,S,g,d,M,m,R)}}else i=x}return super.bvhcast(t,e,{intersectsRanges:i})}intersectsBox(t,e){return Zf.set(t.min,t.max,e),Zf.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Zf.intersectsBox(n),intersectsTriangle:n=>Zf.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,o=1/0){return(this.indirect?ov:tv)(this,t,e,n,i,r,o)}closestPointToPoint(t,e={},n=0,i=1/0){return Oy(this,t,e,n,i)}};var uv=Math.pow(10,-Math.log10(1e-6)),G1=5e-7*uv;function Ti(s){return~~(s*uv+G1)}function hv(s){return`${Ti(s.x)},${Ti(s.y)}`}function ex(s){return`${Ti(s.x)},${Ti(s.y)},${Ti(s.z)}`}function fv(s){return`${Ti(s.x)},${Ti(s.y)},${Ti(s.z)},${Ti(s.w)}`}function dv(s,t,e){e.direction.subVectors(t,s).normalize();let n=s.dot(e.direction);return e.origin.copy(s).addScaledVector(e.direction,-n),e}function Qf(){return typeof SharedArrayBuffer<"u"}function pv(s){if(s.buffer instanceof SharedArrayBuffer)return s;let t=s.constructor,e=s.buffer,n=new SharedArrayBuffer(e.byteLength),i=new Uint8Array(e);return new Uint8Array(n).set(i,0),new t(n)}function W1(s){return s.index?s.index.count:s.attributes.position.count}function va(s){return W1(s)/3}var X1=1e-8,q1=new I;function gv(s){return~~(s/3)}function xv(s){return s%3}function mv(s,t){return s.start-t.start}function nx(s,t){return q1.subVectors(t,s.origin).dot(s.direction)}function _v(s,t,e,n=X1){s.sort(mv),t.sort(mv);for(let a=0;a<s.length;a++){let c=s[a];for(let l=0;l<t.length;l++){let u=t[l];if(!(u.start>c.end)){if(c.end<u.start||u.end<c.start)continue;if(c.start<=u.start&&c.end>=u.end)r(u.end,c.end)||s.splice(a+1,0,{start:u.end,end:c.end,index:c.index}),c.end=u.start,u.start=0,u.end=0;else if(c.start>=u.start&&c.end<=u.end)r(c.end,u.end)||t.splice(l+1,0,{start:c.end,end:u.end,index:u.index}),u.end=c.start,c.start=0,c.end=0;else if(c.start<=u.start&&c.end<=u.end){let h=c.end;c.end=u.start,u.start=h}else if(c.start>=u.start&&c.end>=u.end){let h=u.end;u.end=c.start,c.start=h}else throw new Error}if(e.has(c.index)||e.set(c.index,[]),e.has(u.index)||e.set(u.index,[]),e.get(c.index).push(u.index),e.get(u.index).push(c.index),o(u)&&(t.splice(l,1),l--),o(c)){s.splice(a,1),a--;break}}}i(s),i(t);function i(a){for(let c=0;c<a.length;c++)o(a[c])&&(a.splice(c,1),c--)}function r(a,c){return Math.abs(c-a)<n}function o(a){return Math.abs(a.end-a.start)<n}}var td=class{constructor(){this._rays=[]}addRay(t){this._rays.push(t)}findClosestRay(t){let e=this._rays,n=t.clone();n.direction.multiplyScalar(-1);let i=1/0,r=null;for(let c=0,l=e.length;c<l;c++){let u=e[c];if(o(u,t)&&o(u,n))continue;let h=a(u,t),f=a(u,n),p=Math.min(h,f);p<i&&(i=p,r=u)}return r;function o(c,l){let u=c.origin.distanceTo(l.origin)>1e-5;return c.direction.angleTo(l.direction)>1e-4||u}function a(c,l){let u=c.origin.distanceTo(l.origin),h=c.direction.angleTo(l.direction);return u/1e-5+h/1e-4}}};var ix=new I,rx=new I,ed=new _n;function yv(s,t,e){let n=s.attributes,i=s.index,r=n.position,o=new Map,a=new Map,c=Array.from(t),l=new td;for(let u=0,h=c.length;u<h;u++){let f=c[u],p=gv(f),x=xv(f),v=3*p+x,y=3*p+(x+1)%3;i&&(v=i.getX(v),y=i.getX(y)),ix.fromBufferAttribute(r,v),rx.fromBufferAttribute(r,y),dv(ix,rx,ed);let _,S=l.findClosestRay(ed);S===null&&(S=ed.clone(),l.addRay(S)),a.has(S)||a.set(S,{forward:[],reverse:[],ray:S}),_=a.get(S);let g=nx(S,ix),d=nx(S,rx);g>d&&([g,d]=[d,g]),ed.direction.dot(S.direction)<0?_.reverse.push({start:g,end:d,index:f}):_.forward.push({start:g,end:d,index:f})}return a.forEach(({forward:u,reverse:h},f)=>{_v(u,h,o,e),u.length===0&&h.length===0&&a.delete(f)}),{disjointConnectivityMap:o,fragmentMap:a}}var Y1=new nt,sx=new I,$1=new Qt,ox=["","",""],nd=class{constructor(){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8}getSiblingTriangleIndex(t,e){let n=this.data[t*3+e];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(t,e){let n=this.data[t*3+e];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(t,e){let n=t*3+e,i=this.disjointConnections.get(n);return i?i.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(t,e){let n=t*3+e,i=this.disjointConnections.get(n);return i?i.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(t){let{useAllAttributes:e,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:r}=this,o=e?g:S,a=new Map,{attributes:c}=t,l=e?Object.keys(c):null,u=t.index,h=c.position,f=va(t),p=f,x=0;n&&(x=t.drawRange.start,t.drawRange.count!==1/0&&(f=~~(t.drawRange.count/3)));let v=this.data;(!v||v.length<3*p)&&(v=new Int32Array(3*p)),v.fill(-1);let y=0,_=new Set;for(let d=x,M=f*3+x;d<M;d+=3){let m=d;for(let R=0;R<3;R++){let E=m+R;u&&(E=u.getX(E)),ox[R]=o(E)}for(let R=0;R<3;R++){let E=(R+1)%3,T=ox[R],b=ox[E],w=`${b}_${T}`;if(a.has(w)){let A=m+R,C=a.get(w);v[A]=C,v[C]=A,a.delete(w),y+=2,_.delete(C)}else{let A=`${T}_${b}`,C=m+R;a.set(A,C),_.add(C)}}}if(i){let{fragmentMap:d,disjointConnectivityMap:M}=yv(t,_,r);_.clear(),d.forEach(({forward:m,reverse:R})=>{m.forEach(({index:E})=>_.add(E)),R.forEach(({index:E})=>_.add(E))}),this.unmatchedDisjointEdges=d,this.disjointConnections=M,y=f*3-_.size}this.matchedEdges=y,this.unmatchedEdges=_.size,this.data=v;function S(d){return sx.fromBufferAttribute(h,d),ex(sx)}function g(d){let M="";for(let m=0,R=l.length;m<R;m++){let E=c[l[m]],T;switch(E.itemSize){case 1:T=Ti(E.getX(d));break;case 2:T=hv(Y1.fromBufferAttribute(E,d));break;case 3:T=ex(sx.fromBufferAttribute(E,d));break;case 4:T=fv($1.fromBufferAttribute(E,d));break}M!==""&&(M+="|"),M+=T}return M}}};var ks=class extends ce{constructor(...t){super(...t),this.isBrush=!0,this._previousMatrix=new vt,this._previousMatrix.elements.fill(0),this._halfEdges=null,this._boundsTree=null,this._groupIndices=null,this._hash=null}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){let{matrix:t,_previousMatrix:e}=this,n=t.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!0;return!1}prepareGeometry(){let t=this.geometry,e=t.attributes,n=Qf(),i=t.index,r=t.attributes.position,o=i?`${i.uuid}_${i.count}_${i.version}`:"-1_-1_-1",a=`${r.uuid}_${r.count}_${r.version}`,c=`${t.uuid}_${o}_${a}`;if(this._hash===c)return;if(this._hash=c,n)for(let f in e){let p=e[f];if(p.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");p.array=pv(p.array)}t.boundsTree=new jf(t,{maxLeafSize:3,indirect:!0,useSharedArrayBuffer:n}),t.halfEdges||(t.halfEdges=new nd),t.halfEdges.updateFrom(t);let l=va(t);(!t.groupIndices||t.groupIndices.length!==l)&&(t.groupIndices=new Uint16Array(l));let u=t.groupIndices,h=t.groups;for(let f=0,p=h.length;f<p;f++){let{start:x,count:v}=h[f];for(let y=x/3,_=(x+v)/3;y<_;y++)u[y]=f}}disposeCacheData(){let{geometry:t}=this;t.halfEdges=null,t.boundsTree=null,t.groupIndices=null}};var K1=Object.getOwnPropertyNames,Yn=(s,t)=>function(){return t||(0,s[K1(s)[0]])((t={exports:{}}).exports,t),t.exports},id=Yn({"node_modules/binary-search-bounds/search-bounds.js"(s,t){"use strict";function e(c,l,u,h,f){for(var p=f+1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y>=0?(p=x,f=x-1):h=x+1}return p}function n(c,l,u,h,f){for(var p=f+1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y>0?(p=x,f=x-1):h=x+1}return p}function i(c,l,u,h,f){for(var p=h-1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y<0?(p=x,h=x+1):f=x-1}return p}function r(c,l,u,h,f){for(var p=h-1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y<=0?(p=x,h=x+1):f=x-1}return p}function o(c,l,u,h,f){for(;h<=f;){var p=h+f>>>1,x=c[p],v=u!==void 0?u(x,l):x-l;if(v===0)return p;v<=0?h=p+1:f=p-1}return-1}function a(c,l,u,h,f,p){return typeof u=="function"?p(c,l,u,h===void 0?0:h|0,f===void 0?c.length-1:f|0):p(c,l,void 0,u===void 0?0:u|0,h===void 0?c.length-1:h|0)}t.exports={ge:function(c,l,u,h,f){return a(c,l,u,h,f,e)},gt:function(c,l,u,h,f){return a(c,l,u,h,f,n)},lt:function(c,l,u,h,f){return a(c,l,u,h,f,i)},le:function(c,l,u,h,f){return a(c,l,u,h,f,r)},eq:function(c,l,u,h,f){return a(c,l,u,h,f,o)}}}}),ax=Yn({"node_modules/two-product/two-product.js"(s,t){"use strict";t.exports=n;var e=+(Math.pow(2,27)+1);function n(i,r,o){var a=i*r,c=e*i,l=c-i,u=c-l,h=i-u,f=e*r,p=f-r,x=f-p,v=r-x,y=a-u*x,_=y-h*x,S=_-u*v,g=h*v-S;return o?(o[0]=g,o[1]=a,o):[g,a]}}}),vv=Yn({"node_modules/robust-sum/robust-sum.js"(s,t){"use strict";t.exports=n;function e(i,r){var o=i+r,a=o-i,c=o-a,l=r-a,u=i-c,h=u+l;return h?[h,o]:[o]}function n(i,r){var o=i.length|0,a=r.length|0;if(o===1&&a===1)return e(i[0],r[0]);var c=o+a,l=new Array(c),u=0,h=0,f=0,p=Math.abs,x=i[h],v=p(x),y=r[f],_=p(y),S,g;v<_?(g=x,h+=1,h<o&&(x=i[h],v=p(x))):(g=y,f+=1,f<a&&(y=r[f],_=p(y))),h<o&&v<_||f>=a?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=r[f],_=p(y)));for(var d=S+g,M=d-S,m=g-M,R=m,E=d,T,b,w,A,C;h<o&&f<a;)v<_?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=r[f],_=p(y))),g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T;for(;h<o;)S=x,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,h+=1,h<o&&(x=i[h]);for(;f<a;)S=y,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,f+=1,f<a&&(y=r[f]);return R&&(l[u++]=R),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}}}),Z1=Yn({"node_modules/two-sum/two-sum.js"(s,t){"use strict";t.exports=e;function e(n,i,r){var o=n+i,a=o-n,c=o-a,l=i-a,u=n-c;return r?(r[0]=u+l,r[1]=o,r):[u+l,o]}}}),Mv=Yn({"node_modules/robust-scale/robust-scale.js"(s,t){"use strict";var e=ax(),n=Z1();t.exports=i;function i(r,o){var a=r.length;if(a===1){var c=e(r[0],o);return c[0]?c:[c[1]]}var l=new Array(2*a),u=[.1,.1],h=[.1,.1],f=0;e(r[0],o,u),u[0]&&(l[f++]=u[0]);for(var p=1;p<a;++p){e(r[p],o,h);var x=u[1];n(x,h[0],u),u[0]&&(l[f++]=u[0]);var v=h[1],y=u[1],_=v+y,S=_-v,g=y-S;u[1]=_,g&&(l[f++]=g)}return u[1]&&(l[f++]=u[1]),f===0&&(l[f++]=0),l.length=f,l}}}),Sv=Yn({"node_modules/robust-subtract/robust-diff.js"(s,t){"use strict";t.exports=n;function e(i,r){var o=i+r,a=o-i,c=o-a,l=r-a,u=i-c,h=u+l;return h?[h,o]:[o]}function n(i,r){var o=i.length|0,a=r.length|0;if(o===1&&a===1)return e(i[0],-r[0]);var c=o+a,l=new Array(c),u=0,h=0,f=0,p=Math.abs,x=i[h],v=p(x),y=-r[f],_=p(y),S,g;v<_?(g=x,h+=1,h<o&&(x=i[h],v=p(x))):(g=y,f+=1,f<a&&(y=-r[f],_=p(y))),h<o&&v<_||f>=a?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=-r[f],_=p(y)));for(var d=S+g,M=d-S,m=g-M,R=m,E=d,T,b,w,A,C;h<o&&f<a;)v<_?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=-r[f],_=p(y))),g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T;for(;h<o;)S=x,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,h+=1,h<o&&(x=i[h]);for(;f<a;)S=y,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,f+=1,f<a&&(y=-r[f]);return R&&(l[u++]=R),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}}}),J1=Yn({"node_modules/robust-orientation/orientation.js"(s,t){"use strict";var e=ax(),n=vv(),i=Mv(),r=Sv(),o=5,a=11102230246251565e-32,c=(3+16*a)*a,l=(7+56*a)*a;function u(d,M,m,R){return function(T,b,w){var A=d(d(M(b[1],w[0]),M(-w[1],b[0])),d(M(T[1],b[0]),M(-b[1],T[0]))),C=d(M(T[1],w[0]),M(-w[1],T[0])),D=R(A,C);return D[D.length-1]}}function h(d,M,m,R){return function(T,b,w,A){var C=d(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2])))),D=d(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2])))),F=R(C,D);return F[F.length-1]}}function f(d,M,m,R){return function(T,b,w,A,C){var D=d(d(d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),w[2]),d(m(d(M(w[1],C[0]),M(-C[1],w[0])),-A[2]),m(d(M(w[1],A[0]),M(-A[1],w[0])),C[2]))),b[3]),d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-A[2]),m(d(M(b[1],A[0]),M(-A[1],b[0])),C[2]))),-w[3]),m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),C[2]))),A[3]))),d(m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),-C[3]),d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-A[2]),m(d(M(b[1],A[0]),M(-A[1],b[0])),C[2]))),T[3]),m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-A[2]),m(d(M(T[1],A[0]),M(-A[1],T[0])),C[2]))),-b[3])))),d(d(m(d(m(d(M(b[1],C[0]),M(-C[1],b[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),C[2]))),A[3]),d(m(d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2]))),-C[3]),m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),T[3]))),d(m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),-b[3]),d(m(d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2]))),w[3]),m(d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2]))),-A[3]))))),F=d(d(d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),w[2]),d(m(d(M(w[1],C[0]),M(-C[1],w[0])),-A[2]),m(d(M(w[1],A[0]),M(-A[1],w[0])),C[2]))),T[3]),m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-A[2]),m(d(M(T[1],A[0]),M(-A[1],T[0])),C[2]))),-w[3])),d(m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),C[2]))),A[3]),m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),-C[3]))),d(d(m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),C[2]))),T[3]),m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),C[2]))),-b[3])),d(m(d(m(d(M(b[1],C[0]),M(-C[1],b[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),C[2]))),w[3]),m(d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2]))),-C[3])))),O=R(D,F);return O[O.length-1]}}function p(d){var M=d===3?u:d===4?h:f;return M(n,e,i,r)}var x=p(3),v=p(4),y=[function(){return 0},function(){return 0},function(M,m){return m[0]-M[0]},function(M,m,R){var E=(M[1]-R[1])*(m[0]-R[0]),T=(M[0]-R[0])*(m[1]-R[1]),b=E-T,w;if(E>0){if(T<=0)return b;w=E+T}else if(E<0){if(T>=0)return b;w=-(E+T)}else return b;var A=c*w;return b>=A||b<=-A?b:x(M,m,R)},function(M,m,R,E){var T=M[0]-E[0],b=m[0]-E[0],w=R[0]-E[0],A=M[1]-E[1],C=m[1]-E[1],D=R[1]-E[1],F=M[2]-E[2],O=m[2]-E[2],H=R[2]-E[2],B=b*D,$=w*C,at=w*A,rt=T*D,ht=T*C,bt=b*A,Et=F*(B-$)+O*(at-rt)+H*(ht-bt),Mt=(Math.abs(B)+Math.abs($))*Math.abs(F)+(Math.abs(at)+Math.abs(rt))*Math.abs(O)+(Math.abs(ht)+Math.abs(bt))*Math.abs(H),K=l*Mt;return Et>K||-Et>K?Et:v(M,m,R,E)}];function _(d){var M=y[d.length];return M||(M=y[d.length]=p(d.length)),M.apply(void 0,d)}function S(d,M,m,R,E,T,b){return function(A,C,D,F,O){switch(arguments.length){case 0:case 1:return 0;case 2:return R(A,C);case 3:return E(A,C,D);case 4:return T(A,C,D,F);case 5:return b(A,C,D,F,O)}for(var H=new Array(arguments.length),B=0;B<arguments.length;++B)H[B]=arguments[B];return d(H)}}function g(){for(;y.length<=o;)y.push(p(y.length));t.exports=S.apply(void 0,[_].concat(y));for(var d=0;d<=o;++d)t.exports[d]=y[d]}g()}}),j1=Yn({"node_modules/cdt2d/lib/monotone.js"(s,t){"use strict";var e=id(),n=J1()[3],i=0,r=1,o=2;t.exports=v;function a(y,_,S,g,d){this.a=y,this.b=_,this.idx=S,this.lowerIds=g,this.upperIds=d}function c(y,_,S,g){this.a=y,this.b=_,this.type=S,this.idx=g}function l(y,_){var S=y.a[0]-_.a[0]||y.a[1]-_.a[1]||y.type-_.type;return S||y.type!==i&&(S=n(y.a,y.b,_.b),S)?S:y.idx-_.idx}function u(y,_){return n(y.a,y.b,_)}function h(y,_,S,g,d){for(var M=e.lt(_,g,u),m=e.gt(_,g,u),R=M;R<m;++R){for(var E=_[R],T=E.lowerIds,w=T.length;w>1&&n(S[T[w-2]],S[T[w-1]],g)>0;)y.push([T[w-1],T[w-2],d]),w-=1;T.length=w,T.push(d);for(var b=E.upperIds,w=b.length;w>1&&n(S[b[w-2]],S[b[w-1]],g)<0;)y.push([b[w-2],b[w-1],d]),w-=1;b.length=w,b.push(d)}}function f(y,_){var S;return y.a[0]<_.a[0]?S=n(y.a,y.b,_.a):S=n(_.b,_.a,y.a),S||(_.b[0]<y.b[0]?S=n(y.a,y.b,_.b):S=n(_.b,_.a,y.b),S||y.idx-_.idx)}function p(y,_,S){var g=e.le(y,S,f),d=y[g],M=d.upperIds,m=M[M.length-1];d.upperIds=[m],y.splice(g+1,0,new a(S.a,S.b,S.idx,[m],M))}function x(y,_,S){var g=S.a;S.a=S.b,S.b=g;var d=e.eq(y,S,f),M=y[d],m=y[d-1];m.upperIds=M.upperIds,y.splice(d,1)}function v(y,_){for(var S=y.length,g=_.length,d=[],M=0;M<S;++M)d.push(new c(y[M],null,i,M));for(var M=0;M<g;++M){var m=_[M],R=y[m[0]],E=y[m[1]];R[0]<E[0]?d.push(new c(R,E,o,M),new c(E,R,r,M)):R[0]>E[0]&&d.push(new c(E,R,o,M),new c(R,E,r,M))}d.sort(l);for(var T=d[0].a[0]-(1+Math.abs(d[0].a[0]))*Math.pow(2,-52),b=[new a([T,1],[T,0],-1,[],[],[],[])],w=[],M=0,A=d.length;M<A;++M){var C=d[M],D=C.type;D===i?h(w,b,y,C.a,C.idx):D===o?p(b,y,C):x(b,y,C)}return w}}}),Q1=Yn({"node_modules/cdt2d/lib/triangulation.js"(s,t){"use strict";var e=id();t.exports=o;function n(a,c){this.stars=a,this.edges=c}var i=n.prototype;function r(a,c,l){for(var u=1,h=a.length;u<h;u+=2)if(a[u-1]===c&&a[u]===l){a[u-1]=a[h-2],a[u]=a[h-1],a.length=h-2;return}}i.isConstraint=function(){var a=[0,0];function c(l,u){return l[0]-u[0]||l[1]-u[1]}return function(l,u){return a[0]=Math.min(l,u),a[1]=Math.max(l,u),e.eq(this.edges,a,c)>=0}}(),i.removeTriangle=function(a,c,l){var u=this.stars;r(u[a],c,l),r(u[c],l,a),r(u[l],a,c)},i.addTriangle=function(a,c,l){var u=this.stars;u[a].push(c,l),u[c].push(l,a),u[l].push(a,c)},i.opposite=function(a,c){for(var l=this.stars[c],u=1,h=l.length;u<h;u+=2)if(l[u]===a)return l[u-1];return-1},i.flip=function(a,c){var l=this.opposite(a,c),u=this.opposite(c,a);this.removeTriangle(a,c,l),this.removeTriangle(c,a,u),this.addTriangle(a,u,l),this.addTriangle(c,l,u)},i.edges=function(){for(var a=this.stars,c=[],l=0,u=a.length;l<u;++l)for(var h=a[l],f=0,p=h.length;f<p;f+=2)c.push([h[f],h[f+1]]);return c},i.cells=function(){for(var a=this.stars,c=[],l=0,u=a.length;l<u;++l)for(var h=a[l],f=0,p=h.length;f<p;f+=2){var x=h[f],v=h[f+1];l<Math.min(x,v)&&c.push([l,x,v])}return c};function o(a,c){for(var l=new Array(a),u=0;u<a;++u)l[u]=[];return new n(l,c)}}}),tR=Yn({"node_modules/robust-in-sphere/in-sphere.js"(s,t){"use strict";var e=ax(),n=vv(),i=Sv(),r=Mv(),o=6;function a(g){var d=g===3?h:g===4?f:g===5?p:x;return d(n,i,e,r)}function c(){return 0}function l(){return 0}function u(){return 0}function h(g,d,M,m){function R(E,T,b){var w=M(E[0],E[0]),A=m(w,T[0]),C=m(w,b[0]),D=M(T[0],T[0]),F=m(D,E[0]),O=m(D,b[0]),H=M(b[0],b[0]),B=m(H,E[0]),$=m(H,T[0]),at=g(d($,O),d(F,A)),rt=d(B,C),ht=d(at,rt);return ht[ht.length-1]}return R}function f(g,d,M,m){function R(E,T,b,w){var A=g(M(E[0],E[0]),M(E[1],E[1])),C=m(A,T[0]),D=m(A,b[0]),F=m(A,w[0]),O=g(M(T[0],T[0]),M(T[1],T[1])),H=m(O,E[0]),B=m(O,b[0]),$=m(O,w[0]),at=g(M(b[0],b[0]),M(b[1],b[1])),rt=m(at,E[0]),ht=m(at,T[0]),bt=m(at,w[0]),Et=g(M(w[0],w[0]),M(w[1],w[1])),Mt=m(Et,E[0]),K=m(Et,T[0]),Q=m(Et,b[0]),ct=g(g(m(d(Q,bt),T[1]),g(m(d(K,$),-b[1]),m(d(ht,B),w[1]))),g(m(d(K,$),E[1]),g(m(d(Mt,F),-T[1]),m(d(H,C),w[1])))),lt=g(g(m(d(Q,bt),E[1]),g(m(d(Mt,F),-b[1]),m(d(rt,D),w[1]))),g(m(d(ht,B),E[1]),g(m(d(rt,D),-T[1]),m(d(H,C),b[1])))),ut=d(ct,lt);return ut[ut.length-1]}return R}function p(g,d,M,m){function R(E,T,b,w,A){var C=g(M(E[0],E[0]),g(M(E[1],E[1]),M(E[2],E[2]))),D=m(C,T[0]),F=m(C,b[0]),O=m(C,w[0]),H=m(C,A[0]),B=g(M(T[0],T[0]),g(M(T[1],T[1]),M(T[2],T[2]))),$=m(B,E[0]),at=m(B,b[0]),rt=m(B,w[0]),ht=m(B,A[0]),bt=g(M(b[0],b[0]),g(M(b[1],b[1]),M(b[2],b[2]))),Et=m(bt,E[0]),Mt=m(bt,T[0]),K=m(bt,w[0]),Q=m(bt,A[0]),ct=g(M(w[0],w[0]),g(M(w[1],w[1]),M(w[2],w[2]))),lt=m(ct,E[0]),ut=m(ct,T[0]),Ct=m(ct,b[0]),Kt=m(ct,A[0]),U=g(M(A[0],A[0]),g(M(A[1],A[1]),M(A[2],A[2]))),tt=m(U,E[0]),Z=m(U,T[0]),Y=m(U,b[0]),q=m(U,w[0]),mt=g(g(g(m(g(m(d(q,Kt),b[1]),g(m(d(Y,Q),-w[1]),m(d(Ct,K),A[1]))),T[2]),g(m(g(m(d(q,Kt),T[1]),g(m(d(Z,ht),-w[1]),m(d(ut,rt),A[1]))),-b[2]),m(g(m(d(Y,Q),T[1]),g(m(d(Z,ht),-b[1]),m(d(Mt,at),A[1]))),w[2]))),g(m(g(m(d(Ct,K),T[1]),g(m(d(ut,rt),-b[1]),m(d(Mt,at),w[1]))),-A[2]),g(m(g(m(d(q,Kt),T[1]),g(m(d(Z,ht),-w[1]),m(d(ut,rt),A[1]))),E[2]),m(g(m(d(q,Kt),E[1]),g(m(d(tt,H),-w[1]),m(d(lt,O),A[1]))),-T[2])))),g(g(m(g(m(d(Z,ht),E[1]),g(m(d(tt,H),-T[1]),m(d($,D),A[1]))),w[2]),g(m(g(m(d(ut,rt),E[1]),g(m(d(lt,O),-T[1]),m(d($,D),w[1]))),-A[2]),m(g(m(d(Ct,K),T[1]),g(m(d(ut,rt),-b[1]),m(d(Mt,at),w[1]))),E[2]))),g(m(g(m(d(Ct,K),E[1]),g(m(d(lt,O),-b[1]),m(d(Et,F),w[1]))),-T[2]),g(m(g(m(d(ut,rt),E[1]),g(m(d(lt,O),-T[1]),m(d($,D),w[1]))),b[2]),m(g(m(d(Mt,at),E[1]),g(m(d(Et,F),-T[1]),m(d($,D),b[1]))),-w[2]))))),it=g(g(g(m(g(m(d(q,Kt),b[1]),g(m(d(Y,Q),-w[1]),m(d(Ct,K),A[1]))),E[2]),m(g(m(d(q,Kt),E[1]),g(m(d(tt,H),-w[1]),m(d(lt,O),A[1]))),-b[2])),g(m(g(m(d(Y,Q),E[1]),g(m(d(tt,H),-b[1]),m(d(Et,F),A[1]))),w[2]),m(g(m(d(Ct,K),E[1]),g(m(d(lt,O),-b[1]),m(d(Et,F),w[1]))),-A[2]))),g(g(m(g(m(d(Y,Q),T[1]),g(m(d(Z,ht),-b[1]),m(d(Mt,at),A[1]))),E[2]),m(g(m(d(Y,Q),E[1]),g(m(d(tt,H),-b[1]),m(d(Et,F),A[1]))),-T[2])),g(m(g(m(d(Z,ht),E[1]),g(m(d(tt,H),-T[1]),m(d($,D),A[1]))),b[2]),m(g(m(d(Mt,at),E[1]),g(m(d(Et,F),-T[1]),m(d($,D),b[1]))),-A[2])))),st=d(mt,it);return st[st.length-1]}return R}function x(g,d,M,m){function R(E,T,b,w,A,C){var D=g(g(M(E[0],E[0]),M(E[1],E[1])),g(M(E[2],E[2]),M(E[3],E[3]))),F=m(D,T[0]),O=m(D,b[0]),H=m(D,w[0]),B=m(D,A[0]),$=m(D,C[0]),at=g(g(M(T[0],T[0]),M(T[1],T[1])),g(M(T[2],T[2]),M(T[3],T[3]))),rt=m(at,E[0]),ht=m(at,b[0]),bt=m(at,w[0]),Et=m(at,A[0]),Mt=m(at,C[0]),K=g(g(M(b[0],b[0]),M(b[1],b[1])),g(M(b[2],b[2]),M(b[3],b[3]))),Q=m(K,E[0]),ct=m(K,T[0]),lt=m(K,w[0]),ut=m(K,A[0]),Ct=m(K,C[0]),Kt=g(g(M(w[0],w[0]),M(w[1],w[1])),g(M(w[2],w[2]),M(w[3],w[3]))),U=m(Kt,E[0]),tt=m(Kt,T[0]),Z=m(Kt,b[0]),Y=m(Kt,A[0]),q=m(Kt,C[0]),mt=g(g(M(A[0],A[0]),M(A[1],A[1])),g(M(A[2],A[2]),M(A[3],A[3]))),it=m(mt,E[0]),st=m(mt,T[0]),Pt=m(mt,b[0]),It=m(mt,w[0]),N=m(mt,C[0]),P=g(g(M(C[0],C[0]),M(C[1],C[1])),g(M(C[2],C[2]),M(C[3],C[3]))),k=m(P,E[0]),W=m(P,T[0]),et=m(P,b[0]),X=m(P,w[0]),_t=m(P,A[0]),xt=g(g(g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),b[2]),m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),-w[2])),g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),A[2]),m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),-C[2]))),T[3]),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-w[2])),g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),A[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-C[2]))),-b[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),A[2]),m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),-C[2]))),w[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),T[2]),m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-C[2]))),-A[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),T[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-A[2]))),C[3])),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-w[2])),g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),A[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-C[2]))),E[3]),m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-w[2])),g(m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),A[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-C[2]))),-T[3])))),g(g(g(m(g(g(m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),A[2]),m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),-C[2]))),w[3]),m(g(g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-C[2]))),-A[3])),g(m(g(g(m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-A[2]))),C[3]),m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),T[2]),m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-C[2]))),E[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-C[2]))),-T[3]),m(g(g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-C[2]))),b[3])),g(m(g(g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),E[2]),m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-C[2]))),-w[3]),m(g(g(m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),E[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-T[2])),g(m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-w[2]))),C[3]))))),Ft=g(g(g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),b[2]),m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),-w[2])),g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),A[2]),m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),-C[2]))),E[3]),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-w[2])),g(m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),A[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-C[2]))),-b[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),A[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-C[2]))),w[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-C[2]))),-A[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-A[2]))),C[3])),g(m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),A[2]),m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),-C[2]))),E[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),A[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-C[2]))),-T[3])))),g(g(g(m(g(g(m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),A[2]),m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),-C[2]))),b[3]),m(g(g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),E[2]),m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-C[2]))),-A[3])),g(m(g(g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),E[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-A[2]))),C[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),T[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-A[2]))),E[3]))),g(g(m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-A[2]))),-T[3]),m(g(g(m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-A[2]))),b[3])),g(m(g(g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),E[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-A[2]))),-w[3]),m(g(g(m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),E[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-T[2])),g(m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-w[2]))),A[3]))))),Dt=d(xt,Ft);return Dt[Dt.length-1]}return R}var v=[c,l,u];function y(g){var d=v[g.length];return d||(d=v[g.length]=a(g.length)),d.apply(void 0,g)}function _(g,d,M,m,R,E,T,b){function w(A,C,D,F,O,H){switch(arguments.length){case 0:case 1:return 0;case 2:return m(A,C);case 3:return R(A,C,D);case 4:return E(A,C,D,F);case 5:return T(A,C,D,F,O);case 6:return b(A,C,D,F,O,H)}for(var B=new Array(arguments.length),$=0;$<arguments.length;++$)B[$]=arguments[$];return g(B)}return w}function S(){for(;v.length<=o;)v.push(a(v.length));t.exports=_.apply(void 0,[y].concat(v));for(var g=0;g<=o;++g)t.exports[g]=v[g]}S()}}),eR=Yn({"node_modules/cdt2d/lib/delaunay.js"(s,t){"use strict";var e=tR()[4],n=id();t.exports=r;function i(o,a,c,l,u,h){var f=a.opposite(l,u);if(!(f<0)){if(u<l){var p=l;l=u,u=p,p=h,h=f,f=p}a.isConstraint(l,u)||e(o[l],o[u],o[h],o[f])<0&&c.push(l,u)}}function r(o,a){for(var c=[],l=o.length,u=a.stars,h=0;h<l;++h)for(var f=u[h],p=1;p<f.length;p+=2){var x=f[p];if(!(x<h)&&!a.isConstraint(h,x)){for(var v=f[p-1],y=-1,_=1;_<f.length;_+=2)if(f[_-1]===x){y=f[_];break}y<0||e(o[h],o[x],o[v],o[y])<0&&c.push(h,x)}}for(;c.length>0;){for(var x=c.pop(),h=c.pop(),v=-1,y=-1,f=u[h],S=1;S<f.length;S+=2){var g=f[S-1],d=f[S];g===x?y=d:d===x&&(v=g)}v<0||y<0||e(o[h],o[x],o[v],o[y])>=0||(a.flip(h,x),i(o,a,c,v,h,y),i(o,a,c,h,y,v),i(o,a,c,y,x,v),i(o,a,c,x,v,y))}}}}),nR=Yn({"node_modules/cdt2d/lib/filter.js"(s,t){"use strict";var e=id();t.exports=c;function n(l,u,h,f,p,x,v){this.cells=l,this.neighbor=u,this.flags=f,this.constraint=h,this.active=p,this.next=x,this.boundary=v}var i=n.prototype;function r(l,u){return l[0]-u[0]||l[1]-u[1]||l[2]-u[2]}i.locate=function(){var l=[0,0,0];return function(u,h,f){var p=u,x=h,v=f;return h<f?h<u&&(p=h,x=f,v=u):f<u&&(p=f,x=u,v=h),p<0?-1:(l[0]=p,l[1]=x,l[2]=v,e.eq(this.cells,l,r))}}();function o(l,u){for(var h=l.cells(),f=h.length,p=0;p<f;++p){var x=h[p],v=x[0],y=x[1],_=x[2];y<_?y<v&&(x[0]=y,x[1]=_,x[2]=v):_<v&&(x[0]=_,x[1]=v,x[2]=y)}h.sort(r);for(var S=new Array(f),p=0;p<S.length;++p)S[p]=0;var g=[],d=[],M=new Array(3*f),m=new Array(3*f),R=null;u&&(R=[]);for(var E=new n(h,M,m,S,g,d,R),p=0;p<f;++p)for(var x=h[p],T=0;T<3;++T){var v=x[T],y=x[(T+1)%3],b=M[3*p+T]=E.locate(y,v,l.opposite(y,v)),w=m[3*p+T]=l.isConstraint(v,y);b<0&&(w?d.push(p):(g.push(p),S[p]=1),u&&R.push([y,v,-1]))}return E}function a(l,u,h){for(var f=0,p=0;p<l.length;++p)u[p]===h&&(l[f++]=l[p]);return l.length=f,l}function c(l,u,h){var f=o(l,h);if(u===0)return h?f.cells.concat(f.boundary):f.cells;for(var p=1,x=f.active,v=f.next,y=f.flags,_=f.cells,S=f.constraint,g=f.neighbor;x.length>0||v.length>0;){for(;x.length>0;){var d=x.pop();if(y[d]!==-p){y[d]=p;for(var M=_[d],m=0;m<3;++m){var R=g[3*d+m];R>=0&&y[R]===0&&(S[3*d+m]?v.push(R):(x.push(R),y[R]=p))}}}var E=v;v=x,x=E,v.length=0,p=-p}var T=a(_,y,u);return h?T.concat(f.boundary):T}}}),iR=Yn({"node_modules/cdt2d/cdt2d.js"(s,t){var e=j1(),n=Q1(),i=eR(),r=nR();t.exports=u;function o(h){return[Math.min(h[0],h[1]),Math.max(h[0],h[1])]}function a(h,f){return h[0]-f[0]||h[1]-f[1]}function c(h){return h.map(o).sort(a)}function l(h,f,p){return f in h?h[f]:p}function u(h,f,p){Array.isArray(f)?(p=p||{},f=f||[]):(p=f||{},f=[]);var x=!!l(p,"delaunay",!0),v=!!l(p,"interior",!0),y=!!l(p,"exterior",!0),_=!!l(p,"infinity",!1);if(!v&&!y||h.length===0)return[];var S=e(h,f);if(x||v!==y||_){for(var g=n(h.length,c(f)),d=0;d<S.length;++d){var M=S[d];g.addTriangle(M[0],M[1],M[2])}return x&&i(h,g),y?v?_?r(g,0,_):g.cells():r(g,1,_):r(g,-1)}else return S}}}),bv=iR();var $n=class{constructor(t){this.createFn=t,this._pool=[],this._index=0}getInstance(){return this._index>=this._pool.length&&this._pool.push(this.createFn()),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}};var Tv=1e-16,rR=1e-16,Hs=new I,Ev=new I,wv=new $n(()=>({param:0,index:0})),sR=new $n(()=>new I);function oR(s,t,e,n){wv.clear(),t.length=0,e.length=0;for(let l=0,u=s.length;l<u;l++){let h=s[l];c(h.start),c(h.end)}for(let l=0,u=s.length;l<u;l++){let h=s[l];for(let f=l+1;f<u;f++){let p=s[f];h.distanceSqToLine3(p,Hs,Ev)<Tv*n&&c(Ev)}}let i=[];for(let l=0,u=s.length;l<u;l++){i.length=0;let h=s[l];for(let f=0,p=t.length;f<p;f++){let x=t[f],v=h.closestPointToPointParameter(x,!0);if(h.at(v,Hs),x.distanceToSquared(Hs)<Tv*n){let y=wv.getInstance();y.param=v,y.index=f,i.push(y)}}i.sort(a);for(let f=0,p=i.length-1;f<p;f++){let x=i[f].index,v=i[f+1].index;x!==v&&e.push([x,v])}}let r=new Set,o=0;for(let l=0,u=e.length;l<u;l++){let h=e[l],f=Math.min(h[0],h[1]),p=Math.max(h[0],h[1]),x=f+","+p;r.has(x)||(r.add(x),e[o++]=h)}e.length=o;function a(l,u){return l.param-u.param}function c(l){for(let u=0;u<t.length;u++){let h=t[u];if(l===h||l.distanceToSquared(h)<rR*n)return u}return t.push(sR.getInstance().copy(l)),t.length-1}}var iu=class{constructor(){this.trianglePool=new $n(()=>new ze),this.linePool=new $n(()=>new _e),this.triangles=[],this.triangleIndices=[],this.constrainedEdges=[],this.triangleConnectivity=[],this.normal=new I,this.projOrigin=new I,this.projU=new I,this.projV=new I,this.baseTri=new ze,this.baseIndices=new Array(3)}initialize(t,e=null,n=null,i=null){this.reset();let{normal:r,baseTri:o,projU:a,projV:c,projOrigin:l,constrainedEdges:u,linePool:h,baseIndices:f}=this;t.getNormal(r),o.copy(t),o.update(),f[0]=e,f[1]=n,f[2]=i,u.length=0;let p=h.getInstance();p.start.copy(o.a),p.end.copy(o.b);let x=h.getInstance();x.start.copy(o.b),x.end.copy(o.c);let v=h.getInstance();v.start.copy(o.c),v.end.copy(o.a),u.push(p,x,v),l.copy(o.a),a.subVectors(o.b,o.a).normalize(),c.crossVectors(r,a).normalize()}addConstraintEdge(t){let{constrainedEdges:e,linePool:n}=this,i=n.getInstance().copy(t);e.push(i)}_to2D(t,e){let{projOrigin:n,projU:i,projV:r}=this;return Hs.subVectors(t,n),e.set(Hs.dot(i),Hs.dot(r),0)}_from2D(t,e,n){let{projOrigin:i,projU:r,projV:o}=this;return n.copy(i).addScaledVector(r,t).addScaledVector(o,e),n}triangulate(){let{triangles:t,trianglePool:e,triangleConnectivity:n,triangleIndices:i,linePool:r,baseTri:o,constrainedEdges:a,baseIndices:c}=this;t.length=0,e.clear();let l=[];for(let _=0,S=a.length;_<S;_++){let g=a[_],d=r.getInstance();this._to2D(g.start,d.start),this._to2D(g.end,d.end),l.push(d)}let u=0;for(let _=0;_<3;_++){let S=this._to2D(o.points[_],Hs);u=Math.max(u,Math.abs(S.x),Math.abs(S.y))}let h=[],f=[];oR(l,h,f,u);let p=[];for(let _=0,S=h.length;_<S;_++){let g=h[_];p.push([g.x,g.y])}let x=bv(p,f,{exterior:!1}),v=new Map;for(let _=0,S=f.length;_<S;_++){let g=f[_];v.set(`${g[0]}_${g[1]}`,-1),v.set(`${g[1]}_${g[0]}`,-1)}let y=`${c[0]}_${c[1]}_${c[2]}_`;for(let _=0,S=x.length;_<S;_++){let g=x[_],[d,M,m]=g,R=e.getInstance();this._from2D(p[d][0],p[d][1],R.a),this._from2D(p[M][0],p[M][1],R.b),this._from2D(p[m][0],p[m][1],R.c),t.push(R);let E=[];n.push(E);let T=[];i.push(T);for(let b=0;b<3;b++){let w=g[b];T.push(w<3?c[w]:y+w);let A=g[(b+1)%3],C=`${w}_${A}`;if(v.has(C)){let D=v.get(C);D!==-1&&(E.push(D),n[D].push(_))}else{let D=`${A}_${w}`;v.set(D,_)}}}}reset(){this.trianglePool.clear(),this.linePool.clear(),this.triangles.length=0,this.triangleIndices.length=0,this.triangleConnectivity.length=0,this.constrainedEdges.length=0}};var aR=1e-14,cx=new I,Av=new I,Rv=new I;function Ei(s,t=aR){cx.subVectors(s.b,s.a),Av.subVectors(s.c,s.a),Rv.subVectors(s.b,s.c);let e=cx.angleTo(Av),n=cx.angleTo(Rv),i=Math.PI-e-n;return Math.abs(e)<t||Math.abs(n)<t||Math.abs(i)<t||s.a.distanceToSquared(s.b)<t||s.a.distanceToSquared(s.c)<t||s.b.distanceToSquared(s.c)<t}var lx=1e-10,ru=1e-10,pr=new _e,Ge=new _e,mr=new I,Cv=new I,Iv=new I,rd=new $e,ux=new ze,su=class{constructor(){this.trianglePool=new $n(()=>new me),this.triangles=[],this.normal=new I}initialize(t){this.reset();let{triangles:e,trianglePool:n,normal:i}=this;if(Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];if(r===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(mr).dot(i))>lx)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");let c=n.getInstance();c.copy(a),e.push(c)}else{t.getNormal(i);let r=n.getInstance();r.copy(t),e.push(r)}}splitByTriangle(t,e){let{triangles:n}=this;if(e){for(let r=0,o=n.length;r<o;r++){let a=n[r];a.coplanarCount=0}let i=[t.a,t.b,t.c];for(let r=0;r<3;r++){let o=(r+1)%3,a=i[r],c=i[o];t.getNormal(Cv).normalize(),mr.subVectors(c,a).normalize(),Iv.crossVectors(Cv,mr),rd.setFromNormalAndCoplanarPoint(Iv,a),this.splitByPlane(rd,t)}}else t.getPlane(rd),this.splitByPlane(rd,t)}splitByPlane(t,e){let{triangles:n,trianglePool:i}=this;ux.copy(e),ux.needsUpdate=!0;for(let r=0,o=n.length;r<o;r++){let a=n[r];if(!ux.intersectsTriangle(a,pr,!0))continue;let{a:c,b:l,c:u}=a,h=0,f=-1,p=!1,x=[],v=[],y=[c,l,u];for(let _=0;_<3;_++){let S=(_+1)%3;pr.start.copy(y[_]),pr.end.copy(y[S]);let g=t.distanceToPoint(pr.start),d=t.distanceToPoint(pr.end);if(Math.abs(g)<ru&&Math.abs(d)<ru){p=!0;break}if(g>0?x.push(_):v.push(_),Math.abs(g)<ru)continue;let M=!!t.intersectLine(pr,mr);!M&&Math.abs(d)<ru&&(mr.copy(pr.end),M=!0),M&&!(mr.distanceTo(pr.start)<lx)&&(mr.distanceTo(pr.end)<lx&&(f=_),h===0?Ge.start.copy(mr):Ge.end.copy(mr),h++)}if(!p&&h===2&&Ge.distance()>ru)if(f!==-1){f=(f+1)%3;let _=0;_===f&&(_=(_+1)%3);let S=_+1;S===f&&(S=(S+1)%3);let g=i.getInstance();g.a.copy(y[S]),g.b.copy(Ge.end),g.c.copy(Ge.start),Ei(g)||n.push(g),a.a.copy(y[_]),a.b.copy(Ge.start),a.c.copy(Ge.end),Ei(a)&&(n.splice(r,1),r--,o--)}else{let _=x.length>=2?v[0]:x[0];if(_===0){let m=Ge.start;Ge.start=Ge.end,Ge.end=m}let S=(_+1)%3,g=(_+2)%3,d=i.getInstance(),M=i.getInstance();y[S].distanceToSquared(Ge.start)<y[g].distanceToSquared(Ge.end)?(d.a.copy(y[S]),d.b.copy(Ge.start),d.c.copy(Ge.end),M.a.copy(y[S]),M.b.copy(y[g]),M.c.copy(Ge.start)):(d.a.copy(y[g]),d.b.copy(Ge.start),d.c.copy(Ge.end),M.a.copy(y[S]),M.b.copy(y[g]),M.c.copy(Ge.end)),a.a.copy(y[_]),a.b.copy(Ge.end),a.c.copy(Ge.start),Ei(d)||n.push(d),Ei(M)||n.push(M),Ei(a)&&(n.splice(r,1),r--,o--)}else h===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear()}};var ou=class{constructor(){this.coplanarSet=new Map,this.intersectionSet=new Map,this.edgeSet=new Map,this.ids=[]}add(t,e,n=!1){let{intersectionSet:i,coplanarSet:r,ids:o}=this;i.has(t)||(i.set(t,[]),o.push(t)),i.get(t).push(e),n&&(r.has(t)||r.set(t,new Set),r.get(t).add(e))}addIntersectionEdge(t,e){let{edgeSet:n}=this;n.has(t)||n.set(t,new Set),n.get(t).add(e)}getIntersectionEdges(t){return this.edgeSet.get(t)||null}};var hx=1e-10,cR=1e-15,lR=1e-10,uR=1e-10,Pv=new _e,Ma=new _e,Lv=new I,Nv=new I,Dv=new I,fx=new $e,Sa=new I,sd=new I;function Fv(s,t){s.getNormal(Sa),t.getNormal(sd);let e=Sa.dot(sd);if(Math.abs(1-Math.abs(e))>=lR)return!1;let n=Sa.dot(s.a),i=Sa.dot(t.a);return Math.abs(n-i)<uR}function Uv(s,t,e,n){let i=0,r=1;s.delta(Lv);let o=[t.a,t.b,t.c];for(let a=0;a<3;a++){let c=o[a],l=o[(a+1)%3];Nv.subVectors(l,c),Dv.crossVectors(e,Nv),fx.setFromNormalAndCoplanarPoint(Dv,c);let u=fx.distanceToPoint(s.start),h=fx.normal.dot(Lv);if(Math.abs(h)<cR){if(u<-hx)return null;continue}let f=-u/h;if(h>0?i=Math.max(i,f):r=Math.min(r,f),i>r+hx)return null}return r-i<hx?null:(s.at(i,n.start),s.at(r,n.end),n)}function dx(s,t,e){let n=0;s.getNormal(Sa),t.getNormal(sd);let i=[t.a,t.b,t.c];for(let o=0;o<3;o++){Ma.start.copy(i[o]),Ma.end.copy(i[(o+1)%3]);let a=Uv(Ma,s,Sa,Pv);a!==null&&(n>=e.length&&e.push(new _e),e[n].copy(a),n++)}let r=[s.a,s.b,s.c];for(let o=0;o<3;o++){Ma.start.copy(r[o]),Ma.end.copy(r[(o+1)%3]);let a=Uv(Ma,t,sd,Pv);a!==null&&(n>=e.length&&e.push(new _e),e[n].copy(a),n++)}return n}var ba=new _n,Ov=new vt,od=new _e,px=[],ad=new $n(()=>new _e),Ta=-1,Ea=1,au=-2,cu=2,wa=0,Vs=1,ld=2,cd=null;function mx(s){cd=s}function gx(s,t,e=null){s.getMidpoint(ba.origin),s.getNormal(ba.direction),e&&(ba.origin.applyMatrix4(e),ba.direction.transformDirection(e));let n=t.raycastFirst(ba,Ve);return!!(n&&ba.direction.dot(n.face.normal)>0)?Ta:Ea}function Hv(s,t){let e=new ou,n=new ou;return ad.clear(),Ov.copy(s.matrixWorld).invert().multiply(t.matrixWorld),s.geometry.boundsTree.bvhcast(t.geometry.boundsTree,Ov,{intersectsTriangles(i,r,o,a){if(!Ei(i)&&!Ei(r)){let l=(Fv(i,r)?dx(i,r,px):0)>2;if(l||i.intersectsTriangle(r,od,!0)){let h=s.geometry.boundsTree.resolveTriangleIndex(o),f=t.geometry.boundsTree.resolveTriangleIndex(a);if(e.add(h,f,l),n.add(f,h,l),l){let p=dx(i,r,px);for(let x=0;x<p;x++){let v=ad.getInstance().copy(px[x]);e.addIntersectionEdge(h,v),n.addIntersectionEdge(f,v)}}else{let p=ad.getInstance().copy(od),x=ad.getInstance().copy(od);e.addIntersectionEdge(h,p),n.addIntersectionEdge(f,x)}cd&&(cd.addEdge(od),cd.addIntersectingTriangles(o,i,a,r))}}return!1}}),{aIntersections:e,bIntersections:n}}function xx(s,t,e=!1){switch(s){case 0:if(t===Ea||t===cu&&!e)return Vs;break;case 1:if(e){if(t===Ta)return wa}else if(t===Ea||t===au)return Vs;break;case 2:if(e){if(t===Ea||t===au)return Vs}else if(t===Ta)return wa;break;case 4:if(t===Ta)return wa;if(t===Ea)return Vs;break;case 3:if(t===Ta||t===cu&&!e)return Vs;break;case 5:if(!e&&(t===Ea||t===au))return Vs;break;case 6:if(!e&&(t===Ta||t===cu))return Vs;break;default:throw new Error(`Unrecognized CSG operation enum "${s}".`)}return ld}var _x=class{constructor(t){this.triangle=new me().copy(t),this.intersects={}}addTriangle(t,e){this.intersects[t]=new me().copy(e)}getIntersectArray(){let t=[],{intersects:e}=this;for(let n in e)t.push(e[n]);return t}},ud=class{constructor(){this.data={}}addTriangleIntersection(t,e,n,i){let{data:r}=this;r[t]||(r[t]=new _x(e)),r[t].addTriangle(n,i)}getTrianglesAsArray(t=null){let{data:e}=this,n=[];if(t!==null)t in e&&n.push(e[t].triangle);else for(let i in e)n.push(e[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(t=>parseInt(t))}getIntersectionIndices(t){let{data:e}=this;return e[t]?Object.keys(e[t].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(t=null,e=null){let{data:n}=this,i=new Set,r=[],o=a=>{if(n[a])if(e!==null)n[a].intersects[e]&&r.push(n[a].intersects[e]);else{let c=n[a].intersects;for(let l in c)i.has(l)||(i.add(l),r.push(c[l]))}};if(t!==null)o(t);else for(let a in n)o(a);return r}reset(){this.data={}}},hd=class{constructor(){this.enabled=!1,this.triangleIntersectsA=new ud,this.triangleIntersectsB=new ud,this.intersectionEdges=[]}addIntersectingTriangles(t,e,n,i){let{triangleIntersectsA:r,triangleIntersectsB:o}=this;r.addTriangleIntersection(t,e,n,i),o.addTriangleIntersection(n,i,t,e)}addEdge(t){this.intersectionEdges.push(t.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),mx(this))}complete(){this.enabled&&mx(null)}};var Kn=new vt,Gs=new vt,Pn=new vt,Hr=new $t,wi=new me,Ws=new me,Ai=new me,kr=new me,Xs=[],Ki=[],fd=new Set,Vv=new I,Gv=new I,Wv=new $n(()=>new me),Xv=new I,dd=[];function $v(s,t,e,n,i,r={}){let{useGroups:o=!0}=r,{aIntersections:a,bIntersections:c}=Hv(s,t),l=[],u=null,h;return h=o?0:-1,Yv(s,t,a,e,!1,i,h),qv(s,t,a,e,!1,n,i,h),e.findIndex(p=>p!==6&&p!==5)!==-1&&(i.forEach(p=>p.clearIndexMap()),h=o?s.geometry.groups.length||1:-1,Yv(t,s,c,e,!0,i,h),qv(t,s,c,e,!0,n,i,h)),i.forEach(p=>p.clearIndexMap()),Xs.length=0,{groups:l,materials:u}}function qv(s,t,e,n,i,r,o,a=0){Kn.copy(t.matrixWorld).invert().multiply(s.matrixWorld),Gs.copy(Kn).invert(),i?Pn.copy(Kn):Pn.identity();let c=Pn.determinant()<0;Hr.getNormalMatrix(Pn).multiplyScalar(c?-1:1);let l=s.geometry.groupIndices,u=s.geometry.index,h=s.geometry.attributes.position,f=t.geometry.boundsTree,p=t.geometry.index,x=t.geometry.attributes.position,v=e.ids;for(let y=0,_=v.length;y<_;y++){let S=v[y],g=a===-1?0:l[S]+a,d=3*S,M=d+0,m=d+1,R=d+2;u&&(M=u.getX(M),m=u.getX(m),R=u.getX(R)),wi.a.fromBufferAttribute(h,M),wi.b.fromBufferAttribute(h,m),wi.c.fromBufferAttribute(h,R),i&&(wi.a.applyMatrix4(Kn),wi.b.applyMatrix4(Kn),wi.c.applyMatrix4(Kn)),r.reset(),r.initialize(wi,M,m,R),dd.length=0,Wv.clear(),wi.getNormal(Gv);let E=e.coplanarSet.get(S);if(E)for(let A of E){let C=3*A,D=C+0,F=C+1,O=C+2;p&&(D=p.getX(D),F=p.getX(F),O=p.getX(O));let H=Wv.getInstance();H.a.fromBufferAttribute(x,D),H.b.fromBufferAttribute(x,F),H.c.fromBufferAttribute(x,O),i||(H.a.applyMatrix4(Gs),H.b.applyMatrix4(Gs),H.c.applyMatrix4(Gs)),dd.push(H)}if(r.addConstraintEdge){let A=e.getIntersectionEdges(S);if(A)for(let C of A)r.addConstraintEdge(C);r.triangulate()}else{let C=e.intersectionSet.get(S);for(let D=0,F=C.length;D<F;D++){let O=C[D],H=E&&E.has(O),B=3*O,$=B+0,at=B+1,rt=B+2;p&&($=p.getX($),at=p.getX(at),rt=p.getX(rt)),Ws.a.fromBufferAttribute(x,$),Ws.b.fromBufferAttribute(x,at),Ws.c.fromBufferAttribute(x,rt),i||(Ws.a.applyMatrix4(Gs),Ws.b.applyMatrix4(Gs),Ws.c.applyMatrix4(Gs)),r.splitByTriangle(Ws,H)}}let{triangles:T,triangleIndices:b=[],triangleConnectivity:w=[]}=r;for(let A=0,C=o.length;A<C;A++)o[A].initInterpolatedAttributeData(s.geometry,Pn,Hr,M,m,R);fd.clear();for(let A=0,C=T.length;A<C;A++){if(fd.has(A))continue;let D=T[A],F=i?null:Kn,O=null;D.getMidpoint(Vv);for(let H=0,B=dd.length;H<B;H++){let $=dd[H];if($.containsPoint(Vv)){$.getNormal(Xv),O=Gv.dot(Xv)>0?cu:au;break}}O===null&&(O=gx(D,f,F)),Xs.length=0,Ki.length=0;for(let H=0,B=n.length;H<B;H++){let $=xx(n[H],O,i);$!==ld&&(Xs.push($),Ki.push(o[H]))}if(Ki.length!==0){let H=[A];for(;H.length>0;){let B=H.pop();if(fd.has(B))continue;fd.add(B);let $=b[B],at=null,rt=null,ht=null;$&&(at=$[0],rt=$[1],ht=$[2]);let bt=T[B];wi.getBarycoord(bt.a,kr.a),wi.getBarycoord(bt.b,kr.b),wi.getBarycoord(bt.c,kr.c);for(let Et=0,Mt=Ki.length;Et<Mt;Et++){let K=Ki[Et],ct=Xs[Et]===wa,lt=c!==ct;K.appendInterpolatedAttributeData(g,kr.a,at,lt),lt?(K.appendInterpolatedAttributeData(g,kr.c,ht,lt),K.appendInterpolatedAttributeData(g,kr.b,rt,lt)):(K.appendInterpolatedAttributeData(g,kr.b,rt,lt),K.appendInterpolatedAttributeData(g,kr.c,ht,lt))}}}}}return v.length}function Yv(s,t,e,n,i,r,o=0){Kn.copy(t.matrixWorld).invert().multiply(s.matrixWorld),i?Pn.copy(Kn):Pn.identity();let a=Pn.determinant()<0;Hr.getNormalMatrix(Pn).multiplyScalar(a?-1:1);let c=t.geometry.boundsTree,l=s.geometry.groupIndices,u=s.geometry.index,f=s.geometry.attributes.position,p=[],x=s.geometry.halfEdges,v=new Set(e.ids),y=va(s.geometry);for(let _=0;_<y&&v.size!==y;_++){if(v.has(_))continue;v.add(_),p.push(_);let S=3*_,g=S+0,d=S+1,M=S+2;u&&(g=u.getX(g),d=u.getX(d),M=u.getX(M)),Ai.a.fromBufferAttribute(f,g),Ai.b.fromBufferAttribute(f,d),Ai.c.fromBufferAttribute(f,M),i&&(Ai.a.applyMatrix4(Kn),Ai.b.applyMatrix4(Kn),Ai.c.applyMatrix4(Kn));let m=gx(Ai,c,i?null:Kn);Xs.length=0,Ki.length=0;for(let R=0,E=n.length;R<E;R++){let T=xx(n[R],m,i);T!==ld&&(Xs.push(T),Ki.push(r[R]))}for(;p.length>0;){let R=p.pop();for(let E=0;E<3;E++){let T=x.getSiblingTriangleIndex(R,E);T!==-1&&!v.has(T)&&(p.push(T),v.add(T))}if(Ki.length!==0){let E=3*R,T=E+0,b=E+1,w=E+2;u&&(T=u.getX(T),b=u.getX(b),w=u.getX(w));let A=o===-1?0:l[R]+o;if(Ai.a.fromBufferAttribute(f,T),Ai.b.fromBufferAttribute(f,b),Ai.c.fromBufferAttribute(f,w),!Ei(Ai))for(let C=0,D=Ki.length;C<D;C++){let F=Ki[C],B=Xs[C]===wa!==a;F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,T,B),B?(F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,w,B),F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,b,B)):(F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,b,B),F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,w,B))}}}}}function dR(s){return s=~~s,s+4-s%4}var pd=class{constructor(t,e=500){this.expansionFactor=1.5,this.type=t,this.length=0,this.array=null,this.setSize(e)}setType(t){if(t===this.type)return;if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");let e=this.array.buffer;this.array=new t(e),this.type=t}setSize(t){if(this.array&&t===this.array.length)return;let e=this.type,n=Qf()?SharedArrayBuffer:ArrayBuffer,i=new e(new n(dR(t*e.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){let{array:t,expansionFactor:e}=this;this.setSize(t.length*e)}push(...t){let{array:e,length:n}=this;n+t.length>e.length&&(this.expand(),e=this.array);for(let i=0,r=t.length;i<r;i++)e[n+i]=t[i];this.length+=t.length}clear(){this.length=0}};var Ln=new I,yx=new I,vx=new I,Mx=new I,md=new Qt,pR=new Qt,mR=new Qt,gR=new Qt;function xR(s,t,e,n,i,r=!1,o=!1){return i.set(0,0,0,0).addScaledVector(s,n.x).addScaledVector(t,n.y).addScaledVector(e,n.z),r&&i.normalize(),o&&i.multiplyScalar(-1),i}function Kv(s,t,e){switch(t){case 1:e.push(s.x);break;case 2:e.push(s.x,s.y);break;case 3:e.push(s.x,s.y,s.z);break;case 4:e.push(s.x,s.y,s.z,s.w);break}}var lu=class extends pd{get count(){return this.length/this.itemSize}constructor(...t){super(...t),this.itemSize=1,this.normalized=!1}},gd=class{constructor(){this.attributeData={},this.groupIndices=[],this.forwardIndexMap=new Map,this.invertedIndexMap=new Map,this.interpolatedFields={}}initFromGeometry(t,e){this.clear();let{attributeData:n}=this,i=t.attributes;for(let r=0,o=e.length;r<o;r++){let a=e[r],c=i[a],l=c.array.constructor;n[a]||(n[a]=new lu(l)),n[a].setType(l),n[a].itemSize=c.itemSize,n[a].normalized=c.normalized}for(let r in n.attributes)e.includes(r)||n.delete(r)}initInterpolatedAttributeData(t,e,n,i,r,o){let{attributeData:a,interpolatedFields:c}=this,{attributes:l}=t;for(let u in a){let h=l[u];if(!h)throw new Error(`CSG Operations: Attribute ${u} not available on geometry.`);let f,p,x;if(u==="position"?(f=yx.fromBufferAttribute(h,i).applyMatrix4(e),p=vx.fromBufferAttribute(h,r).applyMatrix4(e),x=Mx.fromBufferAttribute(h,o).applyMatrix4(e)):u==="normal"?(f=yx.fromBufferAttribute(h,i).applyNormalMatrix(n),p=vx.fromBufferAttribute(h,r).applyNormalMatrix(n),x=Mx.fromBufferAttribute(h,o).applyNormalMatrix(n)):u==="tangent"?(f=yx.fromBufferAttribute(h,i).transformDirection(e),p=vx.fromBufferAttribute(h,r).transformDirection(e),x=Mx.fromBufferAttribute(h,o).transformDirection(e)):(f=pR.fromBufferAttribute(h,i),p=mR.fromBufferAttribute(h,r),x=gR.fromBufferAttribute(h,o)),!c[u])c[u]=[f.clone(),p.clone(),x.clone()];else{let v=c[u];v[0].copy(f),v[1].copy(p),v[2].copy(x)}}}appendInterpolatedAttributeData(t,e,n=null,i=!1){let{groupIndices:r,attributeData:o,interpolatedFields:a,forwardIndexMap:c,invertedIndexMap:l}=this;for(;r.length<=t;)r.push(new lu(Uint32Array));let u=i?l:c,h=r[t];if(n!==null&&u.has(n))h.push(u.get(n));else{u.set(n,o.position.count),h.push(o.position.count);for(let f in a){let p=o[f],x=f==="normal"||f==="tangent",v=i&&x,y=p.itemSize,[_,S,g]=a[f];xR(_,S,g,e,md,x,v),Kv(md,y,p)}}}appendIndexFromGeometry(t,e,n,i,r,o=!1){let{groupIndices:a,attributeData:c,forwardIndexMap:l,invertedIndexMap:u}=this;for(;a.length<=i;)a.push(new lu(Uint32Array));let h=o?u:l,f=a[i];if(r!==null&&h.has(r))f.push(h.get(r));else{h.set(r,c.position.count),f.push(c.position.count);let{attributes:p}=t;for(let x in c){let v=c[x],y=p[x];if(!y)throw new Error(`CSG Operations: Attribute ${x} not available on geometry.`);let _=y.itemSize;x==="position"?(Ln.fromBufferAttribute(y,r).applyMatrix4(e),v.push(Ln.x,Ln.y,Ln.z)):x==="normal"?(Ln.fromBufferAttribute(y,r).applyNormalMatrix(n),o&&Ln.multiplyScalar(-1),v.push(Ln.x,Ln.y,Ln.z)):x==="tangent"?(Ln.fromBufferAttribute(y,r).transformDirection(e),o&&Ln.multiplyScalar(-1),v.push(Ln.x,Ln.y,Ln.z)):(md.fromBufferAttribute(y,r),Kv(md,_,v))}}}buildGeometry(t,e){let n=!1,{groupIndices:i,attributeData:r}=this,{attributes:o,index:a}=t;for(let u in r){let h=r[u],{type:f,itemSize:p,normalized:x,length:v,count:y}=h,_=h.array.buffer,S=o[u];(!S||S.count<y||S.array.type!==f)&&(S=new kt(new f(v),p,x),t.setAttribute(u,S),n=!0),S.array.set(new f(_,0,v),0),S.needsUpdate=!0}let c=i.reduce((u,h)=>h.count+u,0);(!t.index||a.count<c||a.array.type!==Uint32Array)&&(t.setIndex(new kt(new Uint32Array(c),1)),n=!0),t.clearGroups();let l=0;for(let u=0,h=Math.min(e.length,i.length);u<h;u++){let{index:f,materialIndex:p}=e[u],{count:x}=i[f],v=i[f].array.buffer;x!==0&&(t.index.array.set(new Uint32Array(v,0,x),l),t.addGroup(l,x,p),l+=x)}t.setDrawRange(0,l),t.boundsTree=null,t.boundingBox=null,t.boundingSphere=null,n&&t.dispose()}clearIndexMap(){this.forwardIndexMap.clear(),this.invertedIndexMap.clear()}clear(){let{groupIndices:t,attributeData:e}=this;this.interpolatedFields={};for(let n in e)e[n].clear();t.forEach(n=>{n.clear()}),this.clearIndexMap()}};function Zv(s,t){for(let e in s.attributes)t.includes(e)||(s.deleteAttribute(e),s.dispose());return s}function Jv(s,t){let e=[];for(let n=0,i=s.length;n<i;n++){let r=s[n],o=t[r.materialIndex];e.push({...r,materialIndex:t.indexOf(o)})}return e}function jv(s,t){let e=[],n=new Map;for(let i=0,r=s.length;i<r;i++){let o=s[i];n.has(o.materialIndex)||(n.set(o.materialIndex,e.length),e.push(t[o.materialIndex])),o.materialIndex=n.get(o.materialIndex)}return e}function Qv(s){for(let t=0;t<s.length-1;t++){let e=s[t],n=s[t+1];if(e.materialIndex===n.materialIndex){let i=e.start,r=n.start+n.count;n.start=i,n.count=r-i,s.splice(t,1),t--}}}function Sx(s,t){let e=t;return Array.isArray(t)||(e=[],s.forEach(n=>{e[n.materialIndex]=t})),e}var xd=class{get useCDTClipping(){return this.triangleSplitter instanceof iu}set useCDTClipping(t){t!==this.useCDTClipping&&(this.triangleSplitter=t?new iu:new su)}constructor(){this.triangleSplitter=new su,this.geometryBuilders=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.removeUnusedMaterials=!0,this.debug=new hd}getGroupRanges(t){return!this.useGroups||t.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:t.groups.map(n=>({...n}))}evaluate(t,e,n,i=new ks){let r=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],r=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");t.prepareGeometry(),e.prepareGeometry();let{triangleSplitter:o,geometryBuilders:a,attributes:c,useGroups:l,consolidateGroups:u,removeUnusedMaterials:h,debug:f}=this;for(;a.length<i.length;)a.push(new gd);i.forEach((g,d)=>{a[d].initFromGeometry(t.geometry,c),Zv(g.geometry,c)}),f.init(),$v(t,e,n,o,a,{useGroups:l}),f.complete();let p=this.getGroupRanges(t.geometry),x=Sx(p,t.material),v=this.getGroupRanges(e.geometry),y=Sx(v,e.material);v.forEach(g=>g.materialIndex+=x.length);let _=[...x,...y],S=[...p,...v].map((g,d)=>({...g,index:d}));return l?l&&u&&(S=Jv(S,_),S.sort((g,d)=>g.materialIndex-d.materialIndex)):S=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach((g,d)=>{let M=g.geometry;a[d].buildGeometry(M,S),t.matrixWorld.decompose(g.position,g.quaternion,g.scale),g.updateMatrix(),g.matrixWorld.copy(t.matrixWorld),l?(g.material=_,u&&Qv(M.groups),h&&(g.material=jv(M.groups,_))):g.material=_[0]}),r?i:i[0]}evaluateHierarchy(t,e=new ks){t.updateMatrixWorld(!0);let n=(r,o)=>{let a=r.children;for(let c=0,l=a.length;c<l;c++){let u=a[c];u.isOperationGroup?n(u,o):o(u)}},i=r=>{let o=r.children,a=!1;for(let l=0,u=o.length;l<u;l++){let h=o[l];a=i(h)||a}let c=r.isDirty();if(c&&r.markUpdated(),a&&!r.isOperationGroup){let l;return n(r,u=>{l?l=this.evaluate(l,u,u.operation):l=this.evaluate(r,u,u.operation)}),r._cachedGeometry=l.geometry,r._cachedMaterials=l.material,!0}else return a||c};return i(t),e.geometry=t._cachedGeometry,e.material=t._cachedMaterials,e}reset(){this.triangleSplitter.reset()}};var tM=["fetch","XMLHttpRequest","WebSocket","WebTransport","EventSource","importScripts","Worker","SharedWorker","BroadcastChannel","FontFace","fonts","indexedDB","caches","navigator","Request","Response"];function eM(s){for(let t=s;t!==null&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of tM)Object.prototype.hasOwnProperty.call(t,e)&&delete t[e];for(let t of tM)t in s&&Object.defineProperty(s,t,{value:void 0,configurable:!1,writable:!1})}function nM(s){return/\bimport\s*\(/.test(s)?"import() is not allowed in a model script.":null}var iM={"stone-blocks":{roughness:.62,metalness:0},"red-brick":{roughness:.58,metalness:0},"old-brick":{roughness:.6,metalness:0},cobblestone:{roughness:.62,metalness:0},rock:{roughness:.65,metalness:0},"mossy-rock":{roughness:.55,metalness:0},planks:{roughness:.45,metalness:0},wood:{roughness:.48,metalness:0},bark:{roughness:.62,metalness:0},"roof-tiles":{roughness:.68,metalness:0},concrete:{roughness:.52,metalness:0},marble:{roughness:.07,metalness:0},"floor-tiles":{roughness:.51,metalness:0},metal:{roughness:.41,metalness:1},"rusty-metal":{roughness:.5,metalness:.75},"metal-plate":{roughness:.56,metalness:.03},grass:{roughness:.54,metalness:0},sand:{roughness:.67,metalness:0},gravel:{roughness:.58,metalness:0},snow:{roughness:.5,metalness:0},ice:{roughness:.21,metalness:0}};var bx=["stone-blocks","red-brick","old-brick","cobblestone","rock","mossy-rock","planks","wood","bark","roof-tiles","concrete","marble","floor-tiles","metal","rusty-metal","metal-plate","grass","sand","gravel","snow","ice"];var _d=s=>s.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(""),rM=(s,t)=>`materials/T_${_d(s)}_${t==="color"?"D":"N"}.jpg`;function sM(s,t){let e=yd(s),[n,i]=[e.roughness,e.metalness].map(r=>Math.round(r*100)/100);return[`${_d(s)}_MAT`,...t.color.toUpperCase()!=="FFFFFF"?[`Tint${t.color.toUpperCase()}`]:[],...t.relief?[]:["Flat"],...t.roughness!==n?[`R${Math.round(t.roughness*100)}`]:[],...t.metalness!==i?[`M${Math.round(t.metalness*100)}`]:[]].join("_")}var vR=new Set(["rock","mossy-rock","concrete","marble","grass","sand","gravel","snow","ice"]),Tx=s=>vR.has(s)?2:1,yd=s=>iM[s];function uu(s){return typeof s=="string"&&bx.includes(s)}function oM(s,t,e=1){let n=s.index===null?s.clone():s.toNonIndexed(),i=n.getAttribute("position"),r=new Float32Array(i.count*2),o=new I,a=new I,c=new I,l=new I;for(let u=0;u<i.count;u+=3){o.fromBufferAttribute(i,u).applyMatrix4(t),a.fromBufferAttribute(i,u+1).applyMatrix4(t),c.fromBufferAttribute(i,u+2).applyMatrix4(t),l.subVectors(c,a).cross(new I().subVectors(o,a));let[h,f,p]=[Math.abs(l.x),Math.abs(l.y),Math.abs(l.z)];for(let[x,v]of[o,a,c].entries()){let[y,_]=h>=f&&h>=p?[v.z,v.y]:f>=p?[v.x,v.z]:[v.x,v.y];r[(u+x)*2]=y/e,r[(u+x)*2+1]=_/e}}return n.setAttribute("uv",new kt(r,2)),n}var Ex=s=>s+3&-4;function aM(s){let t=new Uint8Array(s),e=new DataView(s),n=e.getUint32(12,!0),i=JSON.parse(new TextDecoder().decode(t.subarray(20,20+n))),r=20+n,o=r<t.length?t.subarray(r+8,r+8+e.getUint32(r,!0)):new Uint8Array(0),a=new Map;for(let _ of i.materials??[]){let S=_.extras?.library;if(!uu(S))continue;let g=[["color",_.pbrMetallicRoughness?.baseColorTexture?.index],["normal",_.normalTexture?.index]];for(let[d,M]of g){let m=M===void 0?void 0:i.textures?.[M]?.source;m!==void 0&&a.set(m,{name:S,map:d})}}if(a.size===0)return{glb:s,used:[]};let c=new Set;for(let[_,{name:S,map:g}]of a){let d=i.images?.[_];typeof d?.bufferView=="number"&&c.add(d.bufferView);let M=rM(S,g);i.images!==void 0&&(i.images[_]={uri:M,name:M.replace(/^.*\/|\.jpg$/g,"")})}let l=[],u=0;for(let[_,S]of(i.bufferViews??[]).entries()){if(c.has(_)){S.byteOffset=0,S.byteLength=4;continue}let g=S.byteOffset??0;l.push(o.subarray(g,g+S.byteLength)),S.byteOffset=u,u=Ex(u+S.byteLength)}let h=new Uint8Array(Math.max(4,u)),f=0;for(let _ of l)h.set(_,f),f=Ex(f+_.length);i.buffers?.[0]!==void 0&&(i.buffers[0].byteLength=h.length);let p=new TextEncoder().encode(JSON.stringify(i)),x=new Uint8Array(Ex(p.length)).fill(32);x.set(p);let v=new Uint8Array(20+x.length+8+h.length),y=new DataView(v.buffer);return y.setUint32(0,1179937895,!0),y.setUint32(4,2,!0),y.setUint32(8,v.length,!0),y.setUint32(12,x.length,!0),y.setUint32(16,1313821514,!0),v.set(x,20),y.setUint32(20+x.length,h.length,!0),y.setUint32(24+x.length,5130562,!0),v.set(h,28+x.length),{glb:v.buffer,used:[...new Set([...a.values()].map(_=>_.name))]}}var hM=512,cM=s=>Number.isInteger(s)&&s>=1&&s<=hM&&(s&s-1)===0;function fM(s,t){if(!(cM(s)&&cM(t)))throw new Error(`addons.canvas(${String(s)}, ${String(t)}): each side must be a power of two up to ${hM} (1, 2, 4, 8, 16, 32, 64, 128, 256 or 512); pick those sizes and draw to fit them.`)}var vd=s=>Object.keys(s.attributes).sort().join(", "),lM=s=>`${s.itemSize}:${String(s.normalized)}:${s.array.constructor.name}`;function MR(s){let t=s[0];for(let e=1;e<s.length;e++){if(vd(s[e])!==vd(t))return`parts have different attributes (part 0: ${vd(t)}; part ${e}: ${vd(s[e])}); give every part the same attributes, or add the odd ones as separate meshes.`;let n=Object.keys(t.attributes).find(i=>lM(s[e].getAttribute(i))!==lM(t.getAttribute(i)));if(n!==void 0)return`attribute "${n}" has a different layout in part ${e}; add that part as a separate mesh.`}return"parts have different morph targets; add them as separate meshes."}function dM(s,t=!1){if(!Array.isArray(s)||s.length===0)throw new Error("addons.mergeGeometries: pass an array of at least one geometry.");let n=s.some(r=>r.index!==null)&&s.some(r=>r.index===null)?s.map(r=>r.index===null?r:r.toNonIndexed()):s,i=Qm(n,t);if(i===null)throw new Error(`addons.mergeGeometries: ${MR(n)}`);return i}function pM(s){let t=0;return s.traverse(e=>{if(!(e instanceof ce))return;let n=e.geometry;(n.getAttribute("color")!==void 0||e instanceof ei&&e.instanceColor!==null)&&(n.deleteAttribute("color"),e instanceof ei&&(e.instanceColor=null),t++)}),t===0?[]:[`Removed vertex colours from ${t} part${t===1?"":"s"}: Decentraland ignores them. Colour parts with materials instead.`]}function wx(s,t=!0){let e=s.clone();e.index===null&&e.setIndex([...Array(e.getAttribute("position").count).keys()]);let n=e.index;if(n===null)return e;for(let r=0;r+2<n.count;r+=3){let o=n.getX(r+1);n.setX(r+1,n.getX(r+2)),n.setX(r+2,o)}let i=e.getAttribute("normal");if(t&&i!==void 0)for(let r=0;r<i.count;r++)i.setXYZ(r,-i.getX(r),-i.getY(r),-i.getZ(r));return e}function mM(s,t){let e=new vt().makeScale(-1,1,1),n=l=>l.premultiply(e).multiply(e),i=(l,u)=>{if(l!==void 0)for(let h=0;h<l.count;h++)l[`set${u}`](h,-l[`get${u}`](h))},r=new Map,o=(l,u)=>{let h=`${l.uuid}:${u}`,f=r.get(h);if(f!==void 0)return f;let p=l.clone();for(let x of["position","normal"]){i(p.getAttribute(x),"X");for(let v of p.morphAttributes[x]??[])i(v,"X")}i(p.getAttribute("tangent"),"Y"),i(p.getAttribute("tangent"),"Z");for(let[x,v]of Object.entries(p.attributes))if(/^uv\d*$/.test(x))for(let y=0;y<v.count;y++)v.setX(y,1-v.getX(y));return f=u?wx(p,!1):p,r.set(h,f),f},a=new Set;s.traverse(l=>{if(l.position.x=-l.position.x,l.quaternion.set(l.quaternion.x,-l.quaternion.y,-l.quaternion.z,l.quaternion.w),l.matrixAutoUpdate||n(l.matrix),l instanceof ei){let u=new vt;for(let h=0;h<l.count;h++)l.getMatrixAt(h,u),l.setMatrixAt(h,n(u))}if(l instanceof mi&&(n(l.bindMatrix),n(l.bindMatrixInverse),!a.has(l.skeleton))){a.add(l.skeleton);for(let u of l.skeleton.boneInverses)n(u)}"geometry"in l&&l.geometry instanceof Vt&&(l.geometry=o(l.geometry,l instanceof ce))});let c=new Set;for(let l of new Set(t.flatMap(u=>u.tracks))){if(c.has(l.values))continue;c.add(l.values);let{propertyName:u,propertyIndex:h}=ee.parseTrackName(l.name),f=u==="position"?["x"]:u==="quaternion"?["y","z"]:[],p=u==="position"?3:4;l.values.forEach((x,v)=>{(h===void 0?f.includes("xyzw"[v%p]):f.includes(h))&&(l.values[v]=-x)})}s.updateMatrixWorld(!0)}var uM=s=>[s.material].flat().map(t=>t.side);function gM(s){let t=[],e=[];s.traverse(r=>{!(r instanceof ce)||r instanceof mi||/_collider/i.test(r.name)||(uM(r).every(o=>o===Ve)?t.push(r):uM(r).every(o=>o===qe)&&e.push(r))});let n=new Map,i=r=>{let o=n.get(r.uuid);return o===void 0&&n.set(r.uuid,o=wx(r)),o};for(let r of t){let o=r.clone(!1);o.name="",o.position.set(0,0,0),o.quaternion.identity(),o.scale.set(1,1,1),o.geometry=i(r.geometry),r.add(o)}for(let r of e)r.geometry=i(r.geometry);for(let r of[...t,...e])for(let o of[r.material].flat())o.side=rn;s.updateMatrixWorld(!0)}function Ax(s){let t=_d(s).slice(0,40)||"Model",e=new Set,n=0,i=()=>{let r;do r=`${t}_Part${String(++n).padStart(2,"0")}`;while(e.has(r));return e.add(r),r};return{name:r=>(r.name===""&&(r.name=i()),r.name),nameAll:r=>{r.traverse(o=>{o.name!==""&&e.add(o.name)}),r.traverse(o=>{o!==r&&o.name===""&&(o.name=i())})}}}var SR=(s,t)=>{for(let e=s;e!==null&&e!==t;e=e.parent)if(!e.visible)return!1;return t.visible};function bR(s,t){let e=new Set(t.flatMap(i=>i.tracks.map(r=>ee.parseTrackName(r.name).nodeName))),n=new Set;return s.traverse(i=>{!e.has(i.name)&&!e.has(i.uuid)||(i.traverse(r=>n.add(r)),i.traverseAncestors(r=>n.add(r)))}),n}function xM(s,t,e=5){s.updateMatrixWorld(!0);let n=bR(s,t),i=new Map;s.traverse(o=>{if(!(o instanceof ce)||o instanceof ei||o instanceof mi||o.name!==""||n.has(o)||!SR(o,s))return;let a=o.geometry;if(Array.isArray(o.material)||Object.keys(a.morphAttributes).length>0)return;let c=o.material,l=Object.entries(a.attributes).map(([h,f])=>`${h}:${f.itemSize}:${String(f.normalized)}:${f.array.constructor.name}`).sort().join(","),u=`${c.uuid}|${String(a.index!==null)}|${l}`;i.set(u,[...i.get(u)??[],o])});let r=s.matrixWorld.clone().invert();for(let o of i.values()){if(o.length<e)continue;let a=o.map(l=>{let u=r.clone().multiply(l.matrixWorld),h=l.geometry.clone().applyMatrix4(u);return u.determinant()<0?wx(h,!1):h}),c=Qm(a);if(c!==null){for(let l of o){let u=l.parent;for(let f of[...l.children])u?.attach(f);l.removeFromParent();let h=f=>f instanceof nn||f.constructor===re;for(;u!==null&&u!==s&&h(u)&&u.children.length===0&&u.name===""&&!n.has(u);){let f=u.parent;u.removeFromParent(),u=f}}s.add(new ce(c,o[0].material))}}s.updateMatrixWorld(!0)}var Rx=24,Cx=Ax("Model"),bM=s=>Cx.name(s);function TM(s,t){let e=[],n=[];for(let i=0;i<=Rx;i++)e.push(s*i/Rx),n.push(...t(i/Rx*Math.PI*2));return{times:e,values:n}}function _M(s,t,e,n){let i=s.quaternion.clone(),r=new I(t==="x"?1:0,t==="y"?1:0,t==="z"?1:0),{times:o,values:a}=TM(n,c=>i.clone().multiply(new Ce().setFromAxisAngle(r,e(c))).toArray());return new Gn(`${bM(s)}.quaternion`,o,a)}var yM=new Map;function vM(s,t){let e=yM.get(`${s}/${t}`);return e===void 0&&(e=new Eo(new OffscreenCanvas(1,1)),t==="color"&&(e.colorSpace=Ae),e.wrapS=e.wrapT=An,yM.set(`${s}/${t}`,e)),e}var MM=new Map;function TR(s,t={}){if(!uu(s))throw new Error(`addons.material takes one of ${bx.join(", ")}`);let e=Math.round((t.roughness??yd(s).roughness)*100)/100,n=Math.round((t.metalness??yd(s).metalness)*100)/100,i=t.relief!==!1,r={color:new yt(t.color??16777215).getHexString(),roughness:e,metalness:n,relief:i},o=sM(s,r),a=MM.get(o);if(a!==void 0)return a;let c=new xi({map:vM(s,"color"),...i?{normalMap:vM(s,"normal")}:{},color:t.color??16777215,roughness:e,metalness:n});return c.userData.library=s,c.name=o,MM.set(o,c),c}var ER=s=>[s.material].flat().map(t=>t.userData.library).find(uu),wR={material:TR,RoundedBoxGeometry:Cf,mergeGeometries:dM,mergeVertices:tg,Brush:ks,Evaluator:xd,ADDITION:0,SUBTRACTION:1,INTERSECTION:3,canvas:(s,t)=>(fM(s,t),new OffscreenCanvas(s,t)),spin:(s,t={})=>_M(s,t.axis??"y",e=>e,t.seconds??4),swing:(s,t={})=>_M(s,t.axis??"z",e=>Yi.degToRad(t.degrees??20)*Math.sin(e),t.seconds??1),bob:(s,t={})=>{let e=s.position.clone(),{times:n,values:i}=TM(t.seconds??2,r=>[e.x,e.y+(t.height??.1)*Math.sin(r),e.z]);return new Wn(`${bM(s)}.position`,n,i)}},Md=null,Ra=(s,t=[])=>Md?.postMessage(s,t),SM=1e6;function AR(){let s=0,t=Vt.prototype.setAttribute;Vt.prototype.setAttribute=function(e,n){if(e==="position"&&(s+=n.count,s>SM))throw new Error(`the script made over ${SM.toLocaleString("en")} vertices; build less detail`);return t.call(this,e,n)}}async function RR(s,t){eM(self);let e=nM(s);if(e!==null)throw new Error(e);AR(),Cx=Ax(t);let n=new nn,i=[];new Function("THREE","addons","root","clips",s)(Vl,wR,n,i);let r=i.filter(h=>h instanceof ni);n.updateMatrixWorld(!0),mM(n,r);let o=pM(n);gM(n);let a=new Map;n.traverse(h=>{if(!(h instanceof ce))return;let f=ER(h);if(f===void 0)return;let p=h.matrixWorld.clone().setPosition(0,0,0),x=`${h.geometry.uuid}|${Tx(f)}|${p.elements.map(y=>y.toFixed(4)).join(",")}`,v=a.get(x);v===void 0&&(v=tg(oM(h.geometry,p,Tx(f))),v.getAttribute("normal")!==void 0&&v.computeTangents(),a.set(x,v)),h.geometry=v}),xM(n,r),Cx.nameAll(n);let c=await new Us().parseAsync(n,{binary:!0,animations:r});if(!(c instanceof ArrayBuffer))throw new Error("the exporter returned no binary");let{glb:l,used:u}=aM(c);Ra({kind:"built",glb:l,clips:r.map(h=>h.name),library:u,warnings:o},[l])}function CR(s,t){let e=new Uint8Array(s),n=new DataView(s),i=e.length>=20&&n.getUint32(0,!0)===1179937895?new TextDecoder().decode(e.subarray(20,20+n.getUint32(12,!0))):new TextDecoder().decode(e),r=JSON.parse(i),o=a=>{let c=typeof r=="object"&&r!==null?Reflect.get(r,a):void 0;return Array.isArray(c)?c.map(l=>typeof l=="object"&&l!==null?Reflect.get(l,"uri"):void 0):[]};return[...o("buffers"),...o("images")].some(a=>typeof a=="string"&&!a.startsWith("data:")&&t[a]===void 0)}var dn=null,Aa=null;function EM(s){if(Aa===null)return;let t=Aa.clips.find(e=>e.name===s);t!==void 0&&(Aa.mixer.stopAllAction(),Aa.mixer.clipAction(t).play())}function IR(){let s=new bs,t=()=>{Aa?.mixer.update(s.getDelta()),hu(),setTimeout(t,16)};t()}function hu(){if(dn===null)return;let{camera:s,target:t,yaw:e,pitch:n,distance:i}=dn;s.position.set(t.x+i*Math.cos(n)*Math.sin(e),t.y+i*Math.sin(n),t.z+i*Math.cos(n)*Math.cos(e)),s.lookAt(t),dn.renderer.render(dn.scene,s)}function PR(s){let t=s.files??{};if(CR(s.bytes,t))throw new Error("the model refers to files outside it");let e=new Map(Object.entries(t).map(([c,l])=>[c,URL.createObjectURL(new Blob([l]))])),n=new Pr;n.setURLModifier(c=>e.get(c)??c);let i=new Hl({canvas:s.canvas,antialias:!0,alpha:!0});i.setPixelRatio(s.dpr),i.setSize(s.width,s.height,!1);let r=new Fi;r.add(new vs(16777215,4478310,2.2));let o=new lr(16777215,2);o.position.set(3,6,4),r.add(o);let a=new Re(40,s.width/s.height,.01,2e3);new Af(n).parse(s.bytes,"",c=>{let l=[];c.scene.traverse(f=>{/_collider$/i.test(f.name)&&l.push(f)});for(let f of l)f.removeFromParent();r.add(c.scene);let u=new ne().setFromObject(c.scene),h=Math.max(u.getSize(new I).length()/2,.1);dn={renderer:i,scene:r,camera:a,target:u.getCenter(new I),yaw:Math.PI/4,pitch:.4,distance:h*2.6},c.animations.length>0?(Aa={mixer:new Xo(c.scene),clips:c.animations},EM(c.animations[0].name),IR()):hu(),Ra({kind:"shown"})},c=>Ra({kind:"failed",error:c.message}))}function LR(s){let t=s.data;try{if(t.kind!=="build"&&t.kind!=="view"&&t.kind!=="clip"&&dn===null)return;if(t.kind==="build"&&Sd!=="build"||t.kind==="view"&&Sd!=="view")throw new Error(`a ${String(Sd)} worker does not ${t.kind}`);t.kind==="build"?RR(t.code,t.name).catch(e=>Ra({kind:"failed",error:e instanceof Error?e.message:String(e)})):t.kind==="view"?PR(t):t.kind==="clip"?EM(t.name):dn!==null&&t.kind==="orbit"?(dn.yaw-=t.dx*.01,dn.pitch=Math.max(-1.4,Math.min(1.4,dn.pitch+t.dy*.01)),hu()):dn!==null&&t.kind==="zoom"?(dn.distance*=Math.exp(t.delta*.001),hu()):dn!==null&&t.kind==="resize"&&(dn.renderer.setSize(t.width,t.height,!1),dn.camera.aspect=t.width/t.height,dn.camera.updateProjectionMatrix(),hu())}catch(e){Ra({kind:"failed",error:e instanceof Error?e.message:String(e)})}}var Sd=null;self.onmessage=s=>{Md!==null||s.ports[0]===void 0||s.data!=="build"&&s.data!=="view"||(Sd=s.data,Md=s.ports[0],Md.onmessage=LR,Ra({kind:"ready"}))};})();
|
|
3832
|
+
}`,Dm=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){let n=new Ao(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new Cn({vertexShader:$A,fragmentShader:KA,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new ce(new ys(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Um=class extends kn{constructor(t,e){super();let n=this,i=null,r=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,f=null,p=null,x=null,v=typeof XRWebGLBinding<"u",y=new Dm,_={},S=e.getContextAttributes(),g=null,d=null,M=[],m=[],R=new nt,E=null,T=new Re;T.viewport=new Qt;let b=new Re;b.viewport=new Qt;let w=[T,b],A=new qc,C=null,D=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getGripSpace()},this.getHand=function(K){let Q=M[K];return Q===void 0&&(Q=new fs,M[K]=Q),Q.getHandSpace()};function F(K){let Q=m.indexOf(K.inputSource);if(Q===-1)return;let ct=M[Q];ct!==void 0&&(ct.update(K.inputSource,K.frame,l||o),ct.dispatchEvent({type:K.type,data:K.inputSource}))}function O(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",O),i.removeEventListener("inputsourceschange",H);for(let K=0;K<M.length;K++){let Q=m[K];Q!==null&&(m[K]=null,M[K].disconnect(Q))}C=null,D=null,y.reset();for(let K in _)delete _[K];t.setRenderTarget(g),p=null,f=null,h=null,i=null,d=null,Mt.stop(),n.isPresenting=!1,t.setPixelRatio(E),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){a=K,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return f!==null?f:p},this.getBinding=function(){return h===null&&v&&(h=new XRWebGLBinding(i,e)),h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(g=t.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",O),i.addEventListener("inputsourceschange",H),S.xrCompatible!==!0&&await e.makeXRCompatible(),E=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let ct=null,lt=null,ut=null;S.depth&&(ut=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,ct=S.stencil?Rs:rs,lt=S.stencil?As:qi);let Ct={colorFormat:e.RGBA8,depthFormat:ut,scaleFactor:r};h=this.getBinding(),f=h.createProjectionLayer(Ct),i.updateRenderState({layers:[f]}),t.setPixelRatio(1),t.setSize(f.textureWidth,f.textureHeight,!1),d=new Hn(f.textureWidth,f.textureHeight,{format:Qe,type:ri,depthTexture:new wo(f.textureWidth,f.textureHeight,lt,void 0,void 0,void 0,void 0,void 0,void 0,ct),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let ct={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(i,e,ct),i.updateRenderState({baseLayer:p}),t.setPixelRatio(1),t.setSize(p.framebufferWidth,p.framebufferHeight,!1),d=new Hn(p.framebufferWidth,p.framebufferHeight,{format:Qe,type:ri,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}d.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await i.requestReferenceSpace(a),Mt.setContext(i),Mt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function H(K){for(let Q=0;Q<K.removed.length;Q++){let ct=K.removed[Q],lt=m.indexOf(ct);lt>=0&&(m[lt]=null,M[lt].disconnect(ct))}for(let Q=0;Q<K.added.length;Q++){let ct=K.added[Q],lt=m.indexOf(ct);if(lt===-1){for(let Ct=0;Ct<M.length;Ct++)if(Ct>=m.length){m.push(ct),lt=Ct;break}else if(m[Ct]===null){m[Ct]=ct,lt=Ct;break}if(lt===-1)break}let ut=M[lt];ut&&ut.connect(ct)}}let B=new I,$=new I;function at(K,Q,ct){B.setFromMatrixPosition(Q.matrixWorld),$.setFromMatrixPosition(ct.matrixWorld);let lt=B.distanceTo($),ut=Q.projectionMatrix.elements,Ct=ct.projectionMatrix.elements,Kt=ut[14]/(ut[10]-1),U=ut[14]/(ut[10]+1),tt=(ut[9]+1)/ut[5],Z=(ut[9]-1)/ut[5],Y=(ut[8]-1)/ut[0],q=(Ct[8]+1)/Ct[0],mt=Kt*Y,it=Kt*q,st=lt/(-Y+q),Pt=st*-Y;if(Q.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Pt),K.translateZ(st),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),ut[10]===-1)K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse);else{let It=Kt+st,N=U+st,P=mt-Pt,k=it+(lt-Pt),W=tt*U/N*It,et=Z*U/N*It;K.projectionMatrix.makePerspective(P,k,W,et,It,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function rt(K,Q){Q===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(Q.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let Q=K.near,ct=K.far;y.texture!==null&&(y.depthNear>0&&(Q=y.depthNear),y.depthFar>0&&(ct=y.depthFar)),A.near=b.near=T.near=Q,A.far=b.far=T.far=ct,(C!==A.near||D!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,D=A.far),A.layers.mask=K.layers.mask|6,T.layers.mask=A.layers.mask&3,b.layers.mask=A.layers.mask&5;let lt=K.parent,ut=A.cameras;rt(A,lt);for(let Ct=0;Ct<ut.length;Ct++)rt(ut[Ct],lt);ut.length===2?at(A,T,b):A.projectionMatrix.copy(T.projectionMatrix),ht(K,A,lt)};function ht(K,Q,ct){ct===null?K.matrix.copy(Q.matrixWorld):(K.matrix.copy(ct.matrixWorld),K.matrix.invert(),K.matrix.multiply(Q.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(Q.projectionMatrix),K.projectionMatrixInverse.copy(Q.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=os*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&p===null))return c},this.setFoveation=function(K){c=K,f!==null&&(f.fixedFoveation=K),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=K)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(A)},this.getCameraTexture=function(K){return _[K]};let bt=null;function Et(K,Q){if(u=Q.getViewerPose(l||o),x=Q,u!==null){let ct=u.views;p!==null&&(t.setRenderTargetFramebuffer(d,p.framebuffer),t.setRenderTarget(d));let lt=!1;ct.length!==A.cameras.length&&(A.cameras.length=0,lt=!0);for(let U=0;U<ct.length;U++){let tt=ct[U],Z=null;if(p!==null)Z=p.getViewport(tt);else{let q=h.getViewSubImage(f,tt);Z=q.viewport,U===0&&(t.setRenderTargetTextures(d,q.colorTexture,q.depthStencilTexture),t.setRenderTarget(d))}let Y=w[U];Y===void 0&&(Y=new Re,Y.layers.enable(U),Y.viewport=new Qt,w[U]=Y),Y.matrix.fromArray(tt.transform.matrix),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.projectionMatrix.fromArray(tt.projectionMatrix),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert(),Y.viewport.set(Z.x,Z.y,Z.width,Z.height),U===0&&(A.matrix.copy(Y.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),lt===!0&&A.cameras.push(Y)}let ut=i.enabledFeatures;if(ut&&ut.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){h=n.getBinding();let U=h.getDepthInformation(ct[0]);U&&U.isValid&&U.texture&&y.init(U,i.renderState)}if(ut&&ut.includes("camera-access")&&v){t.state.unbindTexture(),h=n.getBinding();for(let U=0;U<ct.length;U++){let tt=ct[U].camera;if(tt){let Z=_[tt];Z||(Z=new Ao,_[tt]=Z);let Y=h.getCameraImage(tt);Z.sourceTexture=Y}}}}for(let ct=0;ct<M.length;ct++){let lt=m[ct],ut=M[ct];lt!==null&&ut!==void 0&&ut.update(lt,Q,l||o)}bt&&bt(K,Q),Q.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Q}),x=null}let Mt=new sy;Mt.setAnimationLoop(Et),this.setAnimationLoop=function(K){bt=K},this.dispose=function(){}}},Ls=new Rn,ZA=new vt;function JA(s,t){function e(y,_){y.matrixAutoUpdate===!0&&y.updateMatrix(),_.value.copy(y.matrix)}function n(y,_){_.color.getRGB(y.fogColor.value,mm(s)),_.isFog?(y.fogNear.value=_.near,y.fogFar.value=_.far):_.isFogExp2&&(y.fogDensity.value=_.density)}function i(y,_,S,g,d){_.isMeshBasicMaterial||_.isMeshLambertMaterial?r(y,_):_.isMeshToonMaterial?(r(y,_),h(y,_)):_.isMeshPhongMaterial?(r(y,_),u(y,_)):_.isMeshStandardMaterial?(r(y,_),f(y,_),_.isMeshPhysicalMaterial&&p(y,_,d)):_.isMeshMatcapMaterial?(r(y,_),x(y,_)):_.isMeshDepthMaterial?r(y,_):_.isMeshDistanceMaterial?(r(y,_),v(y,_)):_.isMeshNormalMaterial?r(y,_):_.isLineBasicMaterial?(o(y,_),_.isLineDashedMaterial&&a(y,_)):_.isPointsMaterial?c(y,_,S,g):_.isSpriteMaterial?l(y,_):_.isShadowMaterial?(y.color.value.copy(_.color),y.opacity.value=_.opacity):_.isShaderMaterial&&(_.uniformsNeedUpdate=!1)}function r(y,_){y.opacity.value=_.opacity,_.color&&y.diffuse.value.copy(_.color),_.emissive&&y.emissive.value.copy(_.emissive).multiplyScalar(_.emissiveIntensity),_.map&&(y.map.value=_.map,e(_.map,y.mapTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.bumpMap&&(y.bumpMap.value=_.bumpMap,e(_.bumpMap,y.bumpMapTransform),y.bumpScale.value=_.bumpScale,_.side===qe&&(y.bumpScale.value*=-1)),_.normalMap&&(y.normalMap.value=_.normalMap,e(_.normalMap,y.normalMapTransform),y.normalScale.value.copy(_.normalScale),_.side===qe&&y.normalScale.value.negate()),_.displacementMap&&(y.displacementMap.value=_.displacementMap,e(_.displacementMap,y.displacementMapTransform),y.displacementScale.value=_.displacementScale,y.displacementBias.value=_.displacementBias),_.emissiveMap&&(y.emissiveMap.value=_.emissiveMap,e(_.emissiveMap,y.emissiveMapTransform)),_.specularMap&&(y.specularMap.value=_.specularMap,e(_.specularMap,y.specularMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest);let S=t.get(_),g=S.envMap,d=S.envMapRotation;g&&(y.envMap.value=g,Ls.copy(d),Ls.x*=-1,Ls.y*=-1,Ls.z*=-1,g.isCubeTexture&&g.isRenderTargetTexture===!1&&(Ls.y*=-1,Ls.z*=-1),y.envMapRotation.value.setFromMatrix4(ZA.makeRotationFromEuler(Ls)),y.flipEnvMap.value=g.isCubeTexture&&g.isRenderTargetTexture===!1?-1:1,y.reflectivity.value=_.reflectivity,y.ior.value=_.ior,y.refractionRatio.value=_.refractionRatio),_.lightMap&&(y.lightMap.value=_.lightMap,y.lightMapIntensity.value=_.lightMapIntensity,e(_.lightMap,y.lightMapTransform)),_.aoMap&&(y.aoMap.value=_.aoMap,y.aoMapIntensity.value=_.aoMapIntensity,e(_.aoMap,y.aoMapTransform))}function o(y,_){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,_.map&&(y.map.value=_.map,e(_.map,y.mapTransform))}function a(y,_){y.dashSize.value=_.dashSize,y.totalSize.value=_.dashSize+_.gapSize,y.scale.value=_.scale}function c(y,_,S,g){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,y.size.value=_.size*S,y.scale.value=g*.5,_.map&&(y.map.value=_.map,e(_.map,y.uvTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest)}function l(y,_){y.diffuse.value.copy(_.color),y.opacity.value=_.opacity,y.rotation.value=_.rotation,_.map&&(y.map.value=_.map,e(_.map,y.mapTransform)),_.alphaMap&&(y.alphaMap.value=_.alphaMap,e(_.alphaMap,y.alphaMapTransform)),_.alphaTest>0&&(y.alphaTest.value=_.alphaTest)}function u(y,_){y.specular.value.copy(_.specular),y.shininess.value=Math.max(_.shininess,1e-4)}function h(y,_){_.gradientMap&&(y.gradientMap.value=_.gradientMap)}function f(y,_){y.metalness.value=_.metalness,_.metalnessMap&&(y.metalnessMap.value=_.metalnessMap,e(_.metalnessMap,y.metalnessMapTransform)),y.roughness.value=_.roughness,_.roughnessMap&&(y.roughnessMap.value=_.roughnessMap,e(_.roughnessMap,y.roughnessMapTransform)),_.envMap&&(y.envMapIntensity.value=_.envMapIntensity)}function p(y,_,S){y.ior.value=_.ior,_.sheen>0&&(y.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),y.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(y.sheenColorMap.value=_.sheenColorMap,e(_.sheenColorMap,y.sheenColorMapTransform)),_.sheenRoughnessMap&&(y.sheenRoughnessMap.value=_.sheenRoughnessMap,e(_.sheenRoughnessMap,y.sheenRoughnessMapTransform))),_.clearcoat>0&&(y.clearcoat.value=_.clearcoat,y.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(y.clearcoatMap.value=_.clearcoatMap,e(_.clearcoatMap,y.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(y.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,e(_.clearcoatRoughnessMap,y.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(y.clearcoatNormalMap.value=_.clearcoatNormalMap,e(_.clearcoatNormalMap,y.clearcoatNormalMapTransform),y.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===qe&&y.clearcoatNormalScale.value.negate())),_.dispersion>0&&(y.dispersion.value=_.dispersion),_.iridescence>0&&(y.iridescence.value=_.iridescence,y.iridescenceIOR.value=_.iridescenceIOR,y.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],y.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(y.iridescenceMap.value=_.iridescenceMap,e(_.iridescenceMap,y.iridescenceMapTransform)),_.iridescenceThicknessMap&&(y.iridescenceThicknessMap.value=_.iridescenceThicknessMap,e(_.iridescenceThicknessMap,y.iridescenceThicknessMapTransform))),_.transmission>0&&(y.transmission.value=_.transmission,y.transmissionSamplerMap.value=S.texture,y.transmissionSamplerSize.value.set(S.width,S.height),_.transmissionMap&&(y.transmissionMap.value=_.transmissionMap,e(_.transmissionMap,y.transmissionMapTransform)),y.thickness.value=_.thickness,_.thicknessMap&&(y.thicknessMap.value=_.thicknessMap,e(_.thicknessMap,y.thicknessMapTransform)),y.attenuationDistance.value=_.attenuationDistance,y.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(y.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(y.anisotropyMap.value=_.anisotropyMap,e(_.anisotropyMap,y.anisotropyMapTransform))),y.specularIntensity.value=_.specularIntensity,y.specularColor.value.copy(_.specularColor),_.specularColorMap&&(y.specularColorMap.value=_.specularColorMap,e(_.specularColorMap,y.specularColorMapTransform)),_.specularIntensityMap&&(y.specularIntensityMap.value=_.specularIntensityMap,e(_.specularIntensityMap,y.specularIntensityMapTransform))}function x(y,_){_.matcap&&(y.matcap.value=_.matcap)}function v(y,_){let S=t.get(_).light;y.referencePosition.value.setFromMatrixPosition(S.matrixWorld),y.nearDistance.value=S.shadow.camera.near,y.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function jA(s,t,e,n){let i={},r={},o=[],a=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,g){let d=g.program;n.uniformBlockBinding(S,d)}function l(S,g){let d=i[S.id];d===void 0&&(x(S),d=u(S),i[S.id]=d,S.addEventListener("dispose",y));let M=g.program;n.updateUBOMapping(S,M);let m=t.render.frame;r[S.id]!==m&&(f(S),r[S.id]=m)}function u(S){let g=h();S.__bindingPointIndex=g;let d=s.createBuffer(),M=S.__size,m=S.usage;return s.bindBuffer(s.UNIFORM_BUFFER,d),s.bufferData(s.UNIFORM_BUFFER,M,m),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,g,d),d}function h(){for(let S=0;S<a;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function f(S){let g=i[S.id],d=S.uniforms,M=S.__cache;s.bindBuffer(s.UNIFORM_BUFFER,g);for(let m=0,R=d.length;m<R;m++){let E=Array.isArray(d[m])?d[m]:[d[m]];for(let T=0,b=E.length;T<b;T++){let w=E[T];if(p(w,m,T,M)===!0){let A=w.__offset,C=Array.isArray(w.value)?w.value:[w.value],D=0;for(let F=0;F<C.length;F++){let O=C[F],H=v(O);typeof O=="number"||typeof O=="boolean"?(w.__data[0]=O,s.bufferSubData(s.UNIFORM_BUFFER,A+D,w.__data)):O.isMatrix3?(w.__data[0]=O.elements[0],w.__data[1]=O.elements[1],w.__data[2]=O.elements[2],w.__data[3]=0,w.__data[4]=O.elements[3],w.__data[5]=O.elements[4],w.__data[6]=O.elements[5],w.__data[7]=0,w.__data[8]=O.elements[6],w.__data[9]=O.elements[7],w.__data[10]=O.elements[8],w.__data[11]=0):(O.toArray(w.__data,D),D+=H.storage/Float32Array.BYTES_PER_ELEMENT)}s.bufferSubData(s.UNIFORM_BUFFER,A,w.__data)}}}s.bindBuffer(s.UNIFORM_BUFFER,null)}function p(S,g,d,M){let m=S.value,R=g+"_"+d;if(M[R]===void 0)return typeof m=="number"||typeof m=="boolean"?M[R]=m:M[R]=m.clone(),!0;{let E=M[R];if(typeof m=="number"||typeof m=="boolean"){if(E!==m)return M[R]=m,!0}else if(E.equals(m)===!1)return E.copy(m),!0}return!1}function x(S){let g=S.uniforms,d=0,M=16;for(let R=0,E=g.length;R<E;R++){let T=Array.isArray(g[R])?g[R]:[g[R]];for(let b=0,w=T.length;b<w;b++){let A=T[b],C=Array.isArray(A.value)?A.value:[A.value];for(let D=0,F=C.length;D<F;D++){let O=C[D],H=v(O),B=d%M,$=B%H.boundary,at=B+$;d+=$,at!==0&&M-at<H.storage&&(d+=M-at),A.__data=new Float32Array(H.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=d,d+=H.storage}}}let m=d%M;return m>0&&(d+=M-m),S.__size=d,S.__cache={},this}function v(S){let g={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(g.boundary=4,g.storage=4):S.isVector2?(g.boundary=8,g.storage=8):S.isVector3||S.isColor?(g.boundary=16,g.storage=12):S.isVector4?(g.boundary=16,g.storage=16):S.isMatrix3?(g.boundary=48,g.storage=48):S.isMatrix4?(g.boundary=64,g.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),g}function y(S){let g=S.target;g.removeEventListener("dispose",y);let d=o.indexOf(g.__bindingPointIndex);o.splice(d,1),s.deleteBuffer(i[g.id]),delete i[g.id],delete r[g.id]}function _(){for(let S in i)s.deleteBuffer(i[S]);o=[],i={},r={}}return{bind:c,update:l,dispose:_}}var Hl=class{constructor(t={}){let{canvas:e=pm(),context:n=null,depth:i=!0,stencil:r=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;let x=new Uint32Array(4),v=new Int32Array(4),y=null,_=null,S=[],g=[];this.domElement=e,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.toneMapping=Gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let d=this,M=!1;this._outputColorSpace=Ae;let m=0,R=0,E=null,T=-1,b=null,w=new Qt,A=new Qt,C=null,D=new yt(0),F=0,O=e.width,H=e.height,B=1,$=null,at=null,rt=new Qt(0,0,O,H),ht=new Qt(0,0,O,H),bt=!1,Et=new or,Mt=!1,K=!1,Q=new vt,ct=new I,lt=new Qt,ut={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Ct=!1;function Kt(){return E===null?B:1}let U=n;function tt(L,V){return e.getContext(L,V)}try{let L={alpha:!0,depth:i,stencil:r,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Hi}`),e.addEventListener("webglcontextlost",St,!1),e.addEventListener("webglcontextrestored",Ut,!1),e.addEventListener("webglcontextcreationerror",dt,!1),U===null){let V="webgl2";if(U=tt(V,L),U===null)throw tt(V)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(L){throw console.error("THREE.WebGLRenderer: "+L.message),L}let Z,Y,q,mt,it,st,Pt,It,N,P,k,W,et,X,_t,xt,Ft,Dt,ft,Rt,qt,zt,wt,jt;function z(){Z=new xw(U),Z.init(),zt=new uy(U,Z),Y=new uw(U,Z,t,zt),q=new qA(U,Z),Y.reversedDepthBuffer&&f&&q.buffers.depth.setReversed(!0),mt=new vw(U),it=new NA,st=new YA(U,Z,q,it,Y,zt,mt),Pt=new fw(d),It=new gw(d),N=new wb(U),wt=new cw(U,N),P=new _w(U,N,mt,wt),k=new Sw(U,P,N,mt),ft=new Mw(U,Y,st),xt=new hw(it),W=new LA(d,Pt,It,Z,Y,wt,xt),et=new JA(d,it),X=new UA,_t=new HA(Z),Dt=new aw(d,Pt,It,q,k,p,c),Ft=new WA(d,k,Y),jt=new jA(U,mt,Y,q),Rt=new lw(U,Z,mt),qt=new yw(U,Z,mt),mt.programs=W.programs,d.capabilities=Y,d.extensions=Z,d.properties=it,d.renderLists=X,d.shadowMap=Ft,d.state=q,d.info=mt}z();let gt=new Um(d,U);this.xr=gt,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let L=Z.get("WEBGL_lose_context");L&&L.loseContext()},this.forceContextRestore=function(){let L=Z.get("WEBGL_lose_context");L&&L.restoreContext()},this.getPixelRatio=function(){return B},this.setPixelRatio=function(L){L!==void 0&&(B=L,this.setSize(O,H,!1))},this.getSize=function(L){return L.set(O,H)},this.setSize=function(L,V,J=!0){if(gt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}O=L,H=V,e.width=Math.floor(L*B),e.height=Math.floor(V*B),J===!0&&(e.style.width=L+"px",e.style.height=V+"px"),this.setViewport(0,0,L,V)},this.getDrawingBufferSize=function(L){return L.set(O*B,H*B).floor()},this.setDrawingBufferSize=function(L,V,J){O=L,H=V,B=J,e.width=Math.floor(L*J),e.height=Math.floor(V*J),this.setViewport(0,0,L,V)},this.getCurrentViewport=function(L){return L.copy(w)},this.getViewport=function(L){return L.copy(rt)},this.setViewport=function(L,V,J,j){L.isVector4?rt.set(L.x,L.y,L.z,L.w):rt.set(L,V,J,j),q.viewport(w.copy(rt).multiplyScalar(B).round())},this.getScissor=function(L){return L.copy(ht)},this.setScissor=function(L,V,J,j){L.isVector4?ht.set(L.x,L.y,L.z,L.w):ht.set(L,V,J,j),q.scissor(A.copy(ht).multiplyScalar(B).round())},this.getScissorTest=function(){return bt},this.setScissorTest=function(L){q.setScissorTest(bt=L)},this.setOpaqueSort=function(L){$=L},this.setTransparentSort=function(L){at=L},this.getClearColor=function(L){return L.copy(Dt.getClearColor())},this.setClearColor=function(){Dt.setClearColor(...arguments)},this.getClearAlpha=function(){return Dt.getClearAlpha()},this.setClearAlpha=function(){Dt.setClearAlpha(...arguments)},this.clear=function(L=!0,V=!0,J=!0){let j=0;if(L){let G=!1;if(E!==null){let pt=E.texture.format;G=pt===ll||pt===cl||pt===Ko}if(G){let pt=E.texture.type,At=pt===ri||pt===qi||pt===Es||pt===As||pt===sl||pt===ol,Ot=Dt.getClearColor(),Nt=Dt.getClearAlpha(),Wt=Ot.r,Yt=Ot.g,Ht=Ot.b;At?(x[0]=Wt,x[1]=Yt,x[2]=Ht,x[3]=Nt,U.clearBufferuiv(U.COLOR,0,x)):(v[0]=Wt,v[1]=Yt,v[2]=Ht,v[3]=Nt,U.clearBufferiv(U.COLOR,0,v))}else j|=U.COLOR_BUFFER_BIT}V&&(j|=U.DEPTH_BUFFER_BIT),J&&(j|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U.clear(j)},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(){e.removeEventListener("webglcontextlost",St,!1),e.removeEventListener("webglcontextrestored",Ut,!1),e.removeEventListener("webglcontextcreationerror",dt,!1),Dt.dispose(),X.dispose(),_t.dispose(),it.dispose(),Pt.dispose(),It.dispose(),k.dispose(),wt.dispose(),jt.dispose(),W.dispose(),gt.dispose(),gt.removeEventListener("sessionstart",Ri),gt.removeEventListener("sessionend",Ix),Vr.stop()};function St(L){L.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),M=!0}function Ut(){console.log("THREE.WebGLRenderer: Context Restored."),M=!1;let L=mt.autoReset,V=Ft.enabled,J=Ft.autoUpdate,j=Ft.needsUpdate,G=Ft.type;z(),mt.autoReset=L,Ft.enabled=V,Ft.autoUpdate=J,Ft.needsUpdate=j,Ft.type=G}function dt(L){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",L.statusMessage)}function ot(L){let V=L.target;V.removeEventListener("dispose",ot),Bt(V)}function Bt(L){Zt(L),it.remove(L)}function Zt(L){let V=it.get(L).programs;V!==void 0&&(V.forEach(function(J){W.releaseProgram(J)}),L.isShaderMaterial&&W.releaseShaderCache(L))}this.renderBufferDirect=function(L,V,J,j,G,pt){V===null&&(V=ut);let At=G.isMesh&&G.matrixWorld.determinant()<0,Ot=wM(L,V,J,j,G);q.setMaterial(j,At);let Nt=J.index,Wt=1;if(j.wireframe===!0){if(Nt=P.getWireframeAttribute(J),Nt===void 0)return;Wt=2}let Yt=J.drawRange,Ht=J.attributes.position,ae=Yt.start*Wt,ye=(Yt.start+Yt.count)*Wt;pt!==null&&(ae=Math.max(ae,pt.start*Wt),ye=Math.min(ye,(pt.start+pt.count)*Wt)),Nt!==null?(ae=Math.max(ae,0),ye=Math.min(ye,Nt.count)):Ht!=null&&(ae=Math.max(ae,0),ye=Math.min(ye,Ht.count));let Fe=ye-ae;if(Fe<0||Fe===1/0)return;wt.setup(G,j,Ot,J,Nt);let we,Me=Rt;if(Nt!==null&&(we=N.get(Nt),Me=qt,Me.setIndex(we)),G.isMesh)j.wireframe===!0?(q.setLineWidth(j.wireframeLinewidth*Kt()),Me.setMode(U.LINES)):Me.setMode(U.TRIANGLES);else if(G.isLine){let Gt=j.linewidth;Gt===void 0&&(Gt=1),q.setLineWidth(Gt*Kt()),G.isLineSegments?Me.setMode(U.LINES):G.isLineLoop?Me.setMode(U.LINE_LOOP):Me.setMode(U.LINE_STRIP)}else G.isPoints?Me.setMode(U.POINTS):G.isSprite&&Me.setMode(U.TRIANGLES);if(G.isBatchedMesh)if(G._multiDrawInstances!==null)vo("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Me.renderMultiDrawInstances(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount,G._multiDrawInstances);else if(Z.get("WEBGL_multi_draw"))Me.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{let Gt=G._multiDrawStarts,Pe=G._multiDrawCounts,he=G._multiDrawCount,Nn=Nt?N.get(Nt).bytesPerElement:1,qs=it.get(j).currentProgram.getUniforms();for(let Dn=0;Dn<he;Dn++)qs.setValue(U,"_gl_DrawID",Dn),Me.render(Gt[Dn]/Nn,Pe[Dn])}else if(G.isInstancedMesh)Me.renderInstances(ae,Fe,G.count);else if(J.isInstancedBufferGeometry){let Gt=J._maxInstanceCount!==void 0?J._maxInstanceCount:1/0,Pe=Math.min(J.instanceCount,Gt);Me.renderInstances(ae,Fe,Pe)}else Me.render(ae,Fe)};function Te(L,V,J){L.transparent===!0&&L.side===Ve&&L.forceSinglePass===!1?(L.side=qe,L.needsUpdate=!0,du(L,V,J),L.side=rn,L.needsUpdate=!0,du(L,V,J),L.side=Ve):du(L,V,J)}this.compile=function(L,V,J=null){J===null&&(J=L),_=_t.get(J),_.init(V),g.push(_),J.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(_.pushLight(G),G.castShadow&&_.pushShadow(G))}),L!==J&&L.traverseVisible(function(G){G.isLight&&G.layers.test(V.layers)&&(_.pushLight(G),G.castShadow&&_.pushShadow(G))}),_.setupLights();let j=new Set;return L.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;let pt=G.material;if(pt)if(Array.isArray(pt))for(let At=0;At<pt.length;At++){let Ot=pt[At];Te(Ot,J,G),j.add(Ot)}else Te(pt,J,G),j.add(pt)}),_=g.pop(),j},this.compileAsync=function(L,V,J=null){let j=this.compile(L,V,J);return new Promise(G=>{function pt(){if(j.forEach(function(At){it.get(At).currentProgram.isReady()&&j.delete(At)}),j.size===0){G(L);return}setTimeout(pt,10)}Z.get("KHR_parallel_shader_compile")!==null?pt():setTimeout(pt,10)})};let pe=null;function Zi(L){pe&&pe(L)}function Ri(){Vr.stop()}function Ix(){Vr.start()}let Vr=new sy;Vr.setAnimationLoop(Zi),typeof self<"u"&&Vr.setContext(self),this.setAnimationLoop=function(L){pe=L,gt.setAnimationLoop(L),L===null?Vr.stop():Vr.start()},gt.addEventListener("sessionstart",Ri),gt.addEventListener("sessionend",Ix),this.render=function(L,V){if(V!==void 0&&V.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(M===!0)return;if(L.matrixWorldAutoUpdate===!0&&L.updateMatrixWorld(),V.parent===null&&V.matrixWorldAutoUpdate===!0&&V.updateMatrixWorld(),gt.enabled===!0&>.isPresenting===!0&&(gt.cameraAutoUpdate===!0&>.updateCamera(V),V=gt.getCamera()),L.isScene===!0&&L.onBeforeRender(d,L,V,E),_=_t.get(L,g.length),_.init(V),g.push(_),Q.multiplyMatrices(V.projectionMatrix,V.matrixWorldInverse),Et.setFromProjectionMatrix(Q,wn,V.reversedDepth),K=this.localClippingEnabled,Mt=xt.init(this.clippingPlanes,K),y=X.get(L,S.length),y.init(),S.push(y),gt.enabled===!0&>.isPresenting===!0){let pt=d.xr.getDepthSensingMesh();pt!==null&&Td(pt,V,-1/0,d.sortObjects)}Td(L,V,0,d.sortObjects),y.finish(),d.sortObjects===!0&&y.sort($,at),Ct=gt.enabled===!1||gt.isPresenting===!1||gt.hasDepthSensing()===!1,Ct&&Dt.addToRenderList(y,L),this.info.render.frame++,Mt===!0&&xt.beginShadows();let J=_.state.shadowsArray;Ft.render(J,L,V),Mt===!0&&xt.endShadows(),this.info.autoReset===!0&&this.info.reset();let j=y.opaque,G=y.transmissive;if(_.setupLights(),V.isArrayCamera){let pt=V.cameras;if(G.length>0)for(let At=0,Ot=pt.length;At<Ot;At++){let Nt=pt[At];Lx(j,G,L,Nt)}Ct&&Dt.render(L);for(let At=0,Ot=pt.length;At<Ot;At++){let Nt=pt[At];Px(y,L,Nt,Nt.viewport)}}else G.length>0&&Lx(j,G,L,V),Ct&&Dt.render(L),Px(y,L,V);E!==null&&R===0&&(st.updateMultisampleRenderTarget(E),st.updateRenderTargetMipmap(E)),L.isScene===!0&&L.onAfterRender(d,L,V),wt.resetDefaultState(),T=-1,b=null,g.pop(),g.length>0?(_=g[g.length-1],Mt===!0&&xt.setGlobalState(d.clippingPlanes,_.state.camera)):_=null,S.pop(),S.length>0?y=S[S.length-1]:y=null};function Td(L,V,J,j){if(L.visible===!1)return;if(L.layers.test(V.layers)){if(L.isGroup)J=L.renderOrder;else if(L.isLOD)L.autoUpdate===!0&&L.update(V);else if(L.isLight)_.pushLight(L),L.castShadow&&_.pushShadow(L);else if(L.isSprite){if(!L.frustumCulled||Et.intersectsSprite(L)){j&<.setFromMatrixPosition(L.matrixWorld).applyMatrix4(Q);let At=k.update(L),Ot=L.material;Ot.visible&&y.push(L,At,Ot,J,lt.z,null)}}else if((L.isMesh||L.isLine||L.isPoints)&&(!L.frustumCulled||Et.intersectsObject(L))){let At=k.update(L),Ot=L.material;if(j&&(L.boundingSphere!==void 0?(L.boundingSphere===null&&L.computeBoundingSphere(),lt.copy(L.boundingSphere.center)):(At.boundingSphere===null&&At.computeBoundingSphere(),lt.copy(At.boundingSphere.center)),lt.applyMatrix4(L.matrixWorld).applyMatrix4(Q)),Array.isArray(Ot)){let Nt=At.groups;for(let Wt=0,Yt=Nt.length;Wt<Yt;Wt++){let Ht=Nt[Wt],ae=Ot[Ht.materialIndex];ae&&ae.visible&&y.push(L,At,ae,J,lt.z,Ht)}}else Ot.visible&&y.push(L,At,Ot,J,lt.z,null)}}let pt=L.children;for(let At=0,Ot=pt.length;At<Ot;At++)Td(pt[At],V,J,j)}function Px(L,V,J,j){let G=L.opaque,pt=L.transmissive,At=L.transparent;_.setupLightsView(J),Mt===!0&&xt.setGlobalState(d.clippingPlanes,J),j&&q.viewport(w.copy(j)),G.length>0&&fu(G,V,J),pt.length>0&&fu(pt,V,J),At.length>0&&fu(At,V,J),q.buffers.depth.setTest(!0),q.buffers.depth.setMask(!0),q.buffers.color.setMask(!0),q.setPolygonOffset(!1)}function Lx(L,V,J,j){if((J.isScene===!0?J.overrideMaterial:null)!==null)return;_.state.transmissionRenderTarget[j.id]===void 0&&(_.state.transmissionRenderTarget[j.id]=new Hn(1,1,{generateMipmaps:!0,type:Z.has("EXT_color_buffer_half_float")||Z.has("EXT_color_buffer_float")?ws:ri,minFilter:un,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ie.workingColorSpace}));let pt=_.state.transmissionRenderTarget[j.id],At=j.viewport||w;pt.setSize(At.z*d.transmissionResolutionScale,At.w*d.transmissionResolutionScale);let Ot=d.getRenderTarget(),Nt=d.getActiveCubeFace(),Wt=d.getActiveMipmapLevel();d.setRenderTarget(pt),d.getClearColor(D),F=d.getClearAlpha(),F<1&&d.setClearColor(16777215,.5),d.clear(),Ct&&Dt.render(J);let Yt=d.toneMapping;d.toneMapping=Gi;let Ht=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),_.setupLightsView(j),Mt===!0&&xt.setGlobalState(d.clippingPlanes,j),fu(L,J,j),st.updateMultisampleRenderTarget(pt),st.updateRenderTargetMipmap(pt),Z.has("WEBGL_multisampled_render_to_texture")===!1){let ae=!1;for(let ye=0,Fe=V.length;ye<Fe;ye++){let we=V[ye],Me=we.object,Gt=we.geometry,Pe=we.material,he=we.group;if(Pe.side===Ve&&Me.layers.test(j.layers)){let Nn=Pe.side;Pe.side=qe,Pe.needsUpdate=!0,Nx(Me,J,j,Gt,Pe,he),Pe.side=Nn,Pe.needsUpdate=!0,ae=!0}}ae===!0&&(st.updateMultisampleRenderTarget(pt),st.updateRenderTargetMipmap(pt))}d.setRenderTarget(Ot,Nt,Wt),d.setClearColor(D,F),Ht!==void 0&&(j.viewport=Ht),d.toneMapping=Yt}function fu(L,V,J){let j=V.isScene===!0?V.overrideMaterial:null;for(let G=0,pt=L.length;G<pt;G++){let At=L[G],Ot=At.object,Nt=At.geometry,Wt=At.group,Yt=At.material;Yt.allowOverride===!0&&j!==null&&(Yt=j),Ot.layers.test(J.layers)&&Nx(Ot,V,J,Nt,Yt,Wt)}}function Nx(L,V,J,j,G,pt){L.onBeforeRender(d,V,J,j,G,pt),L.modelViewMatrix.multiplyMatrices(J.matrixWorldInverse,L.matrixWorld),L.normalMatrix.getNormalMatrix(L.modelViewMatrix),G.onBeforeRender(d,V,J,j,L,pt),G.transparent===!0&&G.side===Ve&&G.forceSinglePass===!1?(G.side=qe,G.needsUpdate=!0,d.renderBufferDirect(J,V,j,G,L,pt),G.side=rn,G.needsUpdate=!0,d.renderBufferDirect(J,V,j,G,L,pt),G.side=Ve):d.renderBufferDirect(J,V,j,G,L,pt),L.onAfterRender(d,V,J,j,G,pt)}function du(L,V,J){V.isScene!==!0&&(V=ut);let j=it.get(L),G=_.state.lights,pt=_.state.shadowsArray,At=G.state.version,Ot=W.getParameters(L,G.state,pt,V,J),Nt=W.getProgramCacheKey(Ot),Wt=j.programs;j.environment=L.isMeshStandardMaterial?V.environment:null,j.fog=V.fog,j.envMap=(L.isMeshStandardMaterial?It:Pt).get(L.envMap||j.environment),j.envMapRotation=j.environment!==null&&L.envMap===null?V.environmentRotation:L.envMapRotation,Wt===void 0&&(L.addEventListener("dispose",ot),Wt=new Map,j.programs=Wt);let Yt=Wt.get(Nt);if(Yt!==void 0){if(j.currentProgram===Yt&&j.lightsStateVersion===At)return Ux(L,Ot),Yt}else Ot.uniforms=W.getUniforms(L),L.onBeforeCompile(Ot,d),Yt=W.acquireProgram(Ot,Nt),Wt.set(Nt,Yt),j.uniforms=Ot.uniforms;let Ht=j.uniforms;return(!L.isShaderMaterial&&!L.isRawShaderMaterial||L.clipping===!0)&&(Ht.clippingPlanes=xt.uniform),Ux(L,Ot),j.needsLights=RM(L),j.lightsStateVersion=At,j.needsLights&&(Ht.ambientLightColor.value=G.state.ambient,Ht.lightProbe.value=G.state.probe,Ht.directionalLights.value=G.state.directional,Ht.directionalLightShadows.value=G.state.directionalShadow,Ht.spotLights.value=G.state.spot,Ht.spotLightShadows.value=G.state.spotShadow,Ht.rectAreaLights.value=G.state.rectArea,Ht.ltc_1.value=G.state.rectAreaLTC1,Ht.ltc_2.value=G.state.rectAreaLTC2,Ht.pointLights.value=G.state.point,Ht.pointLightShadows.value=G.state.pointShadow,Ht.hemisphereLights.value=G.state.hemi,Ht.directionalShadowMap.value=G.state.directionalShadowMap,Ht.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Ht.spotShadowMap.value=G.state.spotShadowMap,Ht.spotLightMatrix.value=G.state.spotLightMatrix,Ht.spotLightMap.value=G.state.spotLightMap,Ht.pointShadowMap.value=G.state.pointShadowMap,Ht.pointShadowMatrix.value=G.state.pointShadowMatrix),j.currentProgram=Yt,j.uniformsList=null,Yt}function Dx(L){if(L.uniformsList===null){let V=L.currentProgram.getUniforms();L.uniformsList=ia.seqWithValue(V.seq,L.uniforms)}return L.uniformsList}function Ux(L,V){let J=it.get(L);J.outputColorSpace=V.outputColorSpace,J.batching=V.batching,J.batchingColor=V.batchingColor,J.instancing=V.instancing,J.instancingColor=V.instancingColor,J.instancingMorph=V.instancingMorph,J.skinning=V.skinning,J.morphTargets=V.morphTargets,J.morphNormals=V.morphNormals,J.morphColors=V.morphColors,J.morphTargetsCount=V.morphTargetsCount,J.numClippingPlanes=V.numClippingPlanes,J.numIntersection=V.numClipIntersection,J.vertexAlphas=V.vertexAlphas,J.vertexTangents=V.vertexTangents,J.toneMapping=V.toneMapping}function wM(L,V,J,j,G){V.isScene!==!0&&(V=ut),st.resetTextureUnits();let pt=V.fog,At=j.isMeshStandardMaterial?V.environment:null,Ot=E===null?d.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:tn,Nt=(j.isMeshStandardMaterial?It:Pt).get(j.envMap||At),Wt=j.vertexColors===!0&&!!J.attributes.color&&J.attributes.color.itemSize===4,Yt=!!J.attributes.tangent&&(!!j.normalMap||j.anisotropy>0),Ht=!!J.morphAttributes.position,ae=!!J.morphAttributes.normal,ye=!!J.morphAttributes.color,Fe=Gi;j.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(Fe=d.toneMapping);let we=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,Me=we!==void 0?we.length:0,Gt=it.get(j),Pe=_.state.lights;if(Mt===!0&&(K===!0||L!==b)){let pn=L===b&&j.id===T;xt.setState(j,L,pn)}let he=!1;j.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==Pe.state.version||Gt.outputColorSpace!==Ot||G.isBatchedMesh&&Gt.batching===!1||!G.isBatchedMesh&&Gt.batching===!0||G.isBatchedMesh&&Gt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&Gt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&Gt.instancing===!1||!G.isInstancedMesh&&Gt.instancing===!0||G.isSkinnedMesh&&Gt.skinning===!1||!G.isSkinnedMesh&&Gt.skinning===!0||G.isInstancedMesh&&Gt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&Gt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&Gt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&Gt.instancingMorph===!1&&G.morphTexture!==null||Gt.envMap!==Nt||j.fog===!0&&Gt.fog!==pt||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==xt.numPlanes||Gt.numIntersection!==xt.numIntersection)||Gt.vertexAlphas!==Wt||Gt.vertexTangents!==Yt||Gt.morphTargets!==Ht||Gt.morphNormals!==ae||Gt.morphColors!==ye||Gt.toneMapping!==Fe||Gt.morphTargetsCount!==Me)&&(he=!0):(he=!0,Gt.__version=j.version);let Nn=Gt.currentProgram;he===!0&&(Nn=du(j,V,G));let qs=!1,Dn=!1,Ca=!1,Le=Nn.getUniforms(),Zn=Gt.uniforms;if(q.useProgram(Nn.program)&&(qs=!0,Dn=!0,Ca=!0),j.id!==T&&(T=j.id,Dn=!0),qs||b!==L){q.buffers.depth.getReversed()&&L.reversedDepth!==!0&&(L._reversedDepth=!0,L.updateProjectionMatrix()),Le.setValue(U,"projectionMatrix",L.projectionMatrix),Le.setValue(U,"viewMatrix",L.matrixWorldInverse);let bn=Le.map.cameraPosition;bn!==void 0&&bn.setValue(U,ct.setFromMatrixPosition(L.matrixWorld)),Y.logarithmicDepthBuffer&&Le.setValue(U,"logDepthBufFC",2/(Math.log(L.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&Le.setValue(U,"isOrthographic",L.isOrthographicCamera===!0),b!==L&&(b=L,Dn=!0,Ca=!0)}if(G.isSkinnedMesh){Le.setOptional(U,G,"bindMatrix"),Le.setOptional(U,G,"bindMatrixInverse");let pn=G.skeleton;pn&&(pn.boneTexture===null&&pn.computeBoneTexture(),Le.setValue(U,"boneTexture",pn.boneTexture,st))}G.isBatchedMesh&&(Le.setOptional(U,G,"batchingTexture"),Le.setValue(U,"batchingTexture",G._matricesTexture,st),Le.setOptional(U,G,"batchingIdTexture"),Le.setValue(U,"batchingIdTexture",G._indirectTexture,st),Le.setOptional(U,G,"batchingColorTexture"),G._colorsTexture!==null&&Le.setValue(U,"batchingColorTexture",G._colorsTexture,st));let Jn=J.morphAttributes;if((Jn.position!==void 0||Jn.normal!==void 0||Jn.color!==void 0)&&ft.update(G,J,Nn),(Dn||Gt.receiveShadow!==G.receiveShadow)&&(Gt.receiveShadow=G.receiveShadow,Le.setValue(U,"receiveShadow",G.receiveShadow)),j.isMeshGouraudMaterial&&j.envMap!==null&&(Zn.envMap.value=Nt,Zn.flipEnvMap.value=Nt.isCubeTexture&&Nt.isRenderTargetTexture===!1?-1:1),j.isMeshStandardMaterial&&j.envMap===null&&V.environment!==null&&(Zn.envMapIntensity.value=V.environmentIntensity),Dn&&(Le.setValue(U,"toneMappingExposure",d.toneMappingExposure),Gt.needsLights&&AM(Zn,Ca),pt&&j.fog===!0&&et.refreshFogUniforms(Zn,pt),et.refreshMaterialUniforms(Zn,j,B,H,_.state.transmissionRenderTarget[L.id]),ia.upload(U,Dx(Gt),Zn,st)),j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(ia.upload(U,Dx(Gt),Zn,st),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&Le.setValue(U,"center",G.center),Le.setValue(U,"modelViewMatrix",G.modelViewMatrix),Le.setValue(U,"normalMatrix",G.normalMatrix),Le.setValue(U,"modelMatrix",G.matrixWorld),j.isShaderMaterial||j.isRawShaderMaterial){let pn=j.uniformsGroups;for(let bn=0,Ed=pn.length;bn<Ed;bn++){let Gr=pn[bn];jt.update(Gr,Nn),jt.bind(Gr,Nn)}}return Nn}function AM(L,V){L.ambientLightColor.needsUpdate=V,L.lightProbe.needsUpdate=V,L.directionalLights.needsUpdate=V,L.directionalLightShadows.needsUpdate=V,L.pointLights.needsUpdate=V,L.pointLightShadows.needsUpdate=V,L.spotLights.needsUpdate=V,L.spotLightShadows.needsUpdate=V,L.rectAreaLights.needsUpdate=V,L.hemisphereLights.needsUpdate=V}function RM(L){return L.isMeshLambertMaterial||L.isMeshToonMaterial||L.isMeshPhongMaterial||L.isMeshStandardMaterial||L.isShadowMaterial||L.isShaderMaterial&&L.lights===!0}this.getActiveCubeFace=function(){return m},this.getActiveMipmapLevel=function(){return R},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(L,V,J){let j=it.get(L);j.__autoAllocateDepthBuffer=L.resolveDepthBuffer===!1,j.__autoAllocateDepthBuffer===!1&&(j.__useRenderToTexture=!1),it.get(L.texture).__webglTexture=V,it.get(L.depthTexture).__webglTexture=j.__autoAllocateDepthBuffer?void 0:J,j.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(L,V){let J=it.get(L);J.__webglFramebuffer=V,J.__useDefaultFramebuffer=V===void 0};let CM=U.createFramebuffer();this.setRenderTarget=function(L,V=0,J=0){E=L,m=V,R=J;let j=!0,G=null,pt=!1,At=!1;if(L){let Nt=it.get(L);if(Nt.__useDefaultFramebuffer!==void 0)q.bindFramebuffer(U.FRAMEBUFFER,null),j=!1;else if(Nt.__webglFramebuffer===void 0)st.setupRenderTarget(L);else if(Nt.__hasExternalTextures)st.rebindTextures(L,it.get(L.texture).__webglTexture,it.get(L.depthTexture).__webglTexture);else if(L.depthBuffer){let Ht=L.depthTexture;if(Nt.__boundDepthTexture!==Ht){if(Ht!==null&&it.has(Ht)&&(L.width!==Ht.image.width||L.height!==Ht.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");st.setupDepthRenderbuffer(L)}}let Wt=L.texture;(Wt.isData3DTexture||Wt.isDataArrayTexture||Wt.isCompressedArrayTexture)&&(At=!0);let Yt=it.get(L).__webglFramebuffer;L.isWebGLCubeRenderTarget?(Array.isArray(Yt[V])?G=Yt[V][J]:G=Yt[V],pt=!0):L.samples>0&&st.useMultisampledRTT(L)===!1?G=it.get(L).__webglMultisampledFramebuffer:Array.isArray(Yt)?G=Yt[J]:G=Yt,w.copy(L.viewport),A.copy(L.scissor),C=L.scissorTest}else w.copy(rt).multiplyScalar(B).floor(),A.copy(ht).multiplyScalar(B).floor(),C=bt;if(J!==0&&(G=CM),q.bindFramebuffer(U.FRAMEBUFFER,G)&&j&&q.drawBuffers(L,G),q.viewport(w),q.scissor(A),q.setScissorTest(C),pt){let Nt=it.get(L.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+V,Nt.__webglTexture,J)}else if(At){let Nt=V;for(let Wt=0;Wt<L.textures.length;Wt++){let Yt=it.get(L.textures[Wt]);U.framebufferTextureLayer(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0+Wt,Yt.__webglTexture,J,Nt)}}else if(L!==null&&J!==0){let Nt=it.get(L.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Nt.__webglTexture,J)}T=-1},this.readRenderTargetPixels=function(L,V,J,j,G,pt,At,Ot=0){if(!(L&&L.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Nt=it.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&At!==void 0&&(Nt=Nt[At]),Nt){q.bindFramebuffer(U.FRAMEBUFFER,Nt);try{let Wt=L.textures[Ot],Yt=Wt.format,Ht=Wt.type;if(!Y.textureFormatReadable(Yt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Y.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}V>=0&&V<=L.width-j&&J>=0&&J<=L.height-G&&(L.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ot),U.readPixels(V,J,j,G,zt.convert(Yt),zt.convert(Ht),pt))}finally{let Wt=E!==null?it.get(E).__webglFramebuffer:null;q.bindFramebuffer(U.FRAMEBUFFER,Wt)}}},this.readRenderTargetPixelsAsync=async function(L,V,J,j,G,pt,At,Ot=0){if(!(L&&L.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Nt=it.get(L).__webglFramebuffer;if(L.isWebGLCubeRenderTarget&&At!==void 0&&(Nt=Nt[At]),Nt)if(V>=0&&V<=L.width-j&&J>=0&&J<=L.height-G){q.bindFramebuffer(U.FRAMEBUFFER,Nt);let Wt=L.textures[Ot],Yt=Wt.format,Ht=Wt.type;if(!Y.textureFormatReadable(Yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Y.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ae=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,ae),U.bufferData(U.PIXEL_PACK_BUFFER,pt.byteLength,U.STREAM_READ),L.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+Ot),U.readPixels(V,J,j,G,zt.convert(Yt),zt.convert(Ht),0);let ye=E!==null?it.get(E).__webglFramebuffer:null;q.bindFramebuffer(U.FRAMEBUFFER,ye);let Fe=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await w0(U,Fe,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,ae),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,pt),U.deleteBuffer(ae),U.deleteSync(Fe),pt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(L,V=null,J=0){let j=Math.pow(2,-J),G=Math.floor(L.image.width*j),pt=Math.floor(L.image.height*j),At=V!==null?V.x:0,Ot=V!==null?V.y:0;st.setTexture2D(L,0),U.copyTexSubImage2D(U.TEXTURE_2D,J,0,0,At,Ot,G,pt),q.unbindTexture()};let IM=U.createFramebuffer(),PM=U.createFramebuffer();this.copyTextureToTexture=function(L,V,J=null,j=null,G=0,pt=null){pt===null&&(G!==0?(vo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),pt=G,G=0):pt=0);let At,Ot,Nt,Wt,Yt,Ht,ae,ye,Fe,we=L.isCompressedTexture?L.mipmaps[pt]:L.image;if(J!==null)At=J.max.x-J.min.x,Ot=J.max.y-J.min.y,Nt=J.isBox3?J.max.z-J.min.z:1,Wt=J.min.x,Yt=J.min.y,Ht=J.isBox3?J.min.z:0;else{let Jn=Math.pow(2,-G);At=Math.floor(we.width*Jn),Ot=Math.floor(we.height*Jn),L.isDataArrayTexture?Nt=we.depth:L.isData3DTexture?Nt=Math.floor(we.depth*Jn):Nt=1,Wt=0,Yt=0,Ht=0}j!==null?(ae=j.x,ye=j.y,Fe=j.z):(ae=0,ye=0,Fe=0);let Me=zt.convert(V.format),Gt=zt.convert(V.type),Pe;V.isData3DTexture?(st.setTexture3D(V,0),Pe=U.TEXTURE_3D):V.isDataArrayTexture||V.isCompressedArrayTexture?(st.setTexture2DArray(V,0),Pe=U.TEXTURE_2D_ARRAY):(st.setTexture2D(V,0),Pe=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,V.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,V.unpackAlignment);let he=U.getParameter(U.UNPACK_ROW_LENGTH),Nn=U.getParameter(U.UNPACK_IMAGE_HEIGHT),qs=U.getParameter(U.UNPACK_SKIP_PIXELS),Dn=U.getParameter(U.UNPACK_SKIP_ROWS),Ca=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,we.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,we.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,Wt),U.pixelStorei(U.UNPACK_SKIP_ROWS,Yt),U.pixelStorei(U.UNPACK_SKIP_IMAGES,Ht);let Le=L.isDataArrayTexture||L.isData3DTexture,Zn=V.isDataArrayTexture||V.isData3DTexture;if(L.isDepthTexture){let Jn=it.get(L),pn=it.get(V),bn=it.get(Jn.__renderTarget),Ed=it.get(pn.__renderTarget);q.bindFramebuffer(U.READ_FRAMEBUFFER,bn.__webglFramebuffer),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,Ed.__webglFramebuffer);for(let Gr=0;Gr<Nt;Gr++)Le&&(U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,it.get(L).__webglTexture,G,Ht+Gr),U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,it.get(V).__webglTexture,pt,Fe+Gr)),U.blitFramebuffer(Wt,Yt,At,Ot,ae,ye,At,Ot,U.DEPTH_BUFFER_BIT,U.NEAREST);q.bindFramebuffer(U.READ_FRAMEBUFFER,null),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else if(G!==0||L.isRenderTargetTexture||it.has(L)){let Jn=it.get(L),pn=it.get(V);q.bindFramebuffer(U.READ_FRAMEBUFFER,IM),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,PM);for(let bn=0;bn<Nt;bn++)Le?U.framebufferTextureLayer(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,Jn.__webglTexture,G,Ht+bn):U.framebufferTexture2D(U.READ_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,Jn.__webglTexture,G),Zn?U.framebufferTextureLayer(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,pn.__webglTexture,pt,Fe+bn):U.framebufferTexture2D(U.DRAW_FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_2D,pn.__webglTexture,pt),G!==0?U.blitFramebuffer(Wt,Yt,At,Ot,ae,ye,At,Ot,U.COLOR_BUFFER_BIT,U.NEAREST):Zn?U.copyTexSubImage3D(Pe,pt,ae,ye,Fe+bn,Wt,Yt,At,Ot):U.copyTexSubImage2D(Pe,pt,ae,ye,Wt,Yt,At,Ot);q.bindFramebuffer(U.READ_FRAMEBUFFER,null),q.bindFramebuffer(U.DRAW_FRAMEBUFFER,null)}else Zn?L.isDataTexture||L.isData3DTexture?U.texSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,Gt,we.data):V.isCompressedArrayTexture?U.compressedTexSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,we.data):U.texSubImage3D(Pe,pt,ae,ye,Fe,At,Ot,Nt,Me,Gt,we):L.isDataTexture?U.texSubImage2D(U.TEXTURE_2D,pt,ae,ye,At,Ot,Me,Gt,we.data):L.isCompressedTexture?U.compressedTexSubImage2D(U.TEXTURE_2D,pt,ae,ye,we.width,we.height,Me,we.data):U.texSubImage2D(U.TEXTURE_2D,pt,ae,ye,At,Ot,Me,Gt,we);U.pixelStorei(U.UNPACK_ROW_LENGTH,he),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,Nn),U.pixelStorei(U.UNPACK_SKIP_PIXELS,qs),U.pixelStorei(U.UNPACK_SKIP_ROWS,Dn),U.pixelStorei(U.UNPACK_SKIP_IMAGES,Ca),pt===0&&V.generateMipmaps&&U.generateMipmap(Pe),q.unbindTexture()},this.initRenderTarget=function(L){it.get(L).__webglFramebuffer===void 0&&st.setupRenderTarget(L)},this.initTexture=function(L){L.isCubeTexture?st.setTextureCube(L,0):L.isData3DTexture?st.setTexture3D(L,0):L.isDataArrayTexture||L.isCompressedArrayTexture?st.setTexture2DArray(L,0):st.setTexture2D(L,0),q.unbindTexture()},this.resetState=function(){m=0,R=0,E=null,q.reset(),wt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return wn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=ie._getDrawingBufferColorSpace(t),e.unpackColorSpace=ie._getUnpackColorSpace()}};var hy={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},Us=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(t){return new km(t)}),this.register(function(t){return new Hm(t)}),this.register(function(t){return new Xm(t)}),this.register(function(t){return new qm(t)}),this.register(function(t){return new Ym(t)}),this.register(function(t){return new $m(t)}),this.register(function(t){return new Vm(t)}),this.register(function(t){return new Gm(t)}),this.register(function(t){return new Wm(t)}),this.register(function(t){return new Km(t)}),this.register(function(t){return new Zm(t)}),this.register(function(t){return new Jm(t)}),this.register(function(t){return new jm(t)}),this.register(function(t){return new Qm(t)})}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}setTextureUtils(t){return this.textureUtils=t,this}parse(t,e,n,i){let r=new zm,o=[];for(let a=0,c=this.pluginCallbacks.length;a<c;a++)o.push(this.pluginCallbacks[a](r));r.setPlugins(o),r.setTextureUtils(this.textureUtils),r.writeAsync(t,e,i).catch(n)}parseAsync(t,e){let n=this;return new Promise(function(i,r){n.parse(t,i,r,e)})}},se={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Om="KHR_mesh_quantization",Xn={};Xn[De]=se.NEAREST;Xn[Nr]=se.NEAREST_MIPMAP_NEAREST;Xn[Mi]=se.NEAREST_MIPMAP_LINEAR;Xn[Ee]=se.LINEAR;Xn[Xi]=se.LINEAR_MIPMAP_NEAREST;Xn[un]=se.LINEAR_MIPMAP_LINEAR;Xn[en]=se.CLAMP_TO_EDGE;Xn[An]=se.REPEAT;Xn[Li]=se.MIRRORED_REPEAT;var fy={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},QA=new yt,dy=12,t1=1179937895,e1=2,py=8,n1=1313821514,i1=5130562;function Gl(s,t){return s.length===t.length&&s.every(function(e,n){return e===t[n]})}function r1(s){return new TextEncoder().encode(s).buffer}function s1(s){return Gl(s.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function o1(s,t,e){let n={min:new Array(s.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(s.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=t;i<t+e;i++)for(let r=0;r<s.itemSize;r++){let o;s.itemSize>4?o=s.array[i*s.itemSize+r]:(r===0?o=s.getX(i):r===1?o=s.getY(i):r===2?o=s.getZ(i):r===3&&(o=s.getW(i)),s.normalized===!0&&(o=Yi.normalize(o,s.array))),n.min[r]=Math.min(n.min[r],o),n.max[r]=Math.max(n.max[r],o)}return n}function gy(s){return Math.ceil(s/4)*4}function Bm(s,t=0){let e=gy(s.byteLength);if(e!==s.byteLength){let n=new Uint8Array(e);if(n.set(new Uint8Array(s)),t!==0)for(let i=s.byteLength;i<e;i++)n[i]=t;return n.buffer}return s}function my(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function a1(s,t){if(typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas){let e;return t==="image/jpeg"?e=.92:t==="image/webp"&&(e=.8),s.convertToBlob({type:t,quality:e})}else return new Promise(e=>s.toBlob(e,t))}var zm=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r"+Hi}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(t){this.plugins=t}setTextureUtils(t){this.textureUtils=t}async writeAsync(t,e,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(t),await Promise.all(this.pending);let i=this,r=i.buffers,o=i.json;n=i.options;let a=i.extensionsUsed,c=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),u=Object.keys(a),h=Object.keys(c);if(u.length>0&&(o.extensionsUsed=u),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=l.size),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(l),f.onloadend=function(){let p=Bm(f.result),x=new DataView(new ArrayBuffer(py));x.setUint32(0,p.byteLength,!0),x.setUint32(4,i1,!0);let v=Bm(r1(JSON.stringify(o)),32),y=new DataView(new ArrayBuffer(py));y.setUint32(0,v.byteLength,!0),y.setUint32(4,n1,!0);let _=new ArrayBuffer(dy),S=new DataView(_);S.setUint32(0,t1,!0),S.setUint32(4,e1,!0);let g=dy+y.byteLength+v.byteLength+x.byteLength+p.byteLength;S.setUint32(8,g,!0);let d=new Blob([_,y,v,x,p],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(d),M.onloadend=function(){e(M.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(l),f.onloadend=function(){let p=f.result;o.buffers[0].uri=p,e(o)}}else e(o)}serializeUserData(t,e){if(Object.keys(t.userData).length===0)return;let n=this.options,i=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(t.userData));if(n.includeCustomExtensions&&r.gltfExtensions){e.extensions===void 0&&(e.extensions={});for(let o in r.gltfExtensions)e.extensions[o]=r.gltfExtensions[o],i[o]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(e.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+t.name+"' won't be serialized because of JSON.stringify error - "+r.message)}}getUID(t,e=!1){if(this.uids.has(t)===!1){let i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(t,i)}return this.uids.get(t).get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;let n=new I;for(let i=0,r=t.count;i<r;i++)if(Math.abs(n.fromBufferAttribute(t,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){let e=this.cache;if(e.attributesNormalized.has(t))return e.attributesNormalized.get(t);let n=t.clone(),i=new I;for(let r=0,o=n.count;r<o;r++)i.fromBufferAttribute(n,r),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),n.setXYZ(r,i.x,i.y,i.z);return e.attributesNormalized.set(t,n),n}applyTextureTransform(t,e){let n=!1,i={};(e.offset.x!==0||e.offset.y!==0)&&(i.offset=e.offset.toArray(),n=!0),e.rotation!==0&&(i.rotation=e.rotation,n=!0),(e.repeat.x!==1||e.repeat.y!==1)&&(i.scale=e.repeat.toArray(),n=!0),n&&(t.extensions=t.extensions||{},t.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(t,e){if(t===e)return t;function n(p){return p.colorSpace===Ae?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}t instanceof gi&&(t=await this.decompressTextureAsync(t)),e instanceof gi&&(e=await this.decompressTextureAsync(e));let i=t?t.image:null,r=e?e.image:null,o=Math.max(i?i.width:0,r?r.width:0),a=Math.max(i?i.height:0,r?r.height:0),c=my();c.width=o,c.height=a;let l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,o,a);let u=l.getImageData(0,0,o,a);if(i){l.drawImage(i,0,0,o,a);let p=n(t),x=l.getImageData(0,0,o,a).data;for(let v=2;v<x.length;v+=4)u.data[v]=p(x[v]/256)*256}if(r){l.drawImage(r,0,0,o,a);let p=n(e),x=l.getImageData(0,0,o,a).data;for(let v=1;v<x.length;v+=4)u.data[v]=p(x[v]/256)*256}l.putImageData(u,0,0);let f=(t||e).clone();return f.source=new On(c),f.colorSpace=si,f.channel=(t||e).channel,t&&e&&t.channel!==e.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),f}async decompressTextureAsync(t,e=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(t,e)}processBuffer(t){let e=this.json,n=this.buffers;return e.buffers||(e.buffers=[{byteLength:0}]),n.push(t),0}processBufferView(t,e,n,i,r){let o=this.json;o.bufferViews||(o.bufferViews=[]);let a;switch(e){case se.BYTE:case se.UNSIGNED_BYTE:a=1;break;case se.SHORT:case se.UNSIGNED_SHORT:a=2;break;default:a=4}let c=t.itemSize*a;r===se.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);let l=gy(i*c),u=new DataView(new ArrayBuffer(l)),h=0;for(let x=n;x<n+i;x++){for(let v=0;v<t.itemSize;v++){let y;t.itemSize>4?y=t.array[x*t.itemSize+v]:(v===0?y=t.getX(x):v===1?y=t.getY(x):v===2?y=t.getZ(x):v===3&&(y=t.getW(x)),t.normalized===!0&&(y=Yi.normalize(y,t.array))),e===se.FLOAT?u.setFloat32(h,y,!0):e===se.INT?u.setInt32(h,y,!0):e===se.UNSIGNED_INT?u.setUint32(h,y,!0):e===se.SHORT?u.setInt16(h,y,!0):e===se.UNSIGNED_SHORT?u.setUint16(h,y,!0):e===se.BYTE?u.setInt8(h,y):e===se.UNSIGNED_BYTE&&u.setUint8(h,y),h+=a}h%c!==0&&(h+=c-h%c)}let f={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:l};return r!==void 0&&(f.target=r),r===se.ARRAY_BUFFER&&(f.byteStride=c),this.byteOffset+=l,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(t){let e=this,n=e.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(i){let r=new FileReader;r.readAsArrayBuffer(t),r.onloadend=function(){let o=Bm(r.result),a={buffer:e.processBuffer(o),byteOffset:e.byteOffset,byteLength:o.byteLength};e.byteOffset+=o.byteLength,i(n.bufferViews.push(a)-1)}})}processAccessor(t,e,n,i){let r=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(t.array.constructor===Float32Array)a=se.FLOAT;else if(t.array.constructor===Int32Array)a=se.INT;else if(t.array.constructor===Uint32Array)a=se.UNSIGNED_INT;else if(t.array.constructor===Int16Array)a=se.SHORT;else if(t.array.constructor===Uint16Array)a=se.UNSIGNED_SHORT;else if(t.array.constructor===Int8Array)a=se.BYTE;else if(t.array.constructor===Uint8Array)a=se.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+t.array.constructor.name);if(n===void 0&&(n=0),(i===void 0||i===1/0)&&(i=t.count),i===0)return null;let c=o1(t,n,i),l;e!==void 0&&(l=t===e.index?se.ELEMENT_ARRAY_BUFFER:se.ARRAY_BUFFER);let u=this.processBufferView(t,a,n,i,l),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:a,count:i,max:c.max,min:c.min,type:o[t.itemSize]};return t.normalized===!0&&(h.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(h)-1}processImage(t,e,n,i="image/png"){if(t!==null){let r=this,o=r.cache,a=r.json,c=r.options,l=r.pending;o.images.has(t)||o.images.set(t,{});let u=o.images.get(t),h=i+":flipY/"+n.toString();if(u[h]!==void 0)return u[h];a.images||(a.images=[]);let f={mimeType:i},p=my();p.width=Math.min(t.width,c.maxTextureSize),p.height=Math.min(t.height,c.maxTextureSize);let x=p.getContext("2d",{willReadFrequently:!0});if(n===!0&&(x.translate(0,p.height),x.scale(1,-1)),t.data!==void 0){e!==Qe&&console.error("GLTFExporter: Only RGBAFormat is supported.",e),(t.width>c.maxTextureSize||t.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",t);let y=new Uint8ClampedArray(t.height*t.width*4);for(let _=0;_<y.length;_+=4)y[_+0]=t.data[_+0],y[_+1]=t.data[_+1],y[_+2]=t.data[_+2],y[_+3]=t.data[_+3];x.putImageData(new ImageData(y,t.width,t.height),0,0)}else if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)x.drawImage(t,0,0,p.width,p.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(a1(p,i).then(y=>r.processBufferViewImage(y)).then(y=>{f.bufferView=y})):f.uri=as.getDataURL(p,i);let v=a.images.push(f)-1;return u[h]=v,v}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(t){let e=this.json;e.samplers||(e.samplers=[]);let n={magFilter:Xn[t.magFilter],minFilter:Xn[t.minFilter],wrapS:Xn[t.wrapS],wrapT:Xn[t.wrapT]};return e.samplers.push(n)-1}async processTextureAsync(t){let n=this.options,i=this.cache,r=this.json;if(i.textures.has(t))return i.textures.get(t);r.textures||(r.textures=[]),t instanceof gi&&(t=await this.decompressTextureAsync(t,n.maxTextureSize));let o=t.userData.mimeType;o==="image/webp"&&(o="image/png");let a={sampler:this.processSampler(t),source:this.processImage(t.image,t.format,t.flipY,o)};t.name&&(a.name=t.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(t,a)});let c=r.textures.push(a)-1;return i.textures.set(t,c),c}async processMaterialAsync(t){let e=this.cache,n=this.json;if(e.materials.has(t))return e.materials.get(t);if(t.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};t.isMeshStandardMaterial!==!0&&t.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=t.color.toArray().concat([t.opacity]);if(Gl(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=0,i.pbrMetallicRoughness.roughnessFactor=1),t.metalnessMap||t.roughnessMap){let a=await this.buildMetalRoughTextureAsync(t.metalnessMap,t.roughnessMap),c={index:await this.processTextureAsync(a),texCoord:a.channel};this.applyTextureTransform(c,a),i.pbrMetallicRoughness.metallicRoughnessTexture=c}if(t.map){let a={index:await this.processTextureAsync(t.map),texCoord:t.map.channel};this.applyTextureTransform(a,t.map),i.pbrMetallicRoughness.baseColorTexture=a}if(t.emissive){let a=t.emissive;if(Math.max(a.r,a.g,a.b)>0&&(i.emissiveFactor=t.emissive.toArray()),t.emissiveMap){let l={index:await this.processTextureAsync(t.emissiveMap),texCoord:t.emissiveMap.channel};this.applyTextureTransform(l,t.emissiveMap),i.emissiveTexture=l}}if(t.normalMap){let a={index:await this.processTextureAsync(t.normalMap),texCoord:t.normalMap.channel};t.normalScale&&t.normalScale.x!==1&&(a.scale=t.normalScale.x),this.applyTextureTransform(a,t.normalMap),i.normalTexture=a}if(t.aoMap){let a={index:await this.processTextureAsync(t.aoMap),texCoord:t.aoMap.channel};t.aoMapIntensity!==1&&(a.strength=t.aoMapIntensity),this.applyTextureTransform(a,t.aoMap),i.occlusionTexture=a}t.transparent?i.alphaMode="BLEND":t.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=t.alphaTest),t.side===Ve&&(i.doubleSided=!0),t.name!==""&&(i.name=t.name),this.serializeUserData(t,i),await this._invokeAllAsync(async function(a){a.writeMaterialAsync&&await a.writeMaterialAsync(t,i)});let o=n.materials.push(i)-1;return e.materials.set(t,o),o}async processMeshAsync(t){let e=this.cache,n=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let d=0,M=t.material.length;d<M;d++)i.push(t.material[d].uuid);else i.push(t.material.uuid);let r=i.join(":");if(e.meshes.has(r))return e.meshes.get(r);let o=t.geometry,a;t.isLineSegments?a=se.LINES:t.isLineLoop?a=se.LINE_LOOP:t.isLine?a=se.LINE_STRIP:t.isPoints?a=se.POINTS:a=t.material.wireframe?se.LINES:se.TRIANGLES;let c={},l={},u=[],h=[],f={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=o.getAttribute("normal");p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let x=null;for(let d in o.attributes){if(d.slice(0,5)==="morph")continue;let M=o.attributes[d];if(d=f[d]||d.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(d)||(d="_"+d),e.attributes.has(this.getUID(M))){l[d]=e.attributes.get(this.getUID(M));continue}x=null;let R=M.array;d==="JOINTS_0"&&!(R instanceof Uint16Array)&&!(R instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),x=new kt(new Uint16Array(R),M.itemSize,M.normalized)):(R instanceof Uint32Array||R instanceof Int32Array)&&!d.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${d}" converted to type FLOAT.`),x=Us.Utils.toFloat32BufferAttribute(M));let E=this.processAccessor(x||M,o);E!==null&&(d.startsWith("_")||this.detectMeshQuantization(d,M),l[d]=E,e.attributes.set(this.getUID(M),E))}if(p!==void 0&&o.setAttribute("normal",p),Object.keys(l).length===0)return null;if(t.morphTargetInfluences!==void 0&&t.morphTargetInfluences.length>0){let d=[],M=[],m={};if(t.morphTargetDictionary!==void 0)for(let R in t.morphTargetDictionary)m[t.morphTargetDictionary[R]]=R;for(let R=0;R<t.morphTargetInfluences.length;++R){let E={},T=!1;for(let b in o.morphAttributes){if(b!=="position"&&b!=="normal"){T||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),T=!0);continue}let w=o.morphAttributes[b][R],A=b.toUpperCase(),C=o.attributes[b];if(e.attributes.has(this.getUID(w,!0))){E[A]=e.attributes.get(this.getUID(w,!0));continue}let D=w.clone();if(!o.morphTargetsRelative)for(let F=0,O=w.count;F<O;F++)for(let H=0;H<w.itemSize;H++)H===0&&D.setX(F,w.getX(F)-C.getX(F)),H===1&&D.setY(F,w.getY(F)-C.getY(F)),H===2&&D.setZ(F,w.getZ(F)-C.getZ(F)),H===3&&D.setW(F,w.getW(F)-C.getW(F));E[A]=this.processAccessor(D,o),e.attributes.set(this.getUID(C,!0),E[A])}h.push(E),d.push(t.morphTargetInfluences[R]),t.morphTargetDictionary!==void 0&&M.push(m[R])}c.weights=d,M.length>0&&(c.extras={},c.extras.targetNames=M)}let v=Array.isArray(t.material);if(v&&o.groups.length===0)return null;let y=!1;if(v&&o.index===null){let d=[];for(let M=0,m=o.attributes.position.count;M<m;M++)d[M]=M;o.setIndex(d),y=!0}let _=v?t.material:[t.material],S=v?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let d=0,M=S.length;d<M;d++){let m={mode:a,attributes:l};if(this.serializeUserData(o,m),h.length>0&&(m.targets=h),o.index!==null){let E=this.getUID(o.index);(S[d].start!==void 0||S[d].count!==void 0)&&(E+=":"+S[d].start+":"+S[d].count),e.attributes.has(E)?m.indices=e.attributes.get(E):(m.indices=this.processAccessor(o.index,o,S[d].start,S[d].count),e.attributes.set(E,m.indices)),m.indices===null&&delete m.indices}let R=await this.processMaterialAsync(_[S[d].materialIndex]);R!==null&&(m.material=R),u.push(m)}y===!0&&o.setIndex(null),c.primitives=u,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(d){d.writeMesh&&d.writeMesh(t,c)});let g=n.meshes.push(c)-1;return e.meshes.set(r,g),g}detectMeshQuantization(t,e){if(this.extensionsUsed[Om])return;let n;switch(e.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}e.normalized&&(n+=" normalized");let i=t.split("_",1)[0];hy[i]&&hy[i].includes(n)&&(this.extensionsUsed[Om]=!0,this.extensionsRequired[Om]=!0)}processCamera(t){let e=this.json;e.cameras||(e.cameras=[]);let n=t.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:t.right*2,ymag:t.top*2,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:Yi.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},t.name!==""&&(i.name=t.type),e.cameras.push(i)-1}processAnimation(t,e){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]),t=Us.Utils.mergeMorphTargetTracks(t.clone(),e);let r=t.tracks,o=[],a=[];for(let l=0;l<r.length;++l){let u=r[l],h=ee.parseTrackName(u.name),f=ee.findNode(e,h.nodeName),p=fy[h.propertyName];if(h.objectName==="bones"&&(f.isSkinnedMesh===!0?f=f.skeleton.getBoneByName(h.objectIndex):f=void 0),!f||!p){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name);continue}let x=1,v=u.values.length/u.times.length;p===fy.morphTargetInfluences&&(v/=f.morphTargetInfluences.length);let y;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",v/=3):u.getInterpolation()===Ni?y="STEP":y="LINEAR",a.push({input:this.processAccessor(new kt(u.times,x)),output:this.processAccessor(new kt(u.values,v)),interpolation:y}),o.push({sampler:a.length-1,target:{node:i.get(f),path:p}})}let c={name:t.name||"clip_"+n.animations.length,samplers:a,channels:o};return this.serializeUserData(t,c),n.animations.push(c),n.animations.length-1}processSkin(t){let e=this.json,n=this.nodeMap,i=e.nodes[n.get(t)],r=t.skeleton;if(r===void 0)return null;let o=t.skeleton.bones[0];if(o===void 0)return null;let a=[],c=new Float32Array(r.bones.length*16),l=new vt;for(let h=0;h<r.bones.length;++h)a.push(n.get(r.bones[h])),l.copy(r.boneInverses[h]),l.multiply(t.bindMatrix).toArray(c,h*16);return e.skins===void 0&&(e.skins=[]),e.skins.push({inverseBindMatrices:this.processAccessor(new kt(c,16)),joints:a,skeleton:n.get(o)}),i.skin=e.skins.length-1}async processNodeAsync(t){let e=this.json,n=this.options,i=this.nodeMap;e.nodes||(e.nodes=[]);let r={};if(n.trs){let a=t.quaternion.toArray(),c=t.position.toArray(),l=t.scale.toArray();Gl(a,[0,0,0,1])||(r.rotation=a),Gl(c,[0,0,0])||(r.translation=c),Gl(l,[1,1,1])||(r.scale=l)}else t.matrixAutoUpdate&&t.updateMatrix(),s1(t.matrix)===!1&&(r.matrix=t.matrix.elements);if(t.name!==""&&(r.name=String(t.name)),this.serializeUserData(t,r),t.isMesh||t.isLine||t.isPoints){let a=await this.processMeshAsync(t);a!==null&&(r.mesh=a)}else t.isCamera&&(r.camera=this.processCamera(t));t.isSkinnedMesh&&this.skins.push(t);let o=e.nodes.push(r)-1;if(i.set(t,o),t.children.length>0){let a=[];for(let c=0,l=t.children.length;c<l;c++){let u=t.children[c];if(u.visible||n.onlyVisible===!1){let h=await this.processNodeAsync(u);h!==null&&a.push(h)}}a.length>0&&(r.children=a)}return await this._invokeAllAsync(function(a){a.writeNode&&a.writeNode(t,r)}),o}async processSceneAsync(t){let e=this.json,n=this.options;e.scenes||(e.scenes=[],e.scene=0);let i={};t.name!==""&&(i.name=t.name),e.scenes.push(i);let r=[];for(let o=0,a=t.children.length;o<a;o++){let c=t.children[o];if(c.visible||n.onlyVisible===!1){let l=await this.processNodeAsync(c);l!==null&&r.push(l)}}r.length>0&&(i.nodes=r),this.serializeUserData(t,i)}async processObjectsAsync(t){let e=new Fi;e.name="AuxScene";for(let n=0;n<t.length;n++)e.children.push(t[n]);await this.processSceneAsync(e)}async processInputAsync(t){let e=this.options;t=t instanceof Array?t:[t],await this._invokeAllAsync(function(i){i.beforeParse&&i.beforeParse(t)});let n=[];for(let i=0;i<t.length;i++)t[i]instanceof Fi?await this.processSceneAsync(t[i]):n.push(t[i]);n.length>0&&await this.processObjectsAsync(n);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<e.animations.length;++i)this.processAnimation(e.animations[i],t[0]);await this._invokeAllAsync(function(i){i.afterParse&&i.afterParse(t)})}async _invokeAllAsync(t){for(let e=0,n=this.plugins.length;e<n;e++)await t(this.plugins[e])}},km=class{constructor(t){this.writer=t,this.name="KHR_lights_punctual"}writeNode(t,e){if(!t.isLight)return;if(!t.isDirectionalLight&&!t.isPointLight&&!t.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",t);return}let n=this.writer,i=n.json,r=n.extensionsUsed,o={};t.name&&(o.name=t.name),o.color=t.color.toArray(),o.intensity=t.intensity,t.isDirectionalLight?o.type="directional":t.isPointLight?(o.type="point",t.distance>0&&(o.range=t.distance)):t.isSpotLight&&(o.type="spot",t.distance>0&&(o.range=t.distance),o.spot={},o.spot.innerConeAngle=(1-t.penumbra)*t.angle,o.spot.outerConeAngle=t.angle),t.decay!==void 0&&t.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),t.target&&(t.target.parent!==t||t.target.position.x!==0||t.target.position.y!==0||t.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);let a=i.extensions[this.name].lights;a.push(o),e.extensions=e.extensions||{},e.extensions[this.name]={light:a.length-1}}},Hm=class{constructor(t){this.writer=t,this.name="KHR_materials_unlit"}async writeMaterialAsync(t,e){if(!t.isMeshBasicMaterial)return;let i=this.writer.extensionsUsed;e.extensions=e.extensions||{},e.extensions[this.name]={},i[this.name]=!0,e.pbrMetallicRoughness.metallicFactor=0,e.pbrMetallicRoughness.roughnessFactor=.9}},Vm=class{constructor(t){this.writer=t,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.clearcoat===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=t.clearcoat,t.clearcoatMap){let o={index:await n.processTextureAsync(t.clearcoatMap),texCoord:t.clearcoatMap.channel};n.applyTextureTransform(o,t.clearcoatMap),r.clearcoatTexture=o}if(r.clearcoatRoughnessFactor=t.clearcoatRoughness,t.clearcoatRoughnessMap){let o={index:await n.processTextureAsync(t.clearcoatRoughnessMap),texCoord:t.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,t.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=o}if(t.clearcoatNormalMap){let o={index:await n.processTextureAsync(t.clearcoatNormalMap),texCoord:t.clearcoatNormalMap.channel};t.clearcoatNormalScale.x!==1&&(o.scale=t.clearcoatNormalScale.x),n.applyTextureTransform(o,t.clearcoatNormalMap),r.clearcoatNormalTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Gm=class{constructor(t){this.writer=t,this.name="KHR_materials_dispersion"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.dispersion===0)return;let i=this.writer.extensionsUsed,r={};r.dispersion=t.dispersion,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Wm=class{constructor(t){this.writer=t,this.name="KHR_materials_iridescence"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.iridescence===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=t.iridescence,t.iridescenceMap){let o={index:await n.processTextureAsync(t.iridescenceMap),texCoord:t.iridescenceMap.channel};n.applyTextureTransform(o,t.iridescenceMap),r.iridescenceTexture=o}if(r.iridescenceIor=t.iridescenceIOR,r.iridescenceThicknessMinimum=t.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=t.iridescenceThicknessRange[1],t.iridescenceThicknessMap){let o={index:await n.processTextureAsync(t.iridescenceThicknessMap),texCoord:t.iridescenceThicknessMap.channel};n.applyTextureTransform(o,t.iridescenceThicknessMap),r.iridescenceThicknessTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Xm=class{constructor(t){this.writer=t,this.name="KHR_materials_transmission"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=t.transmission,t.transmissionMap){let o={index:await n.processTextureAsync(t.transmissionMap),texCoord:t.transmissionMap.channel};n.applyTextureTransform(o,t.transmissionMap),r.transmissionTexture=o}e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},qm=class{constructor(t){this.writer=t,this.name="KHR_materials_volume"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.transmission===0)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=t.thickness,t.thicknessMap){let o={index:await n.processTextureAsync(t.thicknessMap),texCoord:t.thicknessMap.channel};n.applyTextureTransform(o,t.thicknessMap),r.thicknessTexture=o}t.attenuationDistance!==1/0&&(r.attenuationDistance=t.attenuationDistance),r.attenuationColor=t.attenuationColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Ym=class{constructor(t){this.writer=t,this.name="KHR_materials_ior"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.ior===1.5)return;let i=this.writer.extensionsUsed,r={};r.ior=t.ior,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},$m=class{constructor(t){this.writer=t,this.name="KHR_materials_specular"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.specularIntensity===1&&t.specularColor.equals(QA)&&!t.specularIntensityMap&&!t.specularColorMap)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.specularIntensityMap){let o={index:await n.processTextureAsync(t.specularIntensityMap),texCoord:t.specularIntensityMap.channel};n.applyTextureTransform(o,t.specularIntensityMap),r.specularTexture=o}if(t.specularColorMap){let o={index:await n.processTextureAsync(t.specularColorMap),texCoord:t.specularColorMap.channel};n.applyTextureTransform(o,t.specularColorMap),r.specularColorTexture=o}r.specularFactor=t.specularIntensity,r.specularColorFactor=t.specularColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Km=class{constructor(t){this.writer=t,this.name="KHR_materials_sheen"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.sheen==0)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.sheenRoughnessMap){let o={index:await n.processTextureAsync(t.sheenRoughnessMap),texCoord:t.sheenRoughnessMap.channel};n.applyTextureTransform(o,t.sheenRoughnessMap),r.sheenRoughnessTexture=o}if(t.sheenColorMap){let o={index:await n.processTextureAsync(t.sheenColorMap),texCoord:t.sheenColorMap.channel};n.applyTextureTransform(o,t.sheenColorMap),r.sheenColorTexture=o}r.sheenRoughnessFactor=t.sheenRoughness,r.sheenColorFactor=t.sheenColor.toArray(),e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Zm=class{constructor(t){this.writer=t,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(t,e){if(!t.isMeshPhysicalMaterial||t.anisotropy==0)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.anisotropyMap){let o={index:await n.processTextureAsync(t.anisotropyMap)};n.applyTextureTransform(o,t.anisotropyMap),r.anisotropyTexture=o}r.anisotropyStrength=t.anisotropy,r.anisotropyRotation=t.anisotropyRotation,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Jm=class{constructor(t){this.writer=t,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||t.emissiveIntensity===1)return;let i=this.writer.extensionsUsed,r={};r.emissiveStrength=t.emissiveIntensity,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},jm=class{constructor(t){this.writer=t,this.name="EXT_materials_bump"}async writeMaterialAsync(t,e){if(!t.isMeshStandardMaterial||t.bumpScale===1&&!t.bumpMap)return;let n=this.writer,i=n.extensionsUsed,r={};if(t.bumpMap){let o={index:await n.processTextureAsync(t.bumpMap),texCoord:t.bumpMap.channel};n.applyTextureTransform(o,t.bumpMap),r.bumpTexture=o}r.bumpFactor=t.bumpScale,e.extensions=e.extensions||{},e.extensions[this.name]=r,i[this.name]=!0}},Qm=class{constructor(t){this.writer=t,this.name="EXT_mesh_gpu_instancing"}writeNode(t,e){if(!t.isInstancedMesh)return;let n=this.writer,i=t,r=new Float32Array(i.count*3),o=new Float32Array(i.count*4),a=new Float32Array(i.count*3),c=new vt,l=new I,u=new Ce,h=new I;for(let p=0;p<i.count;p++)i.getMatrixAt(p,c),c.decompose(l,u,h),l.toArray(r,p*3),u.toArray(o,p*4),h.toArray(a,p*3);let f={TRANSLATION:n.processAccessor(new kt(r,3)),ROTATION:n.processAccessor(new kt(o,4)),SCALE:n.processAccessor(new kt(a,3))};i.instanceColor&&(f._COLOR_0=n.processAccessor(i.instanceColor)),e.extensions=e.extensions||{},e.extensions[this.name]={attributes:f},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};Us.Utils={insertKeyframe:function(s,t){let n=s.getValueSize(),i=new s.TimeBufferType(s.times.length+1),r=new s.ValueBufferType(s.values.length+n),o=s.createInterpolant(new s.ValueBufferType(n)),a;if(s.times.length===0){i[0]=t;for(let c=0;c<n;c++)r[c]=0;a=0}else if(t<s.times[0]){if(Math.abs(s.times[0]-t)<.001)return 0;i[0]=t,i.set(s.times,1),r.set(o.evaluate(t),0),r.set(s.values,n),a=0}else if(t>s.times[s.times.length-1]){if(Math.abs(s.times[s.times.length-1]-t)<.001)return s.times.length-1;i[i.length-1]=t,i.set(s.times,0),r.set(s.values,0),r.set(o.evaluate(t),s.values.length),a=i.length-1}else for(let c=0;c<s.times.length;c++){if(Math.abs(s.times[c]-t)<.001)return c;if(s.times[c]<t&&s.times[c+1]>t){i.set(s.times.slice(0,c+1),0),i[c+1]=t,i.set(s.times.slice(c+1),c+2),r.set(s.values.slice(0,(c+1)*n),0),r.set(o.evaluate(t),(c+1)*n),r.set(s.values.slice((c+1)*n),(c+2)*n),a=c+1;break}}return s.times=i,s.values=r,a},mergeMorphTargetTracks:function(s,t){let e=[],n={},i=s.tracks;for(let r=0;r<i.length;++r){let o=i[r],a=ee.parseTrackName(o.name),c=ee.findNode(t,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){e.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(Di)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[a.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let h;if(n[c.uuid]===void 0){h=o.clone();let p=new h.ValueBufferType(l*h.times.length);for(let x=0;x<h.times.length;x++)p[x*l+u]=h.values[x];h.name=(a.nodeName||"")+".morphTargetInfluences",h.values=p,n[c.uuid]=h,e.push(h);continue}let f=o.createInterpolant(new o.ValueBufferType(1));h=n[c.uuid];for(let p=0;p<h.times.length;p++)h.values[p*l+u]=f.evaluate(h.times[p]);for(let p=0;p<o.times.length;p++){let x=this.insertKeyframe(h,o.times[p]);h.values[x*l+u]=o.values[p]}}return s.tracks=e,s},toFloat32BufferAttribute:function(s){let t=new kt(new Float32Array(s.count*s.itemSize),s.itemSize,!1);if(!s.normalized&&!s.isInterleavedBufferAttribute)return t.array.set(s.array),t;for(let e=0,n=s.count;e<n;e++)for(let i=0;i<s.itemSize;i++)t.setComponent(e,i,s.getComponent(e,i));return t}};function tg(s,t=!1){let e=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,c=new Vt,l=0;for(let u=0;u<s.length;++u){let h=s[u],f=0;if(e!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(let p in h.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;r[p]===void 0&&(r[p]=[]),r[p].push(h.attributes[p]),f++}if(f!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(let p in h.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(h.morphAttributes[p])}if(t){let p;if(e)p=h.index.count;else if(h.attributes.position!==void 0)p=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;c.addGroup(l,p,u),l+=p}}if(e){let u=0,h=[];for(let f=0;f<s.length;++f){let p=s[f].index;for(let x=0;x<p.count;++x)h.push(p.getX(x)+u);u+=s[f].attributes.position.count}c.setIndex(h)}for(let u in r){let h=xy(r[u]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;c.setAttribute(u,h)}for(let u in o){let h=o[u][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[u]=[];for(let f=0;f<h;++f){let p=[];for(let v=0;v<o[u].length;++v)p.push(o[u][v][f]);let x=xy(p);if(!x)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;c.morphAttributes[u].push(x)}}return c}function xy(s){let t,e,n,i=-1,r=0;for(let l=0;l<s.length;++l){let u=s[l];if(t===void 0&&(t=u.array.constructor),t!==u.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(e===void 0&&(e=u.itemSize),e!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=u.normalized),n!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=u.count*e}let o=new t(r),a=new kt(o,e,n),c=0;for(let l=0;l<s.length;++l){let u=s[l];if(u.isInterleavedBufferAttribute){let h=c/e;for(let f=0,p=u.count;f<p;f++)for(let x=0;x<e;x++){let v=u.getComponent(f,x);a.setComponent(f+h,x,v)}}else o.set(u.array,c);c+=u.count*e}return i!==void 0&&(a.gpuType=i),a}function eg(s,t=1e-4){t=Math.max(t,Number.EPSILON);let e={},n=s.getIndex(),i=s.getAttribute("position"),r=n?n.count:i.count,o=0,a=Object.keys(s.attributes),c={},l={},u=[],h=["getX","getY","getZ","getW"],f=["setX","setY","setZ","setW"];for(let S=0,g=a.length;S<g;S++){let d=a[S],M=s.attributes[d];c[d]=new M.constructor(new M.array.constructor(M.count*M.itemSize),M.itemSize,M.normalized);let m=s.morphAttributes[d];m&&(l[d]||(l[d]=[]),m.forEach((R,E)=>{let T=new R.array.constructor(R.count*R.itemSize);l[d][E]=new R.constructor(T,R.itemSize,R.normalized)}))}let p=t*.5,x=Math.log10(1/t),v=Math.pow(10,x),y=p*v;for(let S=0;S<r;S++){let g=n?n.getX(S):S,d="";for(let M=0,m=a.length;M<m;M++){let R=a[M],E=s.getAttribute(R),T=E.itemSize;for(let b=0;b<T;b++)d+=`${~~(E[h[b]](g)*v+y)},`}if(d in e)u.push(e[d]);else{for(let M=0,m=a.length;M<m;M++){let R=a[M],E=s.getAttribute(R),T=s.morphAttributes[R],b=E.itemSize,w=c[R],A=l[R];for(let C=0;C<b;C++){let D=h[C],F=f[C];if(w[F](o,E[D](g)),T)for(let O=0,H=T.length;O<H;O++)A[O][F](o,T[O][D](g))}}e[d]=o,u.push(o),o++}}let _=s.clone();for(let S in s.attributes){let g=c[S];if(_.setAttribute(S,new g.constructor(g.array.slice(0,o*g.itemSize),g.itemSize,g.normalized)),S in l)for(let d=0;d<l[S].length;d++){let M=l[S][d];_.morphAttributes[S][d]=new M.constructor(M.array.slice(0,o*M.itemSize),M.itemSize,M.normalized)}}return _.setIndex(u),_}function ng(s,t){if(t===yf)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(t===Cs||t===ta){let e=s.getIndex();if(e===null){let o=[],a=s.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);s.setIndex(o),e=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}let n=e.count-2,i=[];if(t===Cs)for(let o=1;o<=n;o++)i.push(e.getX(0)),i.push(e.getX(o)),i.push(e.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(e.getX(o)),i.push(e.getX(o+1)),i.push(e.getX(o+2))):(i.push(e.getX(o+2)),i.push(e.getX(o+1)),i.push(e.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),s}var Af=class extends Ke{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new lg(e)}),this.register(function(e){return new ug(e)}),this.register(function(e){return new yg(e)}),this.register(function(e){return new vg(e)}),this.register(function(e){return new Mg(e)}),this.register(function(e){return new fg(e)}),this.register(function(e){return new dg(e)}),this.register(function(e){return new pg(e)}),this.register(function(e){return new mg(e)}),this.register(function(e){return new cg(e)}),this.register(function(e){return new gg(e)}),this.register(function(e){return new hg(e)}),this.register(function(e){return new _g(e)}),this.register(function(e){return new xg(e)}),this.register(function(e){return new og(e)}),this.register(function(e){return new Sg(e)}),this.register(function(e){return new bg(e)})}load(t,e,n,i){let r=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=ii.extractUrlBase(t);o=ii.resolveURL(l,this.path)}else o=ii.extractUrlBase(t);this.manager.itemStart(t);let a=function(l){i?i(l):console.error(l),r.manager.itemError(t),r.manager.itemEnd(t)},c=new Mn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(t,function(l){try{r.parse(l,o,function(u){e(u),r.manager.itemEnd(t)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r,o={},a={},c=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(c.decode(new Uint8Array(t,0,4))===Sy){try{o[oe.KHR_BINARY_GLTF]=new Tg(t)}catch(h){i&&i(h);return}r=JSON.parse(o[oe.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new Pg(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){let h=r.extensionsUsed[u],f=r.extensionsRequired||[];switch(h){case oe.KHR_MATERIALS_UNLIT:o[h]=new ag;break;case oe.KHR_DRACO_MESH_COMPRESSION:o[h]=new Eg(r,this.dracoLoader);break;case oe.KHR_TEXTURE_TRANSFORM:o[h]=new wg;break;case oe.KHR_MESH_QUANTIZATION:o[h]=new Ag;break;default:f.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){let n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}};function c1(){let s={};return{get:function(t){return s[t]},add:function(t,e){s[t]=e},remove:function(t){delete s[t]},removeAll:function(){s={}}}}var oe={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},og=class{constructor(t){this.parser=t,this.name=oe.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){let r=e[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){let e=this.parser,n="light:"+t,i=e.cache.get(n);if(i)return i;let r=e.json,c=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t],l,u=new yt(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],tn);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new lr(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new Ss(u),l.distance=h;break;case"spot":l=new Ms(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),$i(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=e.createUniqueName(c.name||"light_"+t),i=Promise.resolve(l),e.cache.add(n,i),i}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){let e=this,n=this.parser,r=n.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(e.cache,a,c)})}},ag=class{constructor(){this.name=oe.KHR_MATERIALS_UNLIT}getMaterialType(){return sn}extendParams(t,e,n){let i=[];t.color=new yt(1,1,1),t.opacity=1;let r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){let o=r.baseColorFactor;t.color.setRGB(o[0],o[1],o[2],tn),t.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(t,"map",r.baseColorTexture,Ae))}return Promise.all(i)}},cg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(e.emissiveIntensity=r),Promise.resolve()}},lg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(e.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(e,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new nt(a,a)}return Promise.all(r)}},ug=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_DISPERSION}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return e.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}},hg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(e.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(e.iridescenceIOR=o.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}},fg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_SHEEN}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[];e.sheenColor=new yt(0,0,0),e.sheenRoughness=0,e.sheen=1;let o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],tn)}return o.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(n.assignTexture(e,"sheenColorMap",o.sheenColorTexture,Ae)),o.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}},dg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(e.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(n.assignTexture(e,"transmissionMap",o.transmissionTexture)),Promise.all(r)}},pg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_VOLUME}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];e.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(n.assignTexture(e,"thicknessMap",o.thicknessTexture)),e.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return e.attenuationColor=new yt().setRGB(a[0],a[1],a[2],tn),Promise.all(r)}},mg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_IOR}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=i.extensions[this.name];return e.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}},gg=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_SPECULAR}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];e.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(n.assignTexture(e,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return e.specularColor=new yt().setRGB(a[0],a[1],a[2],tn),o.specularColorTexture!==void 0&&r.push(n.assignTexture(e,"specularColorMap",o.specularColorTexture,Ae)),Promise.all(r)}},xg=class{constructor(t){this.parser=t,this.name=oe.EXT_MATERIALS_BUMP}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return e.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(n.assignTexture(e,"bumpMap",o.bumpTexture)),Promise.all(r)}},_g=class{constructor(t){this.parser=t,this.name=oe.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){let n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:ln}extendMaterialParams(t,e){let n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();let r=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(e.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(e.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&r.push(n.assignTexture(e,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}},yg=class{constructor(t){this.parser=t,this.name=oe.KHR_TEXTURE_BASISU}loadTexture(t){let e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;let r=i.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,o)}},vg=class{constructor(t){this.parser=t,this.name=oe.EXT_TEXTURE_WEBP}loadTexture(t){let e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;let o=r.extensions[e],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(t,o.source,c)}},Mg=class{constructor(t){this.parser=t,this.name=oe.EXT_TEXTURE_AVIF}loadTexture(t){let e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;let o=r.extensions[e],a=i.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return n.loadTextureImage(t,o.source,c)}},Sg=class{constructor(t){this.name=oe.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){let e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){let i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){let c=i.byteOffset||0,l=i.byteLength||0,u=i.count,h=i.byteStride,f=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){let p=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(p),u,h,f,i.mode,i.filter),p})})}else return null}},bg=class{constructor(t){this.name=oe.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){let e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let i=e.meshes[n.mesh];for(let l of i.primitives)if(l.mode!==oi.TRIANGLES&&l.mode!==oi.TRIANGLE_STRIP&&l.mode!==oi.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],f=l[0].count,p=[];for(let x of h){let v=new vt,y=new I,_=new Ce,S=new I(1,1,1),g=new ei(x.geometry,x.material,f);for(let d=0;d<f;d++)c.TRANSLATION&&y.fromBufferAttribute(c.TRANSLATION,d),c.ROTATION&&_.fromBufferAttribute(c.ROTATION,d),c.SCALE&&S.fromBufferAttribute(c.SCALE,d),g.setMatrixAt(d,v.compose(y,_,S));for(let d in c)if(d==="_COLOR_0"){let M=c[d];g.instanceColor=new ti(M.array,M.itemSize,M.normalized)}else d!=="TRANSLATION"&&d!=="ROTATION"&&d!=="SCALE"&&x.geometry.setAttribute(d,c[d]);re.prototype.copy.call(g,x),this.parser.assignFinalMaterial(g),p.push(g)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}},Sy="glTF",Wl=12,_y={JSON:1313821514,BIN:5130562},Tg=class{constructor(t){this.name=oe.KHR_BINARY_GLTF,this.content=null,this.body=null;let e=new DataView(t,0,Wl),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Sy)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let i=this.header.length-Wl,r=new DataView(t,Wl),o=0;for(;o<i;){let a=r.getUint32(o,!0);o+=4;let c=r.getUint32(o,!0);if(o+=4,c===_y.JSON){let l=new Uint8Array(t,Wl+o,a);this.content=n.decode(l)}else if(c===_y.BIN){let l=Wl+o;this.body=t.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Eg=class{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=oe.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){let n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=Cg[u]||u.toLowerCase();a[h]=o[u]}for(let u in t.attributes){let h=Cg[u]||u.toLowerCase();if(o[u]!==void 0){let f=n.accessors[t.attributes[u]],p=sa[f.componentType];l[h]=p.name,c[h]=f.normalized===!0}}return e.getDependency("bufferView",r).then(function(u){return new Promise(function(h,f){i.decodeDracoFile(u,function(p){for(let x in p.attributes){let v=p.attributes[x],y=c[x];y!==void 0&&(v.normalized=y)}h(p)},a,l,tn,f)})})}},wg=class{constructor(){this.name=oe.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}},Ag=class{constructor(){this.name=oe.KHR_MESH_QUANTIZATION}},Rf=class extends Bi{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){let e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let o=0;o!==i;o++)e[o]=n[r+o];return e}interpolate_(t,e,n,i){let r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=i-e,h=(n-e)/u,f=h*h,p=f*h,x=t*l,v=x-l,y=-2*p+3*f,_=p-f,S=1-y,g=_-f+h;for(let d=0;d!==a;d++){let M=o[v+d+a],m=o[v+d+c]*u,R=o[x+d+a],E=o[x+d]*u;r[d]=S*M+g*m+y*R+_*E}return r}},l1=new Ce,Rg=class extends Rf{interpolate_(t,e,n,i){let r=super.interpolate_(t,e,n,i);return l1.fromArray(r).normalize().toArray(r),r}},oi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},sa={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},yy={9728:De,9729:Ee,9984:Nr,9985:Xi,9986:Mi,9987:un},vy={33071:en,33648:Li,10497:An},ig={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Cg={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Dr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},u1={CUBICSPLINE:void 0,LINEAR:Di,STEP:Ni},rg={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function h1(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new xi({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:rn})),s.DefaultMaterial}function Fs(s,t,e){for(let n in e.extensions)s[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function $i(s,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(s.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function f1(s,t,e){let n=!1,i=!1,r=!1;for(let l=0,u=t.length;l<u;l++){let h=t[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(i=!0),h.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);let o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){let h=t[l];if(n){let f=h.POSITION!==void 0?e.getDependency("accessor",h.POSITION):s.attributes.position;o.push(f)}if(i){let f=h.NORMAL!==void 0?e.getDependency("accessor",h.NORMAL):s.attributes.normal;a.push(f)}if(r){let f=h.COLOR_0!==void 0?e.getDependency("accessor",h.COLOR_0):s.attributes.color;c.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],f=l[2];return n&&(s.morphAttributes.position=u),i&&(s.morphAttributes.normal=h),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function d1(s,t){if(s.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)s.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){let e=t.extras.targetNames;if(s.morphTargetInfluences.length===e.length){s.morphTargetDictionary={};for(let n=0,i=e.length;n<i;n++)s.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function p1(s){let t,e=s.extensions&&s.extensions[oe.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+sg(e.attributes):t=s.indices+":"+sg(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)t+=":"+sg(s.targets[n]);return t}function sg(s){let t="",e=Object.keys(s).sort();for(let n=0,i=e.length;n<i;n++)t+=e[n]+":"+s[e[n]]+";";return t}function Ig(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function m1(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var g1=new vt,Pg=class{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new c1,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,r=!1,o=-1;if(typeof navigator<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);i=n&&c?parseInt(c[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new Vo(this.options.manager):this.textureLoader=new Go(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Mn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return Fs(r,a,i),$i(a,i),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){let t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=e.length;i<r;i++){let o=e[i].joints;for(let a=0,c=o.length;a<c;a++)t[o[a]].isBone=!0}for(let i=0,r=t.length;i<r;i++){let o=t[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;let i=n.clone(),r=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())r(u,a.children[l])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){let e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){let i=t(e[n]);if(i)return i}return null}_invokeAll(t){let e=Object.values(this.plugins);e.unshift(this);let n=[];for(let i=0;i<e.length;i++){let r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){let n=t+":"+e,i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t);break}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){let n=this,i=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(i.map(function(r,o){return n.getDependency(t,o)})),this.cache.add(t,e)}return e}loadBuffer(t){let e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[oe.KHR_BINARY_GLTF].body);let i=this.options;return new Promise(function(r,o){n.load(ii.resolveURL(e.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){let e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){let i=e.byteLength||0,r=e.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(t){let e=this,n=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){let o=ig[i.type],a=sa[i.componentType],c=i.normalized===!0,l=new a(i.count*o);return Promise.resolve(new kt(l,o,c))}let r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){let a=o[0],c=ig[i.type],l=sa[i.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,f=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,x=i.normalized===!0,v,y;if(p&&p!==h){let _=Math.floor(f/p),S="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+_+":"+i.count,g=e.cache.get(S);g||(v=new l(a,_*p,i.count*p/u),g=new Oi(v,p/u),e.cache.add(S,g)),y=new pi(g,c,f%p/u,x)}else a===null?v=new l(i.count*c):v=new l(a,f,i.count*c),y=new kt(v,c,x);if(i.sparse!==void 0){let _=ig.SCALAR,S=sa[i.sparse.indices.componentType],g=i.sparse.indices.byteOffset||0,d=i.sparse.values.byteOffset||0,M=new S(o[1],g,i.sparse.count*_),m=new l(o[2],d,i.sparse.count*c);a!==null&&(y=new kt(y.array.slice(),y.itemSize,y.normalized)),y.normalized=!1;for(let R=0,E=M.length;R<E;R++){let T=M[R];if(y.setX(T,m[R*c]),c>=2&&y.setY(T,m[R*c+1]),c>=3&&y.setZ(T,m[R*c+2]),c>=4&&y.setW(T,m[R*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}y.normalized=x}return y})}loadTexture(t){let e=this.json,n=this.options,r=e.textures[t].source,o=e.images[r],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,n){let i=this,r=this.json,o=r.textures[t],a=r.images[e],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(e,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(r.samplers||{})[o.sampler]||{};return u.magFilter=yy[f.magFilter]||Ee,u.minFilter=yy[f.minFilter]||un,u.wrapS=vy[f.wrapS]||An,u.wrapT=vy[f.wrapT]||An,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==De&&u.minFilter!==Ee,i.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(t,e){let n=this,i=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(h=>h.clone());let o=i.images[t],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let f=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(f),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(f,p){let x=f;e.isImageBitmapLoader===!0&&(x=function(v){let y=new Ie(v);y.needsUpdate=!0,f(y)}),e.load(ii.resolveURL(h,r.path),x,void 0,p)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),$i(h,o),h.userData.mimeType=o.mimeType||m1(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[t]=u,u}assignTexture(t,e,n,i){let r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[oe.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[oe.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=r.associations.get(o);o=r.extensions[oe.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,c)}}return i!==void 0&&(o.colorSpace=i),t[e]=o,o})}assignFinalMaterial(t){let e=t.geometry,n=t.material,i=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,o=e.attributes.normal===void 0;if(t.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Ir,Ue.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(t.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Xe,Ue.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),r&&(c.vertexColors=!0),o&&(c.flatShading=!0),i&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}t.material=n}getMaterialType(){return xi}loadMaterial(t){let e=this,n=this.json,i=this.extensions,r=n.materials[t],o,a={},c=r.extensions||{},l=[];if(c[oe.KHR_MATERIALS_UNLIT]){let h=i[oe.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,r,e))}else{let h=r.pbrMetallicRoughness||{};if(a.color=new yt(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],tn),a.opacity=f[3]}h.baseColorTexture!==void 0&&l.push(e.assignTexture(a,"map",h.baseColorTexture,Ae)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(e.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(e.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),l.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=Ve);let u=r.alphaMode||rg.OPAQUE;if(u===rg.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===rg.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==sn&&(l.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new nt(1,1),r.normalTexture.scale!==void 0)){let h=r.normalTexture.scale;a.normalScale.set(h,h)}if(r.occlusionTexture!==void 0&&o!==sn&&(l.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==sn){let h=r.emissiveFactor;a.emissive=new yt().setRGB(h[0],h[1],h[2],tn)}return r.emissiveTexture!==void 0&&o!==sn&&l.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Ae)),Promise.all(l).then(function(){let h=new o(a);return r.name&&(h.name=r.name),$i(h,r),e.associations.set(h,{materials:t}),r.extensions&&Fs(i,h,r),h})}createUniqueName(t){let e=ee.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){let e=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[oe.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(c){return My(c,a,e)})}let o=[];for(let a=0,c=t.length;a<c;a++){let l=t[a],u=p1(l),h=i[u];if(h)o.push(h.promise);else{let f;l.extensions&&l.extensions[oe.KHR_DRACO_MESH_COMPRESSION]?f=r(l):f=My(new Vt,l,e),i[u]={primitive:l,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(t){let e=this,n=this.json,i=this.extensions,r=n.meshes[t],o=r.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?h1(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(e.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let p=0,x=u.length;p<x;p++){let v=u[p],y=o[p],_,S=l[p];if(y.mode===oi.TRIANGLES||y.mode===oi.TRIANGLE_STRIP||y.mode===oi.TRIANGLE_FAN||y.mode===void 0)_=r.isSkinnedMesh===!0?new mi(v,S):new ce(v,S),_.isSkinnedMesh===!0&&_.normalizeSkinWeights(),y.mode===oi.TRIANGLE_STRIP?_.geometry=ng(_.geometry,ta):y.mode===oi.TRIANGLE_FAN&&(_.geometry=ng(_.geometry,Cs));else if(y.mode===oi.LINES)_=new yn(v,S);else if(y.mode===oi.LINE_STRIP)_=new Vn(v,S);else if(y.mode===oi.LINE_LOOP)_=new ps(v,S);else if(y.mode===oi.POINTS)_=new ms(v,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(_.geometry.morphAttributes).length>0&&d1(_,r),_.name=e.createUniqueName(r.name||"mesh_"+t),$i(_,r),y.extensions&&Fs(i,_,y),e.assignFinalMaterial(_),h.push(_)}for(let p=0,x=h.length;p<x;p++)e.associations.set(h[p],{meshes:t,primitives:p});if(h.length===1)return r.extensions&&Fs(i,h[0],r),h[0];let f=new nn;r.extensions&&Fs(i,f,r),e.associations.set(f,{meshes:t});for(let p=0,x=h.length;p<x;p++)f.add(h[p]);return f})}loadCamera(t){let e,n=this.json.cameras[t],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new Re(Yi.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(e=new cr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),$i(e,n),Promise.resolve(e)}loadSkin(t){let e=this.json.skins[t],n=[];for(let i=0,r=e.joints.length;i<r;i++)n.push(this._loadNodeShallow(e.joints[i]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){let r=i.pop(),o=i,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let f=new vt;r!==null&&f.fromArray(r.array,l*16),c.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[l])}return new ds(a,c)})}loadAnimation(t){let e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,o=[],a=[],c=[],l=[],u=[];for(let h=0,f=i.channels.length;h<f;h++){let p=i.channels[h],x=i.samplers[p.sampler],v=p.target,y=v.node,_=i.parameters!==void 0?i.parameters[x.input]:x.input,S=i.parameters!==void 0?i.parameters[x.output]:x.output;v.node!==void 0&&(o.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",_)),c.push(this.getDependency("accessor",S)),l.push(x),u.push(v))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let f=h[0],p=h[1],x=h[2],v=h[3],y=h[4],_=[];for(let g=0,d=f.length;g<d;g++){let M=f[g],m=p[g],R=x[g],E=v[g],T=y[g];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();let b=n._createAnimationTracks(M,m,R,E,T);if(b)for(let w=0;w<b.length;w++)_.push(b[w])}let S=new ni(r,void 0,_);return $i(S,i),S})}createNodeMesh(t){let e=this.json,n=this,i=e.nodes[t];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){let o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=i.weights.length;c<l;c++)a.morphTargetInfluences[c]=i.weights[c]}),o})}loadNode(t){let e=this.json,n=this,i=e.nodes[t],r=n._loadNodeShallow(t),o=[],a=i.children||[];for(let l=0,u=a.length;l<u;l++)o.push(n.getDependency("node",a[l]));let c=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],f=l[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,g1)});for(let p=0,x=h.length;p<x;p++)u.add(h[p]);return u})}_loadNodeShallow(t){let e=this.json,n=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];let r=e.nodes[t],o=r.name?i.createUniqueName(r.name):"",a=[],c=i._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(t)});return c&&a.push(c),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(l){return i._getNodeRef(i.cameraCache,r.camera,l)})),i._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(t)}).forEach(function(l){a.push(l)}),this.nodeCache[t]=Promise.all(a).then(function(l){let u;if(r.isBone===!0?u=new Cr:l.length>1?u=new nn:l.length===1?u=l[0]:u=new re,u!==l[0])for(let h=0,f=l.length;h<f;h++)u.add(l[h]);if(r.name&&(u.userData.name=r.name,u.name=o),$i(u,r),r.extensions&&Fs(n,u,r),r.matrix!==void 0){let h=new vt;h.fromArray(r.matrix),u.applyMatrix4(h)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){let h=i.associations.get(u);i.associations.set(u,{...h})}return i.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){let e=this.extensions,n=this.json.scenes[t],i=this,r=new nn;n.name&&(r.name=i.createUniqueName(n.name)),$i(r,n),n.extensions&&Fs(e,r,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(i.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)r.add(c[u]);let l=u=>{let h=new Map;for(let[f,p]of i.associations)(f instanceof Ue||f instanceof Ie)&&h.set(f,p);return u.traverse(f=>{let p=i.associations.get(f);p!=null&&h.set(f,p)}),h};return i.associations=l(r),r})}_createAnimationTracks(t,e,n,i,r){let o=[],a=t.name?t.name:t.uuid,c=[];Dr[r.path]===Dr.weights?t.traverse(function(f){f.morphTargetInfluences&&c.push(f.name?f.name:f.uuid)}):c.push(a);let l;switch(Dr[r.path]){case Dr.weights:l=_i;break;case Dr.rotation:l=Gn;break;case Dr.translation:case Dr.scale:l=Wn;break;default:switch(n.itemSize){case 1:l=_i;break;case 2:case 3:default:l=Wn;break}break}let u=i.interpolation!==void 0?u1[i.interpolation]:Di,h=this._getArrayFromAccessor(n);for(let f=0,p=c.length;f<p;f++){let x=new l(c[f]+"."+Dr[r.path],e.array,h,u);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(x),o.push(x)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){let n=Ig(e.constructor),i=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r++)i[r]=e[r]*n;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){let i=this instanceof Gn?Rg:Rf;return new i(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function x1(s,t,e){let n=t.attributes,i=new ne;if(n.POSITION!==void 0){let a=e.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(i.set(new I(c[0],c[1],c[2]),new I(l[0],l[1],l[2])),a.normalized){let u=Ig(sa[a.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let r=t.targets;if(r!==void 0){let a=new I,c=new I;for(let l=0,u=r.length;l<u;l++){let h=r[l];if(h.POSITION!==void 0){let f=e.json.accessors[h.POSITION],p=f.min,x=f.max;if(p!==void 0&&x!==void 0){if(c.setX(Math.max(Math.abs(p[0]),Math.abs(x[0]))),c.setY(Math.max(Math.abs(p[1]),Math.abs(x[1]))),c.setZ(Math.max(Math.abs(p[2]),Math.abs(x[2]))),f.normalized){let v=Ig(sa[f.componentType]);c.multiplyScalar(v)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;let o=new Be;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function My(s,t,e){let n=t.attributes,i=[];function r(o,a){return e.getDependency("accessor",o).then(function(c){s.setAttribute(a,c)})}for(let o in n){let a=Cg[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(t.indices!==void 0&&!s.index){let o=e.getDependency("accessor",t.indices).then(function(a){s.setIndex(a)});i.push(o)}return ie.workingColorSpace!==tn&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${ie.workingColorSpace}" not supported.`),$i(s,t),x1(s,t,e),Promise.all(i).then(function(){return t.targets!==void 0?f1(s,t.targets,e):s})}var Xl=new I;function ai(s,t,e,n,i,r){let o=2*Math.PI*i/4,a=Math.max(r-2*i,0),c=Math.PI/4;Xl.copy(t),Xl[n]=0,Xl.normalize();let l=.5*o/(o+a),u=1-Xl.angleTo(s)/c;return Math.sign(Xl[e])===1?u*l:a/(o+a)+l+l*(1-u)}var Cf=class s extends Ui{constructor(t=1,e=1,n=1,i=2,r=.1){let o=i*2+1;if(r=Math.min(t/2,e/2,n/2,r),super(1,1,1,o,o,o),this.type="RoundedBoxGeometry",this.parameters={width:t,height:e,depth:n,segments:i,radius:r},o===1)return;let a=this.toNonIndexed();this.index=null,this.attributes.position=a.attributes.position,this.attributes.normal=a.attributes.normal,this.attributes.uv=a.attributes.uv;let c=new I,l=new I,u=new I(t,e,n).divideScalar(2).subScalar(r),h=this.attributes.position.array,f=this.attributes.normal.array,p=this.attributes.uv.array,x=h.length/6,v=new I,y=.5/o;for(let _=0,S=0;_<h.length;_+=3,S+=2)switch(c.fromArray(h,_),l.copy(c),l.x-=Math.sign(l.x)*y,l.y-=Math.sign(l.y)*y,l.z-=Math.sign(l.z)*y,l.normalize(),h[_+0]=u.x*Math.sign(c.x)+l.x*r,h[_+1]=u.y*Math.sign(c.y)+l.y*r,h[_+2]=u.z*Math.sign(c.z)+l.z*r,f[_+0]=l.x,f[_+1]=l.y,f[_+2]=l.z,Math.floor(_/x)){case 0:v.set(1,0,0),p[S+0]=ai(v,l,"z","y",r,n),p[S+1]=1-ai(v,l,"y","z",r,e);break;case 1:v.set(-1,0,0),p[S+0]=1-ai(v,l,"z","y",r,n),p[S+1]=1-ai(v,l,"y","z",r,e);break;case 2:v.set(0,1,0),p[S+0]=1-ai(v,l,"x","z",r,t),p[S+1]=ai(v,l,"z","x",r,n);break;case 3:v.set(0,-1,0),p[S+0]=1-ai(v,l,"x","z",r,t),p[S+1]=1-ai(v,l,"z","x",r,n);break;case 4:v.set(0,0,1),p[S+0]=1-ai(v,l,"x","y",r,t),p[S+1]=1-ai(v,l,"y","x",r,e);break;case 5:v.set(0,0,-1),p[S+0]=ai(v,l,"x","y",r,t),p[S+1]=1-ai(v,l,"y","x",r,e);break}}static fromJSON(t){return new s(t.width,t.height,t.depth,t.segments,t.radius)}};var oa=Math.pow(2,-24),ql=Symbol("SKIP_GENERATION"),If={strategy:0,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[ql]:!1};function Se(s,t,e){return e.min.x=t[s],e.min.y=t[s+1],e.min.z=t[s+2],e.max.x=t[s+3],e.max.y=t[s+4],e.max.z=t[s+5],e}function Yl(s){let t=-1,e=-1/0;for(let n=0;n<3;n++){let i=s[n+3]-s[n];i>e&&(e=i,t=n)}return t}function Lg(s,t){t.set(s)}function Ng(s,t,e){let n,i;for(let r=0;r<3;r++){let o=r+3;n=s[r],i=t[r],e[r]=n<i?n:i,n=s[o],i=t[o],e[o]=n>i?n:i}}function $l(s,t,e){for(let n=0;n<3;n++){let i=t[s+2*n],r=t[s+2*n+1],o=i-r,a=i+r;o<e[n]&&(e[n]=o),a>e[n+3]&&(e[n+3]=a)}}function aa(s){let t=s[3]-s[0],e=s[4]-s[1],n=s[5]-s[2];return 2*(t*e+e*n+n*t)}function le(s,t){return t[s+15]===65535}function xe(s,t){return t[s+6]}function ve(s,t){return t[s+14]}function fe(s){return s+8}function de(s,t){let e=t[s+6];return s+e*8}function ca(s,t){return t[s+7]}function Pf(s,t,e,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,u=-1/0,h=1/0,f=1/0,p=1/0,x=-1/0,v=-1/0,y=-1/0,_=s.offset||0;for(let S=(t-_)*6,g=(t+e-_)*6;S<g;S+=6){let d=s[S+0],M=s[S+1],m=d-M,R=d+M;m<r&&(r=m),R>c&&(c=R),d<h&&(h=d),d>x&&(x=d);let E=s[S+2],T=s[S+3],b=E-T,w=E+T;b<o&&(o=b),w>l&&(l=w),E<f&&(f=E),E>v&&(v=E);let A=s[S+4],C=s[S+5],D=A-C,F=A+C;D<a&&(a=D),F>u&&(u=F),A<p&&(p=A),A>y&&(y=A)}n[0]=r,n[1]=o,n[2]=a,n[3]=c,n[4]=l,n[5]=u,i[0]=h,i[1]=f,i[2]=p,i[3]=x,i[4]=v,i[5]=y}var fr=32,v1=(s,t)=>s.candidate-t.candidate,Ur=new Array(fr).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Lf=new Float32Array(6);function Ty(s,t,e,n,i,r){let o=-1,a=0;if(r===0)o=Yl(t),o!==-1&&(a=(t[o]+t[o+3])/2);else if(r===1)o=Yl(s),o!==-1&&(a=M1(e,n,i,o));else if(r===2){let c=aa(s),l=1.25*i,u=e.offset||0,h=(n-u)*6,f=(n+i-u)*6;for(let p=0;p<3;p++){let x=t[p],_=(t[p+3]-x)/fr;if(i<fr/4){let S=[...Ur];S.length=i;let g=0;for(let M=h;M<f;M+=6,g++){let m=S[g];m.candidate=e[M+2*p],m.count=0;let{bounds:R,leftCacheBounds:E,rightCacheBounds:T}=m;for(let b=0;b<3;b++)T[b]=1/0,T[b+3]=-1/0,E[b]=1/0,E[b+3]=-1/0,R[b]=1/0,R[b+3]=-1/0;$l(M,e,R)}S.sort(v1);let d=i;for(let M=0;M<d;M++){let m=S[M];for(;M+1<d&&S[M+1].candidate===m.candidate;)S.splice(M+1,1),d--}for(let M=h;M<f;M+=6){let m=e[M+2*p];for(let R=0;R<d;R++){let E=S[R];m>=E.candidate?$l(M,e,E.rightCacheBounds):($l(M,e,E.leftCacheBounds),E.count++)}}for(let M=0;M<d;M++){let m=S[M],R=m.count,E=i-m.count,T=m.leftCacheBounds,b=m.rightCacheBounds,w=0;R!==0&&(w=aa(T)/c);let A=0;E!==0&&(A=aa(b)/c);let C=1+1.25*(w*R+A*E);C<l&&(o=p,l=C,a=m.candidate)}}else{for(let d=0;d<fr;d++){let M=Ur[d];M.count=0,M.candidate=x+_+d*_;let m=M.bounds;for(let R=0;R<3;R++)m[R]=1/0,m[R+3]=-1/0}for(let d=h;d<f;d+=6){let R=~~((e[d+2*p]-x)/_);R>=fr&&(R=fr-1);let E=Ur[R];E.count++,$l(d,e,E.bounds)}let S=Ur[fr-1];Lg(S.bounds,S.rightCacheBounds);for(let d=fr-2;d>=0;d--){let M=Ur[d],m=Ur[d+1];Ng(M.bounds,m.rightCacheBounds,M.rightCacheBounds)}let g=0;for(let d=0;d<fr-1;d++){let M=Ur[d],m=M.count,R=M.bounds,T=Ur[d+1].rightCacheBounds;m!==0&&(g===0?Lg(R,Lf):Ng(R,Lf,Lf)),g+=m;let b=0,w=0;g!==0&&(b=aa(Lf)/c);let A=i-g;A!==0&&(w=aa(T)/c);let C=1+1.25*(b*g+w*A);C<l&&(o=p,l=C,a=M.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:a}}function M1(s,t,e,n){let i=0,r=s.offset;for(let o=t,a=t+e;o<a;o++)i+=s[(o-r)*6+n*2];return i/e}var la=class{constructor(){this.boundingData=new Float32Array(6)}};function Ey(s,t,e,n,i,r){let o=n,a=n+i-1,c=r.pos,l=r.axis*2,u=e.offset||0;for(;;){for(;o<=a&&e[(o-u)*6+l]<c;)o++;for(;o<=a&&e[(a-u)*6+l]>=c;)a--;if(o<a){for(let h=0;h<t;h++){let f=s[o*t+h];s[o*t+h]=s[a*t+h],s[a*t+h]=f}for(let h=0;h<6;h++){let f=o-u,p=a-u,x=e[f*6+h];e[f*6+h]=e[p*6+h],e[p*6+h]=x}o++,a--}else return o}}var wy,Nf,Dg,Ay,S1=Math.pow(2,32);function Df(s){return"count"in s?1:1+Df(s.left)+Df(s.right)}function Ry(s,t,e){return wy=new Float32Array(e),Nf=new Uint32Array(e),Dg=new Uint16Array(e),Ay=new Uint8Array(e),Ug(s,t)}function Ug(s,t){let e=s/4,n=s/2,i="count"in t,r=t.boundingData;for(let o=0;o<6;o++)wy[e+o]=r[o];if(i)return t.buffer?(Ay.set(new Uint8Array(t.buffer),s),s+t.buffer.byteLength):(Nf[e+6]=t.offset,Dg[n+14]=t.count,Dg[n+15]=65535,s+32);{let{left:o,right:a,splitAxis:c}=t,l=s+32,u=Ug(l,o),h=s/32,p=u/32-h;if(p>S1)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Nf[e+6]=p,Nf[e+7]=c,Ug(u,a)}}function b1(s,t,e,n,i,r){let{maxDepth:o,verbose:a,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:h}=i,f=s.primitiveBuffer,p=s.primitiveBufferStride,x=new Float32Array(6),v=!1,y=new la;return Pf(t,e,n,y.boundingData,x),S(y,e,n,x),y;function _(g){h&&h((g-r.offset)/r.count)}function S(g,d,M,m=null,R=0){!v&&R>=o&&(v=!0,a&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));let E=M>l;if(M<=c&&!E||R>=o)return _(d+M),g.offset=d,g.count=M,g;let T=Ty(g.boundingData,m,t,d,M,u),b=T.axis===-1?-1:Ey(f,p,t,d,M,T);if(T.axis===-1||b===d||b===d+M){if(!E)return _(d+M),g.offset=d,g.count=M,g;T.axis=Math.max(0,Yl(g.boundingData)),b=d+Math.max(1,Math.floor(M/2))}g.splitAxis=T.axis;let w=new la,A=d,C=b-d;g.left=w,Pf(t,A,C,w.boundingData,x),S(w,A,C,x,R+1);let D=new la,F=b,O=M-C;return g.right=D,Pf(t,F,O,D.boundingData,x),S(D,F,O,x,R+1),g}}function Cy(s,t){let e=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=s.getRootRanges(t.range),i=n[0],r=n[n.length-1],o={offset:i.offset,count:r.offset+r.count-i.offset},a=new Float32Array(6*o.count);a.offset=o.offset,s.computePrimitiveBounds(o.offset,o.count,a),s._roots=n.map(c=>{let l=b1(s,a,c.offset,c.count,t,o),u=Df(l),h=new e(32*u);return Ry(0,l,h),h})}var Fr=class{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){let t=this._primitives;return t.length===0?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}};var Fg=class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let t=[],e=null;this.setBuffer=n=>{e&&t.push(e),e=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,t.length!==0&&this.setBuffer(t.pop())}}},ue=new Fg;var Or,ha,ua=[],Uf=new Fr(()=>new ne);function Iy(s,t,e,n,i,r){Or=Uf.getPrimitive(),ha=Uf.getPrimitive(),ua.push(Or,ha),ue.setBuffer(s._roots[t]);let o=Og(0,s.geometry,e,n,i,r);ue.clearBuffer(),Uf.releasePrimitive(Or),Uf.releasePrimitive(ha),ua.pop(),ua.pop();let a=ua.length;return a>0&&(ha=ua[a-1],Or=ua[a-2]),o}function Og(s,t,e,n,i=null,r=0,o=0){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);return Se(s,a,Or),n(f,p,!1,o,r+s/8,Or)}else{let b=function(A){let{uint16Array:C,uint32Array:D}=ue,F=A*2;for(;!le(F,C);)A=fe(A),F=A*2;return xe(A,D)},w=function(A){let{uint16Array:C,uint32Array:D}=ue,F=A*2;for(;!le(F,C);)A=de(A,D),F=A*2;return xe(A,D)+ve(F,C)},f=fe(s),p=de(s,l),x=f,v=p,y,_,S,g;if(i&&(S=Or,g=ha,Se(x,a,S),Se(v,a,g),y=i(S),_=i(g),_<y)){x=p,v=f;let A=y;y=_,_=A,S=g}S||(S=Or,Se(x,a,S));let d=le(x*2,c),M=e(S,d,y,o+1,r+x/8),m;if(M===2){let A=b(x),D=w(x)-A;m=n(A,D,!0,o+1,r+x/8,S)}else m=M&&Og(x,t,e,n,i,r,o+1);if(m)return!0;g=ha,Se(v,a,g);let R=le(v*2,c),E=e(g,R,_,o+1,r+v/8),T;if(E===2){let A=b(v),D=w(v)-A;T=n(A,D,!0,o+1,r+v/8,g)}else T=E&&Og(v,t,e,n,i,r,o+1);return!!T}}var Kl=new ue.constructor,Ff=new ue.constructor,Br=new Fr(()=>new ne),fa=new ne,da=new ne,zg=new ne,kg=new ne,Hg=!1;function Py(s,t,e,n){if(Hg)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Hg=!0;let i=s._roots,r=t._roots,o,a=0,c=0,l=new vt().copy(e).invert();for(let u=0,h=i.length;u<h;u++){Kl.setBuffer(i[u]),c=0;let f=Br.getPrimitive();Se(0,Kl.float32Array,f),f.applyMatrix4(l);for(let p=0,x=r.length;p<x&&(Ff.setBuffer(r[p]),o=bi(0,0,e,l,n,a,c,0,0,f),Ff.clearBuffer(),c+=r[p].byteLength/32,!o);p++);if(Br.releasePrimitive(f),Kl.clearBuffer(),a+=i[u].byteLength/32,o)break}return Hg=!1,o}function bi(s,t,e,n,i,r=0,o=0,a=0,c=0,l=null,u=!1){let h,f;u?(h=Ff,f=Kl):(h=Kl,f=Ff);let p=h.float32Array,x=h.uint32Array,v=h.uint16Array,y=f.float32Array,_=f.uint32Array,S=f.uint16Array,g=s*2,d=t*2,M=le(g,v),m=le(d,S),R=!1;if(m&&M)u?R=i(xe(t,_),ve(t*2,S),xe(s,x),ve(s*2,v),c,o+t/8,a,r+s/8):R=i(xe(s,x),ve(s*2,v),xe(t,_),ve(t*2,S),a,r+s/8,c,o+t/8);else if(m){let E=Br.getPrimitive();Se(t,y,E),E.applyMatrix4(e);let T=fe(s),b=de(s,x);Se(T,p,fa),Se(b,p,da);let w=E.intersectsBox(fa),A=E.intersectsBox(da);R=w&&bi(t,T,n,e,i,o,r,c,a+1,E,!u)||A&&bi(t,b,n,e,i,o,r,c,a+1,E,!u),Br.releasePrimitive(E)}else{let E=fe(t),T=de(t,_);Se(E,y,zg),Se(T,y,kg);let b=l.intersectsBox(zg),w=l.intersectsBox(kg);if(b&&w)R=bi(s,E,e,n,i,r,o,a,c+1,l,u)||bi(s,T,e,n,i,r,o,a,c+1,l,u);else if(b)if(M)R=bi(s,E,e,n,i,r,o,a,c+1,l,u);else{let A=Br.getPrimitive();A.copy(zg).applyMatrix4(e);let C=fe(s),D=de(s,x);Se(C,p,fa),Se(D,p,da);let F=A.intersectsBox(fa),O=A.intersectsBox(da);R=F&&bi(E,C,n,e,i,o,r,c,a+1,A,!u)||O&&bi(E,D,n,e,i,o,r,c,a+1,A,!u),Br.releasePrimitive(A)}else if(w)if(M)R=bi(s,T,e,n,i,r,o,a,c+1,l,u);else{let A=Br.getPrimitive();A.copy(kg).applyMatrix4(e);let C=fe(s),D=de(s,x);Se(C,p,fa),Se(D,p,da);let F=A.intersectsBox(fa),O=A.intersectsBox(da);R=F&&bi(T,C,n,e,i,o,r,c,a+1,A,!u)||O&&bi(T,D,n,e,i,o,r,c,a+1,A,!u),Br.releasePrimitive(A)}}return R}var Of=new class{constructor(){let s=null,t=null,e=null,n=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(r,o)=>{if(n)throw new Error("BVHTraversalHelper: cannot call setBVH during an active traversal.");this.root=o,this.buffer=s=r._roots[o],this.uint16Array=e=new Uint16Array(s),this.uint32Array=t=new Uint32Array(s)},this.reset=()=>{this.root=null,this.buffer=s=null,this.uint16Array=e=null,this.uint32Array=t=null},this.getRangeStart=r=>{let o=r*2;for(;!le(o,e);)r=fe(r),o=r*2;return xe(r,t)},this.getRangeEnd=r=>{let o=r*2;for(;!le(o,e);)r=de(r,t),o=r*2;return xe(r,t)+ve(o,e)};let i=(r,o,a)=>{let c=o*2,l=le(c,e);if(!r(a,l,o)&&!l){let h=fe(o),f=de(o,t);i(r,h,a+1),i(r,f,a+1)}};this.traverseBuffer=r=>{if(n)throw new Error("BVHTraversalHelper: cannot start a traversal during an active traversal.");n=!0;try{i(r,0,0)}finally{n=!1}},this.traverse=r=>{this.traverseBuffer((o,a,c)=>{if(a){let l=c*2,u=t[c+6],h=e[l+14];return r(o,a,new Float32Array(s,c*4,6),u,h)}else{let l=ca(c,t);return r(o,a,new Float32Array(s,c*4,6),l)}})}}};var Ly=new ne,pa=new Float32Array(6),Bf=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){t={...If,...t},"maxLeafSize"in t&&(console.warn('BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.'),t={...t,targetLeafSize:t.maxLeafSize}),Cy(this,t)}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,n,i){let r=1/0,o=1/0,a=1/0,c=-1/0,l=-1/0,u=-1/0;for(let h=t,f=t+e;h<f;h++){this.writePrimitiveBounds(h,pa,0);let[p,x,v,y,_,S]=pa;p<r&&(r=p),y>c&&(c=y),x<o&&(o=x),_>l&&(l=_),v<a&&(a=v),S>u&&(u=S)}return n[i+0]=r,n[i+1]=o,n[i+2]=a,n[i+3]=c,n[i+4]=l,n[i+5]=u,n}computePrimitiveBounds(t,e,n){let i=n.offset||0;for(let r=t,o=t+e;r<o;r++){this.writePrimitiveBounds(r,pa,0);let[a,c,l,u,h,f]=pa,p=(a+u)/2,x=(c+h)/2,v=(l+f)/2,y=(u-a)/2,_=(h-c)/2,S=(f-l)/2,g=(r-i)*6;n[g+0]=p,n[g+1]=y+(Math.abs(p)+y)*oa,n[g+2]=x,n[g+3]=_+(Math.abs(x)+_)*oa,n[g+4]=v,n[g+5]=S+(Math.abs(v)+S)*oa}return n}shiftPrimitiveOffsets(t){let e=this._indirectBuffer;if(e)for(let n=0,i=e.length;n<i;n++)e[n]+=t;else{let n=this._roots;for(let i=0;i<n.length;i++){let r=n[i],o=new Uint32Array(r),a=new Uint16Array(r),c=r.byteLength/32;for(let l=0;l<c;l++){let u=8*l,h=2*u;le(h,a)&&(o[u+6]+=t)}}}}traverse(t,e=0){Of.setBVH(this,e),Of.traverse(t),Of.reset()}refit(){let t=this._roots;for(let e=0,n=t.length;e<n;e++){let i=t[e],r=new Uint32Array(i),o=new Uint16Array(i),a=new Float32Array(i),c=i.byteLength/32;for(let l=c-1;l>=0;l--){let u=l*8,h=u*2;if(le(h,o)){let p=xe(u,r),x=ve(h,o);this.writePrimitiveRangeBounds(p,x,pa,0),a.set(pa,u)}else{let p=fe(u),x=de(u,r);for(let v=0;v<3;v++){let y=a[p+v],_=a[p+v+3],S=a[x+v],g=a[x+v+3];a[u+v]=y<S?y:S,a[u+v+3]=_>g?_:g}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(n=>{Se(0,new Float32Array(n),Ly),t.union(Ly)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:n,intersectsRange:i,intersectsPrimitive:r,scratchPrimitive:o,iterate:a}=t;if(i&&r){let h=i;i=(f,p,x,v,y)=>h(f,p,x,v,y)?!0:a(f,p,this,r,x,v,o)}else i||(r?i=(h,f,p,x)=>a(h,f,this,r,p,x,o):i=(h,f,p)=>p);let c=!1,l=0,u=this._roots;for(let h=0,f=u.length;h<f;h++){let p=u[h];if(c=Iy(this,h,n,i,e,l),c)break;l+=p.byteLength/32}return c}bvhcast(t,e,n){let{intersectsRanges:i}=n;return Py(this,t,e,i)}};function Ny(){return typeof SharedArrayBuffer<"u"}function Vg(s){return s.index?s.index.count:s.attributes.position.count}function zr(s){return Vg(s)/3}function E1(s,t=ArrayBuffer){return s>65535?new Uint32Array(new t(4*s)):new Uint16Array(new t(2*s))}function Dy(s,t){if(!s.index){let e=s.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=E1(e,n);s.setIndex(new kt(i,1));for(let r=0;r<e;r++)i[r]=r}}function w1(s,t,e){let n=Vg(s)/e,i=t||s.drawRange,r=i.start/e,o=(i.start+i.count)/e,a=Math.max(0,r),c=Math.min(n,o)-a;return{offset:Math.floor(a),count:Math.floor(c)}}function A1(s,t){return s.groups.map(e=>({offset:e.start/t,count:e.count/t}))}function Gg(s,t,e){let n=w1(s,t,e),i=A1(s,e);if(!i.length)return[n];let r=[],o=n.offset,a=n.offset+n.count,c=Vg(s)/e,l=[];for(let f of i){let{offset:p,count:x}=f,v=p,y=isFinite(x)?x:c-p,_=p+y;v<a&&_>o&&(l.push({pos:Math.max(o,v),isStart:!0}),l.push({pos:Math.min(a,_),isStart:!1}))}l.sort((f,p)=>f.pos!==p.pos?f.pos-p.pos:f.type==="end"?-1:1);let u=0,h=null;for(let f of l){let p=f.pos;u!==0&&p!==h&&r.push({offset:h,count:p-h}),u+=f.isStart?1:-1,h=p}return r}function R1(s,t){let e=s[s.length-1],n=e.offset+e.count>2**16,i=s.reduce((l,u)=>l+u.count,0),r=n?4:2,o=t?new SharedArrayBuffer(i*r):new ArrayBuffer(i*r),a=n?new Uint32Array(o):new Uint16Array(o),c=0;for(let l=0;l<s.length;l++){let{offset:u,count:h}=s[l];for(let f=0;f<h;f++)a[c+f]=u+f;c+=h}return a}var zf=class extends Bf{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("BVH: Only BufferGeometries are supported.");if(e.useSharedArrayBuffer&&!Ny())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?n=>this._indirectBuffer[n]:n=>n,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,e={...If,...e},e[ql]||this.init(e)}init(t){let{geometry:e,primitiveStride:n}=this;if(t.indirect){let i=Gg(e,t.range,n),r=R1(i,t.useSharedArrayBuffer);this._indirectBuffer=r}else Dy(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new ne))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:Gg(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}};var qn=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,i=-1/0;for(let r=0,o=t.length;r<o;r++){let c=t[r][e];n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}setFromPoints(t,e){let n=1/0,i=-1/0;for(let r=0,o=e.length;r<o;r++){let a=e[r],c=t.dot(a);n=c<n?c:n,i=c>i?c:i}this.min=n,this.max=i}isSeparated(t){return this.min>t.max||t.min>this.max}};qn.prototype.setFromBox=function(){let s=new I;return function(e,n){let i=n.min,r=n.max,o=1/0,a=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let u=0;u<=1;u++){s.x=i.x*c+r.x*(1-c),s.y=i.y*l+r.y*(1-l),s.z=i.z*u+r.z*(1-u);let h=e.dot(s);o=Math.min(h,o),a=Math.max(h,a)}this.min=o,this.max=a}}();var C1=function(){let s=new I,t=new I,e=new I;return function(i,r,o){let a=i.start,c=s,l=r.start,u=t;e.subVectors(a,l),s.subVectors(i.end,i.start),t.subVectors(r.end,r.start);let h=e.dot(u),f=u.dot(c),p=u.dot(u),x=e.dot(c),y=c.dot(c)*p-f*f,_,S;y!==0?_=(h*f-x*p)/y:_=0,S=(h+_*f)/p,o.x=_,o.y=S}}(),Zl=function(){let s=new nt,t=new I,e=new I;return function(i,r,o,a){C1(i,r,s);let c=s.x,l=s.y;if(c>=0&&c<=1&&l>=0&&l<=1){i.at(c,o),r.at(l,a);return}else if(c>=0&&c<=1){l<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(l>=0&&l<=1){c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);return}else{let u;c<0?u=i.start:u=i.end;let h;l<0?h=r.start:h=r.end;let f=t,p=e;if(i.closestPointToPoint(h,!0,t),r.closestPointToPoint(u,!0,e),f.distanceToSquared(h)<=p.distanceToSquared(u)){o.copy(f),a.copy(h);return}else{o.copy(u),a.copy(p);return}}}}(),Uy=function(){let s=new I,t=new I,e=new $e,n=new _e;return function(r,o){let{radius:a,center:c}=r,{a:l,b:u,c:h}=o;if(n.start=l,n.end=u,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a||(n.start=l,n.end=h,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a)||(n.start=u,n.end=h,n.closestPointToPoint(c,!0,s).distanceTo(c)<=a))return!0;let v=o.getPlane(e);if(Math.abs(v.distanceToPoint(c))<=a){let _=v.projectPoint(c,t);if(o.containsPoint(_))return!0}return!1}}();var I1=["x","y","z"],dr=1e-15,Fy=dr*dr;function ci(s){return Math.abs(s)<dr}var ze=class extends me{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new I),this.satBounds=new Array(4).fill().map(()=>new qn),this.points=[this.a,this.b,this.c],this.plane=new $e,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new _e,this.needsUpdate=!0}intersectsSphere(t){return Uy(t,this)}update(){let t=this.a,e=this.b,n=this.c,i=this.points,r=this.satAxes,o=this.satBounds,a=r[0],c=o[0];this.getNormal(a),c.setFromPoints(a,i);let l=r[1],u=o[1];l.subVectors(t,e),u.setFromPoints(l,i);let h=r[2],f=o[2];h.subVectors(e,n),f.setFromPoints(h,i);let p=r[3],x=o[3];p.subVectors(n,t),x.setFromPoints(p,i);let v=l.length(),y=h.length(),_=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,v<dr?y<dr||_<dr?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(n)):y<dr?_<dr?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):_<dr&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}};ze.prototype.closestPointToSegment=function(){let s=new I,t=new I,e=new _e;return function(i,r=null,o=null){let{start:a,end:c}=i,l=this.points,u,h=1/0;for(let f=0;f<3;f++){let p=(f+1)%3;e.start.copy(l[f]),e.end.copy(l[p]),Zl(e,i,s,t),u=s.distanceToSquared(t),u<h&&(h=u,r&&r.copy(s),o&&o.copy(t))}return this.closestPointToPoint(a,s),u=a.distanceToSquared(s),u<h&&(h=u,r&&r.copy(s),o&&o.copy(a)),this.closestPointToPoint(c,s),u=c.distanceToSquared(s),u<h&&(h=u,r&&r.copy(s),o&&o.copy(c)),Math.sqrt(h)}}();ze.prototype.intersectsTriangle=function(){let s=new ze,t=new qn,e=new qn,n=new I,i=new I,r=new I,o=new I,a=new _e,c=new _e,l=new I,u=new nt,h=new nt;function f(g,d,M,m){let R=n;!g.isDegenerateIntoPoint&&!g.isDegenerateIntoSegment?R.copy(g.plane.normal):R.copy(d.plane.normal);let E=g.satBounds,T=g.satAxes;for(let A=1;A<4;A++){let C=E[A],D=T[A];if(t.setFromPoints(D,d.points),C.isSeparated(t)||(o.copy(R).cross(D),t.setFromPoints(o,g.points),e.setFromPoints(o,d.points),t.isSeparated(e)))return!1}let b=d.satBounds,w=d.satAxes;for(let A=1;A<4;A++){let C=b[A],D=w[A];if(t.setFromPoints(D,g.points),C.isSeparated(t)||(o.crossVectors(R,D),t.setFromPoints(o,g.points),e.setFromPoints(o,d.points),t.isSeparated(e)))return!1}return M&&(m||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function p(g,d,M,m,R,E,T,b,w,A,C){let D=T/(T-b);A.x=m+(R-m)*D,C.start.subVectors(d,g).multiplyScalar(D).add(g),D=T/(T-w),A.y=m+(E-m)*D,C.end.subVectors(M,g).multiplyScalar(D).add(g)}function x(g,d,M,m,R,E,T,b,w,A,C){if(R>0)p(g.c,g.a,g.b,m,d,M,w,T,b,A,C);else if(E>0)p(g.b,g.a,g.c,M,d,m,b,T,w,A,C);else if(b*w>0||T!=0)p(g.a,g.b,g.c,d,M,m,T,b,w,A,C);else if(b!=0)p(g.b,g.a,g.c,M,d,m,b,T,w,A,C);else if(w!=0)p(g.c,g.a,g.b,m,d,M,w,T,b,A,C);else return!0;return!1}function v(g,d,M,m){let R=d.degenerateSegment,E=g.plane.distanceToPoint(R.start),T=g.plane.distanceToPoint(R.end);return ci(E)?ci(T)?f(g,d,M,m):(M&&(M.start.copy(R.start),M.end.copy(R.start)),g.containsPoint(R.start)):ci(T)?(M&&(M.start.copy(R.end),M.end.copy(R.end)),g.containsPoint(R.end)):g.plane.intersectLine(R,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),g.containsPoint(n)):!1}function y(g,d,M){let m=d.a;return ci(g.plane.distanceToPoint(m))&&g.containsPoint(m)?(M&&(M.start.copy(m),M.end.copy(m)),!0):!1}function _(g,d,M){let m=g.degenerateSegment,R=d.a;return m.closestPointToPoint(R,!0,n),R.distanceToSquared(n)<Fy?(M&&(M.start.copy(R),M.end.copy(R)),!0):!1}function S(g,d,M,m){if(g.isDegenerateIntoSegment)if(d.isDegenerateIntoSegment){let R=g.degenerateSegment,E=d.degenerateSegment,T=i,b=r;R.delta(T),E.delta(b);let w=n.subVectors(E.start,R.start),A=T.x*b.y-T.y*b.x;if(ci(A))return!1;let C=(w.x*b.y-w.y*b.x)/A,D=-(T.x*w.y-T.y*w.x)/A;if(C<0||C>1||D<0||D>1)return!1;let F=R.start.z+T.z*C,O=E.start.z+b.z*D;return ci(F-O)?(M&&(M.start.copy(R.start).addScaledVector(T,C),M.end.copy(R.start).addScaledVector(T,C)),!0):!1}else return d.isDegenerateIntoPoint?_(g,d,M):v(d,g,M,m);else{if(g.isDegenerateIntoPoint)return d.isDegenerateIntoPoint?d.a.distanceToSquared(g.a)<Fy?(M&&(M.start.copy(g.a),M.end.copy(g.a)),!0):!1:d.isDegenerateIntoSegment?_(d,g,M):y(d,g,M);if(d.isDegenerateIntoPoint)return y(g,d,M);if(d.isDegenerateIntoSegment)return v(g,d,M,m)}}return function(d,M=null,m=!1){this.needsUpdate&&this.update(),d.isExtendedTriangle?d.needsUpdate&&d.update():(s.copy(d),s.update(),d=s);let R=S(this,d,M,m);if(R!==void 0)return R;let E=this.plane,T=d.plane,b=T.distanceToPoint(this.a),w=T.distanceToPoint(this.b),A=T.distanceToPoint(this.c);ci(b)&&(b=0),ci(w)&&(w=0),ci(A)&&(A=0);let C=b*w,D=b*A;if(C>0&&D>0)return!1;let F=E.distanceToPoint(d.a),O=E.distanceToPoint(d.b),H=E.distanceToPoint(d.c);ci(F)&&(F=0),ci(O)&&(O=0),ci(H)&&(H=0);let B=F*O,$=F*H;if(B>0&&$>0)return!1;i.copy(E.normal),r.copy(T.normal);let at=i.cross(r),rt=0,ht=Math.abs(at.x),bt=Math.abs(at.y);bt>ht&&(ht=bt,rt=1),Math.abs(at.z)>ht&&(rt=2);let Mt=I1[rt],K=this.a[Mt],Q=this.b[Mt],ct=this.c[Mt],lt=d.a[Mt],ut=d.b[Mt],Ct=d.c[Mt];if(x(this,K,Q,ct,C,D,b,w,A,u,a))return f(this,d,M,m);if(x(d,lt,ut,Ct,B,$,F,O,H,h,c))return f(this,d,M,m);if(u.y<u.x){let Kt=u.y;u.y=u.x,u.x=Kt,l.copy(a.start),a.start.copy(a.end),a.end.copy(l)}if(h.y<h.x){let Kt=h.y;h.y=h.x,h.x=Kt,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<h.x||h.y<u.x?!1:(M&&(h.x>u.x?M.start.copy(c.start):M.start.copy(a.start),h.y<u.y?M.end.copy(c.end):M.end.copy(a.end)),!0)}}();ze.prototype.distanceToPoint=function(){let s=new I;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();ze.prototype.distanceToTriangle=function(){let s=new I,t=new I,e=["a","b","c"],n=new _e,i=new _e;return function(o,a=null,c=null){let l=a||c?n:null;if(this.intersectsTriangle(o,l,!0))return(a||c)&&(a&&l.getCenter(a),c&&l.getCenter(c)),0;let u=1/0;for(let h=0;h<3;h++){let f,p=e[h],x=o[p];this.closestPointToPoint(x,s),f=x.distanceToSquared(s),f<u&&(u=f,a&&a.copy(s),c&&c.copy(x));let v=this[p];o.closestPointToPoint(v,s),f=v.distanceToSquared(s),f<u&&(u=f,a&&a.copy(v),c&&c.copy(s))}for(let h=0;h<3;h++){let f=e[h],p=e[(h+1)%3];n.set(this[f],this[p]);for(let x=0;x<3;x++){let v=e[x],y=e[(x+1)%3];i.set(o[v],o[y]),Zl(n,i,s,t);let _=s.distanceToSquared(t);_<u&&(u=_,a&&a.copy(s),c&&c.copy(t))}}return Math.sqrt(u)}}();var ke=class{constructor(t,e,n){this.isOrientedBox=!0,this.min=new I,this.max=new I,this.matrix=new vt,this.invMatrix=new vt,this.points=new Array(8).fill().map(()=>new I),this.satAxes=new Array(3).fill().map(()=>new I),this.satBounds=new Array(3).fill().map(()=>new qn),this.alignedSatBounds=new Array(3).fill().map(()=>new qn),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};ke.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){let f=1*l|2*u|4*h,p=i[f];p.x=l?n.x:e.x,p.y=u?n.y:e.y,p.z=h?n.z:e.z,p.applyMatrix4(t)}let r=this.satBounds,o=this.satAxes,a=i[0];for(let l=0;l<3;l++){let u=o[l],h=r[l],f=1<<l,p=i[f];u.subVectors(a,p),h.setFromPoints(u,i)}let c=this.alignedSatBounds;c[0].setFromPointsField(i,"x"),c[1].setFromPointsField(i,"y"),c[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ke.prototype.intersectsBox=function(){let s=new qn;return function(e){this.needsUpdate&&this.update();let n=e.min,i=e.max,r=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(s.min=n.x,s.max=i.x,a[0].isSeparated(s)||(s.min=n.y,s.max=i.y,a[1].isSeparated(s))||(s.min=n.z,s.max=i.z,a[2].isSeparated(s)))return!1;for(let c=0;c<3;c++){let l=o[c],u=r[c];if(s.setFromBox(l,e),u.isSeparated(s))return!1}return!0}}();ke.prototype.intersectsTriangle=function(){let s=new ze,t=new Array(3),e=new qn,n=new qn,i=new I;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(s.copy(o),s.update(),o=s);let a=this.satBounds,c=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let f=0;f<3;f++){let p=a[f],x=c[f];if(e.setFromPoints(x,t),p.isSeparated(e))return!1}let l=o.satBounds,u=o.satAxes,h=this.points;for(let f=0;f<3;f++){let p=l[f],x=u[f];if(e.setFromPoints(x,h),p.isSeparated(e))return!1}for(let f=0;f<3;f++){let p=c[f];for(let x=0;x<4;x++){let v=u[x];if(i.crossVectors(p,v),e.setFromPoints(i,t),n.setFromPoints(i,h),e.isSeparated(n))return!1}}return!0}}();ke.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}();ke.prototype.distanceToPoint=function(){let s=new I;return function(e){return this.closestPointToPoint(e,s),e.distanceTo(s)}}();ke.prototype.distanceToBox=function(){let s=["x","y","z"],t=new Array(12).fill().map(()=>new _e),e=new Array(12).fill().map(()=>new _e),n=new I,i=new I;return function(o,a=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(c||l)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),c&&c.copy(n),l&&l.copy(i)),0;let u=a*a,h=o.min,f=o.max,p=this.points,x=1/0;for(let y=0;y<8;y++){let _=p[y];i.copy(_).clamp(h,f);let S=_.distanceToSquared(i);if(S<x&&(x=S,c&&c.copy(_),l&&l.copy(i),S<u))return Math.sqrt(S)}let v=0;for(let y=0;y<3;y++)for(let _=0;_<=1;_++)for(let S=0;S<=1;S++){let g=(y+1)%3,d=(y+2)%3,M=_<<g|S<<d,m=1<<y|_<<g|S<<d,R=p[M],E=p[m];t[v].set(R,E);let b=s[y],w=s[g],A=s[d],C=e[v],D=C.start,F=C.end;D[b]=h[b],D[w]=_?h[w]:f[w],D[A]=S?h[A]:f[w],F[b]=f[b],F[w]=_?h[w]:f[w],F[A]=S?h[A]:f[w],v++}for(let y=0;y<=1;y++)for(let _=0;_<=1;_++)for(let S=0;S<=1;S++){i.x=y?f.x:h.x,i.y=_?f.y:h.y,i.z=S?f.z:h.z,this.closestPointToPoint(i,n);let g=i.distanceToSquared(n);if(g<x&&(x=g,c&&c.copy(n),l&&l.copy(i),g<u))return Math.sqrt(g)}for(let y=0;y<12;y++){let _=t[y];for(let S=0;S<12;S++){let g=e[S];Zl(_,g,n,i);let d=n.distanceToSquared(i);if(d<x&&(x=d,c&&c.copy(n),l&&l.copy(i),d<u))return Math.sqrt(d)}}return Math.sqrt(x)}}();var Wg=class extends Fr{constructor(){super(()=>new ze)}},Sn=new Wg;var Jl=new I,Xg=new I;function Oy(s,t,e={},n=0,i=1/0){let r=n*n,o=i*i,a=1/0,c=null;if(s.shapecast({boundsTraverseOrder:u=>(Jl.copy(t).clamp(u.min,u.max),Jl.distanceToSquared(t)),intersectsBounds:(u,h,f)=>f<a&&f<o,intersectsTriangle:(u,h)=>{u.closestPointToPoint(t,Jl);let f=t.distanceToSquared(Jl);return f<a&&(Xg.copy(Jl),a=f,c=h),f<r}}),a===1/0)return null;let l=Math.sqrt(a);return e.point?e.point.copy(Xg):e.point=Xg.clone(),e.distance=l,e.faceIndex=c,e}var kf=parseInt(Hi)>=169,P1=parseInt(Hi)<=161,Os=new I,Bs=new I,zs=new I,Hf=new nt,Vf=new nt,Gf=new nt,By=new I,zy=new I,ky=new I,jl=new I;function L1(s,t,e,n,i,r,o,a){let c;if(r===qe?c=s.intersectTriangle(n,e,t,!0,i):c=s.intersectTriangle(t,e,n,r!==Ve,i),c===null)return null;let l=s.origin.distanceTo(i);return l<o||l>a?null:{distance:l,point:i.clone()}}function Hy(s,t,e,n,i,r,o,a,c,l,u){Os.fromBufferAttribute(t,r),Bs.fromBufferAttribute(t,o),zs.fromBufferAttribute(t,a);let h=L1(s,Os,Bs,zs,jl,c,l,u);if(h){if(n){Hf.fromBufferAttribute(n,r),Vf.fromBufferAttribute(n,o),Gf.fromBufferAttribute(n,a),h.uv=new nt;let p=me.getInterpolation(jl,Os,Bs,zs,Hf,Vf,Gf,h.uv);kf||(h.uv=p)}if(i){Hf.fromBufferAttribute(i,r),Vf.fromBufferAttribute(i,o),Gf.fromBufferAttribute(i,a),h.uv1=new nt;let p=me.getInterpolation(jl,Os,Bs,zs,Hf,Vf,Gf,h.uv1);kf||(h.uv1=p),P1&&(h.uv2=h.uv1)}if(e){By.fromBufferAttribute(e,r),zy.fromBufferAttribute(e,o),ky.fromBufferAttribute(e,a),h.normal=new I;let p=me.getInterpolation(jl,Os,Bs,zs,By,zy,ky,h.normal);h.normal.dot(s.direction)>0&&h.normal.multiplyScalar(-1),kf||(h.normal=p)}let f={a:r,b:o,c:a,normal:new I,materialIndex:0};if(me.getNormal(Os,Bs,zs,f.normal),h.face=f,h.faceIndex=r,kf){let p=new I;me.getBarycoord(jl,Os,Bs,zs,p),h.barycoord=p}}return h}function Vy(s){return s&&s.isMaterial?s.side:s}function ma(s,t,e,n,i,r,o){let a=n*3,c=a+0,l=a+1,u=a+2,{index:h,groups:f}=s;s.index&&(c=h.getX(c),l=h.getX(l),u=h.getX(u));let{position:p,normal:x,uv:v,uv1:y}=s.attributes;if(Array.isArray(t)){let _=n*3;for(let S=0,g=f.length;S<g;S++){let{start:d,count:M,materialIndex:m}=f[S];if(_>=d&&_<d+M){let R=Vy(t[m]),E=Hy(e,p,x,v,y,c,l,u,R,r,o);if(E)if(E.faceIndex=n,E.face.materialIndex=m,i)i.push(E);else return E}}}else{let _=Vy(t),S=Hy(e,p,x,v,y,c,l,u,_,r,o);if(S)if(S.faceIndex=n,S.face.materialIndex=0,i)i.push(S);else return S}return null}function be(s,t,e,n){let i=s.a,r=s.b,o=s.c,a=t,c=t+1,l=t+2;e&&(a=e.getX(a),c=e.getX(c),l=e.getX(l)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c),o.x=n.getX(l),o.y=n.getY(l),o.z=n.getZ(l)}function Gy(s,t,e,n,i,r,o,a){let{geometry:c,_indirectBuffer:l}=s;for(let u=n,h=n+i;u<h;u++)ma(c,t,e,u,r,o,a)}function Wy(s,t,e,n,i,r,o){let{geometry:a,_indirectBuffer:c}=s,l=1/0,u=null;for(let h=n,f=n+i;h<f;h++){let p;p=ma(a,t,e,h,null,r,o),p&&p.distance<l&&(u=p,l=p.distance)}return u}function Xy(s,t,e,n,i,r,o){let{geometry:a}=e,{index:c}=a,l=a.attributes.position;for(let u=s,h=t+s;u<h;u++){let f;if(f=u,be(o,f*3,c,l),o.needsUpdate=!0,n(o,f,i,r))return!0}return!1}function qy(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=s.geometry,n=e.index?e.index.array:null,i=e.attributes.position,r,o,a,c,l=0,u=s._roots;for(let f=0,p=u.length;f<p;f++)r=u[f],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),h(0,l),l+=r.byteLength;function h(f,p,x=!1){let v=f*2;if(le(v,a)){let y=xe(f,o),_=ve(v,a),S=1/0,g=1/0,d=1/0,M=-1/0,m=-1/0,R=-1/0;for(let E=3*y,T=3*(y+_);E<T;E++){let b=n[E],w=i.getX(b),A=i.getY(b),C=i.getZ(b);w<S&&(S=w),w>M&&(M=w),A<g&&(g=A),A>m&&(m=A),C<d&&(d=C),C>R&&(R=C)}return c[f+0]!==S||c[f+1]!==g||c[f+2]!==d||c[f+3]!==M||c[f+4]!==m||c[f+5]!==R?(c[f+0]=S,c[f+1]=g,c[f+2]=d,c[f+3]=M,c[f+4]=m,c[f+5]=R,!0):!1}else{let y=fe(f),_=de(f,o),S=x,g=!1,d=!1;if(t){if(!S){let b=y/8+p/32,w=_/8+p/32;g=t.has(b),d=t.has(w),S=!g&&!d}}else g=!0,d=!0;let M=S||g,m=S||d,R=!1;M&&(R=h(y,p,S));let E=!1;m&&(E=h(_,p,S));let T=R||E;if(T)for(let b=0;b<3;b++){let w=y+b,A=_+b,C=c[w],D=c[w+3],F=c[A],O=c[A+3];c[f+b]=C<F?C:F,c[f+b+3]=D>O?D:O}return T}}}function li(s,t,e,n,i){let r,o,a,c,l,u,h=1/e.direction.x,f=1/e.direction.y,p=1/e.direction.z,x=e.origin.x,v=e.origin.y,y=e.origin.z,_=t[s],S=t[s+3],g=t[s+1],d=t[s+3+1],M=t[s+2],m=t[s+3+2];return h>=0?(r=(_-x)*h,o=(S-x)*h):(r=(S-x)*h,o=(_-x)*h),f>=0?(a=(g-v)*f,c=(d-v)*f):(a=(d-v)*f,c=(g-v)*f),r>c||a>o||((a>r||isNaN(r))&&(r=a),(c<o||isNaN(o))&&(o=c),p>=0?(l=(M-y)*p,u=(m-y)*p):(l=(m-y)*p,u=(M-y)*p),r>u||l>o)?!1:((l>r||r!==r)&&(r=l),(u<o||o!==o)&&(o=u),r<=i&&o>=n)}function Yy(s,t,e,n,i,r,o,a){let{geometry:c,_indirectBuffer:l}=s;for(let u=n,h=n+i;u<h;u++){let f=l?l[u]:u;ma(c,t,e,f,r,o,a)}}function $y(s,t,e,n,i,r,o){let{geometry:a,_indirectBuffer:c}=s,l=1/0,u=null;for(let h=n,f=n+i;h<f;h++){let p;p=ma(a,t,e,c?c[h]:h,null,r,o),p&&p.distance<l&&(u=p,l=p.distance)}return u}function Ky(s,t,e,n,i,r,o){let{geometry:a}=e,{index:c}=a,l=a.attributes.position;for(let u=s,h=t+s;u<h;u++){let f;if(f=e.resolveTriangleIndex(u),be(o,f*3,c,l),o.needsUpdate=!0,n(o,f,i,r))return!0}return!1}function Zy(s,t,e,n,i,r,o){ue.setBuffer(s._roots[t]),qg(0,s,e,n,i,r,o),ue.clearBuffer()}function qg(s,t,e,n,i,r,o){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);Gy(t,e,n,f,p,i,r,o)}else{let f=fe(s);li(f,a,n,r,o)&&qg(f,t,e,n,i,r,o);let p=de(s,l);li(p,a,n,r,o)&&qg(p,t,e,n,i,r,o)}}var N1=["x","y","z"];function Jy(s,t,e,n,i,r){ue.setBuffer(s._roots[t]);let o=Yg(0,s,e,n,i,r);return ue.clearBuffer(),o}function Yg(s,t,e,n,i,r){let{float32Array:o,uint16Array:a,uint32Array:c}=ue,l=s*2;if(le(l,a)){let h=xe(s,c),f=ve(l,a);return Wy(t,e,n,h,f,i,r)}else{let h=ca(s,c),f=N1[h],x=n.direction[f]>=0,v,y;x?(v=fe(s),y=de(s,c)):(v=de(s,c),y=fe(s));let S=li(v,o,n,i,r)?Yg(v,t,e,n,i,r):null;if(S){let M=S.point[f];if(x?M<=o[y+h]:M>=o[y+h+3])return S}let d=li(y,o,n,i,r)?Yg(y,t,e,n,i,r):null;return S&&d?S.distance<=d.distance?S:d:S||d||null}}var Wf=new ne,ga=new ze,xa=new ze,Ql=new vt,jy=new ke,Xf=new ke;function Qy(s,t,e,n){ue.setBuffer(s._roots[t]);let i=$g(0,s,e,n);return ue.clearBuffer(),i}function $g(s,t,e,n,i=null){let{float32Array:r,uint16Array:o,uint32Array:a}=ue,c=s*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),jy.set(e.boundingBox.min,e.boundingBox.max,n),i=jy),le(c,o)){let u=t.geometry,h=u.index,f=u.attributes.position,p=e.index,x=e.attributes.position,v=xe(s,a),y=ve(c,o);if(Ql.copy(n).invert(),e.boundsTree)return Se(s,r,Xf),Xf.matrix.copy(Ql),Xf.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:S=>Xf.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(n),S.b.applyMatrix4(n),S.c.applyMatrix4(n),S.needsUpdate=!0;for(let g=v*3,d=(y+v)*3;g<d;g+=3)if(be(xa,g,h,f),xa.needsUpdate=!0,S.intersectsTriangle(xa))return!0;return!1}});{let _=zr(e);for(let S=v*3,g=(y+v)*3;S<g;S+=3){be(ga,S,h,f),ga.a.applyMatrix4(Ql),ga.b.applyMatrix4(Ql),ga.c.applyMatrix4(Ql),ga.needsUpdate=!0;for(let d=0,M=_*3;d<M;d+=3)if(be(xa,d,p,x),xa.needsUpdate=!0,ga.intersectsTriangle(xa))return!0}}}else{let u=fe(s),h=de(s,a);return Se(u,r,Wf),!!(i.intersectsBox(Wf)&&$g(u,t,e,n,i)||(Se(h,r,Wf),i.intersectsBox(Wf)&&$g(h,t,e,n,i)))}}var qf=new vt,Kg=new ke,tu=new ke,D1=new I,U1=new I,F1=new I,O1=new I;function tv(s,t,e,n={},i={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Kg.set(t.boundingBox.min,t.boundingBox.max,e),Kg.needsUpdate=!0;let a=s.geometry,c=a.attributes.position,l=a.index,u=t.attributes.position,h=t.index,f=Sn.getPrimitive(),p=Sn.getPrimitive(),x=D1,v=U1,y=null,_=null;i&&(y=F1,_=O1);let S=1/0,g=null,d=null;return qf.copy(e).invert(),tu.matrix.copy(qf),s.shapecast({boundsTraverseOrder:M=>Kg.distanceToBox(M),intersectsBounds:(M,m,R)=>R<S&&R<o?(m&&(tu.min.copy(M.min),tu.max.copy(M.max),tu.needsUpdate=!0),!0):!1,intersectsRange:(M,m)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:E=>tu.distanceToBox(E),intersectsBounds:(E,T,b)=>b<S&&b<o,intersectsRange:(E,T)=>{for(let b=E,w=E+T;b<w;b++){be(p,3*b,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let A=M,C=M+m;A<C;A++){be(f,3*A,l,c),f.needsUpdate=!0;let D=f.distanceToTriangle(p,x,y);if(D<S&&(v.copy(x),_&&_.copy(y),S=D,g=A,d=b),D<r)return!0}}}});{let R=zr(t);for(let E=0,T=R;E<T;E++){be(p,3*E,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let b=M,w=M+m;b<w;b++){be(f,3*b,l,c),f.needsUpdate=!0;let A=f.distanceToTriangle(p,x,y);if(A<S&&(v.copy(x),_&&_.copy(y),S=A,g=b,d=E),A<r)return!0}}}}}),Sn.releasePrimitive(f),Sn.releasePrimitive(p),S===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=S,n.faceIndex=g,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(qf),v.applyMatrix4(qf),i.distance=v.sub(i.point).length(),i.faceIndex=d),n)}function ev(s,t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=s.geometry,n=e.index?e.index.array:null,i=e.attributes.position,r,o,a,c,l=0,u=s._roots;for(let f=0,p=u.length;f<p;f++)r=u[f],o=new Uint32Array(r),a=new Uint16Array(r),c=new Float32Array(r),h(0,l),l+=r.byteLength;function h(f,p,x=!1){let v=f*2;if(le(v,a)){let y=xe(f,o),_=ve(v,a),S=1/0,g=1/0,d=1/0,M=-1/0,m=-1/0,R=-1/0;for(let E=y,T=y+_;E<T;E++){let b=3*s.resolveTriangleIndex(E);for(let w=0;w<3;w++){let A=b+w;A=n?n[A]:A;let C=i.getX(A),D=i.getY(A),F=i.getZ(A);C<S&&(S=C),C>M&&(M=C),D<g&&(g=D),D>m&&(m=D),F<d&&(d=F),F>R&&(R=F)}}return c[f+0]!==S||c[f+1]!==g||c[f+2]!==d||c[f+3]!==M||c[f+4]!==m||c[f+5]!==R?(c[f+0]=S,c[f+1]=g,c[f+2]=d,c[f+3]=M,c[f+4]=m,c[f+5]=R,!0):!1}else{let y=fe(f),_=de(f,o),S=x,g=!1,d=!1;if(t){if(!S){let b=y/8+p/32,w=_/8+p/32;g=t.has(b),d=t.has(w),S=!g&&!d}}else g=!0,d=!0;let M=S||g,m=S||d,R=!1;M&&(R=h(y,p,S));let E=!1;m&&(E=h(_,p,S));let T=R||E;if(T)for(let b=0;b<3;b++){let w=y+b,A=_+b,C=c[w],D=c[w+3],F=c[A],O=c[A+3];c[f+b]=C<F?C:F,c[f+b+3]=D>O?D:O}return T}}}function nv(s,t,e,n,i,r,o){ue.setBuffer(s._roots[t]),Zg(0,s,e,n,i,r,o),ue.clearBuffer()}function Zg(s,t,e,n,i,r,o){let{float32Array:a,uint16Array:c,uint32Array:l}=ue,u=s*2;if(le(u,c)){let f=xe(s,l),p=ve(u,c);Yy(t,e,n,f,p,i,r,o)}else{let f=fe(s);li(f,a,n,r,o)&&Zg(f,t,e,n,i,r,o);let p=de(s,l);li(p,a,n,r,o)&&Zg(p,t,e,n,i,r,o)}}var B1=["x","y","z"];function iv(s,t,e,n,i,r){ue.setBuffer(s._roots[t]);let o=Jg(0,s,e,n,i,r);return ue.clearBuffer(),o}function Jg(s,t,e,n,i,r){let{float32Array:o,uint16Array:a,uint32Array:c}=ue,l=s*2;if(le(l,a)){let h=xe(s,c),f=ve(l,a);return $y(t,e,n,h,f,i,r)}else{let h=ca(s,c),f=B1[h],x=n.direction[f]>=0,v,y;x?(v=fe(s),y=de(s,c)):(v=de(s,c),y=fe(s));let S=li(v,o,n,i,r)?Jg(v,t,e,n,i,r):null;if(S){let M=S.point[f];if(x?M<=o[y+h]:M>=o[y+h+3])return S}let d=li(y,o,n,i,r)?Jg(y,t,e,n,i,r):null;return S&&d?S.distance<=d.distance?S:d:S||d||null}}var Yf=new ne,_a=new ze,ya=new ze,eu=new vt,rv=new ke,$f=new ke;function sv(s,t,e,n){ue.setBuffer(s._roots[t]);let i=jg(0,s,e,n);return ue.clearBuffer(),i}function jg(s,t,e,n,i=null){let{float32Array:r,uint16Array:o,uint32Array:a}=ue,c=s*2;if(i===null&&(e.boundingBox||e.computeBoundingBox(),rv.set(e.boundingBox.min,e.boundingBox.max,n),i=rv),le(c,o)){let u=t.geometry,h=u.index,f=u.attributes.position,p=e.index,x=e.attributes.position,v=xe(s,a),y=ve(c,o);if(eu.copy(n).invert(),e.boundsTree)return Se(s,r,$f),$f.matrix.copy(eu),$f.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:S=>$f.intersectsBox(S),intersectsTriangle:S=>{S.a.applyMatrix4(n),S.b.applyMatrix4(n),S.c.applyMatrix4(n),S.needsUpdate=!0;for(let g=v,d=y+v;g<d;g++)if(be(ya,3*t.resolveTriangleIndex(g),h,f),ya.needsUpdate=!0,S.intersectsTriangle(ya))return!0;return!1}});{let _=zr(e);for(let S=v,g=y+v;S<g;S++){let d=t.resolveTriangleIndex(S);be(_a,3*d,h,f),_a.a.applyMatrix4(eu),_a.b.applyMatrix4(eu),_a.c.applyMatrix4(eu),_a.needsUpdate=!0;for(let M=0,m=_*3;M<m;M+=3)if(be(ya,M,p,x),ya.needsUpdate=!0,_a.intersectsTriangle(ya))return!0}}}else{let u=fe(s),h=de(s,a);return Se(u,r,Yf),!!(i.intersectsBox(Yf)&&jg(u,t,e,n,i)||(Se(h,r,Yf),i.intersectsBox(Yf)&&jg(h,t,e,n,i)))}}var Kf=new vt,Qg=new ke,nu=new ke,z1=new I,k1=new I,H1=new I,V1=new I;function ov(s,t,e,n={},i={},r=0,o=1/0){t.boundingBox||t.computeBoundingBox(),Qg.set(t.boundingBox.min,t.boundingBox.max,e),Qg.needsUpdate=!0;let a=s.geometry,c=a.attributes.position,l=a.index,u=t.attributes.position,h=t.index,f=Sn.getPrimitive(),p=Sn.getPrimitive(),x=z1,v=k1,y=null,_=null;i&&(y=H1,_=V1);let S=1/0,g=null,d=null;return Kf.copy(e).invert(),nu.matrix.copy(Kf),s.shapecast({boundsTraverseOrder:M=>Qg.distanceToBox(M),intersectsBounds:(M,m,R)=>R<S&&R<o?(m&&(nu.min.copy(M.min),nu.max.copy(M.max),nu.needsUpdate=!0),!0):!1,intersectsRange:(M,m)=>{if(t.boundsTree){let R=t.boundsTree;return R.shapecast({boundsTraverseOrder:E=>nu.distanceToBox(E),intersectsBounds:(E,T,b)=>b<S&&b<o,intersectsRange:(E,T)=>{for(let b=E,w=E+T;b<w;b++){let A=R.resolveTriangleIndex(b);be(p,3*A,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let C=M,D=M+m;C<D;C++){let F=s.resolveTriangleIndex(C);be(f,3*F,l,c),f.needsUpdate=!0;let O=f.distanceToTriangle(p,x,y);if(O<S&&(v.copy(x),_&&_.copy(y),S=O,g=C,d=b),O<r)return!0}}}})}else{let R=zr(t);for(let E=0,T=R;E<T;E++){be(p,3*E,h,u),p.a.applyMatrix4(e),p.b.applyMatrix4(e),p.c.applyMatrix4(e),p.needsUpdate=!0;for(let b=M,w=M+m;b<w;b++){let A=s.resolveTriangleIndex(b);be(f,3*A,l,c),f.needsUpdate=!0;let C=f.distanceToTriangle(p,x,y);if(C<S&&(v.copy(x),_&&_.copy(y),S=C,g=b,d=E),C<r)return!0}}}}}),Sn.releasePrimitive(f),Sn.releasePrimitive(p),S===1/0?null:(n.point?n.point.copy(v):n.point=v.clone(),n.distance=S,n.faceIndex=g,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(Kf),v.applyMatrix4(Kf),i.distance=v.sub(i.point).length(),i.faceIndex=d),n)}function tx(s,t,e){return s===null?null:(s.point.applyMatrix4(t.matrixWorld),s.distance=s.point.distanceTo(e.ray.origin),s.object=t,s)}var Zf=new ke,Jf=new _n,av=new I,cv=new vt,lv=new I,ex=["getX","getY","getZ"],jf=class s extends zf{static serialize(t,e={}){e={cloneBuffers:!0,...e};let n=t.geometry,i=t._roots,r=t._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=i.map(c=>c.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=r?r.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=r),a}static deserialize(t,e,n={}){n={setIndex:!0,indirect:!!t.indirectBuffer,...n};let{index:i,roots:r,indirectBuffer:o}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),c(r));let a=new s(e,{...n,[ql]:!0});if(a._roots=r,a._indirectBuffer=o||null,n.setIndex){let l=e.getIndex();if(l===null){let u=new kt(t.index,1,!1);e.setIndex(u)}else l.array!==i&&(l.array.set(i),l.needsUpdate=!0)}return a;function c(l){for(let u=0;u<l.length;u++){let h=l[u],f=new Uint32Array(h),p=new Uint16Array(h);for(let x=0,v=h.byteLength/32;x<v;x++){let y=8*x,_=2*y;le(_,p)||(f[y+6]=f[y+6]/8-x)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.'),e={...e,targetLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,n){let i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,l=(r?r[t]:t)*3,u=l+0,h=l+1,f=l+2;a&&(u=a[u],h=a[h],f=a[f]);for(let p=0;p<3;p++){let x=o[ex[p]](u),v=o[ex[p]](h),y=o[ex[p]](f),_=x;v<_&&(_=v),y<_&&(_=y);let S=x;v>S&&(S=v),y>S&&(S=y),e[n+p]=_,e[n+p+3]=S}return e}computePrimitiveBounds(t,e,n){let i=this.geometry,r=this._indirectBuffer,o=i.attributes.position,a=i.index?i.index.array:null,c=o.normalized;if(t<0||e+t-n.offset>n.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");let l=o.array,u=o.offset||0,h=3;o.isInterleavedBufferAttribute&&(h=o.data.stride);let f=["getX","getY","getZ"],p=n.offset;for(let x=t,v=t+e;x<v;x++){let _=(r?r[x]:x)*3,S=(x-p)*6,g=_+0,d=_+1,M=_+2;a&&(g=a[g],d=a[d],M=a[M]),c||(g=g*h+u,d=d*h+u,M=M*h+u);for(let m=0;m<3;m++){let R,E,T;c?(R=o[f[m]](g),E=o[f[m]](d),T=o[f[m]](M)):(R=l[g+m],E=l[d+m],T=l[M+m]);let b=R;E<b&&(b=E),T<b&&(b=T);let w=R;E>w&&(w=E),T>w&&(w=T);let A=(w-b)/2,C=m*2;n[S+C+0]=b+A,n[S+C+1]=A+(Math.abs(b)+A)*oa}}return n}raycastObject3D(t,e,n=[]){let{material:i}=t;if(i===void 0)return;cv.copy(t.matrixWorld).invert(),Jf.copy(e.ray).applyMatrix4(cv),lv.setFromMatrixScale(t.matrixWorld),av.copy(Jf.direction).multiply(lv);let r=av.length(),o=e.near/r,a=e.far/r;if(e.firstHitOnly===!0){let c=this.raycastFirst(Jf,i,o,a);c=tx(c,t,e),c&&n.push(c)}else{let c=this.raycast(Jf,i,o,a);for(let l=0,u=c.length;l<u;l++){let h=tx(c[l],t,e);h&&n.push(h)}}return n}refit(t=null){return(this.indirect?ev:qy)(this,t)}raycast(t,e=rn,n=0,i=1/0){let r=this._roots,o=[],a=this.indirect?nv:Zy;for(let c=0,l=r.length;c<l;c++)a(this,c,e,t,o,n,i);return o}raycastFirst(t,e=rn,n=0,i=1/0){let r=this._roots,o=null,a=this.indirect?iv:Jy;for(let c=0,l=r.length;c<l;c++){let u=a(this,c,e,t,n,i);u!=null&&(o==null||u.distance<o.distance)&&(o=u)}return o}intersectsGeometry(t,e){let n=!1,i=this._roots,r=this.indirect?sv:Qy;for(let o=0,a=i.length;o<a&&(n=r(this,o,t,e),!n);o++);return n}shapecast(t){let e=Sn.getPrimitive(),n=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?Ky:Xy});return Sn.releasePrimitive(e),n}bvhcast(t,e,n){let{intersectsRanges:i,intersectsTriangles:r}=n,o=Sn.getPrimitive(),a=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?x=>{let v=this.resolveTriangleIndex(x);be(o,v*3,a,c)}:x=>{be(o,x*3,a,c)},u=Sn.getPrimitive(),h=t.geometry.index,f=t.geometry.attributes.position,p=t.indirect?x=>{let v=t.resolveTriangleIndex(x);be(u,v*3,h,f)}:x=>{be(u,x*3,h,f)};if(r){if(!(t instanceof s))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');let x=(v,y,_,S,g,d,M,m)=>{for(let R=_,E=_+S;R<E;R++){p(R),u.a.applyMatrix4(e),u.b.applyMatrix4(e),u.c.applyMatrix4(e),u.needsUpdate=!0;for(let T=v,b=v+y;T<b;T++)if(l(T),o.needsUpdate=!0,r(o,u,T,R,g,d,M,m))return!0}return!1};if(i){let v=i;i=function(y,_,S,g,d,M,m,R){return v(y,_,S,g,d,M,m,R)?!0:x(y,_,S,g,d,M,m,R)}}else i=x}return super.bvhcast(t,e,{intersectsRanges:i})}intersectsBox(t,e){return Zf.set(t.min,t.max,e),Zf.needsUpdate=!0,this.shapecast({intersectsBounds:n=>Zf.intersectsBox(n),intersectsTriangle:n=>Zf.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},i={},r=0,o=1/0){return(this.indirect?ov:tv)(this,t,e,n,i,r,o)}closestPointToPoint(t,e={},n=0,i=1/0){return Oy(this,t,e,n,i)}};var uv=Math.pow(10,-Math.log10(1e-6)),G1=5e-7*uv;function Ti(s){return~~(s*uv+G1)}function hv(s){return`${Ti(s.x)},${Ti(s.y)}`}function nx(s){return`${Ti(s.x)},${Ti(s.y)},${Ti(s.z)}`}function fv(s){return`${Ti(s.x)},${Ti(s.y)},${Ti(s.z)},${Ti(s.w)}`}function dv(s,t,e){e.direction.subVectors(t,s).normalize();let n=s.dot(e.direction);return e.origin.copy(s).addScaledVector(e.direction,-n),e}function Qf(){return typeof SharedArrayBuffer<"u"}function pv(s){if(s.buffer instanceof SharedArrayBuffer)return s;let t=s.constructor,e=s.buffer,n=new SharedArrayBuffer(e.byteLength),i=new Uint8Array(e);return new Uint8Array(n).set(i,0),new t(n)}function W1(s){return s.index?s.index.count:s.attributes.position.count}function va(s){return W1(s)/3}var X1=1e-8,q1=new I;function gv(s){return~~(s/3)}function xv(s){return s%3}function mv(s,t){return s.start-t.start}function ix(s,t){return q1.subVectors(t,s.origin).dot(s.direction)}function _v(s,t,e,n=X1){s.sort(mv),t.sort(mv);for(let a=0;a<s.length;a++){let c=s[a];for(let l=0;l<t.length;l++){let u=t[l];if(!(u.start>c.end)){if(c.end<u.start||u.end<c.start)continue;if(c.start<=u.start&&c.end>=u.end)r(u.end,c.end)||s.splice(a+1,0,{start:u.end,end:c.end,index:c.index}),c.end=u.start,u.start=0,u.end=0;else if(c.start>=u.start&&c.end<=u.end)r(c.end,u.end)||t.splice(l+1,0,{start:c.end,end:u.end,index:u.index}),u.end=c.start,c.start=0,c.end=0;else if(c.start<=u.start&&c.end<=u.end){let h=c.end;c.end=u.start,u.start=h}else if(c.start>=u.start&&c.end>=u.end){let h=u.end;u.end=c.start,c.start=h}else throw new Error}if(e.has(c.index)||e.set(c.index,[]),e.has(u.index)||e.set(u.index,[]),e.get(c.index).push(u.index),e.get(u.index).push(c.index),o(u)&&(t.splice(l,1),l--),o(c)){s.splice(a,1),a--;break}}}i(s),i(t);function i(a){for(let c=0;c<a.length;c++)o(a[c])&&(a.splice(c,1),c--)}function r(a,c){return Math.abs(c-a)<n}function o(a){return Math.abs(a.end-a.start)<n}}var td=class{constructor(){this._rays=[]}addRay(t){this._rays.push(t)}findClosestRay(t){let e=this._rays,n=t.clone();n.direction.multiplyScalar(-1);let i=1/0,r=null;for(let c=0,l=e.length;c<l;c++){let u=e[c];if(o(u,t)&&o(u,n))continue;let h=a(u,t),f=a(u,n),p=Math.min(h,f);p<i&&(i=p,r=u)}return r;function o(c,l){let u=c.origin.distanceTo(l.origin)>1e-5;return c.direction.angleTo(l.direction)>1e-4||u}function a(c,l){let u=c.origin.distanceTo(l.origin),h=c.direction.angleTo(l.direction);return u/1e-5+h/1e-4}}};var rx=new I,sx=new I,ed=new _n;function yv(s,t,e){let n=s.attributes,i=s.index,r=n.position,o=new Map,a=new Map,c=Array.from(t),l=new td;for(let u=0,h=c.length;u<h;u++){let f=c[u],p=gv(f),x=xv(f),v=3*p+x,y=3*p+(x+1)%3;i&&(v=i.getX(v),y=i.getX(y)),rx.fromBufferAttribute(r,v),sx.fromBufferAttribute(r,y),dv(rx,sx,ed);let _,S=l.findClosestRay(ed);S===null&&(S=ed.clone(),l.addRay(S)),a.has(S)||a.set(S,{forward:[],reverse:[],ray:S}),_=a.get(S);let g=ix(S,rx),d=ix(S,sx);g>d&&([g,d]=[d,g]),ed.direction.dot(S.direction)<0?_.reverse.push({start:g,end:d,index:f}):_.forward.push({start:g,end:d,index:f})}return a.forEach(({forward:u,reverse:h},f)=>{_v(u,h,o,e),u.length===0&&h.length===0&&a.delete(f)}),{disjointConnectivityMap:o,fragmentMap:a}}var Y1=new nt,ox=new I,$1=new Qt,ax=["","",""],nd=class{constructor(){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8}getSiblingTriangleIndex(t,e){let n=this.data[t*3+e];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(t,e){let n=this.data[t*3+e];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(t,e){let n=t*3+e,i=this.disjointConnections.get(n);return i?i.map(r=>~~(r/3)):[]}getDisjointSiblingEdgeIndices(t,e){let n=t*3+e,i=this.disjointConnections.get(n);return i?i.map(r=>r%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(t){let{useAllAttributes:e,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:r}=this,o=e?g:S,a=new Map,{attributes:c}=t,l=e?Object.keys(c):null,u=t.index,h=c.position,f=va(t),p=f,x=0;n&&(x=t.drawRange.start,t.drawRange.count!==1/0&&(f=~~(t.drawRange.count/3)));let v=this.data;(!v||v.length<3*p)&&(v=new Int32Array(3*p)),v.fill(-1);let y=0,_=new Set;for(let d=x,M=f*3+x;d<M;d+=3){let m=d;for(let R=0;R<3;R++){let E=m+R;u&&(E=u.getX(E)),ax[R]=o(E)}for(let R=0;R<3;R++){let E=(R+1)%3,T=ax[R],b=ax[E],w=`${b}_${T}`;if(a.has(w)){let A=m+R,C=a.get(w);v[A]=C,v[C]=A,a.delete(w),y+=2,_.delete(C)}else{let A=`${T}_${b}`,C=m+R;a.set(A,C),_.add(C)}}}if(i){let{fragmentMap:d,disjointConnectivityMap:M}=yv(t,_,r);_.clear(),d.forEach(({forward:m,reverse:R})=>{m.forEach(({index:E})=>_.add(E)),R.forEach(({index:E})=>_.add(E))}),this.unmatchedDisjointEdges=d,this.disjointConnections=M,y=f*3-_.size}this.matchedEdges=y,this.unmatchedEdges=_.size,this.data=v;function S(d){return ox.fromBufferAttribute(h,d),nx(ox)}function g(d){let M="";for(let m=0,R=l.length;m<R;m++){let E=c[l[m]],T;switch(E.itemSize){case 1:T=Ti(E.getX(d));break;case 2:T=hv(Y1.fromBufferAttribute(E,d));break;case 3:T=nx(ox.fromBufferAttribute(E,d));break;case 4:T=fv($1.fromBufferAttribute(E,d));break}M!==""&&(M+="|"),M+=T}return M}}};var ks=class extends ce{constructor(...t){super(...t),this.isBrush=!0,this._previousMatrix=new vt,this._previousMatrix.elements.fill(0),this._halfEdges=null,this._boundsTree=null,this._groupIndices=null,this._hash=null}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){let{matrix:t,_previousMatrix:e}=this,n=t.elements,i=e.elements;for(let r=0;r<16;r++)if(n[r]!==i[r])return!0;return!1}prepareGeometry(){let t=this.geometry,e=t.attributes,n=Qf(),i=t.index,r=t.attributes.position,o=i?`${i.uuid}_${i.count}_${i.version}`:"-1_-1_-1",a=`${r.uuid}_${r.count}_${r.version}`,c=`${t.uuid}_${o}_${a}`;if(this._hash===c)return;if(this._hash=c,n)for(let f in e){let p=e[f];if(p.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");p.array=pv(p.array)}t.boundsTree=new jf(t,{maxLeafSize:3,indirect:!0,useSharedArrayBuffer:n}),t.halfEdges||(t.halfEdges=new nd),t.halfEdges.updateFrom(t);let l=va(t);(!t.groupIndices||t.groupIndices.length!==l)&&(t.groupIndices=new Uint16Array(l));let u=t.groupIndices,h=t.groups;for(let f=0,p=h.length;f<p;f++){let{start:x,count:v}=h[f];for(let y=x/3,_=(x+v)/3;y<_;y++)u[y]=f}}disposeCacheData(){let{geometry:t}=this;t.halfEdges=null,t.boundsTree=null,t.groupIndices=null}};var K1=Object.getOwnPropertyNames,Yn=(s,t)=>function(){return t||(0,s[K1(s)[0]])((t={exports:{}}).exports,t),t.exports},id=Yn({"node_modules/binary-search-bounds/search-bounds.js"(s,t){"use strict";function e(c,l,u,h,f){for(var p=f+1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y>=0?(p=x,f=x-1):h=x+1}return p}function n(c,l,u,h,f){for(var p=f+1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y>0?(p=x,f=x-1):h=x+1}return p}function i(c,l,u,h,f){for(var p=h-1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y<0?(p=x,h=x+1):f=x-1}return p}function r(c,l,u,h,f){for(var p=h-1;h<=f;){var x=h+f>>>1,v=c[x],y=u!==void 0?u(v,l):v-l;y<=0?(p=x,h=x+1):f=x-1}return p}function o(c,l,u,h,f){for(;h<=f;){var p=h+f>>>1,x=c[p],v=u!==void 0?u(x,l):x-l;if(v===0)return p;v<=0?h=p+1:f=p-1}return-1}function a(c,l,u,h,f,p){return typeof u=="function"?p(c,l,u,h===void 0?0:h|0,f===void 0?c.length-1:f|0):p(c,l,void 0,u===void 0?0:u|0,h===void 0?c.length-1:h|0)}t.exports={ge:function(c,l,u,h,f){return a(c,l,u,h,f,e)},gt:function(c,l,u,h,f){return a(c,l,u,h,f,n)},lt:function(c,l,u,h,f){return a(c,l,u,h,f,i)},le:function(c,l,u,h,f){return a(c,l,u,h,f,r)},eq:function(c,l,u,h,f){return a(c,l,u,h,f,o)}}}}),cx=Yn({"node_modules/two-product/two-product.js"(s,t){"use strict";t.exports=n;var e=+(Math.pow(2,27)+1);function n(i,r,o){var a=i*r,c=e*i,l=c-i,u=c-l,h=i-u,f=e*r,p=f-r,x=f-p,v=r-x,y=a-u*x,_=y-h*x,S=_-u*v,g=h*v-S;return o?(o[0]=g,o[1]=a,o):[g,a]}}}),vv=Yn({"node_modules/robust-sum/robust-sum.js"(s,t){"use strict";t.exports=n;function e(i,r){var o=i+r,a=o-i,c=o-a,l=r-a,u=i-c,h=u+l;return h?[h,o]:[o]}function n(i,r){var o=i.length|0,a=r.length|0;if(o===1&&a===1)return e(i[0],r[0]);var c=o+a,l=new Array(c),u=0,h=0,f=0,p=Math.abs,x=i[h],v=p(x),y=r[f],_=p(y),S,g;v<_?(g=x,h+=1,h<o&&(x=i[h],v=p(x))):(g=y,f+=1,f<a&&(y=r[f],_=p(y))),h<o&&v<_||f>=a?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=r[f],_=p(y)));for(var d=S+g,M=d-S,m=g-M,R=m,E=d,T,b,w,A,C;h<o&&f<a;)v<_?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=r[f],_=p(y))),g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T;for(;h<o;)S=x,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,h+=1,h<o&&(x=i[h]);for(;f<a;)S=y,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,f+=1,f<a&&(y=r[f]);return R&&(l[u++]=R),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}}}),Z1=Yn({"node_modules/two-sum/two-sum.js"(s,t){"use strict";t.exports=e;function e(n,i,r){var o=n+i,a=o-n,c=o-a,l=i-a,u=n-c;return r?(r[0]=u+l,r[1]=o,r):[u+l,o]}}}),Mv=Yn({"node_modules/robust-scale/robust-scale.js"(s,t){"use strict";var e=cx(),n=Z1();t.exports=i;function i(r,o){var a=r.length;if(a===1){var c=e(r[0],o);return c[0]?c:[c[1]]}var l=new Array(2*a),u=[.1,.1],h=[.1,.1],f=0;e(r[0],o,u),u[0]&&(l[f++]=u[0]);for(var p=1;p<a;++p){e(r[p],o,h);var x=u[1];n(x,h[0],u),u[0]&&(l[f++]=u[0]);var v=h[1],y=u[1],_=v+y,S=_-v,g=y-S;u[1]=_,g&&(l[f++]=g)}return u[1]&&(l[f++]=u[1]),f===0&&(l[f++]=0),l.length=f,l}}}),Sv=Yn({"node_modules/robust-subtract/robust-diff.js"(s,t){"use strict";t.exports=n;function e(i,r){var o=i+r,a=o-i,c=o-a,l=r-a,u=i-c,h=u+l;return h?[h,o]:[o]}function n(i,r){var o=i.length|0,a=r.length|0;if(o===1&&a===1)return e(i[0],-r[0]);var c=o+a,l=new Array(c),u=0,h=0,f=0,p=Math.abs,x=i[h],v=p(x),y=-r[f],_=p(y),S,g;v<_?(g=x,h+=1,h<o&&(x=i[h],v=p(x))):(g=y,f+=1,f<a&&(y=-r[f],_=p(y))),h<o&&v<_||f>=a?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=-r[f],_=p(y)));for(var d=S+g,M=d-S,m=g-M,R=m,E=d,T,b,w,A,C;h<o&&f<a;)v<_?(S=x,h+=1,h<o&&(x=i[h],v=p(x))):(S=y,f+=1,f<a&&(y=-r[f],_=p(y))),g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T;for(;h<o;)S=x,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,h+=1,h<o&&(x=i[h]);for(;f<a;)S=y,g=R,d=S+g,M=d-S,m=g-M,m&&(l[u++]=m),T=E+d,b=T-E,w=T-b,A=d-b,C=E-w,R=C+A,E=T,f+=1,f<a&&(y=-r[f]);return R&&(l[u++]=R),E&&(l[u++]=E),u||(l[u++]=0),l.length=u,l}}}),J1=Yn({"node_modules/robust-orientation/orientation.js"(s,t){"use strict";var e=cx(),n=vv(),i=Mv(),r=Sv(),o=5,a=11102230246251565e-32,c=(3+16*a)*a,l=(7+56*a)*a;function u(d,M,m,R){return function(T,b,w){var A=d(d(M(b[1],w[0]),M(-w[1],b[0])),d(M(T[1],b[0]),M(-b[1],T[0]))),C=d(M(T[1],w[0]),M(-w[1],T[0])),D=R(A,C);return D[D.length-1]}}function h(d,M,m,R){return function(T,b,w,A){var C=d(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2])))),D=d(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2])))),F=R(C,D);return F[F.length-1]}}function f(d,M,m,R){return function(T,b,w,A,C){var D=d(d(d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),w[2]),d(m(d(M(w[1],C[0]),M(-C[1],w[0])),-A[2]),m(d(M(w[1],A[0]),M(-A[1],w[0])),C[2]))),b[3]),d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-A[2]),m(d(M(b[1],A[0]),M(-A[1],b[0])),C[2]))),-w[3]),m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),C[2]))),A[3]))),d(m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),-C[3]),d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-A[2]),m(d(M(b[1],A[0]),M(-A[1],b[0])),C[2]))),T[3]),m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-A[2]),m(d(M(T[1],A[0]),M(-A[1],T[0])),C[2]))),-b[3])))),d(d(m(d(m(d(M(b[1],C[0]),M(-C[1],b[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),C[2]))),A[3]),d(m(d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2]))),-C[3]),m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),b[2]),d(m(d(M(b[1],A[0]),M(-A[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),A[2]))),T[3]))),d(m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),-b[3]),d(m(d(m(d(M(b[1],A[0]),M(-A[1],b[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),A[2]))),w[3]),m(d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2]))),-A[3]))))),F=d(d(d(m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),w[2]),d(m(d(M(w[1],C[0]),M(-C[1],w[0])),-A[2]),m(d(M(w[1],A[0]),M(-A[1],w[0])),C[2]))),T[3]),m(d(m(d(M(A[1],C[0]),M(-C[1],A[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-A[2]),m(d(M(T[1],A[0]),M(-A[1],T[0])),C[2]))),-w[3])),d(m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),C[2]))),A[3]),m(d(m(d(M(w[1],A[0]),M(-A[1],w[0])),T[2]),d(m(d(M(T[1],A[0]),M(-A[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),A[2]))),-C[3]))),d(d(m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),b[2]),d(m(d(M(b[1],C[0]),M(-C[1],b[0])),-w[2]),m(d(M(b[1],w[0]),M(-w[1],b[0])),C[2]))),T[3]),m(d(m(d(M(w[1],C[0]),M(-C[1],w[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-w[2]),m(d(M(T[1],w[0]),M(-w[1],T[0])),C[2]))),-b[3])),d(m(d(m(d(M(b[1],C[0]),M(-C[1],b[0])),T[2]),d(m(d(M(T[1],C[0]),M(-C[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),C[2]))),w[3]),m(d(m(d(M(b[1],w[0]),M(-w[1],b[0])),T[2]),d(m(d(M(T[1],w[0]),M(-w[1],T[0])),-b[2]),m(d(M(T[1],b[0]),M(-b[1],T[0])),w[2]))),-C[3])))),O=R(D,F);return O[O.length-1]}}function p(d){var M=d===3?u:d===4?h:f;return M(n,e,i,r)}var x=p(3),v=p(4),y=[function(){return 0},function(){return 0},function(M,m){return m[0]-M[0]},function(M,m,R){var E=(M[1]-R[1])*(m[0]-R[0]),T=(M[0]-R[0])*(m[1]-R[1]),b=E-T,w;if(E>0){if(T<=0)return b;w=E+T}else if(E<0){if(T>=0)return b;w=-(E+T)}else return b;var A=c*w;return b>=A||b<=-A?b:x(M,m,R)},function(M,m,R,E){var T=M[0]-E[0],b=m[0]-E[0],w=R[0]-E[0],A=M[1]-E[1],C=m[1]-E[1],D=R[1]-E[1],F=M[2]-E[2],O=m[2]-E[2],H=R[2]-E[2],B=b*D,$=w*C,at=w*A,rt=T*D,ht=T*C,bt=b*A,Et=F*(B-$)+O*(at-rt)+H*(ht-bt),Mt=(Math.abs(B)+Math.abs($))*Math.abs(F)+(Math.abs(at)+Math.abs(rt))*Math.abs(O)+(Math.abs(ht)+Math.abs(bt))*Math.abs(H),K=l*Mt;return Et>K||-Et>K?Et:v(M,m,R,E)}];function _(d){var M=y[d.length];return M||(M=y[d.length]=p(d.length)),M.apply(void 0,d)}function S(d,M,m,R,E,T,b){return function(A,C,D,F,O){switch(arguments.length){case 0:case 1:return 0;case 2:return R(A,C);case 3:return E(A,C,D);case 4:return T(A,C,D,F);case 5:return b(A,C,D,F,O)}for(var H=new Array(arguments.length),B=0;B<arguments.length;++B)H[B]=arguments[B];return d(H)}}function g(){for(;y.length<=o;)y.push(p(y.length));t.exports=S.apply(void 0,[_].concat(y));for(var d=0;d<=o;++d)t.exports[d]=y[d]}g()}}),j1=Yn({"node_modules/cdt2d/lib/monotone.js"(s,t){"use strict";var e=id(),n=J1()[3],i=0,r=1,o=2;t.exports=v;function a(y,_,S,g,d){this.a=y,this.b=_,this.idx=S,this.lowerIds=g,this.upperIds=d}function c(y,_,S,g){this.a=y,this.b=_,this.type=S,this.idx=g}function l(y,_){var S=y.a[0]-_.a[0]||y.a[1]-_.a[1]||y.type-_.type;return S||y.type!==i&&(S=n(y.a,y.b,_.b),S)?S:y.idx-_.idx}function u(y,_){return n(y.a,y.b,_)}function h(y,_,S,g,d){for(var M=e.lt(_,g,u),m=e.gt(_,g,u),R=M;R<m;++R){for(var E=_[R],T=E.lowerIds,w=T.length;w>1&&n(S[T[w-2]],S[T[w-1]],g)>0;)y.push([T[w-1],T[w-2],d]),w-=1;T.length=w,T.push(d);for(var b=E.upperIds,w=b.length;w>1&&n(S[b[w-2]],S[b[w-1]],g)<0;)y.push([b[w-2],b[w-1],d]),w-=1;b.length=w,b.push(d)}}function f(y,_){var S;return y.a[0]<_.a[0]?S=n(y.a,y.b,_.a):S=n(_.b,_.a,y.a),S||(_.b[0]<y.b[0]?S=n(y.a,y.b,_.b):S=n(_.b,_.a,y.b),S||y.idx-_.idx)}function p(y,_,S){var g=e.le(y,S,f),d=y[g],M=d.upperIds,m=M[M.length-1];d.upperIds=[m],y.splice(g+1,0,new a(S.a,S.b,S.idx,[m],M))}function x(y,_,S){var g=S.a;S.a=S.b,S.b=g;var d=e.eq(y,S,f),M=y[d],m=y[d-1];m.upperIds=M.upperIds,y.splice(d,1)}function v(y,_){for(var S=y.length,g=_.length,d=[],M=0;M<S;++M)d.push(new c(y[M],null,i,M));for(var M=0;M<g;++M){var m=_[M],R=y[m[0]],E=y[m[1]];R[0]<E[0]?d.push(new c(R,E,o,M),new c(E,R,r,M)):R[0]>E[0]&&d.push(new c(E,R,o,M),new c(R,E,r,M))}d.sort(l);for(var T=d[0].a[0]-(1+Math.abs(d[0].a[0]))*Math.pow(2,-52),b=[new a([T,1],[T,0],-1,[],[],[],[])],w=[],M=0,A=d.length;M<A;++M){var C=d[M],D=C.type;D===i?h(w,b,y,C.a,C.idx):D===o?p(b,y,C):x(b,y,C)}return w}}}),Q1=Yn({"node_modules/cdt2d/lib/triangulation.js"(s,t){"use strict";var e=id();t.exports=o;function n(a,c){this.stars=a,this.edges=c}var i=n.prototype;function r(a,c,l){for(var u=1,h=a.length;u<h;u+=2)if(a[u-1]===c&&a[u]===l){a[u-1]=a[h-2],a[u]=a[h-1],a.length=h-2;return}}i.isConstraint=function(){var a=[0,0];function c(l,u){return l[0]-u[0]||l[1]-u[1]}return function(l,u){return a[0]=Math.min(l,u),a[1]=Math.max(l,u),e.eq(this.edges,a,c)>=0}}(),i.removeTriangle=function(a,c,l){var u=this.stars;r(u[a],c,l),r(u[c],l,a),r(u[l],a,c)},i.addTriangle=function(a,c,l){var u=this.stars;u[a].push(c,l),u[c].push(l,a),u[l].push(a,c)},i.opposite=function(a,c){for(var l=this.stars[c],u=1,h=l.length;u<h;u+=2)if(l[u]===a)return l[u-1];return-1},i.flip=function(a,c){var l=this.opposite(a,c),u=this.opposite(c,a);this.removeTriangle(a,c,l),this.removeTriangle(c,a,u),this.addTriangle(a,u,l),this.addTriangle(c,l,u)},i.edges=function(){for(var a=this.stars,c=[],l=0,u=a.length;l<u;++l)for(var h=a[l],f=0,p=h.length;f<p;f+=2)c.push([h[f],h[f+1]]);return c},i.cells=function(){for(var a=this.stars,c=[],l=0,u=a.length;l<u;++l)for(var h=a[l],f=0,p=h.length;f<p;f+=2){var x=h[f],v=h[f+1];l<Math.min(x,v)&&c.push([l,x,v])}return c};function o(a,c){for(var l=new Array(a),u=0;u<a;++u)l[u]=[];return new n(l,c)}}}),tR=Yn({"node_modules/robust-in-sphere/in-sphere.js"(s,t){"use strict";var e=cx(),n=vv(),i=Sv(),r=Mv(),o=6;function a(g){var d=g===3?h:g===4?f:g===5?p:x;return d(n,i,e,r)}function c(){return 0}function l(){return 0}function u(){return 0}function h(g,d,M,m){function R(E,T,b){var w=M(E[0],E[0]),A=m(w,T[0]),C=m(w,b[0]),D=M(T[0],T[0]),F=m(D,E[0]),O=m(D,b[0]),H=M(b[0],b[0]),B=m(H,E[0]),$=m(H,T[0]),at=g(d($,O),d(F,A)),rt=d(B,C),ht=d(at,rt);return ht[ht.length-1]}return R}function f(g,d,M,m){function R(E,T,b,w){var A=g(M(E[0],E[0]),M(E[1],E[1])),C=m(A,T[0]),D=m(A,b[0]),F=m(A,w[0]),O=g(M(T[0],T[0]),M(T[1],T[1])),H=m(O,E[0]),B=m(O,b[0]),$=m(O,w[0]),at=g(M(b[0],b[0]),M(b[1],b[1])),rt=m(at,E[0]),ht=m(at,T[0]),bt=m(at,w[0]),Et=g(M(w[0],w[0]),M(w[1],w[1])),Mt=m(Et,E[0]),K=m(Et,T[0]),Q=m(Et,b[0]),ct=g(g(m(d(Q,bt),T[1]),g(m(d(K,$),-b[1]),m(d(ht,B),w[1]))),g(m(d(K,$),E[1]),g(m(d(Mt,F),-T[1]),m(d(H,C),w[1])))),lt=g(g(m(d(Q,bt),E[1]),g(m(d(Mt,F),-b[1]),m(d(rt,D),w[1]))),g(m(d(ht,B),E[1]),g(m(d(rt,D),-T[1]),m(d(H,C),b[1])))),ut=d(ct,lt);return ut[ut.length-1]}return R}function p(g,d,M,m){function R(E,T,b,w,A){var C=g(M(E[0],E[0]),g(M(E[1],E[1]),M(E[2],E[2]))),D=m(C,T[0]),F=m(C,b[0]),O=m(C,w[0]),H=m(C,A[0]),B=g(M(T[0],T[0]),g(M(T[1],T[1]),M(T[2],T[2]))),$=m(B,E[0]),at=m(B,b[0]),rt=m(B,w[0]),ht=m(B,A[0]),bt=g(M(b[0],b[0]),g(M(b[1],b[1]),M(b[2],b[2]))),Et=m(bt,E[0]),Mt=m(bt,T[0]),K=m(bt,w[0]),Q=m(bt,A[0]),ct=g(M(w[0],w[0]),g(M(w[1],w[1]),M(w[2],w[2]))),lt=m(ct,E[0]),ut=m(ct,T[0]),Ct=m(ct,b[0]),Kt=m(ct,A[0]),U=g(M(A[0],A[0]),g(M(A[1],A[1]),M(A[2],A[2]))),tt=m(U,E[0]),Z=m(U,T[0]),Y=m(U,b[0]),q=m(U,w[0]),mt=g(g(g(m(g(m(d(q,Kt),b[1]),g(m(d(Y,Q),-w[1]),m(d(Ct,K),A[1]))),T[2]),g(m(g(m(d(q,Kt),T[1]),g(m(d(Z,ht),-w[1]),m(d(ut,rt),A[1]))),-b[2]),m(g(m(d(Y,Q),T[1]),g(m(d(Z,ht),-b[1]),m(d(Mt,at),A[1]))),w[2]))),g(m(g(m(d(Ct,K),T[1]),g(m(d(ut,rt),-b[1]),m(d(Mt,at),w[1]))),-A[2]),g(m(g(m(d(q,Kt),T[1]),g(m(d(Z,ht),-w[1]),m(d(ut,rt),A[1]))),E[2]),m(g(m(d(q,Kt),E[1]),g(m(d(tt,H),-w[1]),m(d(lt,O),A[1]))),-T[2])))),g(g(m(g(m(d(Z,ht),E[1]),g(m(d(tt,H),-T[1]),m(d($,D),A[1]))),w[2]),g(m(g(m(d(ut,rt),E[1]),g(m(d(lt,O),-T[1]),m(d($,D),w[1]))),-A[2]),m(g(m(d(Ct,K),T[1]),g(m(d(ut,rt),-b[1]),m(d(Mt,at),w[1]))),E[2]))),g(m(g(m(d(Ct,K),E[1]),g(m(d(lt,O),-b[1]),m(d(Et,F),w[1]))),-T[2]),g(m(g(m(d(ut,rt),E[1]),g(m(d(lt,O),-T[1]),m(d($,D),w[1]))),b[2]),m(g(m(d(Mt,at),E[1]),g(m(d(Et,F),-T[1]),m(d($,D),b[1]))),-w[2]))))),it=g(g(g(m(g(m(d(q,Kt),b[1]),g(m(d(Y,Q),-w[1]),m(d(Ct,K),A[1]))),E[2]),m(g(m(d(q,Kt),E[1]),g(m(d(tt,H),-w[1]),m(d(lt,O),A[1]))),-b[2])),g(m(g(m(d(Y,Q),E[1]),g(m(d(tt,H),-b[1]),m(d(Et,F),A[1]))),w[2]),m(g(m(d(Ct,K),E[1]),g(m(d(lt,O),-b[1]),m(d(Et,F),w[1]))),-A[2]))),g(g(m(g(m(d(Y,Q),T[1]),g(m(d(Z,ht),-b[1]),m(d(Mt,at),A[1]))),E[2]),m(g(m(d(Y,Q),E[1]),g(m(d(tt,H),-b[1]),m(d(Et,F),A[1]))),-T[2])),g(m(g(m(d(Z,ht),E[1]),g(m(d(tt,H),-T[1]),m(d($,D),A[1]))),b[2]),m(g(m(d(Mt,at),E[1]),g(m(d(Et,F),-T[1]),m(d($,D),b[1]))),-A[2])))),st=d(mt,it);return st[st.length-1]}return R}function x(g,d,M,m){function R(E,T,b,w,A,C){var D=g(g(M(E[0],E[0]),M(E[1],E[1])),g(M(E[2],E[2]),M(E[3],E[3]))),F=m(D,T[0]),O=m(D,b[0]),H=m(D,w[0]),B=m(D,A[0]),$=m(D,C[0]),at=g(g(M(T[0],T[0]),M(T[1],T[1])),g(M(T[2],T[2]),M(T[3],T[3]))),rt=m(at,E[0]),ht=m(at,b[0]),bt=m(at,w[0]),Et=m(at,A[0]),Mt=m(at,C[0]),K=g(g(M(b[0],b[0]),M(b[1],b[1])),g(M(b[2],b[2]),M(b[3],b[3]))),Q=m(K,E[0]),ct=m(K,T[0]),lt=m(K,w[0]),ut=m(K,A[0]),Ct=m(K,C[0]),Kt=g(g(M(w[0],w[0]),M(w[1],w[1])),g(M(w[2],w[2]),M(w[3],w[3]))),U=m(Kt,E[0]),tt=m(Kt,T[0]),Z=m(Kt,b[0]),Y=m(Kt,A[0]),q=m(Kt,C[0]),mt=g(g(M(A[0],A[0]),M(A[1],A[1])),g(M(A[2],A[2]),M(A[3],A[3]))),it=m(mt,E[0]),st=m(mt,T[0]),Pt=m(mt,b[0]),It=m(mt,w[0]),N=m(mt,C[0]),P=g(g(M(C[0],C[0]),M(C[1],C[1])),g(M(C[2],C[2]),M(C[3],C[3]))),k=m(P,E[0]),W=m(P,T[0]),et=m(P,b[0]),X=m(P,w[0]),_t=m(P,A[0]),xt=g(g(g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),b[2]),m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),-w[2])),g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),A[2]),m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),-C[2]))),T[3]),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-w[2])),g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),A[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-C[2]))),-b[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),A[2]),m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),-C[2]))),w[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),T[2]),m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-C[2]))),-A[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),T[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-A[2]))),C[3])),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-w[2])),g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),A[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-C[2]))),E[3]),m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-w[2])),g(m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),A[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-C[2]))),-T[3])))),g(g(g(m(g(g(m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),A[2]),m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),-C[2]))),w[3]),m(g(g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-C[2]))),-A[3])),g(m(g(g(m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-A[2]))),C[3]),m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),T[2]),m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-C[2]))),E[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-C[2]))),-T[3]),m(g(g(m(g(m(d(X,q),T[1]),g(m(d(W,Mt),-w[1]),m(d(tt,bt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-C[2]))),b[3])),g(m(g(g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),E[2]),m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-C[2]))),-w[3]),m(g(g(m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),E[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-T[2])),g(m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-w[2]))),C[3]))))),Ft=g(g(g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),b[2]),m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),-w[2])),g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),A[2]),m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),-C[2]))),E[3]),g(m(g(g(m(g(m(d(_t,N),w[1]),g(m(d(X,q),-A[1]),m(d(It,Y),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-w[2])),g(m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),A[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-C[2]))),-b[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),A[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-C[2]))),w[3]))),g(g(m(g(g(m(g(m(d(X,q),b[1]),g(m(d(et,Ct),-w[1]),m(d(Z,lt),C[1]))),E[2]),m(g(m(d(X,q),E[1]),g(m(d(k,$),-w[1]),m(d(U,H),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-C[2]))),-A[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-A[2]))),C[3])),g(m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),T[2]),m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),-b[2])),g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),A[2]),m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),-C[2]))),E[3]),m(g(g(m(g(m(d(_t,N),b[1]),g(m(d(et,Ct),-A[1]),m(d(Pt,ut),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-b[2])),g(m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),A[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-C[2]))),-T[3])))),g(g(g(m(g(g(m(g(m(d(_t,N),T[1]),g(m(d(W,Mt),-A[1]),m(d(st,Et),C[1]))),E[2]),m(g(m(d(_t,N),E[1]),g(m(d(k,$),-A[1]),m(d(it,B),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),A[2]),m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),-C[2]))),b[3]),m(g(g(m(g(m(d(et,Ct),T[1]),g(m(d(W,Mt),-b[1]),m(d(ct,ht),C[1]))),E[2]),m(g(m(d(et,Ct),E[1]),g(m(d(k,$),-b[1]),m(d(Q,O),C[1]))),-T[2])),g(m(g(m(d(W,Mt),E[1]),g(m(d(k,$),-T[1]),m(d(rt,F),C[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-C[2]))),-A[3])),g(m(g(g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),E[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-A[2]))),C[3]),m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),T[2]),m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),w[2]),m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),-A[2]))),E[3]))),g(g(m(g(g(m(g(m(d(It,Y),b[1]),g(m(d(Pt,ut),-w[1]),m(d(Z,lt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-b[2])),g(m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),w[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-A[2]))),-T[3]),m(g(g(m(g(m(d(It,Y),T[1]),g(m(d(st,Et),-w[1]),m(d(tt,bt),A[1]))),E[2]),m(g(m(d(It,Y),E[1]),g(m(d(it,B),-w[1]),m(d(U,H),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),w[2]),m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),-A[2]))),b[3])),g(m(g(g(m(g(m(d(Pt,ut),T[1]),g(m(d(st,Et),-b[1]),m(d(ct,ht),A[1]))),E[2]),m(g(m(d(Pt,ut),E[1]),g(m(d(it,B),-b[1]),m(d(Q,O),A[1]))),-T[2])),g(m(g(m(d(st,Et),E[1]),g(m(d(it,B),-T[1]),m(d(rt,F),A[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-A[2]))),-w[3]),m(g(g(m(g(m(d(Z,lt),T[1]),g(m(d(tt,bt),-b[1]),m(d(ct,ht),w[1]))),E[2]),m(g(m(d(Z,lt),E[1]),g(m(d(U,H),-b[1]),m(d(Q,O),w[1]))),-T[2])),g(m(g(m(d(tt,bt),E[1]),g(m(d(U,H),-T[1]),m(d(rt,F),w[1]))),b[2]),m(g(m(d(ct,ht),E[1]),g(m(d(Q,O),-T[1]),m(d(rt,F),b[1]))),-w[2]))),A[3]))))),Dt=d(xt,Ft);return Dt[Dt.length-1]}return R}var v=[c,l,u];function y(g){var d=v[g.length];return d||(d=v[g.length]=a(g.length)),d.apply(void 0,g)}function _(g,d,M,m,R,E,T,b){function w(A,C,D,F,O,H){switch(arguments.length){case 0:case 1:return 0;case 2:return m(A,C);case 3:return R(A,C,D);case 4:return E(A,C,D,F);case 5:return T(A,C,D,F,O);case 6:return b(A,C,D,F,O,H)}for(var B=new Array(arguments.length),$=0;$<arguments.length;++$)B[$]=arguments[$];return g(B)}return w}function S(){for(;v.length<=o;)v.push(a(v.length));t.exports=_.apply(void 0,[y].concat(v));for(var g=0;g<=o;++g)t.exports[g]=v[g]}S()}}),eR=Yn({"node_modules/cdt2d/lib/delaunay.js"(s,t){"use strict";var e=tR()[4],n=id();t.exports=r;function i(o,a,c,l,u,h){var f=a.opposite(l,u);if(!(f<0)){if(u<l){var p=l;l=u,u=p,p=h,h=f,f=p}a.isConstraint(l,u)||e(o[l],o[u],o[h],o[f])<0&&c.push(l,u)}}function r(o,a){for(var c=[],l=o.length,u=a.stars,h=0;h<l;++h)for(var f=u[h],p=1;p<f.length;p+=2){var x=f[p];if(!(x<h)&&!a.isConstraint(h,x)){for(var v=f[p-1],y=-1,_=1;_<f.length;_+=2)if(f[_-1]===x){y=f[_];break}y<0||e(o[h],o[x],o[v],o[y])<0&&c.push(h,x)}}for(;c.length>0;){for(var x=c.pop(),h=c.pop(),v=-1,y=-1,f=u[h],S=1;S<f.length;S+=2){var g=f[S-1],d=f[S];g===x?y=d:d===x&&(v=g)}v<0||y<0||e(o[h],o[x],o[v],o[y])>=0||(a.flip(h,x),i(o,a,c,v,h,y),i(o,a,c,h,y,v),i(o,a,c,y,x,v),i(o,a,c,x,v,y))}}}}),nR=Yn({"node_modules/cdt2d/lib/filter.js"(s,t){"use strict";var e=id();t.exports=c;function n(l,u,h,f,p,x,v){this.cells=l,this.neighbor=u,this.flags=f,this.constraint=h,this.active=p,this.next=x,this.boundary=v}var i=n.prototype;function r(l,u){return l[0]-u[0]||l[1]-u[1]||l[2]-u[2]}i.locate=function(){var l=[0,0,0];return function(u,h,f){var p=u,x=h,v=f;return h<f?h<u&&(p=h,x=f,v=u):f<u&&(p=f,x=u,v=h),p<0?-1:(l[0]=p,l[1]=x,l[2]=v,e.eq(this.cells,l,r))}}();function o(l,u){for(var h=l.cells(),f=h.length,p=0;p<f;++p){var x=h[p],v=x[0],y=x[1],_=x[2];y<_?y<v&&(x[0]=y,x[1]=_,x[2]=v):_<v&&(x[0]=_,x[1]=v,x[2]=y)}h.sort(r);for(var S=new Array(f),p=0;p<S.length;++p)S[p]=0;var g=[],d=[],M=new Array(3*f),m=new Array(3*f),R=null;u&&(R=[]);for(var E=new n(h,M,m,S,g,d,R),p=0;p<f;++p)for(var x=h[p],T=0;T<3;++T){var v=x[T],y=x[(T+1)%3],b=M[3*p+T]=E.locate(y,v,l.opposite(y,v)),w=m[3*p+T]=l.isConstraint(v,y);b<0&&(w?d.push(p):(g.push(p),S[p]=1),u&&R.push([y,v,-1]))}return E}function a(l,u,h){for(var f=0,p=0;p<l.length;++p)u[p]===h&&(l[f++]=l[p]);return l.length=f,l}function c(l,u,h){var f=o(l,h);if(u===0)return h?f.cells.concat(f.boundary):f.cells;for(var p=1,x=f.active,v=f.next,y=f.flags,_=f.cells,S=f.constraint,g=f.neighbor;x.length>0||v.length>0;){for(;x.length>0;){var d=x.pop();if(y[d]!==-p){y[d]=p;for(var M=_[d],m=0;m<3;++m){var R=g[3*d+m];R>=0&&y[R]===0&&(S[3*d+m]?v.push(R):(x.push(R),y[R]=p))}}}var E=v;v=x,x=E,v.length=0,p=-p}var T=a(_,y,u);return h?T.concat(f.boundary):T}}}),iR=Yn({"node_modules/cdt2d/cdt2d.js"(s,t){var e=j1(),n=Q1(),i=eR(),r=nR();t.exports=u;function o(h){return[Math.min(h[0],h[1]),Math.max(h[0],h[1])]}function a(h,f){return h[0]-f[0]||h[1]-f[1]}function c(h){return h.map(o).sort(a)}function l(h,f,p){return f in h?h[f]:p}function u(h,f,p){Array.isArray(f)?(p=p||{},f=f||[]):(p=f||{},f=[]);var x=!!l(p,"delaunay",!0),v=!!l(p,"interior",!0),y=!!l(p,"exterior",!0),_=!!l(p,"infinity",!1);if(!v&&!y||h.length===0)return[];var S=e(h,f);if(x||v!==y||_){for(var g=n(h.length,c(f)),d=0;d<S.length;++d){var M=S[d];g.addTriangle(M[0],M[1],M[2])}return x&&i(h,g),y?v?_?r(g,0,_):g.cells():r(g,1,_):r(g,-1)}else return S}}}),bv=iR();var $n=class{constructor(t){this.createFn=t,this._pool=[],this._index=0}getInstance(){return this._index>=this._pool.length&&this._pool.push(this.createFn()),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}};var Tv=1e-16,rR=1e-16,Hs=new I,Ev=new I,wv=new $n(()=>({param:0,index:0})),sR=new $n(()=>new I);function oR(s,t,e,n){wv.clear(),t.length=0,e.length=0;for(let l=0,u=s.length;l<u;l++){let h=s[l];c(h.start),c(h.end)}for(let l=0,u=s.length;l<u;l++){let h=s[l];for(let f=l+1;f<u;f++){let p=s[f];h.distanceSqToLine3(p,Hs,Ev)<Tv*n&&c(Ev)}}let i=[];for(let l=0,u=s.length;l<u;l++){i.length=0;let h=s[l];for(let f=0,p=t.length;f<p;f++){let x=t[f],v=h.closestPointToPointParameter(x,!0);if(h.at(v,Hs),x.distanceToSquared(Hs)<Tv*n){let y=wv.getInstance();y.param=v,y.index=f,i.push(y)}}i.sort(a);for(let f=0,p=i.length-1;f<p;f++){let x=i[f].index,v=i[f+1].index;x!==v&&e.push([x,v])}}let r=new Set,o=0;for(let l=0,u=e.length;l<u;l++){let h=e[l],f=Math.min(h[0],h[1]),p=Math.max(h[0],h[1]),x=f+","+p;r.has(x)||(r.add(x),e[o++]=h)}e.length=o;function a(l,u){return l.param-u.param}function c(l){for(let u=0;u<t.length;u++){let h=t[u];if(l===h||l.distanceToSquared(h)<rR*n)return u}return t.push(sR.getInstance().copy(l)),t.length-1}}var iu=class{constructor(){this.trianglePool=new $n(()=>new ze),this.linePool=new $n(()=>new _e),this.triangles=[],this.triangleIndices=[],this.constrainedEdges=[],this.triangleConnectivity=[],this.normal=new I,this.projOrigin=new I,this.projU=new I,this.projV=new I,this.baseTri=new ze,this.baseIndices=new Array(3)}initialize(t,e=null,n=null,i=null){this.reset();let{normal:r,baseTri:o,projU:a,projV:c,projOrigin:l,constrainedEdges:u,linePool:h,baseIndices:f}=this;t.getNormal(r),o.copy(t),o.update(),f[0]=e,f[1]=n,f[2]=i,u.length=0;let p=h.getInstance();p.start.copy(o.a),p.end.copy(o.b);let x=h.getInstance();x.start.copy(o.b),x.end.copy(o.c);let v=h.getInstance();v.start.copy(o.c),v.end.copy(o.a),u.push(p,x,v),l.copy(o.a),a.subVectors(o.b,o.a).normalize(),c.crossVectors(r,a).normalize()}addConstraintEdge(t){let{constrainedEdges:e,linePool:n}=this,i=n.getInstance().copy(t);e.push(i)}_to2D(t,e){let{projOrigin:n,projU:i,projV:r}=this;return Hs.subVectors(t,n),e.set(Hs.dot(i),Hs.dot(r),0)}_from2D(t,e,n){let{projOrigin:i,projU:r,projV:o}=this;return n.copy(i).addScaledVector(r,t).addScaledVector(o,e),n}triangulate(){let{triangles:t,trianglePool:e,triangleConnectivity:n,triangleIndices:i,linePool:r,baseTri:o,constrainedEdges:a,baseIndices:c}=this;t.length=0,e.clear();let l=[];for(let _=0,S=a.length;_<S;_++){let g=a[_],d=r.getInstance();this._to2D(g.start,d.start),this._to2D(g.end,d.end),l.push(d)}let u=0;for(let _=0;_<3;_++){let S=this._to2D(o.points[_],Hs);u=Math.max(u,Math.abs(S.x),Math.abs(S.y))}let h=[],f=[];oR(l,h,f,u);let p=[];for(let _=0,S=h.length;_<S;_++){let g=h[_];p.push([g.x,g.y])}let x=bv(p,f,{exterior:!1}),v=new Map;for(let _=0,S=f.length;_<S;_++){let g=f[_];v.set(`${g[0]}_${g[1]}`,-1),v.set(`${g[1]}_${g[0]}`,-1)}let y=`${c[0]}_${c[1]}_${c[2]}_`;for(let _=0,S=x.length;_<S;_++){let g=x[_],[d,M,m]=g,R=e.getInstance();this._from2D(p[d][0],p[d][1],R.a),this._from2D(p[M][0],p[M][1],R.b),this._from2D(p[m][0],p[m][1],R.c),t.push(R);let E=[];n.push(E);let T=[];i.push(T);for(let b=0;b<3;b++){let w=g[b];T.push(w<3?c[w]:y+w);let A=g[(b+1)%3],C=`${w}_${A}`;if(v.has(C)){let D=v.get(C);D!==-1&&(E.push(D),n[D].push(_))}else{let D=`${A}_${w}`;v.set(D,_)}}}}reset(){this.trianglePool.clear(),this.linePool.clear(),this.triangles.length=0,this.triangleIndices.length=0,this.triangleConnectivity.length=0,this.constrainedEdges.length=0}};var aR=1e-14,lx=new I,Av=new I,Rv=new I;function Ei(s,t=aR){lx.subVectors(s.b,s.a),Av.subVectors(s.c,s.a),Rv.subVectors(s.b,s.c);let e=lx.angleTo(Av),n=lx.angleTo(Rv),i=Math.PI-e-n;return Math.abs(e)<t||Math.abs(n)<t||Math.abs(i)<t||s.a.distanceToSquared(s.b)<t||s.a.distanceToSquared(s.c)<t||s.b.distanceToSquared(s.c)<t}var ux=1e-10,ru=1e-10,pr=new _e,Ge=new _e,mr=new I,Cv=new I,Iv=new I,rd=new $e,hx=new ze,su=class{constructor(){this.trianglePool=new $n(()=>new me),this.triangles=[],this.normal=new I}initialize(t){this.reset();let{triangles:e,trianglePool:n,normal:i}=this;if(Array.isArray(t))for(let r=0,o=t.length;r<o;r++){let a=t[r];if(r===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(mr).dot(i))>ux)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");let c=n.getInstance();c.copy(a),e.push(c)}else{t.getNormal(i);let r=n.getInstance();r.copy(t),e.push(r)}}splitByTriangle(t,e){let{triangles:n}=this;if(e){for(let r=0,o=n.length;r<o;r++){let a=n[r];a.coplanarCount=0}let i=[t.a,t.b,t.c];for(let r=0;r<3;r++){let o=(r+1)%3,a=i[r],c=i[o];t.getNormal(Cv).normalize(),mr.subVectors(c,a).normalize(),Iv.crossVectors(Cv,mr),rd.setFromNormalAndCoplanarPoint(Iv,a),this.splitByPlane(rd,t)}}else t.getPlane(rd),this.splitByPlane(rd,t)}splitByPlane(t,e){let{triangles:n,trianglePool:i}=this;hx.copy(e),hx.needsUpdate=!0;for(let r=0,o=n.length;r<o;r++){let a=n[r];if(!hx.intersectsTriangle(a,pr,!0))continue;let{a:c,b:l,c:u}=a,h=0,f=-1,p=!1,x=[],v=[],y=[c,l,u];for(let _=0;_<3;_++){let S=(_+1)%3;pr.start.copy(y[_]),pr.end.copy(y[S]);let g=t.distanceToPoint(pr.start),d=t.distanceToPoint(pr.end);if(Math.abs(g)<ru&&Math.abs(d)<ru){p=!0;break}if(g>0?x.push(_):v.push(_),Math.abs(g)<ru)continue;let M=!!t.intersectLine(pr,mr);!M&&Math.abs(d)<ru&&(mr.copy(pr.end),M=!0),M&&!(mr.distanceTo(pr.start)<ux)&&(mr.distanceTo(pr.end)<ux&&(f=_),h===0?Ge.start.copy(mr):Ge.end.copy(mr),h++)}if(!p&&h===2&&Ge.distance()>ru)if(f!==-1){f=(f+1)%3;let _=0;_===f&&(_=(_+1)%3);let S=_+1;S===f&&(S=(S+1)%3);let g=i.getInstance();g.a.copy(y[S]),g.b.copy(Ge.end),g.c.copy(Ge.start),Ei(g)||n.push(g),a.a.copy(y[_]),a.b.copy(Ge.start),a.c.copy(Ge.end),Ei(a)&&(n.splice(r,1),r--,o--)}else{let _=x.length>=2?v[0]:x[0];if(_===0){let m=Ge.start;Ge.start=Ge.end,Ge.end=m}let S=(_+1)%3,g=(_+2)%3,d=i.getInstance(),M=i.getInstance();y[S].distanceToSquared(Ge.start)<y[g].distanceToSquared(Ge.end)?(d.a.copy(y[S]),d.b.copy(Ge.start),d.c.copy(Ge.end),M.a.copy(y[S]),M.b.copy(y[g]),M.c.copy(Ge.start)):(d.a.copy(y[g]),d.b.copy(Ge.start),d.c.copy(Ge.end),M.a.copy(y[S]),M.b.copy(y[g]),M.c.copy(Ge.end)),a.a.copy(y[_]),a.b.copy(Ge.end),a.c.copy(Ge.start),Ei(d)||n.push(d),Ei(M)||n.push(M),Ei(a)&&(n.splice(r,1),r--,o--)}else h===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear()}};var ou=class{constructor(){this.coplanarSet=new Map,this.intersectionSet=new Map,this.edgeSet=new Map,this.ids=[]}add(t,e,n=!1){let{intersectionSet:i,coplanarSet:r,ids:o}=this;i.has(t)||(i.set(t,[]),o.push(t)),i.get(t).push(e),n&&(r.has(t)||r.set(t,new Set),r.get(t).add(e))}addIntersectionEdge(t,e){let{edgeSet:n}=this;n.has(t)||n.set(t,new Set),n.get(t).add(e)}getIntersectionEdges(t){return this.edgeSet.get(t)||null}};var fx=1e-10,cR=1e-15,lR=1e-10,uR=1e-10,Pv=new _e,Ma=new _e,Lv=new I,Nv=new I,Dv=new I,dx=new $e,Sa=new I,sd=new I;function Fv(s,t){s.getNormal(Sa),t.getNormal(sd);let e=Sa.dot(sd);if(Math.abs(1-Math.abs(e))>=lR)return!1;let n=Sa.dot(s.a),i=Sa.dot(t.a);return Math.abs(n-i)<uR}function Uv(s,t,e,n){let i=0,r=1;s.delta(Lv);let o=[t.a,t.b,t.c];for(let a=0;a<3;a++){let c=o[a],l=o[(a+1)%3];Nv.subVectors(l,c),Dv.crossVectors(e,Nv),dx.setFromNormalAndCoplanarPoint(Dv,c);let u=dx.distanceToPoint(s.start),h=dx.normal.dot(Lv);if(Math.abs(h)<cR){if(u<-fx)return null;continue}let f=-u/h;if(h>0?i=Math.max(i,f):r=Math.min(r,f),i>r+fx)return null}return r-i<fx?null:(s.at(i,n.start),s.at(r,n.end),n)}function px(s,t,e){let n=0;s.getNormal(Sa),t.getNormal(sd);let i=[t.a,t.b,t.c];for(let o=0;o<3;o++){Ma.start.copy(i[o]),Ma.end.copy(i[(o+1)%3]);let a=Uv(Ma,s,Sa,Pv);a!==null&&(n>=e.length&&e.push(new _e),e[n].copy(a),n++)}let r=[s.a,s.b,s.c];for(let o=0;o<3;o++){Ma.start.copy(r[o]),Ma.end.copy(r[(o+1)%3]);let a=Uv(Ma,t,sd,Pv);a!==null&&(n>=e.length&&e.push(new _e),e[n].copy(a),n++)}return n}var ba=new _n,Ov=new vt,od=new _e,mx=[],ad=new $n(()=>new _e),Ta=-1,Ea=1,au=-2,cu=2,wa=0,Vs=1,ld=2,cd=null;function gx(s){cd=s}function xx(s,t,e=null){s.getMidpoint(ba.origin),s.getNormal(ba.direction),e&&(ba.origin.applyMatrix4(e),ba.direction.transformDirection(e));let n=t.raycastFirst(ba,Ve);return!!(n&&ba.direction.dot(n.face.normal)>0)?Ta:Ea}function Hv(s,t){let e=new ou,n=new ou;return ad.clear(),Ov.copy(s.matrixWorld).invert().multiply(t.matrixWorld),s.geometry.boundsTree.bvhcast(t.geometry.boundsTree,Ov,{intersectsTriangles(i,r,o,a){if(!Ei(i)&&!Ei(r)){let l=(Fv(i,r)?px(i,r,mx):0)>2;if(l||i.intersectsTriangle(r,od,!0)){let h=s.geometry.boundsTree.resolveTriangleIndex(o),f=t.geometry.boundsTree.resolveTriangleIndex(a);if(e.add(h,f,l),n.add(f,h,l),l){let p=px(i,r,mx);for(let x=0;x<p;x++){let v=ad.getInstance().copy(mx[x]);e.addIntersectionEdge(h,v),n.addIntersectionEdge(f,v)}}else{let p=ad.getInstance().copy(od),x=ad.getInstance().copy(od);e.addIntersectionEdge(h,p),n.addIntersectionEdge(f,x)}cd&&(cd.addEdge(od),cd.addIntersectingTriangles(o,i,a,r))}}return!1}}),{aIntersections:e,bIntersections:n}}function _x(s,t,e=!1){switch(s){case 0:if(t===Ea||t===cu&&!e)return Vs;break;case 1:if(e){if(t===Ta)return wa}else if(t===Ea||t===au)return Vs;break;case 2:if(e){if(t===Ea||t===au)return Vs}else if(t===Ta)return wa;break;case 4:if(t===Ta)return wa;if(t===Ea)return Vs;break;case 3:if(t===Ta||t===cu&&!e)return Vs;break;case 5:if(!e&&(t===Ea||t===au))return Vs;break;case 6:if(!e&&(t===Ta||t===cu))return Vs;break;default:throw new Error(`Unrecognized CSG operation enum "${s}".`)}return ld}var yx=class{constructor(t){this.triangle=new me().copy(t),this.intersects={}}addTriangle(t,e){this.intersects[t]=new me().copy(e)}getIntersectArray(){let t=[],{intersects:e}=this;for(let n in e)t.push(e[n]);return t}},ud=class{constructor(){this.data={}}addTriangleIntersection(t,e,n,i){let{data:r}=this;r[t]||(r[t]=new yx(e)),r[t].addTriangle(n,i)}getTrianglesAsArray(t=null){let{data:e}=this,n=[];if(t!==null)t in e&&n.push(e[t].triangle);else for(let i in e)n.push(e[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(t=>parseInt(t))}getIntersectionIndices(t){let{data:e}=this;return e[t]?Object.keys(e[t].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(t=null,e=null){let{data:n}=this,i=new Set,r=[],o=a=>{if(n[a])if(e!==null)n[a].intersects[e]&&r.push(n[a].intersects[e]);else{let c=n[a].intersects;for(let l in c)i.has(l)||(i.add(l),r.push(c[l]))}};if(t!==null)o(t);else for(let a in n)o(a);return r}reset(){this.data={}}},hd=class{constructor(){this.enabled=!1,this.triangleIntersectsA=new ud,this.triangleIntersectsB=new ud,this.intersectionEdges=[]}addIntersectingTriangles(t,e,n,i){let{triangleIntersectsA:r,triangleIntersectsB:o}=this;r.addTriangleIntersection(t,e,n,i),o.addTriangleIntersection(n,i,t,e)}addEdge(t){this.intersectionEdges.push(t.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),gx(this))}complete(){this.enabled&&gx(null)}};var Kn=new vt,Gs=new vt,Pn=new vt,Hr=new $t,wi=new me,Ws=new me,Ai=new me,kr=new me,Xs=[],Ki=[],fd=new Set,Vv=new I,Gv=new I,Wv=new $n(()=>new me),Xv=new I,dd=[];function $v(s,t,e,n,i,r={}){let{useGroups:o=!0}=r,{aIntersections:a,bIntersections:c}=Hv(s,t),l=[],u=null,h;return h=o?0:-1,Yv(s,t,a,e,!1,i,h),qv(s,t,a,e,!1,n,i,h),e.findIndex(p=>p!==6&&p!==5)!==-1&&(i.forEach(p=>p.clearIndexMap()),h=o?s.geometry.groups.length||1:-1,Yv(t,s,c,e,!0,i,h),qv(t,s,c,e,!0,n,i,h)),i.forEach(p=>p.clearIndexMap()),Xs.length=0,{groups:l,materials:u}}function qv(s,t,e,n,i,r,o,a=0){Kn.copy(t.matrixWorld).invert().multiply(s.matrixWorld),Gs.copy(Kn).invert(),i?Pn.copy(Kn):Pn.identity();let c=Pn.determinant()<0;Hr.getNormalMatrix(Pn).multiplyScalar(c?-1:1);let l=s.geometry.groupIndices,u=s.geometry.index,h=s.geometry.attributes.position,f=t.geometry.boundsTree,p=t.geometry.index,x=t.geometry.attributes.position,v=e.ids;for(let y=0,_=v.length;y<_;y++){let S=v[y],g=a===-1?0:l[S]+a,d=3*S,M=d+0,m=d+1,R=d+2;u&&(M=u.getX(M),m=u.getX(m),R=u.getX(R)),wi.a.fromBufferAttribute(h,M),wi.b.fromBufferAttribute(h,m),wi.c.fromBufferAttribute(h,R),i&&(wi.a.applyMatrix4(Kn),wi.b.applyMatrix4(Kn),wi.c.applyMatrix4(Kn)),r.reset(),r.initialize(wi,M,m,R),dd.length=0,Wv.clear(),wi.getNormal(Gv);let E=e.coplanarSet.get(S);if(E)for(let A of E){let C=3*A,D=C+0,F=C+1,O=C+2;p&&(D=p.getX(D),F=p.getX(F),O=p.getX(O));let H=Wv.getInstance();H.a.fromBufferAttribute(x,D),H.b.fromBufferAttribute(x,F),H.c.fromBufferAttribute(x,O),i||(H.a.applyMatrix4(Gs),H.b.applyMatrix4(Gs),H.c.applyMatrix4(Gs)),dd.push(H)}if(r.addConstraintEdge){let A=e.getIntersectionEdges(S);if(A)for(let C of A)r.addConstraintEdge(C);r.triangulate()}else{let C=e.intersectionSet.get(S);for(let D=0,F=C.length;D<F;D++){let O=C[D],H=E&&E.has(O),B=3*O,$=B+0,at=B+1,rt=B+2;p&&($=p.getX($),at=p.getX(at),rt=p.getX(rt)),Ws.a.fromBufferAttribute(x,$),Ws.b.fromBufferAttribute(x,at),Ws.c.fromBufferAttribute(x,rt),i||(Ws.a.applyMatrix4(Gs),Ws.b.applyMatrix4(Gs),Ws.c.applyMatrix4(Gs)),r.splitByTriangle(Ws,H)}}let{triangles:T,triangleIndices:b=[],triangleConnectivity:w=[]}=r;for(let A=0,C=o.length;A<C;A++)o[A].initInterpolatedAttributeData(s.geometry,Pn,Hr,M,m,R);fd.clear();for(let A=0,C=T.length;A<C;A++){if(fd.has(A))continue;let D=T[A],F=i?null:Kn,O=null;D.getMidpoint(Vv);for(let H=0,B=dd.length;H<B;H++){let $=dd[H];if($.containsPoint(Vv)){$.getNormal(Xv),O=Gv.dot(Xv)>0?cu:au;break}}O===null&&(O=xx(D,f,F)),Xs.length=0,Ki.length=0;for(let H=0,B=n.length;H<B;H++){let $=_x(n[H],O,i);$!==ld&&(Xs.push($),Ki.push(o[H]))}if(Ki.length!==0){let H=[A];for(;H.length>0;){let B=H.pop();if(fd.has(B))continue;fd.add(B);let $=b[B],at=null,rt=null,ht=null;$&&(at=$[0],rt=$[1],ht=$[2]);let bt=T[B];wi.getBarycoord(bt.a,kr.a),wi.getBarycoord(bt.b,kr.b),wi.getBarycoord(bt.c,kr.c);for(let Et=0,Mt=Ki.length;Et<Mt;Et++){let K=Ki[Et],ct=Xs[Et]===wa,lt=c!==ct;K.appendInterpolatedAttributeData(g,kr.a,at,lt),lt?(K.appendInterpolatedAttributeData(g,kr.c,ht,lt),K.appendInterpolatedAttributeData(g,kr.b,rt,lt)):(K.appendInterpolatedAttributeData(g,kr.b,rt,lt),K.appendInterpolatedAttributeData(g,kr.c,ht,lt))}}}}}return v.length}function Yv(s,t,e,n,i,r,o=0){Kn.copy(t.matrixWorld).invert().multiply(s.matrixWorld),i?Pn.copy(Kn):Pn.identity();let a=Pn.determinant()<0;Hr.getNormalMatrix(Pn).multiplyScalar(a?-1:1);let c=t.geometry.boundsTree,l=s.geometry.groupIndices,u=s.geometry.index,f=s.geometry.attributes.position,p=[],x=s.geometry.halfEdges,v=new Set(e.ids),y=va(s.geometry);for(let _=0;_<y&&v.size!==y;_++){if(v.has(_))continue;v.add(_),p.push(_);let S=3*_,g=S+0,d=S+1,M=S+2;u&&(g=u.getX(g),d=u.getX(d),M=u.getX(M)),Ai.a.fromBufferAttribute(f,g),Ai.b.fromBufferAttribute(f,d),Ai.c.fromBufferAttribute(f,M),i&&(Ai.a.applyMatrix4(Kn),Ai.b.applyMatrix4(Kn),Ai.c.applyMatrix4(Kn));let m=xx(Ai,c,i?null:Kn);Xs.length=0,Ki.length=0;for(let R=0,E=n.length;R<E;R++){let T=_x(n[R],m,i);T!==ld&&(Xs.push(T),Ki.push(r[R]))}for(;p.length>0;){let R=p.pop();for(let E=0;E<3;E++){let T=x.getSiblingTriangleIndex(R,E);T!==-1&&!v.has(T)&&(p.push(T),v.add(T))}if(Ki.length!==0){let E=3*R,T=E+0,b=E+1,w=E+2;u&&(T=u.getX(T),b=u.getX(b),w=u.getX(w));let A=o===-1?0:l[R]+o;if(Ai.a.fromBufferAttribute(f,T),Ai.b.fromBufferAttribute(f,b),Ai.c.fromBufferAttribute(f,w),!Ei(Ai))for(let C=0,D=Ki.length;C<D;C++){let F=Ki[C],B=Xs[C]===wa!==a;F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,T,B),B?(F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,w,B),F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,b,B)):(F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,b,B),F.appendIndexFromGeometry(s.geometry,Pn,Hr,A,w,B))}}}}}function dR(s){return s=~~s,s+4-s%4}var pd=class{constructor(t,e=500){this.expansionFactor=1.5,this.type=t,this.length=0,this.array=null,this.setSize(e)}setType(t){if(t===this.type)return;if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");let e=this.array.buffer;this.array=new t(e),this.type=t}setSize(t){if(this.array&&t===this.array.length)return;let e=this.type,n=Qf()?SharedArrayBuffer:ArrayBuffer,i=new e(new n(dR(t*e.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){let{array:t,expansionFactor:e}=this;this.setSize(t.length*e)}push(...t){let{array:e,length:n}=this;n+t.length>e.length&&(this.expand(),e=this.array);for(let i=0,r=t.length;i<r;i++)e[n+i]=t[i];this.length+=t.length}clear(){this.length=0}};var Ln=new I,vx=new I,Mx=new I,Sx=new I,md=new Qt,pR=new Qt,mR=new Qt,gR=new Qt;function xR(s,t,e,n,i,r=!1,o=!1){return i.set(0,0,0,0).addScaledVector(s,n.x).addScaledVector(t,n.y).addScaledVector(e,n.z),r&&i.normalize(),o&&i.multiplyScalar(-1),i}function Kv(s,t,e){switch(t){case 1:e.push(s.x);break;case 2:e.push(s.x,s.y);break;case 3:e.push(s.x,s.y,s.z);break;case 4:e.push(s.x,s.y,s.z,s.w);break}}var lu=class extends pd{get count(){return this.length/this.itemSize}constructor(...t){super(...t),this.itemSize=1,this.normalized=!1}},gd=class{constructor(){this.attributeData={},this.groupIndices=[],this.forwardIndexMap=new Map,this.invertedIndexMap=new Map,this.interpolatedFields={}}initFromGeometry(t,e){this.clear();let{attributeData:n}=this,i=t.attributes;for(let r=0,o=e.length;r<o;r++){let a=e[r],c=i[a],l=c.array.constructor;n[a]||(n[a]=new lu(l)),n[a].setType(l),n[a].itemSize=c.itemSize,n[a].normalized=c.normalized}for(let r in n.attributes)e.includes(r)||n.delete(r)}initInterpolatedAttributeData(t,e,n,i,r,o){let{attributeData:a,interpolatedFields:c}=this,{attributes:l}=t;for(let u in a){let h=l[u];if(!h)throw new Error(`CSG Operations: Attribute ${u} not available on geometry.`);let f,p,x;if(u==="position"?(f=vx.fromBufferAttribute(h,i).applyMatrix4(e),p=Mx.fromBufferAttribute(h,r).applyMatrix4(e),x=Sx.fromBufferAttribute(h,o).applyMatrix4(e)):u==="normal"?(f=vx.fromBufferAttribute(h,i).applyNormalMatrix(n),p=Mx.fromBufferAttribute(h,r).applyNormalMatrix(n),x=Sx.fromBufferAttribute(h,o).applyNormalMatrix(n)):u==="tangent"?(f=vx.fromBufferAttribute(h,i).transformDirection(e),p=Mx.fromBufferAttribute(h,r).transformDirection(e),x=Sx.fromBufferAttribute(h,o).transformDirection(e)):(f=pR.fromBufferAttribute(h,i),p=mR.fromBufferAttribute(h,r),x=gR.fromBufferAttribute(h,o)),!c[u])c[u]=[f.clone(),p.clone(),x.clone()];else{let v=c[u];v[0].copy(f),v[1].copy(p),v[2].copy(x)}}}appendInterpolatedAttributeData(t,e,n=null,i=!1){let{groupIndices:r,attributeData:o,interpolatedFields:a,forwardIndexMap:c,invertedIndexMap:l}=this;for(;r.length<=t;)r.push(new lu(Uint32Array));let u=i?l:c,h=r[t];if(n!==null&&u.has(n))h.push(u.get(n));else{u.set(n,o.position.count),h.push(o.position.count);for(let f in a){let p=o[f],x=f==="normal"||f==="tangent",v=i&&x,y=p.itemSize,[_,S,g]=a[f];xR(_,S,g,e,md,x,v),Kv(md,y,p)}}}appendIndexFromGeometry(t,e,n,i,r,o=!1){let{groupIndices:a,attributeData:c,forwardIndexMap:l,invertedIndexMap:u}=this;for(;a.length<=i;)a.push(new lu(Uint32Array));let h=o?u:l,f=a[i];if(r!==null&&h.has(r))f.push(h.get(r));else{h.set(r,c.position.count),f.push(c.position.count);let{attributes:p}=t;for(let x in c){let v=c[x],y=p[x];if(!y)throw new Error(`CSG Operations: Attribute ${x} not available on geometry.`);let _=y.itemSize;x==="position"?(Ln.fromBufferAttribute(y,r).applyMatrix4(e),v.push(Ln.x,Ln.y,Ln.z)):x==="normal"?(Ln.fromBufferAttribute(y,r).applyNormalMatrix(n),o&&Ln.multiplyScalar(-1),v.push(Ln.x,Ln.y,Ln.z)):x==="tangent"?(Ln.fromBufferAttribute(y,r).transformDirection(e),o&&Ln.multiplyScalar(-1),v.push(Ln.x,Ln.y,Ln.z)):(md.fromBufferAttribute(y,r),Kv(md,_,v))}}}buildGeometry(t,e){let n=!1,{groupIndices:i,attributeData:r}=this,{attributes:o,index:a}=t;for(let u in r){let h=r[u],{type:f,itemSize:p,normalized:x,length:v,count:y}=h,_=h.array.buffer,S=o[u];(!S||S.count<y||S.array.type!==f)&&(S=new kt(new f(v),p,x),t.setAttribute(u,S),n=!0),S.array.set(new f(_,0,v),0),S.needsUpdate=!0}let c=i.reduce((u,h)=>h.count+u,0);(!t.index||a.count<c||a.array.type!==Uint32Array)&&(t.setIndex(new kt(new Uint32Array(c),1)),n=!0),t.clearGroups();let l=0;for(let u=0,h=Math.min(e.length,i.length);u<h;u++){let{index:f,materialIndex:p}=e[u],{count:x}=i[f],v=i[f].array.buffer;x!==0&&(t.index.array.set(new Uint32Array(v,0,x),l),t.addGroup(l,x,p),l+=x)}t.setDrawRange(0,l),t.boundsTree=null,t.boundingBox=null,t.boundingSphere=null,n&&t.dispose()}clearIndexMap(){this.forwardIndexMap.clear(),this.invertedIndexMap.clear()}clear(){let{groupIndices:t,attributeData:e}=this;this.interpolatedFields={};for(let n in e)e[n].clear();t.forEach(n=>{n.clear()}),this.clearIndexMap()}};function Zv(s,t){for(let e in s.attributes)t.includes(e)||(s.deleteAttribute(e),s.dispose());return s}function Jv(s,t){let e=[];for(let n=0,i=s.length;n<i;n++){let r=s[n],o=t[r.materialIndex];e.push({...r,materialIndex:t.indexOf(o)})}return e}function jv(s,t){let e=[],n=new Map;for(let i=0,r=s.length;i<r;i++){let o=s[i];n.has(o.materialIndex)||(n.set(o.materialIndex,e.length),e.push(t[o.materialIndex])),o.materialIndex=n.get(o.materialIndex)}return e}function Qv(s){for(let t=0;t<s.length-1;t++){let e=s[t],n=s[t+1];if(e.materialIndex===n.materialIndex){let i=e.start,r=n.start+n.count;n.start=i,n.count=r-i,s.splice(t,1),t--}}}function bx(s,t){let e=t;return Array.isArray(t)||(e=[],s.forEach(n=>{e[n.materialIndex]=t})),e}var xd=class{get useCDTClipping(){return this.triangleSplitter instanceof iu}set useCDTClipping(t){t!==this.useCDTClipping&&(this.triangleSplitter=t?new iu:new su)}constructor(){this.triangleSplitter=new su,this.geometryBuilders=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.removeUnusedMaterials=!0,this.debug=new hd}getGroupRanges(t){return!this.useGroups||t.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:t.groups.map(n=>({...n}))}evaluate(t,e,n,i=new ks){let r=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],r=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");t.prepareGeometry(),e.prepareGeometry();let{triangleSplitter:o,geometryBuilders:a,attributes:c,useGroups:l,consolidateGroups:u,removeUnusedMaterials:h,debug:f}=this;for(;a.length<i.length;)a.push(new gd);i.forEach((g,d)=>{a[d].initFromGeometry(t.geometry,c),Zv(g.geometry,c)}),f.init(),$v(t,e,n,o,a,{useGroups:l}),f.complete();let p=this.getGroupRanges(t.geometry),x=bx(p,t.material),v=this.getGroupRanges(e.geometry),y=bx(v,e.material);v.forEach(g=>g.materialIndex+=x.length);let _=[...x,...y],S=[...p,...v].map((g,d)=>({...g,index:d}));return l?l&&u&&(S=Jv(S,_),S.sort((g,d)=>g.materialIndex-d.materialIndex)):S=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach((g,d)=>{let M=g.geometry;a[d].buildGeometry(M,S),t.matrixWorld.decompose(g.position,g.quaternion,g.scale),g.updateMatrix(),g.matrixWorld.copy(t.matrixWorld),l?(g.material=_,u&&Qv(M.groups),h&&(g.material=jv(M.groups,_))):g.material=_[0]}),r?i:i[0]}evaluateHierarchy(t,e=new ks){t.updateMatrixWorld(!0);let n=(r,o)=>{let a=r.children;for(let c=0,l=a.length;c<l;c++){let u=a[c];u.isOperationGroup?n(u,o):o(u)}},i=r=>{let o=r.children,a=!1;for(let l=0,u=o.length;l<u;l++){let h=o[l];a=i(h)||a}let c=r.isDirty();if(c&&r.markUpdated(),a&&!r.isOperationGroup){let l;return n(r,u=>{l?l=this.evaluate(l,u,u.operation):l=this.evaluate(r,u,u.operation)}),r._cachedGeometry=l.geometry,r._cachedMaterials=l.material,!0}else return a||c};return i(t),e.geometry=t._cachedGeometry,e.material=t._cachedMaterials,e}reset(){this.triangleSplitter.reset()}};var tM=["fetch","XMLHttpRequest","WebSocket","WebTransport","EventSource","importScripts","Worker","SharedWorker","BroadcastChannel","FontFace","fonts","indexedDB","caches","navigator","Request","Response"];function eM(s){for(let t=s;t!==null&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let e of tM)Object.prototype.hasOwnProperty.call(t,e)&&delete t[e];for(let t of tM)t in s&&Object.defineProperty(s,t,{value:void 0,configurable:!1,writable:!1})}function nM(s){return/\bimport\s*\(/.test(s)?"import() is not allowed in a model script.":null}var iM={"stone-blocks":{roughness:.62,metalness:0},"red-brick":{roughness:.58,metalness:0},"old-brick":{roughness:.6,metalness:0},cobblestone:{roughness:.62,metalness:0},rock:{roughness:.65,metalness:0},"mossy-rock":{roughness:.55,metalness:0},planks:{roughness:.45,metalness:0},wood:{roughness:.48,metalness:0},bark:{roughness:.62,metalness:0},"roof-tiles":{roughness:.68,metalness:0},concrete:{roughness:.52,metalness:0},marble:{roughness:.07,metalness:0},"floor-tiles":{roughness:.51,metalness:0},metal:{roughness:.41,metalness:1},"rusty-metal":{roughness:.5,metalness:.75},"metal-plate":{roughness:.56,metalness:.03},grass:{roughness:.54,metalness:0},sand:{roughness:.67,metalness:0},gravel:{roughness:.58,metalness:0},snow:{roughness:.5,metalness:0},ice:{roughness:.21,metalness:0}};var Tx=["stone-blocks","red-brick","old-brick","cobblestone","rock","mossy-rock","planks","wood","bark","roof-tiles","concrete","marble","floor-tiles","metal","rusty-metal","metal-plate","grass","sand","gravel","snow","ice"];var _d=s=>s.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join(""),rM=(s,t)=>`materials/T_${_d(s)}_${t==="color"?"D":"N"}.jpg`;function sM(s,t){let e=yd(s),[n,i]=[e.roughness,e.metalness].map(r=>Math.round(r*100)/100);return[`${_d(s)}_MAT`,...t.color.toUpperCase()!=="FFFFFF"?[`Tint${t.color.toUpperCase()}`]:[],...t.relief?[]:["Flat"],...t.roughness!==n?[`R${Math.round(t.roughness*100)}`]:[],...t.metalness!==i?[`M${Math.round(t.metalness*100)}`]:[]].join("_")}var vR=new Set(["rock","mossy-rock","concrete","marble","grass","sand","gravel","snow","ice"]),Ex=s=>vR.has(s)?2:1,yd=s=>iM[s];function uu(s){return typeof s=="string"&&Tx.includes(s)}function oM(s,t,e=1){let n=s.index===null?s.clone():s.toNonIndexed(),i=n.getAttribute("position"),r=new Float32Array(i.count*2),o=new I,a=new I,c=new I,l=new I;for(let u=0;u<i.count;u+=3){o.fromBufferAttribute(i,u).applyMatrix4(t),a.fromBufferAttribute(i,u+1).applyMatrix4(t),c.fromBufferAttribute(i,u+2).applyMatrix4(t),l.subVectors(c,a).cross(new I().subVectors(o,a));let[h,f,p]=[Math.abs(l.x),Math.abs(l.y),Math.abs(l.z)];for(let[x,v]of[o,a,c].entries()){let[y,_]=h>=f&&h>=p?[v.z,v.y]:f>=p?[v.x,v.z]:[v.x,v.y];r[(u+x)*2]=y/e,r[(u+x)*2+1]=_/e}}return n.setAttribute("uv",new kt(r,2)),n}var wx=s=>s+3&-4;function aM(s){let t=new Uint8Array(s),e=new DataView(s),n=e.getUint32(12,!0),i=JSON.parse(new TextDecoder().decode(t.subarray(20,20+n))),r=20+n,o=r<t.length?t.subarray(r+8,r+8+e.getUint32(r,!0)):new Uint8Array(0),a=new Map;for(let _ of i.materials??[]){let S=_.extras?.library;if(!uu(S))continue;let g=[["color",_.pbrMetallicRoughness?.baseColorTexture?.index],["normal",_.normalTexture?.index]];for(let[d,M]of g){let m=M===void 0?void 0:i.textures?.[M]?.source;m!==void 0&&a.set(m,{name:S,map:d})}}if(a.size===0)return{glb:s,used:[]};let c=new Set;for(let[_,{name:S,map:g}]of a){let d=i.images?.[_];typeof d?.bufferView=="number"&&c.add(d.bufferView);let M=rM(S,g);i.images!==void 0&&(i.images[_]={uri:M,name:M.replace(/^.*\/|\.jpg$/g,"")})}let l=[],u=0;for(let[_,S]of(i.bufferViews??[]).entries()){if(c.has(_)){S.byteOffset=0,S.byteLength=4;continue}let g=S.byteOffset??0;l.push(o.subarray(g,g+S.byteLength)),S.byteOffset=u,u=wx(u+S.byteLength)}let h=new Uint8Array(Math.max(4,u)),f=0;for(let _ of l)h.set(_,f),f=wx(f+_.length);i.buffers?.[0]!==void 0&&(i.buffers[0].byteLength=h.length);let p=new TextEncoder().encode(JSON.stringify(i)),x=new Uint8Array(wx(p.length)).fill(32);x.set(p);let v=new Uint8Array(20+x.length+8+h.length),y=new DataView(v.buffer);return y.setUint32(0,1179937895,!0),y.setUint32(4,2,!0),y.setUint32(8,v.length,!0),y.setUint32(12,x.length,!0),y.setUint32(16,1313821514,!0),v.set(x,20),y.setUint32(20+x.length,h.length,!0),y.setUint32(24+x.length,5130562,!0),v.set(h,28+x.length),{glb:v.buffer,used:[...new Set([...a.values()].map(_=>_.name))]}}var hM=512,cM=s=>Number.isInteger(s)&&s>=1&&s<=hM&&(s&s-1)===0;function fM(s,t){if(!(cM(s)&&cM(t)))throw new Error(`addons.canvas(${String(s)}, ${String(t)}): each side must be a power of two up to ${hM} (1, 2, 4, 8, 16, 32, 64, 128, 256 or 512); pick those sizes and draw to fit them.`)}var vd=s=>Object.keys(s.attributes).sort().join(", "),lM=s=>`${s.itemSize}:${String(s.normalized)}:${s.array.constructor.name}`;function MR(s){let t=s[0];for(let e=1;e<s.length;e++){if(vd(s[e])!==vd(t))return`parts have different attributes (part 0: ${vd(t)}; part ${e}: ${vd(s[e])}); give every part the same attributes, or add the odd ones as separate meshes.`;let n=Object.keys(t.attributes).find(i=>lM(s[e].getAttribute(i))!==lM(t.getAttribute(i)));if(n!==void 0)return`attribute "${n}" has a different layout in part ${e}; add that part as a separate mesh.`}return"parts have different morph targets; add them as separate meshes."}function dM(s,t=!1){if(!Array.isArray(s)||s.length===0)throw new Error("addons.mergeGeometries: pass an array of at least one geometry.");let n=s.some(r=>r.index!==null)&&s.some(r=>r.index===null)?s.map(r=>r.index===null?r:r.toNonIndexed()):s,i=tg(n,t);if(i===null)throw new Error(`addons.mergeGeometries: ${MR(n)}`);return i}function pM(s){let t=0;return s.traverse(e=>{if(!(e instanceof ce))return;let n=e.geometry;(n.getAttribute("color")!==void 0||e instanceof ei&&e.instanceColor!==null)&&(n.deleteAttribute("color"),e instanceof ei&&(e.instanceColor=null),t++)}),t===0?[]:[`Removed vertex colours from ${t} part${t===1?"":"s"}: Decentraland ignores them. Colour parts with materials instead.`]}function Md(s,t=!0){let e=s.clone();e.index===null&&e.setIndex([...Array(e.getAttribute("position").count).keys()]);let n=e.index;if(n===null)return e;for(let r=0;r+2<n.count;r+=3){let o=n.getX(r+1);n.setX(r+1,n.getX(r+2)),n.setX(r+2,o)}let i=e.getAttribute("normal");if(t&&i!==void 0)for(let r=0;r<i.count;r++)i.setXYZ(r,-i.getX(r),-i.getY(r),-i.getZ(r));return e}function mM(s,t){let e=new vt().makeScale(-1,1,1),n=l=>l.premultiply(e).multiply(e),i=(l,u)=>{if(l!==void 0)for(let h=0;h<l.count;h++)l[`set${u}`](h,-l[`get${u}`](h))},r=new Map,o=(l,u)=>{let h=`${l.uuid}:${u}`,f=r.get(h);if(f!==void 0)return f;let p=l.clone();for(let x of["position","normal"]){i(p.getAttribute(x),"X");for(let v of p.morphAttributes[x]??[])i(v,"X")}i(p.getAttribute("tangent"),"Y"),i(p.getAttribute("tangent"),"Z");for(let[x,v]of Object.entries(p.attributes))if(/^uv\d*$/.test(x))for(let y=0;y<v.count;y++)v.setX(y,1-v.getX(y));return f=u?Md(p,!1):p,r.set(h,f),f},a=new Set;s.traverse(l=>{if(l.position.x=-l.position.x,l.quaternion.set(l.quaternion.x,-l.quaternion.y,-l.quaternion.z,l.quaternion.w),l.matrixAutoUpdate||n(l.matrix),l instanceof ei){let u=new vt;for(let h=0;h<l.count;h++)l.getMatrixAt(h,u),l.setMatrixAt(h,n(u))}if(l instanceof mi&&(n(l.bindMatrix),n(l.bindMatrixInverse),!a.has(l.skeleton))){a.add(l.skeleton);for(let u of l.skeleton.boneInverses)n(u)}"geometry"in l&&l.geometry instanceof Vt&&(l.geometry=o(l.geometry,l instanceof ce))});let c=new Set;for(let l of new Set(t.flatMap(u=>u.tracks))){if(c.has(l.values))continue;c.add(l.values);let{propertyName:u,propertyIndex:h}=ee.parseTrackName(l.name),f=u==="position"?["x"]:u==="quaternion"?["y","z"]:[],p=u==="position"?3:4;l.values.forEach((x,v)=>{(h===void 0?f.includes("xyzw"[v%p]):f.includes(h))&&(l.values[v]=-x)})}s.updateMatrixWorld(!0)}var uM=s=>[s.material].flat().map(t=>t.side);function SR(s){for(let[e,n]of Object.entries(s.attributes)){if(!/^uv\d*$/.test(e)||n.count===0)continue;let i=1/0,r=-1/0;for(let o=0;o<n.count;o++)i=Math.min(i,n.getX(o)),r=Math.max(r,n.getX(o));for(let o=0;o<n.count;o++)n.setX(o,i+r-n.getX(o))}let t=s.getAttribute("tangent");if(t!==void 0)for(let e=0;e<t.count;e++)t.setXYZ(e,-t.getX(e),-t.getY(e),-t.getZ(e));return s}function gM(s){let t=[],e=[];s.traverse(r=>{!(r instanceof ce)||r instanceof mi||/_collider/i.test(r.name)||(uM(r).every(o=>o===Ve)?t.push(r):uM(r).every(o=>o===qe)&&e.push(r))});let n=new Map,i=(r,o)=>{let a=`${r.uuid}:${String(o)}`,c=n.get(a);return c===void 0&&n.set(a,c=o?SR(Md(r)):Md(r)),c};for(let r of t){let o=r.clone(!1);o.name="",o.position.set(0,0,0),o.quaternion.identity(),o.scale.set(1,1,1),o.geometry=i(r.geometry,!0),r.add(o)}for(let r of e)r.geometry=i(r.geometry,!1);for(let r of[...t,...e])for(let o of[r.material].flat())o.side=rn;s.updateMatrixWorld(!0)}function Ax(s){let t=_d(s).slice(0,40)||"Model",e=new Set,n=0,i=()=>{let r;do r=`${t}_Part${String(++n).padStart(2,"0")}`;while(e.has(r));return e.add(r),r};return{name:r=>(r.name===""&&(r.name=i()),r.name),nameAll:r=>{r.traverse(o=>{o.name!==""&&e.add(o.name)}),r.traverse(o=>{o!==r&&o.name===""&&(o.name=i())})}}}var bR=(s,t)=>{for(let e=s;e!==null&&e!==t;e=e.parent)if(!e.visible)return!1;return t.visible};function TR(s,t){let e=new Set(t.flatMap(i=>i.tracks.map(r=>ee.parseTrackName(r.name).nodeName))),n=new Set;return s.traverse(i=>{!e.has(i.name)&&!e.has(i.uuid)||(i.traverse(r=>n.add(r)),i.traverseAncestors(r=>n.add(r)))}),n}function xM(s,t,e=5){s.updateMatrixWorld(!0);let n=TR(s,t),i=new Map;s.traverse(o=>{if(!(o instanceof ce)||o instanceof ei||o instanceof mi||o.name!==""||n.has(o)||!bR(o,s))return;let a=o.geometry;if(Array.isArray(o.material)||Object.keys(a.morphAttributes).length>0)return;let c=o.material,l=Object.entries(a.attributes).map(([h,f])=>`${h}:${f.itemSize}:${String(f.normalized)}:${f.array.constructor.name}`).sort().join(","),u=`${c.uuid}|${String(a.index!==null)}|${l}`;i.set(u,[...i.get(u)??[],o])});let r=s.matrixWorld.clone().invert();for(let o of i.values()){if(o.length<e)continue;let a=o.map(l=>{let u=r.clone().multiply(l.matrixWorld),h=l.geometry.clone().applyMatrix4(u);return u.determinant()<0?Md(h,!1):h}),c=tg(a);if(c!==null){for(let l of o){let u=l.parent;for(let f of[...l.children])u?.attach(f);l.removeFromParent();let h=f=>f instanceof nn||f.constructor===re;for(;u!==null&&u!==s&&h(u)&&u.children.length===0&&u.name===""&&!n.has(u);){let f=u.parent;u.removeFromParent(),u=f}}s.add(new ce(c,o[0].material))}}s.updateMatrixWorld(!0)}var Rx=24,Cx=Ax("Model"),bM=s=>Cx.name(s);function TM(s,t){let e=[],n=[];for(let i=0;i<=Rx;i++)e.push(s*i/Rx),n.push(...t(i/Rx*Math.PI*2));return{times:e,values:n}}function _M(s,t,e,n){let i=s.quaternion.clone(),r=new I(t==="x"?1:0,t==="y"?1:0,t==="z"?1:0),{times:o,values:a}=TM(n,c=>i.clone().multiply(new Ce().setFromAxisAngle(r,e(c))).toArray());return new Gn(`${bM(s)}.quaternion`,o,a)}var yM=new Map;function vM(s,t){let e=yM.get(`${s}/${t}`);return e===void 0&&(e=new Eo(new OffscreenCanvas(1,1)),t==="color"&&(e.colorSpace=Ae),e.wrapS=e.wrapT=An,yM.set(`${s}/${t}`,e)),e}var MM=new Map;function ER(s,t={}){if(!uu(s))throw new Error(`addons.material takes one of ${Tx.join(", ")}`);let e=Math.round((t.roughness??yd(s).roughness)*100)/100,n=Math.round((t.metalness??yd(s).metalness)*100)/100,i=t.relief!==!1,r={color:new yt(t.color??16777215).getHexString(),roughness:e,metalness:n,relief:i},o=sM(s,r),a=MM.get(o);if(a!==void 0)return a;let c=new xi({map:vM(s,"color"),...i?{normalMap:vM(s,"normal")}:{},color:t.color??16777215,roughness:e,metalness:n});return c.userData.library=s,c.name=o,MM.set(o,c),c}var wR=s=>[s.material].flat().map(t=>t.userData.library).find(uu),AR={material:ER,RoundedBoxGeometry:Cf,mergeGeometries:dM,mergeVertices:eg,Brush:ks,Evaluator:xd,ADDITION:0,SUBTRACTION:1,INTERSECTION:3,canvas:(s,t)=>(fM(s,t),new OffscreenCanvas(s,t)),spin:(s,t={})=>_M(s,t.axis??"y",e=>e,t.seconds??4),swing:(s,t={})=>_M(s,t.axis??"z",e=>Yi.degToRad(t.degrees??20)*Math.sin(e),t.seconds??1),bob:(s,t={})=>{let e=s.position.clone(),{times:n,values:i}=TM(t.seconds??2,r=>[e.x,e.y+(t.height??.1)*Math.sin(r),e.z]);return new Wn(`${bM(s)}.position`,n,i)}},Sd=null,Ra=(s,t=[])=>Sd?.postMessage(s,t),SM=1e6;function RR(){let s=0,t=Vt.prototype.setAttribute;Vt.prototype.setAttribute=function(e,n){if(e==="position"&&(s+=n.count,s>SM))throw new Error(`the script made over ${SM.toLocaleString("en")} vertices; build less detail`);return t.call(this,e,n)}}async function CR(s,t){eM(self);let e=nM(s);if(e!==null)throw new Error(e);RR(),Cx=Ax(t);let n=new nn,i=[];new Function("THREE","addons","root","clips",s)(Vl,AR,n,i);let r=i.filter(h=>h instanceof ni);n.updateMatrixWorld(!0),mM(n,r);let o=pM(n);gM(n);let a=new Map;n.traverse(h=>{if(!(h instanceof ce))return;let f=wR(h);if(f===void 0)return;let p=h.matrixWorld.clone().setPosition(0,0,0),x=`${h.geometry.uuid}|${Ex(f)}|${p.elements.map(y=>y.toFixed(4)).join(",")}`,v=a.get(x);v===void 0&&(v=eg(oM(h.geometry,p,Ex(f))),v.getAttribute("normal")!==void 0&&v.computeTangents(),a.set(x,v)),h.geometry=v}),xM(n,r),Cx.nameAll(n);let c=await new Us().parseAsync(n,{binary:!0,animations:r});if(!(c instanceof ArrayBuffer))throw new Error("the exporter returned no binary");let{glb:l,used:u}=aM(c);Ra({kind:"built",glb:l,clips:r.map(h=>h.name),library:u,warnings:o},[l])}function IR(s,t){let e=new Uint8Array(s),n=new DataView(s),i=e.length>=20&&n.getUint32(0,!0)===1179937895?new TextDecoder().decode(e.subarray(20,20+n.getUint32(12,!0))):new TextDecoder().decode(e),r=JSON.parse(i),o=a=>{let c=typeof r=="object"&&r!==null?Reflect.get(r,a):void 0;return Array.isArray(c)?c.map(l=>typeof l=="object"&&l!==null?Reflect.get(l,"uri"):void 0):[]};return[...o("buffers"),...o("images")].some(a=>typeof a=="string"&&!a.startsWith("data:")&&t[a]===void 0)}var dn=null,Aa=null;function EM(s){if(Aa===null)return;let t=Aa.clips.find(e=>e.name===s);t!==void 0&&(Aa.mixer.stopAllAction(),Aa.mixer.clipAction(t).play())}function PR(){let s=new bs,t=()=>{Aa?.mixer.update(s.getDelta()),hu(),setTimeout(t,16)};t()}function hu(){if(dn===null)return;let{camera:s,target:t,yaw:e,pitch:n,distance:i}=dn;s.position.set(t.x+i*Math.cos(n)*Math.sin(e),t.y+i*Math.sin(n),t.z+i*Math.cos(n)*Math.cos(e)),s.lookAt(t),dn.renderer.render(dn.scene,s)}function LR(s){let t=s.files??{};if(IR(s.bytes,t))throw new Error("the model refers to files outside it");let e=new Map(Object.entries(t).map(([c,l])=>[c,URL.createObjectURL(new Blob([l]))])),n=new Pr;n.setURLModifier(c=>e.get(c)??c);let i=new Hl({canvas:s.canvas,antialias:!0,alpha:!0});i.setPixelRatio(s.dpr),i.setSize(s.width,s.height,!1);let r=new Fi;r.add(new vs(16777215,4478310,2.2));let o=new lr(16777215,2);o.position.set(3,6,4),r.add(o);let a=new Re(40,s.width/s.height,.01,2e3);new Af(n).parse(s.bytes,"",c=>{let l=[];c.scene.traverse(f=>{/_collider$/i.test(f.name)&&l.push(f)});for(let f of l)f.removeFromParent();r.add(c.scene);let u=new ne().setFromObject(c.scene),h=Math.max(u.getSize(new I).length()/2,.1);dn={renderer:i,scene:r,camera:a,target:u.getCenter(new I),yaw:Math.PI/4,pitch:.4,distance:h*2.6},c.animations.length>0?(Aa={mixer:new Xo(c.scene),clips:c.animations},EM(c.animations[0].name),PR()):hu(),Ra({kind:"shown"})},c=>Ra({kind:"failed",error:c.message}))}function NR(s){let t=s.data;try{if(t.kind!=="build"&&t.kind!=="view"&&t.kind!=="clip"&&dn===null)return;if(t.kind==="build"&&bd!=="build"||t.kind==="view"&&bd!=="view")throw new Error(`a ${String(bd)} worker does not ${t.kind}`);t.kind==="build"?CR(t.code,t.name).catch(e=>Ra({kind:"failed",error:e instanceof Error?e.message:String(e)})):t.kind==="view"?LR(t):t.kind==="clip"?EM(t.name):dn!==null&&t.kind==="orbit"?(dn.yaw-=t.dx*.01,dn.pitch=Math.max(-1.4,Math.min(1.4,dn.pitch+t.dy*.01)),hu()):dn!==null&&t.kind==="zoom"?(dn.distance*=Math.exp(t.delta*.001),hu()):dn!==null&&t.kind==="resize"&&(dn.renderer.setSize(t.width,t.height,!1),dn.camera.aspect=t.width/t.height,dn.camera.updateProjectionMatrix(),hu())}catch(e){Ra({kind:"failed",error:e instanceof Error?e.message:String(e)})}}var bd=null;self.onmessage=s=>{Sd!==null||s.ports[0]===void 0||s.data!=="build"&&s.data!=="view"||(bd=s.data,Sd=s.ports[0],Sd.onmessage=NR,Ra({kind:"ready"}))};})();
|